Skip to content

Instantly share code, notes, and snippets.

View Aurora12's full-sized avatar
🔥
burning with the fires of Orc

Michael Antipin Aurora12

🔥
burning with the fires of Orc
View GitHub Profile
@Aurora12
Aurora12 / find-append.md
Last active April 2, 2024 10:27
Recursively find all files with extension and append something to them
find ./ -type f -name "*.ts" -exec bash -c "echo -e \"// $(date -u)\" >> {}" \;
@Aurora12
Aurora12 / openssl.rsa.sh
Last active May 10, 2023 09:13
Basic openssl encrypt-decrypt with RSA
# Generate a private key
# Note: RSA can only encrypt messages that have fewer bits than the key.
openssl genrsa -des3 -out ./private4096.pem 4096
# Export public key
openssl rsa -in ./private4096.pem -outform PEM -pubout -out ./public4096.pem
# Encrypt
openssl rsautl -encrypt -inkey ./public4096.pem -pubin -out ./ciphertext.$(date +'%Y-%m-%d_%H-%M-%S') -in ./plaintext.file
@Aurora12
Aurora12 / get-prev-tag.md
Created July 26, 2022 10:29
Get the previous semver Git tag
git fetch --tags -f
git tag|grep -B 1 vX.Y.Z|head -n 1
@Aurora12
Aurora12 / git-delete-tags.md
Created July 5, 2022 10:38
Git: delete tags matching pattern
git tag -d $(git tag -l "vX.*")
git push -d origin $(git tag -l "vX.*")

-d is the short for --delete

@Aurora12
Aurora12 / macos-ssh.md
Last active July 26, 2022 10:29
macOS configuration setting for SSH sessions

By default, SSH sessions are dropped after a small period of time (broken pipe) on macOS. This setting in /etc/ssh/ssh_config prevents this:

Host *
        ServerAliveInterval 60
@Aurora12
Aurora12 / dump-pg-k8s.sh
Created August 31, 2021 16:01
Get a PostgreSQL database dump from a running K8s container
SOURCE="$POD:/tmp/dump.sql"
TARGET="./dump.compressed.sql"
kubectl exec -n $NS --stdin --tty $POD -c $CONTAINER -- pg_dump -f /tmp/dump.sql -F c -Z 9 -U $DBUSER $DBNAME
kubectl cp -n $NS -c $CONTAINER "$SOURCE" "$TARGET"
@Aurora12
Aurora12 / copy-k8s.sh
Created August 31, 2021 15:58
Copy a file from a running K8s container
SOURCE="$POD:/path/to/a/file"
TARGET="./file"
kubectl cp -n $NS -c $CONTAINER "$SOURCE" "$TARGET"
@Aurora12
Aurora12 / misc-k8s.sh
Last active January 24, 2022 13:47
Snippets for bashing to a running K8s container
# List namespaces
kubectl get ns
# List pods in a namespace
kubectl -n $NS get pod
# List containers in a pod
kubectl -n $NS describe pod $POD
# Bash to a pod
@Aurora12
Aurora12 / 2-list-containers.sh
Last active November 12, 2021 11:19
List containers in a K8s pod
# All entites in k8s can be inspected with describe
kubectl -n $NAMESPACE describe pod $POD
@Aurora12
Aurora12 / 1-get-pod.sh
Last active November 12, 2021 11:18
Get list of pods in a K8s namespace
# All entities in k8s can be listed with get
kubectl -n $NS get pod