Skip to content

Instantly share code, notes, and snippets.

View tuananh's full-sized avatar
☁️
Head of Tech Platform @ VPBank. AWS Community Builder

Tuan Anh Tran tuananh

☁️
Head of Tech Platform @ VPBank. AWS Community Builder
View GitHub Profile
@tuananh
tuananh / README.md
Last active April 16, 2024 05:47
i3blocks script to toggle warp on/off

This is a tiny script to toggle Cloudflare Warp on/off.

  • warp-cli status output is changing, unreliable to grep/awk. So I just use https://cloudflare.com/cdn-cgi/trace endpoint.
  • -z "$BLOCK_BUTTON" check is performed in order to see if it's a block click or not.
@tuananh
tuananh / starship.toml
Created April 2, 2024 10:05
starship prompt
format = """\
[ ](bg:#7DF9AA fg:#7DF9AA)\
[󰣇 ](bg:#7DF9AA fg:#090c0c)\
[](fg:#7DF9AA bg:#1C3A5E)\
$time\
[](fg:#1C3A5E bg:#3B76F0)\
$directory\
[](fg:#3B76F0 bg:#FCF392)\
$git_branch\
$git_status\
@tuananh
tuananh / readme.md
Created March 14, 2024 08:50
Ubuntu: how to change tty resolution at boot

Edit /etc/default/grub file

sudo nano /etc/default/grub

Edit the GRUB_CMDLINE_LINUX_DEFAULT flag to add nomodeset and vga=795. Change vga modeset accordingly. You can reference the table below.

Color Depth 800x600 1024x768 1152x864 1280x1024 1600x1200
@tuananh
tuananh / starship.toml
Created February 23, 2024 14:00
My starship.toml configuration
format = """\
[ ](bg:#7DF9AA fg:#7DF9AA)\
[󰣇 ](bg:#7DF9AA fg:#090c0c)\
[](fg:#7DF9AA bg:#1C3A5E)\
$time\
[](fg:#1C3A5E bg:#3B76F0)\
$directory\
[](fg:#3B76F0 bg:#FCF392)\
$git_branch\
$git_status\
declare -A -r my_hashmap=(
["foo"]="bar"
["baz"]="qux"
)
echo "${my_hashmap["foo"]}"
for key in "${!my_hashmap[@]}"; do
echo "key: $key, val: ${my_hashmap[$key]}"
done
@tuananh
tuananh / aptdeps.sh
Last active November 1, 2023 03:29
apt find recursive dependencies of packages
#!/bin/bash
set -eu
declare -a all_deps=( )
for pkg_name in "$@"
do
declare -a deps=$(apt-cache depends -i --recurse $pkg_name | awk -F 'Depends: ' 'NF>1{ sub(/ .*/,"",$NF); print $NF }' | sort | uniq)
all_deps+=$deps
done
@tuananh
tuananh / install.sh
Created August 11, 2023 07:22
install.sh
#!/bin/sh
set -eu
# code-server's automatic install script.
# See https://coder.com/docs/code-server/latest/install
usage() {
arg0="$0"
if [ "$0" = sh ]; then
arg0="curl -fsSL https://code-server.dev/install.sh | sh -s --"
#!/bin/env bash
result=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" | fzf)
if [ $# -eq 0 ]
then
echo "kubectl exec -it $result /bin/bash"
kubectl exec -it "$result" /bin/bash
fi
cd /tmp
java -Xmx5g -jar /opt/sonatype/nexus/lib/support/nexus-orient-console.jar
CONNECT PLOCAL:/nexus-data/db/component admin admin
REBUILD INDEX *
REPAIR DATABASE --fix-graph
REPAIR DATABASE --fix-links
REPAIR DATABASE --fix-ridbags
REPAIR DATABASE --fix-bonsai
DISCONNECT
trivy image argoproj/argocd
2023-03-03T15:09:56.331+0700 INFO Vulnerability scanning is enabled
2023-03-03T15:09:56.331+0700 INFO Secret scanning is enabled
2023-03-03T15:09:56.331+0700 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2023-03-03T15:09:56.331+0700 INFO Please see also https://aquasecurity.github.io/trivy/v0.38/docs/secret/scanning/#recommendation for faster secret detection
^C
[ssm-user@ip-10-9-28-94 ~]$ trivy image argoproj/argocd:v2.6.3
2023-03-03T15:10:14.270+0700 INFO Vulnerability scanning is enabled
2023-03-03T15:10:14.270+0700 INFO Secret scanning is enabled
2023-03-03T15:10:14.270+0700 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning