Erlang Examples
Erlang aligned plain-text table renderer
Renders headers and rows as a pipe-delimited table with each column padded to its widest cell.
Erlang base64 encode and validated decode
Encodes binaries and iolists to Base64 and decodes strings safely, returning an error tuple on bad input.
Erlang query string builder and parser
Encodes key-value pairs into a query string and parses a query string back into pairs with error handling.
Erlang field-level input validation
Validates required and one-of fields and returns per-field error messages instead of raising exceptions.
Erlang JSON decode with error context
Decodes JSON and returns a clear error tuple with the reason and a short snippet of the invalid input.
Erlang bounded worker pool collecting results
Runs tasks in batches of N linked processes, collecting every result or crash and enforcing a receive timeout.
Erlang httpc GET JSON with timeouts
Performs an HTTP GET with connect and request timeouts, checks the status, and decodes a JSON body.
Erlang env var config with validation
Reads environment variables with defaults and validates integer values against an inclusive range.
Erlang token bucket rate limiter
Refills tokens at a fixed average rate per second and allows bursts up to the configured bucket size.
Erlang bounded LRU cache with map and list
Keeps a map capped at N entries and moves every read or write to the front of the recency list.
Erlang multi-key sort with nulls last
Sorts records by several map keys in order, comparing left to right and placing undefined values last.
Erlang chunk a list into fixed batches
Splits any list into consecutive sublists of at most N elements, preserving order and keeping the leftover tail.
Erlang stream a file line by line
Folds over a text file one line at a time using read_ahead buffering and trims trailing CRLF newlines.
Erlang deep clone and recursive map merge
Deep copies Erlang terms through a binary round-trip and recursively merges nested maps without mutating inputs.
Erlang retry with capped exponential backoff
Runs a function with capped exponential backoff plus jitter, retrying failed attempts until the limit is reached.