More in Networking
Open an SSH tunnel to a remote database
Networking
Forwards a local port through a bastion so a client can connect as if the database were local.
Call a JSON API from PowerShell
Networking
Invoke-RestMethod parses the response for you, so no ConvertFrom-Json step is needed.
Follow redirects and show only the headers
Networking
Traces a redirect chain to its destination without downloading the body.
Inspect a TLS certificate from the command line
Networking
Prints the subject, issuer and validity dates without opening a browser.
Time every phase of an HTTP request
Networking
Splits DNS, connect, TLS and first byte apart, which tells you which one is actually slow.
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.
Freeze time in a test
Testing
Node's mock timers make anything date-dependent deterministic without injecting a clock everywhere.
Throttle with a trailing call
JavaScript
Runs at most once per interval but still fires once more after the last event, so the final state is never dropped.
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.
Tail a log and colour only what matters
Shell
Follows a growing file and highlights errors and warnings, leaving the rest readable but quiet.
Time a block of code
Python
A context manager that prints how long its body took, without scattering time.perf_counter calls through the function.
A Makefile that documents itself
Build & CI
Running make with no arguments prints every target that carries a comment.
Truncate text to a number of lines
Web & CSS
Ellipsis after two lines. The -webkit- prefixes are still required despite being supported everywhere.