Skip to content

Instantly share code, notes, and snippets.

@MrHen
Last active June 24, 2022 12:55
Show Gist options
  • Save MrHen/515d89d85c9cc46def29b8de8f94061f to your computer and use it in GitHub Desktop.
Save MrHen/515d89d85c9cc46def29b8de8f94061f to your computer and use it in GitHub Desktop.
Scratchpad

AWS

KMS

aws kms encrypt --key-id '' --plaintext '' --query CiphertextBlob --output text
aws kms decrypt --ciphertext-blob fileb://<(echo '' | base64 -D)
aws kms decrypt --ciphertext-blob fileb://<(echo '' | base64 -D) --output text --query Plaintext | base64 -D

RDS

aws rds download-db-log-file-portion --db-instance-identifier prod-reporting-api --log-file-name error/postgresql.log.2019-08-15-13 --output text --starting-token 0 > full.txt

git

git branch --merged master | egrep -v '^\s*\*?\s*master$' | xargs git branch -d

gpg

gpg --output doc.gpg --encrypt --recipient business@myalerts.com doc
gpg --output lists_mcom.csv.gz.gpg --encrypt --armor --recipient business@myalerts.com lists_mcom_item.csv.gz
gpg --output mcom_wishlist_item_TEST.txt.gz.gpg --recipient D48D0A81 --encrypt mcom_wishlist_item_TEST.txt.gz

gpg --output abc2.txt --decrypt abc.gpg

gpg --list-keys
gpg --export-secret-key --armor -a 'qa@myalerts.com' > private.asc

Postgres

TIMESTAMP WITH TIME ZONE 'epoch' + p.imported / 1000 * INTERVAL '1 second' AS imported_date
CREATE TEMP TABLE ab_one
  (key, val) AS
VALUES 
  (0::bigint, -99999::int), 
  (1, 100) ;

UPDATE campaigns_campaign_meta_record metas
SET
  assignee_id = contacts.agent_id
FROM contacts_newcontactrecord contacts
WHERE metas.newest_contact_entry_id = contacts.id
  AND metas.campaign_id = 321
  AND metas.assignee_id is null
  AND metas.newest_contact_entry_id is not null
;

Credstash

credstash put key.goes.here "$(openssl rand -hex 10)"
credstash put key.goes.here "$(cat filename)"

curl

curl -H "Content-Type: application/json" -X POST https://example.com/ -d '{"hello": "world"}'

ECS

aws ecs run-task --cluster test --task-definition test-reporting-client:1 --overrides '{"containerOverrides": [{"name": "test-reporting-client", "command": ["deploy"]}]}'

Docker

docker-compose up -d --build --force-recreate --renew-anon-volumes reporting-2-client

Terraform

terraform import aws_cloudwatch_metric_alarm.outbound-events-emails-read-alarm prod-outbound-events-emails-ReadCapacityUnitsLimit-BasicAlarm
terraform state rm aws_cloudwatch_metric_alarm.outbound-events-emails-read-alarm
terraform output -module=cx-db

SSL / SSH

ssh-keygen -f adam_babcock
ssh-keygen -i -f jake_selvey_2019_07.pub > jake_selvey_2019_07.pem
scp -P 2222 ~/Downloads/id_rsa sftp.cwc.centriam.com:/tmp/adam.babcock
openssl x509 -in cert.der -inform der -text -noout

Ubuntu

journalctl -u service-name.service
tail -f /var/log/jcagent.log

Finding large files

du -a /dir/ | sort -n -r | head -n 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment