Snippets

A curated collection of short, copy-pasteable solutions - "snippets" that I’ve picked up over time, some to speed up my workflow, others just because I found them useful or interesting.

Name Description Category Last Updated
Hammerspoon network ping with feedback Bind a hotkey that pings 8.8.8.8 and shows you a quick connection status overlay. macos lua Mar 2026
requestIdleCallback for low-priority work Schedule non-urgent work for when the browser is idle, without fighting for the main thread. javascript Feb 2026
Generators for lazy sequences Use `function*` to produce values on demand — no array allocation, no end. javascript Jan 2026
Conic gradient spinner A modern loading spinner in pure CSS using `conic-gradient` and `mask`. Single div, no SVG. css Dec 2025
Truncate string with ellipsis A tiny one-liner to cut long strings down to size with a proper ellipsis character. javascript Nov 2025
Copy-to-clipboard with feedback A clipboard copy button that briefly switches its label to confirm the copy. javascript css Nov 2025
Hammerspoon for keyboard backlight Bring back keyboard brightness controls on the new MacBook keyboards using Hammerspoon. macos lua Oct 2025
Hammerspoon for window management Free, scriptable window snapping on macOS with a few lines of Lua. macos lua Oct 2025
useOnClickOutside hook Close menus, modals, and popovers when the user clicks anywhere outside. react Sep 2025
Format relative time Get '2 hours ago' style strings without moment.js or date-fns — just the built-in Intl API. javascript Aug 2025
useDebouncedValue hook A typed React hook to debounce a fast-changing value — perfect for search inputs. react Aug 2025
CSS-only tooltip A simple tooltip with no JavaScript, using `data-tooltip` attribute and `::after`. css Jul 2025
structuredClone for deep copies The modern, built-in way to deep-clone objects — no JSON tricks, no lodash. javascript Jul 2025
Find files modified recently Quick `find` recipes to locate files changed in the last N days. terminal Jun 2025
HTML5 Web notifications Testing HTML5 web notifications javascript May 2025
LocalStorage used size A simple script to help you determine how much of `localStorage` space is currently being used by your application. javascript May 2025
Swipping scroll lock hook A hook to lock/unlock scrolling react Mar 2025
Format a number as an ordinal Format a number as an ordinal, e.g. `3` to `3rd` javascript Feb 2025
Scroll area shadow Scroll area shadow to indicate overflow area css javascript Feb 2025
Page progress bar A simple page progress bar using page scroll and css variable css javascript Feb 2025
Kill a process How to kill a process in MacOS/Linux which is running on a port terminal Feb 2025
OnHover link decoration effect Fun with Hover Effects: Random Colors and Avatars css javascript Jan 2025
Animated gradient stripe Cool animated gradient stripe css Jan 2025