{"id":22419936,"url":"https://github.com/ravijo/dump-lua-array","last_synced_at":"2025-07-21T17:31:36.771Z","repository":{"id":145158738,"uuid":"140452059","full_name":"ravijo/dump-lua-array","owner":"ravijo","description":"Dump 1-dimensional Lua array into a file efficiently","archived":false,"fork":false,"pushed_at":"2020-01-15T13:40:47.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T04:42:26.327Z","etag":null,"topics":["lua","tutorial"],"latest_commit_sha":null,"homepage":"https://ravijo.github.io/lua/","language":"Lua","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/ravijo.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}},"created_at":"2018-07-10T15:23:44.000Z","updated_at":"2020-04-19T07:25:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea05f292-f69c-4f32-a0b3-6ab8cfa0337e","html_url":"https://github.com/ravijo/dump-lua-array","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ravijo/dump-lua-array","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravijo%2Fdump-lua-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravijo%2Fdump-lua-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravijo%2Fdump-lua-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravijo%2Fdump-lua-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ravijo","download_url":"https://codeload.github.com/ravijo/dump-lua-array/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravijo%2Fdump-lua-array/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266342809,"owners_count":23914262,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["lua","tutorial"],"created_at":"2024-12-05T16:17:10.104Z","updated_at":"2025-07-21T17:31:36.734Z","avatar_url":"https://github.com/ravijo.png","language":"Lua","readme":"# dump-lua-array\nDump 1-dimensional Lua array into a file efficiently\n\nEnvironmental Details\n---------------------\n1. Ubuntu 14.04 LTS 64 Bit OS\n1. Lua v5.1\n1. GCC v4.8.4\n\nInstall Lua v5.1\n-----------------\n1. Open terminal or press \u003ckbd\u003eCTRL\u003c/kbd\u003e+\u003ckbd\u003eALT\u003c/kbd\u003e+\u003ckbd\u003eT\u003c/kbd\u003e then use following command-\n```\nsudo apt-get install lua5.1\n```\n2. Install Lua headers by following command-\n```\nsudo apt-get install liblua5.1-0-dev\n```\n\nCompilation\n-------------\nBefore proceding further make sure to download the code from the repository.\n1. Open terminal or press \u003ckbd\u003eCTRL\u003c/kbd\u003e+\u003ckbd\u003eALT\u003c/kbd\u003e+\u003ckbd\u003eT\u003c/kbd\u003e\n1. Compile C code using the following command-\n```\ngcc -I/usr/include/lua5.1 -o array.so -shared array.c -fPIC\n```\nThe above command is going to produce shared object. \n\nRead files\n-------------\n1. Compile C code using the following command-\n```\ngcc -o read read.c\n```\n2. Execute `read` from terminal\n\nUsage\n-----\nWe can use the above shared object in Lua code as shown below-\n```\n-- add the shared object to our Lua code\n-- make sure to keep 'array.so' along with this code\nrequire \"array\"\n\n-- define number of elements in our array\nlocal n = 1000000\n\n-- create array\nlocal my_array = {}\nfor i=1,n do\n  my_array[i] = i+1\nend\n\n-- now we have an array called 'my_array', \n-- which we want to dump into a file. there\n-- are two ways to do it\n\n-- case 1\n-- create new array first\n-- then call dump function\nlocal arr = array.new(my_array)\narray.dump(arr, \"out.bin\")\n\n-- case 2\n-- directly call dump function\narray.dump(my_array, \"out.bin\")\n\n-- if we use 'array.new', we can do much more as shown below\nlocal i=1\nprint(string.format(\"size of arr:%d, my_array[%d]:%d, arr[%d]:%d\", array.size(arr), i, my_array[i], i, array.get_element(arr, i)))\n```\n\nNote\n----\nCheck out my blog post [here](https://ravijo.github.io/lua/) for more information about it.\n\nIssues (or Error Reporting)\n----\nPlease check [here](https://github.com/ravijo/dump-lua-array/issues) and create issues accordingly.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravijo%2Fdump-lua-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravijo%2Fdump-lua-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravijo%2Fdump-lua-array/lists"}