Skip to content

Instantly share code, notes, and snippets.

View cty41's full-sized avatar

Frank Cheng cty41

  • NikkiGame
  • Shanghai, China
View GitHub Profile
@cty41
cty41 / gist:80df5367a23e46cf093301c870842a7a
Created June 13, 2022 02:21
How to get a number of random elements from an array?
https://stackoverflow.com/questions/19269545/how-to-get-a-number-of-random-elements-from-an-array
https://mattwarren.org/2016/12/14/Why-is-Reflection-slow/
@cty41
cty41 / gist:3413f260869b388de34f2d448742a8a2
Created May 21, 2022 10:05
Notes on the Implementation of Lua 5.3
https://poga.github.io/lua53-notes/introduction.html
@cty41
cty41 / .lua
Created September 11, 2017 05:29
Delete non-empty directory
local lfs = require('lfs')
local deletedir
deletedir = function(dir)
for file in lfs.dir(dir) do
local file_path = dir..'/'..file
if file ~= "." and file ~= ".." then
if lfs.attributes(file_path, 'mode') == 'file' then
os.remove(file_path)
print('remove file',file_path)
@cty41
cty41 / .sh
Created August 29, 2017 03:22
Touch all files and subdirectories (recursive touch)
find . -exec touch {} \;
@cty41
cty41 / .lua
Created August 25, 2017 03:42
efficient way to determine if a Lua table is empty (contains no entries)?
if next(myTable) == nil then
-- myTable is empty
end