More in Shell
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.
Count lines of code by extension
Shell
A quick census of a repository without installing a tool for it.
Tail a log and colour only what matters
Shell
Follows a growing file and highlights errors and warnings, leaving the rest readable but quiet.
Watch a command until it succeeds
Shell
Retries every two seconds and stops the moment the command exits zero. Useful while waiting for a service to come up.
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.
Serve the current directory over HTTP
Shell
Three ways to put a folder on localhost when you need to test something quickly.
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.
Find the largest files with PowerShell
Shell
The Windows counterpart to du | sort | head.
Random picks
Iterate and collect in Rust
Systems
Filter and map fuse into a single pass; collect decides what comes out the other end.
Respect a reduced-motion preference
Web & CSS
One rule that disables animation for people who asked their system for less of it.
Reset a Postgres sequence after a bulk import
Databases
Copying rows with explicit ids leaves the identity sequence behind, so the next insert collides with an existing row.
Relative time without a date library
JavaScript
Turns a timestamp into 'three days ago' using the built-in formatter.
Copy text to the clipboard
JavaScript
The modern API needs a secure context and a real user gesture, so the failure path matters as much as the success one.
Pin a dependency to an exact version
Build & CI
Caret ranges are how a build that passed last week fails today. Exact versions plus a lockfile remove the surprise.
Throttle with a trailing call
JavaScript
Runs at most once per interval but still fires once more after the last event, so the final state is never dropped.
Show which process is holding a port
Shell
Answers 'address already in use' without guessing.