More in Networking
Time every phase of an HTTP request
Networking
Splits DNS, connect, TLS and first byte apart, which tells you which one is actually slow.
Inspect a TLS certificate from the command line
Networking
Prints the subject, issuer and validity dates without opening a browser.
Call a JSON API from PowerShell
Networking
Invoke-RestMethod parses the response for you, so no ConvertFrom-Json step is needed.
Which DNS records does a domain have?
Networking
dig with +short strips everything but the answer.
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.
Random picks
Narrow a union with a type guard
TypeScript
A predicate returning `x is T` teaches the compiler what a runtime check proved.
Read a large file without loading it into memory
Python
Iterating a file object yields one line at a time, which is the difference between a constant footprint and an OOM.
Merge dictionaries
Python
The | operator returns a new dict; |= updates in place. Later keys win in both.
Run promises with a concurrency limit
JavaScript
Keeps a fixed number of jobs in flight rather than firing a thousand requests at once.
Shell into a running container
Containers
Falls back to sh, since slim images often have no bash.
Group an array by a key
JavaScript
Object.groupBy is available in current runtimes; the reduce version is the fallback for older ones.
Sum a column with awk
Text Processing
Adds the third field of every line and prints the total, ignoring anything non-numeric.
Centre a box, two ways
Web & CSS
Grid is one line. Flex is three and gives you control over the axes separately.