Examples

Page 49 of 50

Browse code examples

typescript

Minimal JSON Schema Validator

A dependency free validator for the common JSON Schema subset that reports every violation with its JSON path instead of stopping at the first mismatch.

typescript

LRU Cache With TTL Expiry

A generic LRU cache with per-entry TTL that evicts least recently used keys and reports hits, misses and evictions for observability.

goSnippet

Go CLI Tool with Cobra

Build a command-line tool in Go using Cobra with subcommands, persistent flags, shell completion, help templates, and configuration loading from environment.

goSnippet

Go CORS Middleware

Implement CORS middleware in Go with configurable allowed origins, methods, headers, preflight request handling, and credential support for cross-origin API.

goSnippet

Go File Upload Handler

Handle multipart file uploads in Go with size limits, MIME type validation, unique filename generation, streaming to disk without buffering entire file, and.

goSnippet

Go gRPC Server Setup

Create a gRPC server in Go with protobuf service definitions, interceptor middleware for logging and auth, graceful shutdown, health checks, and reflection.

goSnippet

Go HTTP Client with Retry

Make HTTP requests in Go with retry logic, exponential backoff, context-based timeouts, connection pooling, and response decoding to typed structs using.

goSnippet

Go HTTP Server with Middleware

Create a production-ready HTTP server in Go with middleware chaining, graceful shutdown, request logging, CORS handling, and context-based timeouts. Uses.

goSnippet

Go JWT Authentication with Claims

Generate and validate JWT tokens in Go using the golang-jwt package with custom claims, token expiration, and middleware for protected HTTP routes. Includes.

javascriptSnippet

Node.js JWT Auth with Express

Implement JWT authentication flow in Node.js Express with bcrypt password hashing, token signing and verification, refresh token endpoint, and protected.

javascriptSnippet

Node.js CLI with Inquirer

Build an interactive CLI tool in Node.js using Inquirer for prompts, chalk for colored output, and ora for spinners. Includes command chaining, template.

javascriptSnippet

Node.js Express File Upload

Handle file uploads in Node.js Express using multer middleware with disk and memory storage strategies, file filtering by MIME type, size limits, and.

javascriptSnippet

Vanilla JavaScript JWT Auth

Implement JWT authentication in vanilla JavaScript with token storage in localStorage, automatic token attachment to fetch requests, expiry checking, and.

javascriptSnippet

JavaScript Fetch with Caching

Implement a cached fetch wrapper in vanilla JavaScript using the Cache API with stale-while-revalidate strategy, request deduplication, and automatic cache.

javascriptSnippet

Vanilla JavaScript CLI Script

Build a command-line utility in vanilla JavaScript using process.argv parsing, readline for interactive prompts, chalk-free colored output with ANSI codes,.

javascriptSnippet

Vanilla JavaScript Data Fetching

Fetch and render remote data with vanilla JavaScript using async/await, AbortController for cancellation, loading state management, and error handling with.

javascriptSnippet

Vanilla JavaScript File Upload

Upload files with vanilla JavaScript using XMLHttpRequest for progress tracking, drag-and-drop support, file type validation, and chunked upload for large.

javascriptSnippet

Vue 3 File Upload Component

Build a file upload component in Vue 3 with drag-and-drop, progress bar, multiple file support, preview thumbnails for images, and automatic upload with.

pythonSnippet

FastAPI Data Fetching with Async

Fetch and aggregate data from multiple APIs in FastAPI using asyncio.gather for concurrent requests, httpx connection pooling, response caching with TTL,.

pythonSnippet

Python File Upload with FastAPI

Handle file uploads in FastAPI using UploadFile with async streaming, file size validation, MIME type checking, background task processing, and multiple.

pythonSnippet

FastAPI JWT Authentication Middleware

Implement JWT authentication in FastAPI with python-jose and passlib. Includes token generation, verification middleware, password hashing with bcrypt, and.

FastapiAuth Jwt
pythonSnippet

Python JWT Authentication

Implement JWT authentication in Python using PyJWT with HS256 signing, token verification, expiry validation, and FastAPI dependency injection for protected.

pythonSnippet

Python CLI with Click

Build a command-line tool in Python using Click with subcommands, option parsing, colored output, progress bars, and configuration file loading. Includes.

pythonSnippet

Python HTTP Data Fetching

Fetch remote data in Python using httpx with async support, retry logic, timeout handling, response parsing with Pydantic models, and connection pooling for.

rustSnippet

Rust JWT Authentication

Implement JWT authentication in Rust using the jsonwebtoken crate with HMAC-SHA256 signing, claims validation, expiry checking, and Axum extractor for.

rustSnippet

Rust CLI Tool with Clap

Build a command-line tool in Rust using Clap with derive macros for subcommands, typed arguments, environment variable fallback, colored output, and shell.

rustSnippet

Rust File Upload with Axum

Handle multipart file uploads in Rust using Axum with size limits, content type validation, streaming to disk, and async file operations using tokio for.

rustSnippet

Rust HTTP Client with Reqwest

Make HTTP requests in Rust using reqwest with async/await, retry logic, JSON deserialization with serde, timeout handling, and connection pooling for.

rustSnippet

Rust HTTP Server with Axum

Build a type-safe HTTP server in Rust using Axum with extractors, JSON responses, error handling, and state sharing. Includes route definitions, middleware.

typescriptSnippet

Next.js API Route Handler

Create typed API route handlers in Next.js App Router with Zod validation, standard Response objects, error handling middleware, and OpenAPI-compatible.

typescriptSnippet

Next.js JWT Authentication Middleware

Implement JWT-based authentication in Next.js using middleware for route protection, cookie-based token storage, and edge-compatible jose library for token.

typescriptSnippet

Next.js File Upload with Progress

Upload files in Next.js using server actions with streaming progress, file size validation, MIME type checking, and chunked transfer to handle large files.

typescriptSnippet

Node.js JWT Auth with TypeScript

Implement JWT authentication in a Node.js Express server with TypeScript, including token signing, verification middleware, refresh token rotation, and.

typescriptSnippet

Node.js CLI Tool with Commander

Build a type-safe CLI tool in Node.js using Commander.js with subcommands, option parsing, help generation, and TypeScript. Includes chalk-colored output.

typescriptSnippet

Node.js Typed Data Fetching

Fetch remote data in Node.js with TypeScript using generic HTTP wrappers, retry logic with exponential backoff, response parsing with Zod, and.

typescriptSnippet

React Data Fetching with SWR

Fetch and cache remote data in React using the SWR library with automatic revalidation, error retry, optimistic updates, and TypeScript generics for.

typescriptSnippet

TypeScript React Error Boundary

Implement a typed error boundary in React with TypeScript that catches render errors, displays fallback UI, logs error details, and supports recovery.

typescriptSnippet

React JWT Auth with Context API

Implement JWT authentication in React using Context API and useReducer. Includes login, logout, token refresh, protected route wrapper, and automatic token.

typescriptSnippet

Vue 3 Data Fetching with Suspense

Fetch async data in Vue 3 using Suspense components, async setup, and error boundaries. Provides loading fallbacks, error recovery, and TypeScript typing.

typescriptSnippet

Vue 3 Typed Form Validation

Build type-safe reactive forms in Vue 3 with TypeScript using composable validators, computed error states, and debounced field validation that prevents.

bashSnippet

Arithmetic Operations and Math

Performs arithmetic operations using $(( )), let, and expr including integer math, bitwise operations, increment/decrement, and conditional expressions.

bashSnippet

Conditional Tests and Logic

Demonstrates if/elif/else conditionals with test commands, file tests, string tests, numeric comparisons, and logical operators in Bash scripts.

bashSnippet

Functions and Return Values

Defines and uses Bash functions with local variables, return values, argument passing, and recursive calls for modular and reusable script logic.

bashSnippet

Getopts for Option Parsing

Uses getopts to parse command-line options with short flags, default values, and argument validation for building robust CLI tools in Bash.

bashSnippet

Loops and Iteration Patterns

Demonstrates for loops, while loops, until loops, and C-style loops with break, continue, and range iteration for various data processing patterns.

bashSnippet

Advanced Parameter Expansion

Demonstrates advanced Bash parameter expansion patterns including defaults, alternatives, substring, case modification, and variable indirection.

bashSnippet

Pipelines and Data Flow

Constructs multi-stage pipelines connecting commands with pipes for data transformation, filtering, and aggregation in a streaming fashion.

bashSnippet

Input/Output Redirection

Demonstrates stdin, stdout, stderr redirection including appending, merging streams, discarding output, and using file descriptors for advanced I/O control.

bashSnippet

String Manipulation Operations

Demonstrates Bash string manipulation including substring extraction, pattern replacement, case conversion, trimming, and splitting operations.

bashSnippet

Traps for Signal Handling

Sets up trap handlers for signals like EXIT, INT, TERM, and ERR to ensure cleanup, graceful shutdown, and error recovery in Bash scripts.

bashSnippet

Xargs for Parallel Execution

Uses xargs to build and execute commands from standard input with parallel execution, argument batching, and null-delimiter handling for safe processing.