More in Systems
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.
Nullable reference types in C#
Systems
Turning the feature on makes the compiler point at every place a null could slip through.
Read a file into a string in Go
Systems
os.ReadFile replaced ioutil.ReadFile in 1.16 and is the one-liner for small files.
Iterate and collect in Rust
Systems
Filter and map fuse into a single pass; collect decides what comes out the other end.
RAII file handling in C++
Systems
The stream closes itself when it leaves scope, whether the function returns normally or throws.
Context with a timeout in Go
Systems
Cancels the request and everything downstream of it after two seconds. The defer is not optional.
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.
Records and pattern matching in Java
Systems
A record plus a switch pattern removes most of the ceremony this used to take.
Random picks
Format a number as currency
JavaScript
Intl handles the symbol, the separators and the decimal places for the locale, so you never hand-roll them.
Hash and verify a password in PHP
PHP
password_hash picks the algorithm and the salt. Never store anything a hash function can reverse.
Recover a branch you deleted
Git
The reflog remembers where HEAD has been for about ninety days, so a deleted branch is almost never really gone.
Which DNS records does a domain have?
Networking
dig with +short strips everything but the answer.
Pretty-print and query JSON
Text Processing
jq for the common cases: reformat, pick a path, filter an array, and reshape.
Security headers for an Express app
Security
The handful worth setting even when you are not using a framework that sets them for you.
Make some properties optional
TypeScript
Composes the built-in helpers rather than writing a second interface that will drift from the first.
A README that people actually read
Data Formats
The order matters more than the length: what it is, how to run it, how to develop on it.