Skip to content

Instantly share code, notes, and snippets.

View khaliqgant's full-sized avatar
💯
👨🏿‍💻

Khaliq khaliqgant

💯
👨🏿‍💻
View GitHub Profile
@khaliqgant
khaliqgant / space.sh
Created April 22, 2022 11:26
[Docker Disk Size Usage] See how much space docker is using #docker
docker system df
@khaliqgant
khaliqgant / cp.bash
Created May 5, 2022 07:19
[Docker CP] Copy Files from container/host #docker
# host to container
docker cp 2020-5-5-11-19.bak unruffled_khayyam:/var/opt/mssql/data/
# container to host
docker cp awesome_davinci:/var/opt/mssql/data/202048-12-28-43.bak .
@khaliqgant
khaliqgant / k8s-restart.bash
Created May 24, 2022 07:49
[Kubernetes Restart Deployment] Restart a deployment which will restart pods #kubernetes #infrastructure
k rollout restart deployment frontend
# k === kubectl
@khaliqgant
khaliqgant / command.sql
Created June 7, 2022 12:21
[Postgres Query Duration] Find long running postgres tasks #postgres #database
select now() - xact_start as duration, * from pg_stat_activity WHERE state = 'active';
SELECT max(now() - xact_start) FROM pg_stat_activity
WHERE state IN ('idle in transaction', 'active');
--- https://dba.stackexchange.com/questions/44084/troubleshooting-high-cpu-usage-from-postgres-and-postmaster-services
@khaliqgant
khaliqgant / download.sh
Created June 9, 2022 07:07
[Rsync Download] Download using rsync #rsync
rsync -avz hzn:/home/khaliq/repos/backend/docker/data/db/demo_data_05_02.sql .
@khaliqgant
khaliqgant / upload.sh
Created June 9, 2022 07:08
[Rsync Upload] Upload using rsync #rsync
rsync my_mock.sql -avz hzn:/home/khaliq/repos/backend/docker/data/db -v
@khaliqgant
khaliqgant / flags.sh
Created June 9, 2022 07:08
[Rsync Compression] Rsync compression flags #rsync
// bash variabes
repo=~/Sites/columbia-repo/
dropbox=~/Dropbox\ \(Personal\)/KJG/Personal/Education/Classes/Advanced\ Programming/homework
pass=$repo/auth/.pass
clic=clic:/home/kjg2150/cs3157
hw=~/Sites/columbia-repo/c/3157/hw
-avz =
a = archive
v = verbose
@khaliqgant
khaliqgant / changed.sh
Created June 9, 2022 07:09
[Rsync Only Changed Files] Only changed files #rsync
rsync -v -r --update . [email protected]:/storage/av03089/www/public_html
// test with dry run
rsync -v -r --update . [email protected]:/storage/av03089/www/public_html --dry-run
// had to run sudo -- run from the directory you want to transfer over
sudo rsync -v -r --update . [email protected]:/storage/av03089/www/public_html
@khaliqgant
khaliqgant / dropbox.sh
Created June 9, 2022 07:10
[Rsync Finances Sync] Sync from finances server #rsync
// syncing from my server to my dropbox some data files
rsync -r khaliqgant:/home/kjg/finances/data "/Users/kgant/Dropbox (Personal)/KJG/Personal/Finances/App Data Backup/"
@khaliqgant
khaliqgant / fallback.bash
Created July 13, 2022 08:23
[Bash Default Value] Fallback Variable For Bash #bash #cli
environment=${1:-develop}
FOO="${VARIABLE:=default}"
https://stackoverflow.com/questions/2013547/assigning-default-values-to-shell-variables-with-a-single-command-in-bash
https://stackoverflow.com/questions/9332802/how-to-write-a-bash-script-that-takes-optional-input-arguments