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
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.
SQL RANK / DENSE_RANK
`RANK` leaves gaps after ties (1, 2, 2, 4); `DENSE_RANK` doesn't (1, 2, 2, 3). `ROW_NUMBER` is always unique. Pick by what tied rows should produce.
PHP Resize Image to Max Dimension
Shrink an uploaded image so its longest side is no more than $maxDim pixels, preserving aspect ratio. Re-encodes to JPEG at the given quality. Uses the GD extension.
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.
Go Empty Struct Sentinel (struct{})
`struct{}` is a zero-size value — no memory cost. Use it as the value type in a Set (`map[T]struct{}`), as a channel signal (`chan struct{}`), or as a marker type.
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.
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.
SQL LAG / LEAD — Previous and Next Row
Access the row before (`LAG`) or after (`LEAD`) the current one, in the window's order. Perfect for "delta from previous reading", session boundaries, etc.
SQL Full-Text Search (PostgreSQL tsvector)
`tsvector` + `tsquery` is built-in full-text search — stemming, ranking, multilingual. For most apps this beats reaching for Elasticsearch right away.
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.
Go defer / panic / recover
`defer` runs a statement when the enclosing function returns — LIFO order. `panic` aborts; `recover` (inside a deferred func) catches a panic and converts it back to a normal return. Use sparingly.
HTML Tabs (ARIA tablist pattern)
The accessible tab pattern: a `role="tablist"` container, each tab as `role="tab"`, panels as `role="tabpanel"`. `aria-selected` + `aria-controls` link them and announce state.
SQL NTILE — Bucket Rows into N Buckets
Assign rows to N approximately-equal-sized buckets based on the ORDER BY. The standard way to compute quartiles, deciles, or any percentile bucket.
Bash List Listening Ports
`ss` is the modern netstat — faster, more readable, ships everywhere. Show only listening TCP ports with their owning process.
Go Concurrency Limit via Buffered Channel (Semaphore)
A buffered channel of size N is the simplest semaphore in Go — acquire by sending, release by receiving. Zero dependencies, no sync.Semaphore needed.
Kotlin OkHttp Client (Java interop)
OkHttp is the JVM-standard HTTP library. Works fine from Kotlin; use the `await()` extension from `okhttp3.coroutines` to get suspend support.
Kotlin Higher-Order Functions
Functions that take or return other functions. Foundation for streams, callbacks, DSLs — and an alternative to interfaces with a single method.
Rust Generic Function with Trait Bounds
Use `T: Trait` to require a capability on a generic parameter. The `where` clause is the more readable variant when bounds get long.