Snippets

SNP 001–148

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

Showing 20 of 148 snippets

  1. SNP 088 #245

    Pick a random element in GDScript

    Random loot, random lines, random enemies. Godot 4 has it built in.

  2. SNP 087 #694

    Delete all branches that are already merged

    Thirty old feature branches in git branch? Clean house in one line.

  3. SNP 086 #3B1

    Sync a folder to S3

    Upload a built site to a bucket, sending only what changed.

  4. SNP 085 #349

    An RSS feed for one folder in Stati

    Why contentPatterns needs a **/ in front, and the link Stati doesn't add for you.

  5. SNP 084 #45A

    __dirname in ES modules

    It's gone in ESM. Here is the replacement, and the newer, nicer one.

  6. SNP 083 #962

    Tunnel to a remote database over SSH

    Use your local database tools on a server's database that isn't exposed to the internet.

  7. SNP 082 #135

    Fluid font sizes with clamp

    A heading that grows with the viewport between a minimum and a maximum, no media queries.

  8. SNP 081 #152

    Your own title format with Stati's SEO tags

    Write the <title> yourself and let Stati fill in the rest of the head.

  9. SNP 080 #259

    List listening ports on linux

    What is this server actually exposing to the world?

  10. SNP 079 #B41

    v-model on your own component with defineModel

    Vue 3.4 made two-way binding on custom components a one-liner.

  11. SNP 078 #A47

    A nested table of contents in Stati

    stati.page.toc is a flat list. A few lines of Eta turn it into nested lists.

  12. SNP 077 #396

    Delete duplicate rows but keep one

    Clean up a table after finding the duplicates, keeping the oldest of each.

  13. SNP 076 #614

    Environment variables in Nuxt

    Runtime config, the NUXT_ prefix and which values end up in the browser.

  14. SNP 075 #3A1

    Callout boxes in Stati Markdown

    GitHub's > [!NOTE] syntax as a small markdown-it rule.

  15. SNP 074 #52B

    Upscale pixel art with ImageMagick without blur

    Turn a 32 px sprite into a 256 px image where every pixel stays a square.

  16. SNP 073 #513

    Add markdown-it plugins to Stati

    Footnotes, containers and emoji, and the plugin that has to go through configure instead.

  17. SNP 072 #935

    Do something when an element scrolls into view

    Lazy loading, fade-ins and "read" markers without a scroll listener.

  18. SNP 071 #426

    Find and replace text in many files with sed

    Rename a function across a project from the terminal.

  19. SNP 070 #15A

    Disable SSH password login on a server

    Once your key works, close the door the bots keep knocking on.

  20. SNP 069 #2B4

    Highlight code with Shiki in Stati

    Build-time syntax highlighting with Shiki, ready before Stati's synchronous markdown.configure runs.