{"id":50893979,"url":"https://github.com/pmarreck/random","last_synced_at":"2026-06-15T23:01:23.176Z","repository":{"id":361950522,"uuid":"1256579684","full_name":"pmarreck/random","owner":"pmarreck","description":"Unified CLI random number generator in LuaJIT: multiple distributions, true + deterministic, stdin ops, multiple output formats","archived":false,"fork":false,"pushed_at":"2026-06-01T23:24:36.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"yolo","last_synced_at":"2026-06-02T01:14:32.861Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmarreck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-01T23:05:33.000Z","updated_at":"2026-06-01T23:24:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pmarreck/random","commit_stats":null,"previous_names":["pmarreck/random"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pmarreck/random","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarreck%2Frandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarreck%2Frandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarreck%2Frandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarreck%2Frandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmarreck","download_url":"https://codeload.github.com/pmarreck/random/tar.gz/refs/heads/yolo","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarreck%2Frandom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34383468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-15T23:01:22.109Z","updated_at":"2026-06-15T23:01:23.146Z","avatar_url":"https://github.com/pmarreck.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# random\n\nA unified command-line random number generator, written in [LuaJIT](https://luajit.org/).\nOne small program that covers the cases you usually reach for several tools to do:\nmultiple statistical distributions, both **true** randomness (`/dev/urandom`) and\n**reproducible** randomness (seeded PCG32), stdin operations (choose/shuffle/weighted),\nand several output encodings.\n\nIt ships as three commands — `random`, `nrandom`, `drandom` — that are the same binary;\nthe invocation name selects the mode (`nrandom` ⇒ normalized, `drandom` ⇒ deterministic).\n\n## Features\n\n- **Distributions:** uniform (default), normal (Box-Muller), exponential, Poisson, log-normal, beta\n- **Two sources:** true random from `/dev/urandom`, or deterministic PCG32 (`-d`/`--seed`)\n- **Stdin ops:** `--choose` one item, `--shuffle` all items, `--weighted` (`value:weight`)\n- **Output formats:** decimal, `--hex`, `--base64`, raw `--binaryoutput`\n- **Reproducible sessions:** deterministic state persists per session so sequences continue across calls\n- **Zero heavy deps:** just LuaJIT (FFI + bit are built in)\n\n## Usage\n\n```sh\nrandom                              # uniform 0-99\nrandom 1 6                          # uniform in [1, 6]\nrandom -n --mean 50 --stddev 10     # normal distribution\nrandom -d --seed 42 -c 5            # 5 reproducible numbers\nrandom --hex -c 5                   # 5 hex values\nprintf 'a\\nb\\nc\\n' | random --choose\nprintf 'rare:1,common:10' | random --weighted --delimiter ','\n```\n\nRun `random -h` for the full option list.\n\n### State persistence note\n\nIn deterministic mode, state is saved per session (keyed by `DRANDOM_CONTEXT`, defaulting\nto the parent PID) so successive calls continue the sequence. Because pipes and `$(...)`\nsubshells change the parent PID, set a stable context in scripts:\n\n```sh\nexport DRANDOM_CONTEXT=$$\n```\n\nState lives under `DRANDOM_STATE_HOME` (default `/tmp`).\n\n## Install\n\n### Nix (flake)\n\n```sh\nnix run github:pmarreck/random            # run without installing\nnix profile install github:pmarreck/random\n```\n\n### Manual\n\nPut `bin/` on your `PATH` (it contains `random` plus the `nrandom`/`drandom` symlinks).\nRequires `luajit` on your `PATH`.\n\n## Development\n\nA dev shell with LuaJIT and the test tooling is provided:\n\n```sh\ndirenv allow      # or: nix develop\n./test            # FAST mode (quick, quiet on success)\nFAST= ./test      # full statistical run\nnix flake check   # hermetic CI check (also what Garnix runs)\n```\n\nThe suite lives in `tests/random_test` and is hermetic and concurrency-safe (each run\nisolates its own state directory).\n\n## Layout\n\n```\nbin/random          the program (LuaJIT)\nbin/nrandom         -\u003e random   (normalized mode)\nbin/drandom         -\u003e random   (deterministic mode)\ntests/random_test   the test suite (bash)\nalternates/         earlier reference implementations (nrandombash, nrandomlua)\nflake.nix           dev shell, package, and CI check\ntest                test runner\n```\n\nThe `alternates/` directory keeps earlier single-distribution implementations\n(`nrandombash`, an awk/bash normal generator; `nrandomlua`, a plain-Lua one) for\nlineage and benchmarking. They are not installed.\n\n## License\n\nMIT © Peter Marreck\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmarreck%2Frandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmarreck%2Frandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmarreck%2Frandom/lists"}