Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Python unique_everseen — Order-Preserving Dedupe
Remove duplicates while preserving original order (set() loses order on collisions). Optional key function lets you dedupe by a derived value — e.g., lowercased email.
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.
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.
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.
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.
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.
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.
Kotlin Property Delegation by Map
Delegate a property to a `Map<String, V>` — reading the property fetches by name; writing stores by name. Quick way to back a class with a config map.
Kotlin JDBC with use { } — Auto-Close Connections
Plain JDBC is fine for simple cases. Wrap connections / statements / result sets in `use { }` for guaranteed cleanup even on exceptions.
Python group_by — Group Items by a Key
A dict-returning groupby that doesn't require sorted input. Like itertools.groupby but materializes the groups so consumers can iterate them multiple times.
HTML Print Stylesheet Setup
Tune the print layout: hide nav/footer, force black-on-white text, expand absolute URLs, hide images you don't want printed. Save your users from wasting paper on the page chrome.
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.
SQL Running Totals (SUM OVER)
Window aggregates with an implicit "rows up to here" frame give you running totals, cumulative counts, and ratchet-up metrics. No self-join needed.
TypeScript safeJsonParse — Result-Typed
Parse JSON without ever throwing. Returns a Result-like discriminated union so callers must handle both success and failure paths at compile time.
Go time.Format — The Reference Time
Go's time formatting uses a reference date instead of strftime tokens: `Mon Jan 2 15:04:05 MST 2006` (which is 01/02 03:04:05PM '06 -0700, or 1/2/3/4/5/6/7 — mnemonic). Strange at first, instantly memorable.
Bash Prune Dangling Docker Images
Reclaim disk space from Docker. `prune` operates on stopped containers, dangling images, build cache, and unused networks. Run periodically on CI runners.
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.
Python TypedDict for JSON API Shapes
When you parse JSON, you want types — but creating a class for every payload is overkill. TypedDict gives you the static-checking benefits without the runtime overhead, and `total=False` marks every field optional.