Last active
August 29, 2025 14:39
-
-
Save benjishults/5d58c0027efd62bda04505597b9f558c to your computer and use it in GitHub Desktop.
general purpose shell scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for this to work on MacOs, do | |
# > brew install coreutils | |
# then add this to your .zshrc: | |
# export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" | |
isoNow() { | |
date -u "+%Y-%m-%dT%H:%M:%S.%3NZ" | |
} | |
# > urlEncode ":&%:'\"fd" | |
#%3A%26%25%3A%27%22fd | |
urlEncode() { | |
printf %s "$1" | jq -sRr @uri | |
} | |
# > urlDecode %3A%26%25%3A%27%22fd | |
#:&%:'"fd | |
urlDecode() { | |
printf %s "$1" | jq -sRr @urid | |
} | |
# Usage: | |
# | |
# > echo '"asdf":'"$(escapeQuotes 'asdf"fds')" | |
# "asdf":"asdf\"fds" | |
escapeQuotes() { | |
printf %s "$@" | sed 's/["\]/\\&/g; s/.*/"&"/' | |
} | |
createBasicToken() { | |
printf "%s:%s" "$1" "$2" | base64 --wrap=0 | |
} | |
toLowerCase() { | |
printf %s "$1" | tr '[:upper:]' '[:lower:]' | |
} | |
spacesToColons() { | |
printf "%s" "$1" | sed 's/[ \]/::/g' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment