{"id":20057629,"url":"https://github.com/todesking/fair_random","last_synced_at":"2025-09-15T06:33:11.336Z","repository":{"id":9879458,"uuid":"11881256","full_name":"todesking/fair_random","owner":"todesking","description":"\"Fair\" random number generator","archived":false,"fork":false,"pushed_at":"2013-08-04T16:20:44.000Z","size":120,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T10:48:00.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/todesking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-04T16:16:08.000Z","updated_at":"2014-09-29T05:35:20.000Z","dependencies_parsed_at":"2022-08-26T16:32:52.953Z","dependency_job_id":null,"html_url":"https://github.com/todesking/fair_random","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ffair_random","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ffair_random/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ffair_random/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ffair_random/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/todesking","download_url":"https://codeload.github.com/todesking/fair_random/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241488152,"owners_count":19970826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-13T12:59:42.487Z","updated_at":"2025-03-02T09:41:39.848Z","avatar_url":"https://github.com/todesking.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FairRandom\n\nFairRandom is random number generator that outputs more 'fair' numer serquence than true random.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'fair_random'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install fair_random\n\n## Usage\n\n### FairRandom::Box\n\n`FairRandom::Box.new(N, M)` generates numbers that in range 0 to N-1(incusive).\nThere is M numbers in the box and occurence of any number is same, M/N.\nEach `next` called, box will remove a element and return it.\nIf box is empty, box contents will regenerate.\n\n(NOTE: M % N should == 0)\n\n```ruby\n# Example\nrequire 'fair_random'\n\nclass FairCoinToss\n  def initialize\n    @rng = FairRandom::Box.new(2, 10)\n  end\n\n  # return 0 or 1\n  def toss!\n    @rng.next\n  end\nend\n```\n\n#### Serialize state\n\n You can serialize random state with to_poro/from_poro (with to_json or Marshal etc if needed).\n\n```ruby\nother_instance = FairRandom::Box.from_poro(random.to_poro)\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Changes\n\n# 0.0.1\n* initial: FairRandom::Box\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftodesking%2Ffair_random","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftodesking%2Ffair_random","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftodesking%2Ffair_random/lists"}