{"id":23807003,"url":"https://github.com/stuartcarnie/lua-snowflake","last_synced_at":"2025-09-06T17:31:26.516Z","repository":{"id":22516175,"uuid":"25856550","full_name":"stuartcarnie/lua-snowflake","owner":"stuartcarnie","description":"An implementation of Snowflake for Lua. Snowflake is an algorithm which supports ordered, distributed id generation","archived":false,"fork":false,"pushed_at":"2014-11-03T19:53:00.000Z","size":180,"stargazers_count":19,"open_issues_count":0,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-04-14T06:38:29.303Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/stuartcarnie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-28T06:44:33.000Z","updated_at":"2023-02-09T13:50:22.000Z","dependencies_parsed_at":"2022-08-05T18:15:11.934Z","dependency_job_id":null,"html_url":"https://github.com/stuartcarnie/lua-snowflake","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartcarnie%2Flua-snowflake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartcarnie%2Flua-snowflake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartcarnie%2Flua-snowflake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartcarnie%2Flua-snowflake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuartcarnie","download_url":"https://codeload.github.com/stuartcarnie/lua-snowflake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232133878,"owners_count":18477299,"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":"2025-01-01T23:17:11.260Z","updated_at":"2025-01-01T23:17:12.804Z","avatar_url":"https://github.com/stuartcarnie.png","language":"C","readme":"lua-snowflake\n=============\n\nAn implementation of [Snowflake](https://blog.twitter.com/2010/announcing-snowflake) for Lua. Snowflake is an algorithm\nwhich supports ordered, distributed id generation. \n\nInstallation\n------------\n\n    $ luarocks install snowflake\n     \nUsage\n-----\n\n    local sf = require \"snowflake\"\n    sf.init(0x01, 0x01)\n    local uuid = sf.next_id()\n\n`uuid` will be a 64-bit number represented as a string that is structured as follows:\n\n    6  6         5         4         3         2         1         \n    3210987654321098765432109876543210987654321098765432109876543210\n    \n    tttttttttttttttttttttttttttttttttttttttttdddddnnnnnsssssssssssss\n\nwhere\n\n* `s` is a 12-bit integer that increments when next_id() is called multiple times for the same millisecond\n* `n` is a 5-bit integer representing the node within a given data center\n* `d` is a 5-bit integer representing a unique data center or group of servers\n* `t` is a 42-bit integer representing the current timestamp in milliseconds\n    * the number of milliseconds to have elapsed since 1413817200000 or 2014-10-20T15:00:00.000Z\n\n`sf.init(datacenter_id, node_id)` is used to initialize snowflake and set values for ddddd and nnnnn as follows:\n\n* `datacenter_id` is an integer n, where 0 ≤ n ≤ 0x1f and specifies the `ddddd` portion of the id\n* `node_id` is an integer n, where 0 ≤ n ≤ 0x1f and specifies the `nnnnn` portion of the id\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartcarnie%2Flua-snowflake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuartcarnie%2Flua-snowflake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartcarnie%2Flua-snowflake/lists"}