More in Testing
A test that fails for the right reason
Testing
Assert on the message, not merely that something threw. A typo raising TypeError would otherwise pass.
Table-driven tests in Go
Testing
The idiomatic Go pattern: a slice of cases and a subtest per entry, each named so failures are readable.
Freeze time in a test
Testing
Node's mock timers make anything date-dependent deterministic without injecting a clock everywhere.
Random picks
Which indexes is nobody using?
Databases
Lists indexes that have never been scanned, which are pure write cost. Check against a long uptime before dropping any.
Retry with exponential backoff and jitter
Python
Backs off on each failure and spreads retries out, so a recovering service is not hit by every client at once.
A GitHub Actions workflow for a Node project
Build & CI
Caches the dependency install, runs on a matrix of versions, and fails the build on a lint error.
Check a malloc result in C
Systems
The allocation that nobody checks is the one that fails in production.
Cache busting with a content hash
Build & CI
Names the built file after its contents so a deploy invalidates the cache without a version bump.
Run a command on every file changed in a commit
Shell
Lints only what a commit touched, which is usually all you need in a pre-commit hook.
A Makefile that documents itself
Build & CI
Running make with no arguments prints every target that carries a comment.
Rotate links
wordpress
Rotate daily link order