misc
A scratchpad. Shell one-liners I keep coming back to, links worth a second visit, notes I'd otherwise lose.
-
On rewrites
Most rewrites are mistakes. The rewrites that aren't are the ones where the platform you're built on grew a primitive that subsumes one of your components. The cost of the rewrite is paid; the cost of carrying the old way is paid forever.
-
Quickly check what's actually in your PATH
I use this one weekly. Splits $PATH on colons, one per line, easy to scan.
echo $PATH | tr ':' '\n' -
The Twelve-Factor App
Old, still right. I re-read it whenever I'm about to put config in a YAML file.
-
Find the largest things on disk
Faster than any GUI disk-usage tool. Pipe it to `head` if you only want the top offenders.
du -h -d 1 . 2>/dev/null | sort -rh -
shellcheck saves embarrassment
Every time I add it to a project I find at least one bug I'd already shipped. It is a quiet, free, install-once linter that catches the bash mistakes you didn't know you were making.
-
On naming
I have spent more hours on names than on the code those names live in. I do not regret a single one. A bad name compounds; a good name pays for itself the first time someone else reads it.
-
Stop forgetting your EC2 is running
Cron this if you're forgetful about test instances. Stops anything tagged `Env=dev` every night at midnight UTC.
aws ec2 stop-instances --instance-ids \ $(aws ec2 describe-instances \ --filters Name=tag:Env,Values=dev Name=instance-state-name,Values=running \ --query 'Reservations[].Instances[].InstanceId' \ --output text) -
Julia Evans on debugging
If you write software and you haven't read her zines, you're missing one of the kindest debugging educations on the internet.