More in Text Processing
Sum a column with awk
Text Processing
Adds the third field of every line and prints the total, ignoring anything non-numeric.
Replace text across a whole project
Text Processing
ripgrep finds the files, sed edits them in place. The dry run first is not optional.
Extract matches with a regular expression
Text Processing
grep -o prints only the matching part, which turns grep into a crude extractor.
Sort and deduplicate lines by a field
Text Processing
Sorts on the second column and keeps the first row of each group.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.
Rewrite a CSV column with perl
Text Processing
A one-liner that upper-cases the second field of every row, leaving the rest alone.
Random picks
A GitHub Actions workflow for a Node project
Build & CI
Caches the dependency install, runs on a matrix of versions, and fails the build on a lint error.
Upsert a row in SQLite
Databases
Inserts, or updates the existing row when the unique column already holds that value.
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.
Compare secrets in constant time
Security
A plain === leaks how much of the token matched through its timing. This does not.
Multi-stage Dockerfile for a Node service
Containers
Builds with the full toolchain, ships only production dependencies, and runs as a non-root user.
Records and pattern matching in Java
Systems
A record plus a switch pattern removes most of the ceremony this used to take.
Group an array by a key
JavaScript
Object.groupBy is available in current runtimes; the reduce version is the fallback for older ones.
Table sizes, largest first
Databases
Where the disk actually went, including indexes and TOAST.