Skip to content

Instantly share code, notes, and snippets.

View CapsAdmin's full-sized avatar
🌜
Lua

Elias Hogstvedt CapsAdmin

🌜
Lua
View GitHub Profile
local excluded = {["<para>"]=true,
["<eod>"]=true}
local function get_second_column(line, separator)
local start_pos, end_pos = line:find(separator, 1, true)
if not start_pos then error("unable to find separator") end
local sub_pos = end_pos + 1
start_pos, end_pos = line:find(separator, sub_pos, true)
if not start_pos then error("unable to find separator") end
local excluded = {["<para>"]=true,
["<eod>"]=true}
local function write_table(data, fname)
local file = io.open(fname, "w")
io.output(file)
io.write(table.concat(data, " "))
io.close(file)
end
local excluded = {["<para>"]=true,
["<eod>"]=true}
local function write_table(data, fname)
local file = io.open(fname, "w")
io.output(file)
io.write(table.concat(data, " "))
io.close(file)
end
function write_table(data, fname)
local file = io.open(fname, "w")
io.output(file)
io.write(table.concat(data, " "))
io.close(file)
end
local function split_string(self, separator, max)
local tbl = {}
local current_pos = 1
@CapsAdmin
CapsAdmin / csv2tbl.lua
Created September 27, 2018 11:58
csv to table
local function split(self, separator, plain_search)
if plain_search == nil then
plain_search = true
end
local tbl = {}
local current_pos = 1
for i = 1, #self do
local start_pos, end_pos = self:find(separator, current_pos, plain_search)
local function split_line(self, separator, plain_search)
if plain_search == nil then
plain_search = true
end
local tbl = {}
local current_pos = 1
for i = 1, #self do
local start_pos, end_pos = self:find(separator, current_pos, plain_search)
@CapsAdmin
CapsAdmin / struct_benchmark_test.lua
Last active September 16, 2018 09:25
struct_benchmark_test.lua
local ffi = require("ffi")
local tests = {
aligned_float = [[
struct __attribute__(( aligned(16) )) NAME {
__attribute__(( packed ))
float x, y, z;
};
]],
aligned_double = [[
-- binary expressions
-- operator precedence
do -- BitWise tutorial https://www.youtube.com/watch?v=L4P98pGhpnE
local tokens, token, i
local function next_token()
i = i + 1
token = tokens:sub(i, i)
@CapsAdmin
CapsAdmin / input.lua
Last active August 19, 2018 08:40
tokenzier/lexer/transpiler
local a = a+i < b/2+1
local b = 5+x^2*8
local a = (1+2)+(3+4)
local a = a+i < b/2+1
local b = 5+x^2*8
local a =a < y and y <= z
local a =-x^2
local a =x^y^z
local a = 5+x^2*8
void scanBlocks(IntVector2 origin, List<LetterBlock> foundBlocks, List<LetterBlock> solved)
{
if (foundBlocks.Count > 20) // crash safe for now
return;
LetterBlock block = getBlocks()[origin.x, origin.y] as LetterBlock;
if (!block || !block.inWord || solved.Contains(block))
return;