Snippet
-
Postgres advisory locks for cross-process deduplication
A cheap mutex across N service replicas that does not need Redis.
-
Deduplicating in-flight requests with singleflight
Ten lines that collapse a thundering herd into a single upstream call.
-
AWK script that sums a column with a header
The awk one-liner I keep forgetting, with the one option that made it robust.
-
A tiny Rust macro for safe env var parsing
A declarative macro that turns std::env::var into a typed, required-or-default lookup.
-
Nginx location block to serve one file under many names
A tiny block for robots.txt, favicon, humans.txt and all their cousins.
-
Postgres: find long-running queries and who is blocking whom
A view of pg_stat_activity that tells me the query and its blockers in one shot.
-
errgroup that cancels siblings on the first error
The 10-line pattern that replaces half the goroutine orchestration I used to write.
-
Find files modified today across multiple repos
A shell one-liner I run every morning to remember what I was touching yesterday.
-
Postgres query to find bloated indexes
A quick-and-dirty bloat estimate so I can decide which indexes to REINDEX tonight.
-
Deadline-wrapping an io.Reader
A small helper to cancel a slow read with a deadline, using context and a goroutine proxy.