Clojure Examples
plain-text-table-renderer
Renders maps as an aligned plain-text table with padded columns, a header row and a dashed separator.
field-validation-error-map
Validates a map against per-field predicate and message pairs, returning every field error at once.
base64-encode-decode-utf8
Encodes strings or byte arrays as Base64 and decodes them back, wrapping malformed input in ex-info.
url-query-string-round-trip
Encodes maps into URL query strings and parses them back into decoded maps of key to value vectors.
json-read-with-error-context
Parses JSON text into EDN and rethrows read failures with the error message and a nearby input snippet.
bounded-worker-pool-pmap
Runs a function over a collection on a fixed thread pool, preserving input order and surfacing task exceptions.
http-json-get-with-timeout
Performs an HTTP GET with a millisecond timeout and decodes the JSON body through a small JSON-to-EDN pass.
env-config-with-validation
Reads environment variables with defaults and validators, throwing ex-info that names the offending variable.
token-bucket-rate-limiter-clj
A stateful token bucket that allows short bursts up to capacity while enforcing a steady refill rate.
atom-backed-lru-cache
A compact atom-backed LRU cache that evicts the least recently used key once it grows past its capacity.
multi-key-stable-sort-with-nils
Stable multi-key sort over maps with per-key direction, keeping nil values predictable at either end.
chunked-lazy-sequence-batches
Splits any collection into fixed-size vectors eagerly, plus a lazy variant that also handles infinite sequences.
stream-file-lines-with-closing
Streams a UTF-8 file line by line with a reader that always closes, counting or transforming each line.
deep-clone-and-recursive-merge
Recursively deep-copies nested maps, vectors, sets and seqs, then merges two maps without mutating either.
with-retry-exponential-backoff
Retries a thunk with capped exponential backoff and random jitter, rethrowing the final exception.