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 under a directory
Shell
Sorts everything beneath the working directory by real disk usage and shows the twenty worst offenders.
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'.
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 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.
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.
Count lines of code by extension
Shell
A quick census of a repository without installing a tool for it.
Random picks
Hash and verify a password in PHP
PHP
password_hash picks the algorithm and the salt. Never store anything a hash function can reverse.
Table sizes, largest first
Databases
Where the disk actually went, including indexes and TOAST.
Sort and deduplicate lines by a field
Text Processing
Sorts on the second column and keeps the first row of each group.
Sum a column with awk
Text Processing
Adds the third field of every line and prints the total, ignoring anything non-numeric.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.
An RSS feed skeleton
Data Formats
The minimum a reader needs. Dates must be RFC 822, which is the part most generators get wrong.
Which DNS records does a domain have?
Networking
dig with +short strips everything but the answer.
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.