Snippets

SNP 001–148

Loosely organized collection of code snippets. Maybe you'll find something useful here.

Showing 20 of 148 snippets

  1. SNP 128 #294

    Find the commit that broke things with git bisect

    Binary search through history, so 200 commits take 8 steps.

  2. SNP 127 #53B

    LLM prompt for reviewing a pull request

    A second pair of eyes before you ask a human for theirs.

  3. 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.

  4. 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.

  5. SNP 124 #316

    Rerun a command whenever a file changes

    A poor man's watch mode for anything that doesn't have one.

  6. SNP 123 #952

    Update a table from another table

    Copy values across tables with a join, in MySQL, MariaDB and PostgreSQL.

  7. SNP 122 #42A

    Load .env files in Node without a package

    dotenv is built into Node now.

  8. 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.

  9. SNP 120 #593

    Reverse proxy a Node app with nginx

    Your app listens on 3000, the world talks to nginx on 443.

  10. SNP 119 #1B5

    Copy your public key to a server

    One command instead of pasting into authorized_keys by hand.

  11. SNP 118 #639

    Lazy load images without JavaScript

    Two attributes and the browser handles it.

  12. SNP 117 #235

    Keep Stati's build cache between CI runs

    Cache .stati and dist together, or the next build starts from nothing anyway.

  13. SNP 116 #4B1

    Mermaid sequence diagram quick reference

    The handful of arrows and blocks I keep looking up.

  14. SNP 115 #26B

    chmod numbers explained

    What 755 and 644 actually mean, so you stop copying them blindly.

  15. SNP 114 #942

    Rename files in bulk with Python

    A pathlib loop beats fighting with the shell's rename command every time.

  16. SNP 113 #531

    Check when an SSL certificate expires from the terminal

    Before the browser warning does it for you.

  17. SNP 112 #61B

    ISG aging rules in Stati

    Rebuild new posts often and old ones rarely, and the catch on a static host.

  18. SNP 111 #25B

    Sweetie 16 as CSS variables

    The palette this site is coloured with, ready to paste into a stylesheet.

  19. SNP 110 #A14

    Find which process uses a port on Windows

    The Windows version of lsof -i :3000.

  20. SNP 109 #942

    stati invalidate cheat sheet

    Clear Stati's build cache by tag, path, glob or age, and what each query really matches.