More in Shell
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.
Show which process is holding a port
Shell
Answers 'address already in use' without guessing.
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.
Serve the current directory over HTTP
Shell
Three ways to put a folder on localhost when you need to test something quickly.
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.
Random picks
Make some properties optional
TypeScript
Composes the built-in helpers rather than writing a second interface that will drift from the first.
YAML anchors to avoid repeating yourself
Data Formats
Define a block once, merge it into each service. Changing the base changes all of them.
Remove every stopped container and dangling image
Containers
Reclaims disk after a week of building. The volume flag is separate because it is the one that loses data.
Prepared statement with PDO
PHP
Placeholders rather than interpolation. This is the whole of SQL injection defence in PHP.
List branches merged into main
Git
Finds the branches that are safe to delete, and the ones that are not.
Result and the question mark operator in Rust
Systems
? propagates the error to the caller, which is why Rust functions rarely need explicit error branches.
Find slow queries in Postgres
Databases
Ranks statements by total time spent. Needs the pg_stat_statements extension enabled.
Context with a timeout in Go
Systems
Cancels the request and everything downstream of it after two seconds. The defer is not optional.