More in Shell
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'.
Find the largest files with PowerShell
Shell
The Windows counterpart to du | sort | head.
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.
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 under a directory
Shell
Sorts everything beneath the working directory by real disk usage and shows the twenty worst offenders.
Serve the current directory over HTTP
Shell
Three ways to put a folder on localhost when you need to test something quickly.
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
Safe navigation and fetch in Ruby
Ruby
&. stops at nil; fetch raises rather than returning nil when a key is genuinely required.
Delete duplicate rows, keeping the oldest
Databases
Uses a window function to number the duplicates and removes everything but the first of each group.
Worker pool with a wait group in Go
Systems
Fixed number of goroutines draining a channel, with the group ensuring main waits for all of them.
YAML anchors to avoid repeating yourself
Data Formats
Define a block once, merge it into each service. Changing the base changes all of them.
Table-driven tests in Go
Testing
The idiomatic Go pattern: a slice of cases and a subtest per entry, each named so failures are readable.
Fetch with a timeout
JavaScript
fetch has no timeout of its own. AbortSignal.timeout is the short way to give it one.
Records and pattern matching in Java
Systems
A record plus a switch pattern removes most of the ceremony this used to take.
Centre a box, two ways
Web & CSS
Grid is one line. Flex is three and gives you control over the axes separately.