Skip to content

Instantly share code, notes, and snippets.

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

Michael A. Aurora12

🔥
burning with the fires of Orc
View GitHub Profile
@Aurora12
Aurora12 / gist:44f1cbf7f5ad267602963599e14f6c47
Last active November 18, 2024 14:40
Go mod replace package version with a commit
go mod edit -replace github.com/repo=github.com/repo@commit-hash
go mod tidy
go mod vendor
@Aurora12
Aurora12 / html-favicon-tab-badge.md
Last active August 27, 2024 15:31
Display notification badge over the favicon in a browser tab
<html>
<head>
	<link rel="icon" href="favicon.png" type="image/png" id="favicon" />
</head>

<script>
var badge = 0;
var icon = document.getElementById("favicon");
var original = new Image(32, 32);
@Aurora12
Aurora12 / random-bash.md
Last active July 23, 2024 14:07
Generate random strings in bash
shuf -er -n128 {A..Z} {a..z} {0..9}|tr -d '\n'
shuf -er -n20 {0..9}|sha512sum|cut -c 1-128
shuf -er -n20 {A..Z} {a-z} {0..9}|sha512sum|cut -c 1-128
openssl rand -base64 128|tr -d '\n'
@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"