More in Security
Generate a strong random secret
Security
For session keys and tokens. Never reach for a password generator or a UUID for this.
Generate an SSH key and add it to the agent
Security
Ed25519 rather than RSA: shorter, faster, and no key-size decision to get wrong.
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
Count lines of code by extension
Shell
A quick census of a repository without installing a tool for it.
Amend a commit without changing its message
Git
Adds forgotten files to the previous commit and leaves the message exactly as it was.
Show what a merge will do before doing it
Git
Lists the commits and the files a merge would bring in, so a surprise is less likely.
Sort and deduplicate lines by a field
Text Processing
Sorts on the second column and keeps the first row of each group.
Null-safe chaining in Kotlin
Systems
?. stops at the first null and ?: supplies the fallback, replacing a stack of if statements.
Table-driven tests in Go
Testing
The idiomatic Go pattern: a slice of cases and a subtest per entry, each named so failures are readable.
Find the largest files with PowerShell
Shell
The Windows counterpart to du | sort | head.
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.