Snippets
SNP 001–148
Loosely organized collection of code snippets. Maybe you'll find something useful here.
Showing 20 of 148 snippets
-
SNP 068
#B26
Exhaustive switch in TypeScript
Make the compiler complain when you add a case to a union and forget to handle it.
-
SNP 067
#694
Redirect from a route middleware in Nuxt
Send people who aren't logged in to the login page before the page even renders.
-
SNP 066
#742
Serve Stati's clean URLs from nginx
/about is about.html. The try_files line, the trailing slash redirect and the 404 page.
-
SNP 065
#513
Check if a port is open from the terminal
Is it the firewall, the service, or me?
-
SNP 064
#A42
Stop tracking a file without deleting it
You committed .env or a build folder. Get it out of git but keep it on disk.
-
SNP 063
#13B
Class names with stati.propValue
Stati's own classnames, for class lists with conditions in them.
-
SNP 062
#295
Find the processes eating your memory
The server is swapping. Who's responsible?
-
SNP 061
#351
Format dates without a library
Intl.DateTimeFormat does most of what you used moment or date-fns for.
-
SNP 060
#495
Custom template filters in Stati
A date format and a reading time, registered once in the config and called like functions.
-
SNP 059
#64B
Sign your commits with your SSH key
Verified badges on GitHub without setting up GPG.
-
SNP 058
#B12
Send JSON with curl
POST a JSON body to an API from the terminal, and read the answer.
-
SNP 057
#641
Pick a layout per page in Stati
How Stati finds a page's layout, and the typo it won't tell you about.
-
SNP 056
#496
Group an array by a key
Object.groupBy is finally a thing. Here it is, with the fallback for older runtimes.
-
SNP 055
#539
Pixel-perfect settings in Godot 4
The project settings that keep pixel art sharp when the window is scaled.
-
SNP 054
#1B3
Different git identity for work and personal projects
Stop committing to work repos with your personal email, automatically.
-
SNP 053
#359
Partials with props in Stati
A card component that takes data, and the one line that keeps it from breaking every page.
-
SNP 052
#25A
Fetch with a timeout
fetch() waits forever by default. Give up after a few seconds.
-
SNP 051
#941
Crontab cheat sheet
The five fields, the shortcuts and the two mistakes everybody makes.
-
SNP 050
#B14
Eta tags in Stati templates
The three tags, the one variable, and the comment that breaks a template.
-
SNP 049
#624
Named stashes
stash@{3} means nothing to anyone. Give your stashes names.
No snippets match this filter.