Nim Examples
Aligned plain-text table renderer in Nim
Renders rows as a plain-text table with padded columns and separator lines for terminal output.
Nim base64 encode and validated decode
Encodes text to base64 and decodes it with length checks plus friendly errors for malformed input.
Form field validation with Nim Table errors
Validates form fields and returns a table of per-field messages instead of failing on the first error.
Nim query string encode and parse helpers
Encodes key-value pairs into a URL query string and parses one back with percent decoding.
JSON decoding with field-level errors in Nim
Decodes JSON into a typed record and raises descriptive errors for missing fields or wrong value types.
Bounded Nim threadpool worker pool with results
Runs tasks on a fixed thread pool, collecting results in order and capturing per-task exceptions.
Nim: Typed environment config with validation in Nim
Reads integer environment variables with safe defaults and validates each value against an allowed range.
Nim HTTP GET JSON with timeout and parse errors
Fetches a URL with a configurable timeout and turns malformed JSON responses into a clear error message.
Token bucket rate limiter for Nim
Allows short bursts up to a capacity while refilling tokens over time, enforcing an average request rate.
Bounded LRU cache built on Nim OrderedTable
Keeps at most N entries in an ordered table, evicting the least recently used key whenever the cache fills up.
Stable multi-key sort of Nim records with nulls
Sorts records by score descending with missing values last, breaking ties by name and keeping the order stable.
Stream a text file line by line with Nim streams
Opens a text file as a stream and invokes a callback for each line, trimming stray carriage returns.
Split a Nim sequence into fixed-size chunks
Splits any sequence into consecutive batches of N items, with a final shorter batch holding the remainder.
Deep clone and recursive merge for Nim JsonNode
Recursively merges JSON objects into a deep copy so nested keys combine without ever mutating the source node.
Nim capped exponential backoff retry helper
Runs a failing operation with capped exponential backoff and jitter, retrying until it succeeds or the attempt budget is exhausted.