More in Security
Check a file's checksum
Security
Verifies a download actually matches what the publisher signed, rather than trusting the transfer.
Generate a strong random secret
Security
For session keys and tokens. Never reach for a password generator or a UUID for this.
A starting Content-Security-Policy
Security
Blocks inline script and restricts everything to the origin. Tighten from here rather than loosening from nothing.
Security headers for an Express app
Security
The handful worth setting even when you are not using a framework that sets them for you.
Compare secrets in constant time
Security
A plain === leaks how much of the token matched through its timing. This does not.
Random picks
Make some properties optional
TypeScript
Composes the built-in helpers rather than writing a second interface that will drift from the first.
Recover a branch you deleted
Git
The reflog remembers where HEAD has been for about ninety days, so a deleted branch is almost never really gone.
Undo the last commit but keep the changes
Git
Moves HEAD back one commit and leaves everything staged, which is what you usually want after committing too early.
List branches merged into main
Git
Finds the branches that are safe to delete, and the ones that are not.
Copy text to the clipboard
JavaScript
The modern API needs a secure context and a real user gesture, so the failure path matters as much as the success one.
Safe navigation and fetch in Ruby
Ruby
&. stops at nil; fetch raises rather than returning nil when a key is genuinely required.
Check a malloc result in C
Systems
The allocation that nobody checks is the one that fails in production.
Parameterised tests in Python
Testing
One test body, many cases, and a failure that names the case that broke.