SaveSnippets
Community
Pricing
Sign In
Get Started
@admin
ADMIN
Member since Apr 2026
770
Public snippets
5
Net score
5
Total upvotes
Showing
61–90
of
770
public snippets
HTML
Breadcrumb Navigation (with Schema)
A keyboard- and screen-reader-friendly breadcrumb. The `aria-label="Breadcrumb"` on `<nav>` announces the role; `aria-current="page"` marks the final segment. Add the JSON-LD for Google's rich result.
1m ago
0
Java
Atomic File Write (move with ATOMIC_MOVE)
Write to a temp file in the same directory, then `Files.move` with `ATOMIC_MOVE` to the target. Readers never see a half-written file — critical for config / state files.
1m ago
0
Go
time.Ticker — Periodic Tasks
`time.NewTicker(d)` fires on a channel every `d` interval. Combine with select + a done channel for a clean way to run periodic work that can be cancelled.
1m ago
0
Java
Collectors.groupingBy — Group by Key
Like SQL GROUP BY for streams. Produces a `Map<K, List<V>>` (or any downstream collector you specify). Indispensable for analytics-style aggregations.
1m ago
0
Python
Generate Strong Random Password
Build a password using the `secrets` module (CSPRNG) with rejection sampling for unbiased distribution. Use this — NOT random.choice, which is seeded predictably.
1m ago
0
Rust
String vs &str — The Cheat Sheet
`String` is an owned, growable heap allocation; `&str` is a borrowed view into a UTF-8 buffer. Function params should usually take `&str`; return types use `String` when ownership is needed.
1m ago
0
Kotlin
Exposed — Kotlin-First ORM
JetBrains' Exposed combines a SQL DSL with a lightweight ORM. Either style is fully type-safe; both compile to plain SQL.
1m ago
0
Python
Timing Decorator with Logger
Drop @timed on any function and get its wall-clock duration logged on every call. Uses functools.wraps so introspection (name, docstring, signature) still works.
1m ago
0
PHP
Verify a JWT (HS256)
Pair to jwtSign: verify the signature, check the exp claim, and return the decoded payload — or null on any failure. Uses hash_equals for constant-time signature comparison.
1m ago
0
Bash
Print Environment Variables Matching Pattern
Quick audit of env vars by prefix — useful when debugging containerized apps that read from `STRIPE_*`, `DB_*`, etc.
1m ago
0
Rust
mpsc Channel Between Threads
`std::sync::mpsc` is the standard cross-thread channel. Multiple producers, single consumer. Send any `Send` type; the receiver blocks on `recv()` until something arrives.
1m ago
0
Rust
Threads with thread::spawn + join
Native OS threads with `std::thread::spawn`. The returned `JoinHandle` lets you wait for the thread and get its return value. Use `move` to transfer ownership of captured variables.
1m ago
0
Kotlin
apply — Configure Object, Return Itself
`x.apply { ... }` runs the block with `x` as `this` (so you call methods/set properties directly) and returns `x`. The canonical builder-style configuration.
1m ago
0
HTML
Skip-to-Main-Content Link
Keyboard users (and screen-reader users) tab through every nav link before reaching content. A skip-link as the first focusable element jumps straight to <main>. Required for WCAG 2.1 AA.
1m ago
0
TypeScript
Template Tag for Safe HTML
Build HTML strings with a tagged template literal that auto-escapes every interpolated value. Eliminates a class of XSS bugs without pulling in a templating library.
1m ago
0
Kotlin
Compose Modifier Chain
`Modifier` is how you customize composables — padding, click handlers, background, size, alignment. Order matters: each modifier wraps the previous one.
1m ago
0
Bash
Check If Port Is Open
Several ways to probe a remote port: nc (most portable), bash's /dev/tcp pseudo-device (zero deps), or curl. Pick by what's available.
1m ago
0
PHP
URL-Safe Base64 Encode / Decode
Standard base64 uses + and / which break in URLs. Swap them for - and _, drop the = padding, and you get a string you can put in path segments and query parameters safely.
1m ago
0
Bash
Pretty-Print JSON from cURL
Pipe API responses through jq for syntax-colored, indented output. Also great for extracting specific fields without writing a parser.
1m ago
0
HTML
Navigation with aria-current
Use `<nav>` for primary navigation. Mark the currently-active link with `aria-current="page"` — screen readers will announce it, and you get a free CSS hook with `[aria-current]`.
1m ago
0
HTML
Picture Element — Art Direction
`<picture>` lets you serve DIFFERENT images at different breakpoints — not just different sizes of the same crop. Perfect for a wide desktop banner that becomes a square mobile poster.
1m ago
0
HTML
Radio Group with Fieldset + Legend
Always wrap radio groups (and checkboxes that share semantics) in a `<fieldset>` with a `<legend>`. Screen readers announce the legend before each option — without it, the choice is contextless.
1m 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).
2m ago
0
Java
Builder Pattern
For objects with many optional parameters, a Builder beats a constructor with 12 args (or a half-initialized object you have to call setters on). Method chaining + a `build()` step that validates.
2m ago
0
PHP
Pretty-Print JSON
One-liner wrapper around json_encode with the right flags: indented, no escaped slashes, no escaped unicode. Use it everywhere instead of raw json_encode for human-readable output.
2m ago
0
Python
requests Session with Retry + Timeouts
A pre-configured requests.Session that auto-retries 5xx + connect errors with exponential backoff, applies a default timeout, and uses connection pooling. Use this everywhere instead of bare requests.get().
2m ago
0
SQL
Recursive CTE — Date Spine Generator
Generate a row per day (or month, year, hour) without a calendar table. Useful for filling gaps when a date has no events but you still want it in your output.
2m ago
0
Java
CountDownLatch — Wait for N Events
Block one or more threads until a count of events occurs. Set the count up front; each event calls `countDown()`; waiters call `await()`. Classic "wait until all workers are ready" pattern.
2m ago
0
PHP
Validate Uploaded File
A defense-in-depth check for $_FILES uploads: confirms the upload completed, the size is within bounds, the MIME type matches an allow-list (by libmagic, not by extension), and the file landed where PHP expected.
2m ago
0
HTML
Card Pattern (article + link wrapper)
The standard content card — image, title, excerpt, meta. Make the WHOLE card clickable by wrapping the title link and using `::after` to extend the hit area to the full card.
2m ago
0
1
2
3
4
5
…
26