More in Systems
Nullable reference types in C#
Systems
Turning the feature on makes the compiler point at every place a null could slip through.
RAII file handling in C++
Systems
The stream closes itself when it leaves scope, whether the function returns normally or throws.
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.
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.
Iterate and collect in Rust
Systems
Filter and map fuse into a single pass; collect decides what comes out the other end.
Records and pattern matching in Java
Systems
A record plus a switch pattern removes most of the ceremony this used to take.
Async/await with a task group in Swift
Systems
Runs the downloads concurrently and collects them, with cancellation propagating to all of them.
Random picks
Serve the current directory over HTTP
Shell
Three ways to put a folder on localhost when you need to test something quickly.
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.
Narrow a union with a type guard
TypeScript
A predicate returning `x is T` teaches the compiler what a runtime check proved.
Pretty-print and query JSON
Text Processing
jq for the common cases: reformat, pick a path, filter an array, and reshape.
Deep clone a value
JavaScript
structuredClone handles Dates, Maps, Sets and cycles, which JSON round-tripping quietly destroys.
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.
Compose file with a healthcheck and dependency order
Containers
Makes the app wait until Postgres actually answers, not merely until its container has started.
Show which process is holding a port
Shell
Answers 'address already in use' without guessing.