Parse JSON into a typed value with a guard
Safely turn unknown JSON into a typed result by validating its shape instead of casting.
Loading snippets…
137 snippets
Safely turn unknown JSON into a typed result by validating its shape instead of casting.
Convert ISO timestamps to timezone-aware UTC datetimes and back, avoiding naive datetime bugs.
Handle -v, -o FILE and -h in a bash script with getopts and a usage message.
Process many files concurrently with xargs -P, safely handling spaces and newlines in names.
Wrap a function so it executes on the first call and returns the same result afterwards.
Encode "at least one element" in the type so head, max and similar functions never see an empty array.
Compute a 7-day rolling average with AVG over a ROWS BETWEEN frame.
Sensible defaults for box sizing, media, form fonts and text wrapping in a dozen lines.
Cache results by argument so expensive pure functions only run once per distinct input.
Memoize pure functions with a bounded least-recently-used cache and inspect or clear it.
Small log, warn and die helpers that write ISO timestamps to stderr and keep stdout clean for data.
Defer off-screen images and embeds with loading="lazy", while keeping the main image eager to protect LCP.