SaveSnippets
Community
Pricing
Sign In
Get Started
@admin
ADMIN
Member since Apr 2026
770
Public snippets
5
Net score
5
Total upvotes
Showing
421–450
of
770
public snippets
HTML
Form Validation Attributes
Built-in client-side validation: `required`, `pattern`, `minlength`/`maxlength`, `min`/`max`. The browser blocks submission and shows a native error if anything fails. Always validate on the server too.
1h ago
0
Kotlin
Ktor Server — Hello World
Ktor lets you stand up an HTTP server in a few lines. Pick an engine (Netty / Jetty / CIO), declare routes, run. Coroutine-native end to end.
1h ago
0
PHP
Date Range Iterator
Yield each date in a [start, end] interval as a DateTimeImmutable, with a configurable step. Builds on DatePeriod under the hood — but exposes a generator so you can break out early.
1h ago
0
PHP
JSON Lines (NDJSON) Stream Reader
Read newline-delimited JSON (one object per line) as a generator. Each yield gives you the next decoded record without holding the whole file in memory.
1h ago
0
PHP
Set Nested Value by Dot Path
Mutate a nested array by dot path, auto-creating any intermediate arrays. Companion to getPath; together they replace a lot of isset+array_key_exists ladders.
1h ago
0
Bash
URL-Encode and URL-Decode
Encode and decode URL-safe strings entirely in bash — no python or external tool required. Useful in pure-shell deployment scripts that need to build query strings.
1h ago
0
Rust
Async Timeout
Wrap any future in `tokio::time::timeout` to fail it if it takes too long. Returns `Err(Elapsed)` on timeout; you decide what to do next (retry, fall back, propagate).
1h ago
0
Rust
Rayon — Parallel Iterators
`rayon` lets you parallelize CPU-bound iterator chains by changing `.iter()` to `.par_iter()`. Handles thread-pool, work-stealing, and synchronization for you.
1h ago
0
SQL
Self-Join — Org Chart / Hierarchies
A self-join is just a regular join with the same table aliased twice. The canonical example is an employee table where each row points to a manager in the same table.
1h ago
0
SQL
EXTRACT — Pull Parts Out of a Timestamp
`EXTRACT(field FROM timestamp)` pulls year, month, hour, day-of-week, week, epoch — whatever you need to group, filter, or render. Standard SQL across every database.
1h ago
0
HTML
Pricing Plan Card
Single-tier pricing card with plan name, price, feature list, CTA. Replicate three times for a standard pricing page; highlight the "recommended" tier with a different border color.
1h ago
0
Kotlin
Extension Functions
Add methods to ANY type — including stdlib types like String, List, or Int — without subclassing. Compiled as a static dispatched function, so no runtime overhead.
1h ago
0
PHP
Validate UUID (any version)
Match the canonical 8-4-4-4-12 hex format, optionally pinning to a specific UUID version (1-5). Case-insensitive.
1h ago
0
PHP
Rate Limiter (token bucket, file-backed)
A dirt-simple rate limiter that throttles per-key using a token bucket persisted to a JSON file. Good for single-server protection of expensive endpoints; reach for Redis when you scale out.
1h ago
0
TypeScript
Promise.allSettled — Typed Results
`Promise.all` rejects on the first failure; `allSettled` waits for every promise and gives you per-promise status. Pair with a type guard to split fulfilled from rejected.
1h ago
0
Python
textwrap dedent + fill (Multi-line Strings)
`textwrap.dedent` strips common leading whitespace from a triple-quoted string — finally, you can indent multiline strings inside functions without breaking the formatting. `fill` wraps to a max width.
1h ago
0
Python
logging.basicConfig with Rotating File
A solid logging setup: rich format, rotating file handler so logs don't fill the disk, plus a console handler at a higher level so noisy DEBUG only goes to the file.
1h ago
0
Python
AES-GCM Encrypt / Decrypt (cryptography)
Authenticated symmetric encryption using AES-256-GCM from the `cryptography` package. Stores nonce + ciphertext + tag together as base64 so storage is a single column.
1h ago
0
Go
text/template — Simple Templating
Stdlib templating with `{{.Field}}` placeholders, range loops, if/else, and function pipelines. Safe alternative for non-HTML text (e.g. emails, config files).
1h ago
0
Java
Collectors.partitioningBy — Split by Predicate
Special case of groupingBy when the key is boolean — returns a `Map<Boolean, List<T>>` for the "true" and "false" buckets. Slightly more efficient than groupingBy.
1h ago
0
HTML
Registration Form (new-password + email-verify)
`autocomplete="new-password"` tells password managers to OFFER a generated password instead of filling an existing one. `autocomplete="email"` and `inputmode="email"` give phones the right keyboard.
1h ago
0
Kotlin
Ktor Server — JSON API with kotlinx.serialization
Install `ContentNegotiation` + `Json` plugin and you get typed (de)serialization for every route. Decode request bodies into data classes; respond with data classes.
1h ago
0
JavaScript
LocalStorage with Expiry
Extends localStorage with TTL (time-to-live) support. setItem stores a value alongside an expiry timestamp. getItem returns null and removes the key if the TTL has elapsed. Useful for caching API responses client-side, storing ephemeral UI state, and implementing remember-me tokens without a backend session.
1h ago
0
PHP
Generate Secure API Key
Mint an API key with a recognizable prefix ("sk_live_…") and 32 bytes of crypto-random entropy encoded as URL-safe base64. Stripe-style readable IDs.
1h ago
0
TypeScript
JSON POST Helper
Companion to `http<T>` — POST a JSON body and parse a JSON response, both typed. Handles the boilerplate Content-Type header and JSON serialization.
1h ago
0
Python
Producer / Consumer Queue (threading)
Classic producer / multi-consumer pattern using queue.Queue. Producers put work onto the queue; consumers pull and process; a sentinel value signals shutdown.
1h ago
0
Bash
Slice Bash Array
Bash supports Python-like array slicing via ${arr[@]:offset:length}. Lets you take/skip elements without external tools.
1h ago
0
Bash
Deduplicate Array (preserve order)
Bash's associative arrays let you dedupe in a single pass while keeping the original order — `sort -u` would shuffle.
1h ago
0
Bash
Check If Array Contains Element
A pure-bash membership test using `=~` or by iterating. Both are useful — pick by readability vs. speed.
1h ago
0
Bash
Epoch ↔ Human Date Conversion
`date +%s` gives now-as-epoch; `date -d @N` converts an epoch number back to a human date. Often what API responses expect / return.
1h ago
0
1
…
13
14
15
16
17
…
26