Skip to content

Instantly share code, notes, and snippets.

@jda0
Last active July 3, 2024 16:32
Show Gist options
  • Save jda0/dc25ca85842b188e98444dc1ec115b39 to your computer and use it in GitHub Desktop.
Save jda0/dc25ca85842b188e98444dc1ec115b39 to your computer and use it in GitHub Desktop.
# Mistakes
alias sudo='sudo ';
alias fuck='sudo $(history -p !!)';
# Rich copy (pbcopy doesn't like file handles)
yy () {
osascript \
-e 'on run args' \
-e 'set the clipboard to POSIX file (first item of args)' \
-e end \
"$@"
}
# Make gifs
gif () {
local resize
if [[ "$1" == '-r' ]]; then
local width
if [ "$#" -lt 3 ]; then width='800'; else width=$2; fi
resize=",scale=$width:-1"
else resize=''; fi
target=${@: -1}
ffmpeg -hide_banner -loglevel panic -i "$target" -f gif -filter_complex "[0:v] fps=10$resize,split [a][b];[a] palettegen [p];[b][p] paletteuse" - | gifsicle --optimize=3 -o "$target.gif"
}
webm () {
local resize
if [[ "$1" == '-r' ]]; then
local width
if [ "$#" -lt 3 ]; then width='800'; else width=$2; fi
resize=",scale=$width:-1"
else resize=''; fi
target=${@: -1}
ffmpeg -hide_banner -loglevel panic -i "$target" -an -crf 40 -movflags faststart -vf "fps=10,scale=1920:-2,unsharp=5:5:1.0" "$target.webm"
}
# Utilities
alias al='aws-login';
alias jq='gojq '
dirty () {
git status | perl -n -e'/(new file:|modified:|renamed:.+->)\s+(.+\S\.py)/ && print " $2"'
}
aws-ecr-login () {
AWS_ACCOUNT_ID=`aws configure get sso_account_id`
AWS_REGION=`aws configure get region`
aws ecr get-login-password --region ${AWS_REGION} |
docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com
}
killof () {
local lsof_args=()
local kill_args=()
local target_switch=''
for arg in "$@"; do
if [[ "$arg" == '--' ]]; then target_switch=1
else
if [ -z "$target_switch" ]; then lsof_args+=("$arg");
else kill_args+=("$arg")
fi
fi
done
lsof $lsof_args | awk 'NR>1 {print $2}' | xargs kill $kill_args
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment