SaveSnippets
Community
Pricing
Sign In
Get Started
@admin
ADMIN
Member since Apr 2026
770
Public snippets
5
Net score
5
Total upvotes
Showing
751–770
of
770
public snippets
Go
strings package essentials
The most-reached-for functions in the `strings` package: Split, Contains, TrimSpace, ToLower/Upper, Replace, Index, HasPrefix/Suffix.
1d ago
0
Kotlin
Companion Objects
A `companion object` inside a class hosts what other languages call "static" members. Methods + properties on the companion are callable as `Foo.bar()`, but unlike static, they're a real object you can extend or implement interfaces on.
1d ago
0
Kotlin
JSON Annotations — Rename, Default, Optional
Per-field annotations let you map Kotlin camelCase ↔ JSON snake_case, set defaults for missing fields, and skip nulls.
1d ago
0
Bash
Trap Signals for Cleanup
Use `trap` to delete temp files / kill background workers when the script exits — even on Ctrl-C or an unhandled error. Single most-undervalued bash feature.
2d ago
0
JavaScript
Chunk Array
Splits an array into smaller arrays (chunks) of a specified size. The last chunk may be smaller if the array length is not evenly divisible. Useful for batch processing, pagination, rendering large lists in chunks, and rate-limited API calls.
2d ago
0
SQL
EXPLAIN / EXPLAIN ANALYZE
`EXPLAIN` shows the query plan; `EXPLAIN ANALYZE` actually runs it and shows real timings. The first tool when a query is slow — look for sequential scans on big tables.
2d ago
0
JavaScript
String Template Tag — SQL / HTML Sanitiser
A tagged template literal that automatically escapes interpolated values, preventing SQL injection (server-side) or XSS (client-side) from untrusted input. The html tag HTML-encodes values; the sql tag parameterises values and returns a { text, values } tuple ready for a parameterised query driver.
3d ago
0
TypeScript
Typed Fetch Wrapper
A thin fetch wrapper that returns parsed JSON typed as `T`, throws on non-2xx, and accepts an AbortSignal. Single source of truth for "how this app talks to APIs."
4d ago
0
JavaScript
Long Polling Helper
Implements a long-polling loop that repeatedly calls a fetch endpoint and invokes a callback with the result. Backs off exponentially on errors and stops cleanly when cancelled via the returned stop function. A simple alternative to WebSockets for low-frequency server-push events without SSE support.
4d ago
0
Bash
Symlink Force-Update
`ln -s` fails if the target already exists. `ln -sf` is the idempotent variant — useful in deploy scripts that point a "current" symlink to a fresh release directory.
4d ago
0
Kotlin
Type Aliases
`typealias` gives a shorter / more meaningful name to an existing type. Compile-time only — no new type, no overhead. Great for taming verbose function types or generic parameters.
4d ago
0
Kotlin
takeIf / takeUnless — Conditional Pipelines
`takeIf { predicate }` returns `this` if the predicate holds, else null. `takeUnless` is the inverse. Combine with `?.let { ... }` for clean conditional transformations.
4d ago
0
Go
embed — Compile Assets into the Binary
Go 1.16+ `embed` lets you bundle static files (templates, web assets, SQL migrations) directly into the compiled binary — no companion files to ship.
4d ago
0
Go
sql.NullString — Nullable DB Columns
Plain `string` can't represent SQL NULL. Use `sql.NullString` (and its siblings `NullInt64`, `NullBool`, etc.) for columns where NULL is a real value distinct from empty.
5d ago
0
Go
sync.Pool — Reuse Allocations
`sync.Pool` keeps a pool of reusable objects to reduce allocator pressure in hot paths. Good for byte buffers, JSON encoders, or anything you allocate frequently and only need briefly.
5d ago
0
JavaScript
Fetch with Retry
Wraps the native fetch API with automatic retry logic using exponential backoff. Retries on network errors or non-OK HTTP responses up to a configurable number of attempts. Exponential backoff with optional jitter prevents thundering herd problems when many clients retry simultaneously.
6d ago
0
Bash
Squash Last N Commits
Combine the last N commits into one before merging a feature branch. Avoids hours of "WIP" / "fix typo" commits cluttering history.
6d ago
0
TypeScript
AbortController-Wrapped Fetch
Wire an AbortController so you can cancel in-flight fetches when the user navigates away or types another search query. The optional timeout helper rejects automatically.
6d ago
0
JavaScript
Rate Limiter (Token Bucket)
Implements a token-bucket rate limiter that allows a burst of calls up to a maximum capacity, then replenishes tokens at a steady rate. Useful for throttling outbound API requests, user-facing actions, or any operation where you need to allow occasional bursts without exceeding a sustained rate.
6d ago
0
PHP
Mask Sensitive Strings (credit cards / emails)
Mask the middle of a string while keeping a few characters at each end visible. Useful for displaying credit card numbers, emails, or API keys in UI without leaking them in full.
Aug 19, 2026
0
1
…
24
25
26