More in Shell
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.
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.
Find the largest files under a directory
Shell
Sorts everything beneath the working directory by real disk usage and shows the twenty worst offenders.
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.
Tail a log and colour only what matters
Shell
Follows a growing file and highlights errors and warnings, leaving the rest readable but quiet.
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.
Show which process is holding a port
Shell
Answers 'address already in use' without guessing.
Random picks
Retry a fetch with exponential backoff
JavaScript
Backs off on each failure and adds jitter, so a recovering service is not hit by every client at the same moment.
Type a fetch response safely
TypeScript
unknown forces a parse step rather than letting an any spread silently through the codebase.
Show what a merge will do before doing it
Git
Lists the commits and the files a merge would bring in, so a surprise is less likely.
A Makefile that documents itself
Build & CI
Running make with no arguments prints every target that carries a comment.
Group an array by a key
JavaScript
Object.groupBy is available in current runtimes; the reduce version is the fallback for older ones.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.
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.
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.