Snippy Snappy 🐊 Snippets
Sometimes I write elegant code that I like to share. Just kidding, this is mostly the stuff I have to google all the time.
Anchor If Tag Helper
A simple ASP.NET Core tag helper that either renders as a link or as the given fallback tag.
Validate HTML using Fluent Assertions
ASP.NET HTML helpers often return dynamically built HTML that may or may not be valid.
Shell in Docker container
Open an interactive shell in a docker container, e.g. for debugging purposes.
Git Aliases
A collection of essential git aliases I use on a daily basis.
Revert unpushed commit
Reverts the most recent commit and adds the reverted changes to stage.
left-pad string
Break free from dependency hell with this one simple trick.
useRouterRouteIsActive()
A really simple hook for Next.js to check if the given page path is currently active.
Batch-remove file extension
A simple PowerShell one-liner to batch-remove the extension of multiple files.
useResettableState()
A simple hook extending useState() with an option to reset to the evaluated initial value.
useXmlHttpUpload()
A hook to upload a file with progress tracking, request abortion etc.
Asymmetrical Array Diff
Easy method to get the asymmetrical difference (elements in the first array but no the second) of two arrays.
Distinct Array Items
An easy, elegant way to get distinct (unique) values of an array using Set (ES6 only).
S3 presigned upload URL
Simple method to generate a presigned upload URL for Amazon S3 or compatible storage services, allowing client-side uploads without the necessity of routing the file through an additional backend service.