Skip to content

Instantly share code, notes, and snippets.

@tubaterry
Last active October 3, 2019 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubaterry/8bcecca3b6f5a69b2eaf86422188de0a to your computer and use it in GitHub Desktop.
Save tubaterry/8bcecca3b6f5a69b2eaf86422188de0a to your computer and use it in GitHub Desktop.
One-liners
# This isn't REALLY a one-liner per-se, just a wildly effecient timesaver.
# But it did save my ass on a tight deadline when I didn't have supporting automation ready yet
# `pbcopy` (and its friend, `pbpaste`) are works of art.
for aws_account in `cat data_file.json | jq -r '.aws_account[] | .number'`; do
for role in `cat data_file.json | jq -r '.roles[]'`; do
echo "arn:someshitIforgot:${aws_account}:roles/${role}" | pbcopy
echo "Role copied, paste it into the policy document. Hit enter to continue."
# I'm not using PLACEHOLDER anywhere else in the real script, this is purely about lazy.
read PLACEHOLDER
done
done
# I'm using this to make an excel/sheets equation easier to read
# Take what's in your clipboard and replace it with the same thing minus newlines and spaces
echo `pbpaste` | tr -d " " | pbcopy
# Get a clean list of processes with listeners. Provides process name, pid, address, and port
sudo lsof -P | grep LISTEN | tr -s " " | cut -d " " -f 1,2,9- | sed -e s/TCP\ //g | sort -u
# Export a sensitive variable you're tired of typing but don't wanna expose in your command history
# Optionally: read -s VAR_NAME if your dingus terminal writes recent history to disk too
read VAR_NAME; export VAR_NAME="${VAR_NAME}"
#Quick-ass temp folder with date stamp
TODAY=`date +%Y%m%d`; mkdir temp-${TODAY}; cd temp-${TODAY};
#tbh this is probably wildly inefficient but I have that TODAY=`date blah blah` chunk update as part of my ZSH theme
# It's always ready that way.
# (technically: ~/.oh-my-zsh/custom/handy-vars.zsh, which gets called by my fingerguns.zsh-theme every time I hit enter lol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment