admin
@admin ADMIN
Member since Apr 2026
770
Public snippets
5
Net score
5
Total upvotes

Showing 751–770 of 770 public snippets

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.
Jun 13, 2026 0
Kotlin
associate and associateBy
`associateBy` builds a `Map<K, T>` keyed by a derived value. `associateWith` keys by the items themselves with derived values. `associate` lets you build both key and value from each item.
Jun 13, 2026 0
Kotlin
Type-Safe Builder DSL
`@DslMarker` + lambdas with receivers let you build statically-typed DSLs that look like declarative configuration. The HTML / Gradle Kotlin DSL style.
Jun 13, 2026 0
Go
slices package — Modern Helpers
`slices` (Go 1.21+) ships the iteration helpers everyone wrote by hand for years: Contains, Index, Sort, SortFunc, BinarySearch, Clone, Reverse, Equal, Max/Min.
Jun 13, 2026 0
Go
errors.Join — Aggregate Multiple Errors
Go 1.20+ ships `errors.Join`, which combines multiple errors into one. Stop accumulating errors in a slice and stringifying yourself — use the standard library.
Jun 13, 2026 0
Kotlin
Coroutine Cancellation
Cancellation is cooperative — your coroutine must check via `ensureActive()`, `yield()`, or any other suspending call. CPU-busy loops without a suspend point are NOT cancellable.
Jun 13, 2026 0
Kotlin
kotlin.test — Basic Tests
`kotlin.test` is the multiplatform test stdlib. `@Test` marks a test; `assertEquals`, `assertTrue`, `assertFailsWith` are the workhorses.
Jun 13, 2026 0
Bash
Word Frequency Count
Classic shell one-liner: split text into words, sort, count uniques, sort by count. Useful for log analysis, content audits, and tag-cloud-style summaries.
Jun 13, 2026 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.
Jun 13, 2026 0
TypeScript
useClickOutside — Detect Outside Clicks
Fire a callback when the user clicks anywhere outside a referenced element. Perfect for closing dropdowns, popovers, and modal-less menus.
Jun 13, 2026 0
Kotlin
minOf / maxOf / sumOf / averageOf
Numerical reducers with a selector lambda — much cleaner than `.map { ... }.max()` chains. `sumOf` is type-aware (returns Int, Long, Double, BigDecimal as appropriate).
Jun 13, 2026 0
Kotlin
Path Operations with java.nio.file
Modern Kotlin code uses `java.nio.file.Path` over the legacy `File`. Operator overloads + Kotlin extensions make it ergonomic.
Jun 13, 2026 0
Go
Static File Server
`http.FileServer` serves a directory; combine with `http.StripPrefix` to mount it at a URL path. One line for the most common static-asset use case.
Jun 13, 2026 0
TypeScript
usePrevious — Track Last Render's Value
Returns the value the prop/state had on the previous render. Useful for detecting transitions (e.g. "the count just went from 0 to 1") inside effects.
Jun 13, 2026 0
Kotlin
use { } — Auto-Close Resources
`use { }` calls `close()` on any `Closeable` (file, stream, JDBC connection, …) when the block exits — even on exception. Kotlin's try-with-resources.
Jun 13, 2026 0
Bash
List Listening Ports
`ss` is the modern netstat — faster, more readable, ships everywhere. Show only listening TCP ports with their owning process.
Jun 13, 2026 0
TypeScript
Sleep / Delay
The async/await-friendly version of `setTimeout`. The one-liner everyone re-invents — keep it in a util file. Optional AbortSignal lets you cancel mid-wait.
Jun 13, 2026 0
Rust
Read a File — Whole / Lines / Bytes
Three common patterns: load it all into memory, iterate line-by-line, or stream bytes. Pick by file size — `read_to_string` is convenient but bad for huge files.
Jun 13, 2026 0
Kotlin
MockK — Kotlin-Idiomatic Mocking
MockK plays well with Kotlin: final classes, coroutines, top-level functions, all mockable. `every { ... } returns ...` is the canonical setup.
Jun 12, 2026 0
JavaScript
IndexedDB Wrapper
A Promise-based wrapper for the IndexedDB API — simplifies the verbose request/onsuccess/onerror pattern into clean async/await calls. Supports get, set, delete, and getAll operations on a named object store. Ideal for storing large client-side datasets, offline data, and blobs that exceed localStorage limits.
Jun 12, 2026 0