More in Shell
Show which process is holding a port
Shell
Answers 'address already in use' without guessing.
Find the largest files under a directory
Shell
Sorts everything beneath the working directory by real disk usage and shows the twenty worst offenders.
Count lines of code by extension
Shell
A quick census of a repository without installing a tool for it.
Serve the current directory over HTTP
Shell
Three ways to put a folder on localhost when you need to test something quickly.
Find the largest files with PowerShell
Shell
The Windows counterpart to du | sort | head.
Delete files older than thirty days
Shell
Prunes an archive directory without touching anything recent. Run it with -print first to see what would go.
Make a shell script fail loudly
Shell
The four lines that turn a script from 'carries on after an error' into 'stops at the first problem'.
Rename a batch of files with a pattern
Shell
Strips a prefix from every file in a directory using shell parameter expansion, no rename utility required.
Random picks
Compose file with a healthcheck and dependency order
Containers
Makes the app wait until Postgres actually answers, not merely until its container has started.
Merge dictionaries
Python
The | operator returns a new dict; |= updates in place. Later keys win in both.
Escape output in a PHP template
PHP
htmlspecialchars with the flags spelled out, because the defaults have changed between versions.
Iterate and collect in Rust
Systems
Filter and map fuse into a single pass; collect decides what comes out the other end.
Time every phase of an HTTP request
Networking
Splits DNS, connect, TLS and first byte apart, which tells you which one is actually slow.
Narrow a union with a type guard
TypeScript
A predicate returning `x is T` teaches the compiler what a runtime check proved.
Generate a strong random secret
Security
For session keys and tokens. Never reach for a password generator or a UUID for this.
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.