Code Snippets

A collection of useful code snippets - Serverless Functions, Node.js scripts, and CSS tricks.

Docker Compose - Node + Postgres + Redis

Docker Compose - Node + Postgres + Redis

Production-ready docker-compose for a Node.js API with database and cache.

GitHub Actions CI Pipeline

GitHub Actions CI Pipeline

Full CI pipeline: install, lint, type-check, test, and build on every PR.

Go Worker Pool

Go Worker Pool

Concurrent worker pool pattern using goroutines and channels.

Go HTTP Server

Go HTTP Server

Minimal HTTP server with routing and JSON response in Go.

Go HTTP Middleware Chain

Go HTTP Middleware Chain

Composable middleware pattern for logging, auth, and CORS in Go.

GraphQL Schema & Resolver

GraphQL Schema & Resolver

Apollo Server schema definition with typed resolvers and context.

NestJS JWT Auth Guard

NestJS JWT Auth Guard

JWT authentication guard with role-based access control for NestJS.

Node.js Redis Cache

Node.js Redis Cache

Cache-aside pattern with Redis and automatic TTL expiry.

Playwright E2E Test

Playwright E2E Test

Page Object Model pattern with Playwright for maintainable E2E tests.

useDebounce Hook

useDebounce Hook

React hook to debounce any rapidly-changing value.

TypeScript Generic API Client

TypeScript Generic API Client

Type-safe fetch wrapper with generics, error handling, and abort support.

Card rotating on hover

Card rotating on hover

Creates a two sided card which rotates on hover.

Copy to clipboard

Copy to clipboard

Copies a string to the clipboard. Only works as a result of user action

CRUD API Route

CRUD API Route

For use with Next.js.

Get images

Get images

Fetches all images from within an element and puts them into an array.

hashBrowser

hashBrowser

Creates a hash for a value using the SHA-256 algorithm. Returns a promise.

HashNode

HashNode

Creates a hash for a value using the SHA-256 algorithm. Returns a promise.

Json to csv

Json to csv

Converts an array of objects to a comma-separated values

Menu on image hover

Menu on image hover

Displays a menu overlay when the user hovers over the image.

Mouse cursor gradient

Mouse cursor gradient

A hover effect where the gradient follows the mouse cursor.

Parse cookie

Parse cookie

Parses an HTTP Cookie header string, returning an object of all cookie name-value pairs.

Revue

Revue

Get all subscribers.

Revue

Revue

Subscribe to a newsletter.

Spotify

Spotify

Show what you're listening to.

Sticky Nav

Sticky Nav

Create a fixed navbar.

Tailwind CSS Snippets

Tailwind CSS Snippets

🌟 Unleash web magic with Tailwind CSS, a lightning-fast framework! 💪 Dazzling snippets.

Navigator

Navigator

Checks if the client is online or offline.

Use SSR

Use SSR

Checks if the code is running on the browser or the server.

UUID genertor

UUID genertor

Generates a UUID in a browser.