Things I've written down.
Ruby, Rails, performance, security and applied machine learning. Updated when something feels finished.
Secrets that stay secret
The dangerous part is not storage. It's that a secret in git history is still there after you delete the file — and .gitignore won't save you.
Stop guessing: profiling Ruby properly
Benchmarking a suspicion confirms the suspicion. A sampling profiler tells you where the time actually went.
Retries fell 30% when I stopped retrying the wrong things
A retry is a bet that the failure was temporary. Most retried jobs were losing that bet — and the ones that won were doing their work twice.
Reading a query plan without fear
EXPLAIN output looks impenetrable and answers three questions. Those three cover most of what makes a query slow.
Your logs are a database nobody secured
Logs are copied to aggregators, retained for months and read by people who would never be granted access to the production database.
Migrations that don't take the site down
The dangerous migrations aren't the slow ones. They're the ones that take a lock while old and new code are both running.
One statement instead of ten thousand
Saving records in a loop is the slowest correct way to write data. The alternatives are faster and quietly skip things you may be relying on.
Counting on read is a bug you ship on purpose
A count in a loop is the N+1 nobody spots, because each query is fast and the logs look fine.
Accepting files from strangers
An upload endpoint accepts arbitrary bytes chosen by someone you don't know. Almost every mistake here comes from trusting what they say it is.