More in Security
A starting Content-Security-Policy
Security
Blocks inline script and restricts everything to the origin. Tighten from here rather than loosening from nothing.
Check a file's checksum
Security
Verifies a download actually matches what the publisher signed, rather than trusting the transfer.
Security headers for an Express app
Security
The handful worth setting even when you are not using a framework that sets them for you.
Generate an SSH key and add it to the agent
Security
Ed25519 rather than RSA: shorter, faster, and no key-size decision to get wrong.
Compare secrets in constant time
Security
A plain === leaks how much of the token matched through its timing. This does not.
Random picks
Chunk an iterable into fixed-size batches
Python
itertools.batched on 3.12 and later; the islice version works everywhere and never materialises the whole input.
Table sizes, largest first
Databases
Where the disk actually went, including indexes and TOAST.
Find what is taking up space in an image
Containers
Prints the size each layer adds, which usually points straight at the offending RUN line.
An RSS feed skeleton
Data Formats
The minimum a reader needs. Dates must be RFC 822, which is the part most generators get wrong.
Fetch with a timeout
JavaScript
fetch has no timeout of its own. AbortSignal.timeout is the short way to give it one.
List branches merged into main
Git
Finds the branches that are safe to delete, and the ones that are not.
Remove every stopped container and dangling image
Containers
Reclaims disk after a week of building. The volume flag is separate because it is the one that loses data.
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.