Skip to content

Instantly share code, notes, and snippets.

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

Khaliq khaliqgant

💯
👨🏿‍💻
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / jq.bash
Created April 21, 2022 10:14
[JQ Boolean to Integer] Convert a boolean to an integer #jq #cli
cat customers/develop.json | jq '. [] | select(.creates_infrastructure_foundation == true)' | jq 'if .run_edge then 1 else 0 end'
Source: https://www.garysieling.com/blog/jq-boolean-integer/
@khaliqgant
khaliqgant / slack.command
Created March 31, 2022 14:48
[Slack Subscriptions] Slack Github Subscriptions #slack #github
/github subscribe MyCorp/infrastructure comments reviews
@khaliqgant
khaliqgant / import.hcl
Created March 29, 2022 11:51
[Terraform Import] Import Module #terraform #infrastructure
terraform import -var-file="../prod.tfvars" 'module.ip-address.azurerm_public_ip.static_ip' /subscriptions/6ba1-4e5d-a23e-0e4d3a59208d/resourceGroups/MC_h-network-resources_h-cluster_northeurope/providers/Microsoft.Network/publicIPAddresses/h-ip
terraform import -var-file="../prod.tfvars" 'module.key-vault.azurerm_key_vault.main' /subscriptions/6ba1-4e5d-a23e-0e4d3a59208d/resourceGroups/h-resources/providers/Microsoft.KeyVault/vaults/h
@khaliqgant
khaliqgant / conditional.hcl
Created March 29, 2022 11:49
[Terraform Conditional Module] Conditional Module #terraform #infrastructure
Version 11
count = "${var.create_bucket == true ? 1 : 0}"
> version 12
count = var.db_username != "" ? 1 : 0
Version 13
count = var.create_bucket ? 1 : 0
@khaliqgant
khaliqgant / tags.hcl
Created March 29, 2022 11:49
[Terraform Merge] Merge Tags #terraform #infrastructure
tags = merge(
{
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
},
var.tags,
)