More in Containers
Compose file with a healthcheck and dependency order
Containers
Makes the app wait until Postgres actually answers, not merely until its container has started.
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.
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.
Multi-stage Dockerfile for a Node service
Containers
Builds with the full toolchain, ships only production dependencies, and runs as a non-root user.
Random picks
Which DNS records does a domain have?
Networking
dig with +short strips everything but the answer.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.
Sum a column with awk
Text Processing
Adds the third field of every line and prints the total, ignoring anything non-numeric.
RAII file handling in C++
Systems
The stream closes itself when it leaves scope, whether the function returns normally or throws.
Show which process is holding a port
Shell
Answers 'address already in use' without guessing.
Debounce without pulling in a library
JavaScript
Twelve lines covering the case most projects add a dependency for, including cancelling a call that has not fired yet.
A dataclass with validation
Python
__post_init__ runs after the generated constructor, which is where cheap invariants belong.
A starting Content-Security-Policy
Security
Blocks inline script and restricts everything to the origin. Tighten from here rather than loosening from nothing.