Nim Examples

NimOct 23, 2026

Aligned plain-text table renderer in Nim

Renders rows as a plain-text table with padded columns and separator lines for terminal output.

formattingtablescli
000
NimOct 23, 2026

Nim base64 encode and validated decode

Encodes text to base64 and decodes it with length checks plus friendly errors for malformed input.

validationencodingbase64
000
NimOct 23, 2026

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.

tablesvalidationforms
000
NimOct 23, 2026

Nim query string encode and parse helpers

Encodes key-value pairs into a URL query string and parses one back with percent decoding.

query-stringurlencoding
000
NimOct 23, 2026

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.

error-handlingparsingjson
000
NimOct 23, 2026

Bounded Nim threadpool worker pool with results

Runs tasks on a fixed thread pool, collecting results in order and capturing per-task exceptions.

concurrencyerror-handlingthreadpool
000
NimOct 23, 2026

Nim: Typed environment config with validation in Nim

Reads integer environment variables with safe defaults and validates each value against an allowed range.

environmentconfigurationvalidation
000
NimOct 23, 2026

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.

httpjsontimeout
000
NimOct 23, 2026

Token bucket rate limiter for Nim

Allows short bursts up to a capacity while refilling tokens over time, enforcing an average request rate.

timingtoken-bucketrate-limiting
000
NimOct 23, 2026

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.

tableslrucache
000
NimOct 23, 2026

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.

sortingcomparatoroptions
000
NimOct 23, 2026

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.

linesstreamsfile-io
000
NimOct 23, 2026

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.

batchingsequencesiteration
000
NimOct 23, 2026

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.

mergedeep-copyjson
000
NimOct 23, 2026

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.

error-handlingbackoffretryjitter
000