Assert a value is not null or undefined
An assertion function that narrows away null and undefined and throws a clear error otherwise.
Loading snippets…
137 snippets
An assertion function that narrows away null and undefined and throws a clear error otherwise.
Reserve space for videos and images with aspect-ratio so the page does not jump while loading.
A small CLI with a positional argument, flags, a main function and proper exit codes.
Use caption, thead, th scope and a scroll wrapper so screen readers and small screens handle tables well.
Hide content visually while keeping it available to assistive technology.
Validate an HMAC-SHA256 webhook against the raw request body with a constant-time comparison and replay window.
Validate a signed webhook body with hmac.compare_digest and a timestamp tolerance.
Check a webhook or signed-request HMAC with hash_hmac and hash_equals to avoid timing attacks.
Insert a row or update it if the unique key already exists, atomically and safely under concurrency.
Copy selected keys from an object (or drop some) with return types that match at compile time.
Archive a directory with a sortable timestamp and delete older backups beyond a retention count.
Run a function at most once per interval, calling immediately and again at the end of a burst.