Snippets
SNP 001–148
Loosely organized collection of code snippets. Maybe you'll find something useful here.
Showing 20 of 148 snippets
-
SNP 128
#294
Find the commit that broke things with git bisect
Binary search through history, so 200 commits take 8 steps.
-
SNP 127
#53B
LLM prompt for reviewing a pull request
A second pair of eyes before you ask a human for theirs.
-
SNP 126
#A25
Pages from a CMS in Stati
Write the CMS's posts as Markdown before the build starts. A hook is too late.
-
SNP 125
#A45
Run a throwaway container with the current folder mounted
Try a tool, a Node version or a Python version without installing anything.
-
SNP 124
#316
Rerun a command whenever a file changes
A poor man's watch mode for anything that doesn't have one.
-
SNP 123
#952
Update a table from another table
Copy values across tables with a join, in MySQL, MariaDB and PostgreSQL.
-
SNP 122
#42A
Load .env files in Node without a package
dotenv is built into Node now.
-
SNP 121
#471
Compute page data in beforeAll, not beforeRender
A Stati hook that writes front matter in beforeRender makes those pages rebuild on every build.
-
SNP 120
#593
Reverse proxy a Node app with nginx
Your app listens on 3000, the world talks to nginx on 443.
-
SNP 119
#1B5
Copy your public key to a server
One command instead of pasting into authorized_keys by hand.
-
SNP 118
#639
Lazy load images without JavaScript
Two attributes and the browser handles it.
-
SNP 117
#235
Keep Stati's build cache between CI runs
Cache .stati and dist together, or the next build starts from nothing anyway.
-
SNP 116
#4B1
Mermaid sequence diagram quick reference
The handful of arrows and blocks I keep looking up.
-
SNP 115
#26B
chmod numbers explained
What 755 and 644 actually mean, so you stop copying them blindly.
-
SNP 114
#942
Rename files in bulk with Python
A pathlib loop beats fighting with the shell's rename command every time.
-
SNP 113
#531
Check when an SSL certificate expires from the terminal
Before the browser warning does it for you.
-
SNP 112
#61B
ISG aging rules in Stati
Rebuild new posts often and old ones rarely, and the catch on a static host.
-
SNP 111
#25B
Sweetie 16 as CSS variables
The palette this site is coloured with, ready to paste into a stylesheet.
-
SNP 110
#A14
Find which process uses a port on Windows
The Windows version of lsof -i :3000.
-
SNP 109
#942
stati invalidate cheat sheet
Clear Stati's build cache by tag, path, glob or age, and what each query really matches.
No snippets match this filter.