All PostsAll the stuff I've written on this sitecreateTypedContext (React)Easily make a typed context provider and helper hook in React08/09/2409/09/24Eslint errors for bad importsRaise Eslint errors when importing from bad modules.03/09/24Simpler Pact consumer tests with MSWSimplify your Pact consumer tests with MSW and this helper02/09/24Use Touch ID for sudo commandsUse your finger instead of your password for sudo!10/08/24Slack emoji engineering: partyify anyone!Learn how to make a party emoji out of anything or anyone for your Slack workspace or Discord server. 2 min read~242 words25/05/24Overlay an image on your pageCSS-only method to overlay an image on an html page.21/02/2424/02/24toComputedVue 3 composable that simplifies using a value that's a MaybeRefOrGetter20/02/2429/02/24Mocking classes from mocked modules in Vitest testsHow to mock and expect on class methods from mocked modules.13/02/2402/06/24Drizzle ORM Type HelpersA couple type helpers to get a table's document type (when you SELECT) and the table's insert type (when you INSERT).03/01/2419/08/24Pinpoint Bugs with Git BisectFind the exact commit that caused a bug using a less known git command. 3 min read~512 words02/10/23Include<T, U>A more inclusive complement to TypeScript's Exclude helper type - only include the parts of a union type that are assignable to another type07/09/23useFullscreen (React)Get access to the current fullscreen element, and controls to enter, exit, and toggle fullscreen.14/08/23safeViewTransitionA tiny wrapper around document.startViewTransition that respects users' prefers-reduced-motion preferences11/07/2313/09/23createManualPromiseCreate a promise that you manually resolve or reject at any time!20/06/2323/07/23Write your own Promise.all()Work your way up to the super useful Promise.all() function from scratch! 7 min read~1.3K words22/02/2419/03/23useTemporaryState (React)State that resets after a timeout.19/06/2313/09/23createPreviousMemo (SolidJS)Get the previous value of a SolidJS signal01/01/2320/06/23Event DelegationA better way to handle multiple elements with the same event handlers5 min read~868 words09/03/2423/10/22FormData - My 2nd Favourite Web APIThe FormData API lets you easily access the values of inputs inside a form. 7 min read~1.4K words18/03/2322/10/22Cypress StuffMiscellaneous snippets for doing things in Cypress30/11/2209/03/24PartiallyOptionalA TypeScript generic type to make part of another type optional10/10/22Over-Engineering a Website (September 2022)How I discovered the secrets of the TMNT stack, built this website and procrastinated uni course work for 2 years. 15 min read~2.9K words22/09/2221/09/22InspectA useful function to print out the value of something with an optional message06/10/2212/01/23Tailwind CSS Hocus PluginA plugin for lazy people like me who use the same styles for hover and focus states19/09/2230/11/22Stop Vercel GitHub CommentsStop Vercel's bot from commenting on PRs and commits (and the associated emails)27/08/2220/06/23useIsMouseInactive (SolidJS)Know when the mouse hasn't moved for a period of time27/08/2207/08/23useSyncedLocalStorage (React)Save state to localStorage and sync it between hook instances, tabs and windows!07/07/2230/08/23useCssVar (React)Control a css variable from the comfort of React.04/05/2207/08/23useCopy (React)Copy to clipboard with a 'copied' timeout02/05/2219/06/23useCopy (SolidJS)Copy to clipboard with a 'copied' timeout02/05/2227/08/22File DownloadsDownload a file with or without JavaScript26/04/2213/10/22Enzyme StuffMiscellaneous snippets for working if you have to do tests with Enzyme20/02/2230/11/22PartiallyRequiredA TypeScript generic type to make part of another type required28/10/2110/10/22cxA tiny helper function to conditionally join classnames.09/05/2118/03/23useBoolean (React)Toggle and set a boolean piece of state with a slightly better interface than straight useState02/05/2118/03/23Next.js <Redirect />A <Redirect /> component like the one for react-router.02/04/2118/03/23useMounted (React)Know when the current component is mounted.02/04/2118/03/23debounceRun a function at most once every N seconds, at the end of the N seconds.28/03/21throttleRun a function at most once every N seconds, at the start of the N seconds.28/03/21useLocalStorage (React)Save state to localStorage with an interface almost identical to useState26/03/2130/08/23Hello WorldShow "Hello, World!" to your screen.24/03/2102/10/2341 posts total