This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FOS = {} | |
-- serialize functions | |
local function char(c) return ("\\%3d"):format(c:byte()) end | |
local function szstr(s) return ('("%s")'):format(s:gsub("[^ !#-~]", char)) end | |
local function szfun(f) return "loadstring"..szstr(string.dump(f)) end | |
function hex_dump(buf) for i=1,math.ceil(#buf/16) * 16 do if (i-1) % 16 == 0 then io.write(string.format('%08X ', i-1)) end io.write( i > #buf and ' ' or string.format('%02X ', buf:byte(i)) ) if i % 8 == 0 then io.write(' ') end if i % 16 == 0 then io.write( buf:sub(i-16+1, i):gsub('%c','.'), '\n' ) end end end | |
-- Root directory | |
FOS["/"] = {"bin", "home"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local a = os.date('%c') | |
local b = os.date('!%a %b %d %H:%M:%S %Y') | |
print('Date: ' .. a) | |
print('UTC: ' .. b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function os.capture(cmd, raw) | |
local f = assert(io.popen(cmd, 'r')) | |
local s = assert(f:read('*a')) | |
f:close() | |
if raw then return s end | |
s = string.gsub(s, '^%s+', '') | |
s = string.gsub(s, '%s+$', '') | |
s = string.gsub(s, '[\n\r]+', ' ') | |
return s | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local test = {1,2,4,2,3,4,2,3,4,"A", "B", "A"} | |
local hash = {} | |
local res = {} | |
for _,v in ipairs(test) do | |
if (not hash[v]) then | |
res[#res+1] = v | |
hash[v] = true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local str = "text" | |
local t = {} | |
for i = 1, #str do | |
t[i] = str:sub(i, i) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Matasano Crypto Challenge | |
-- | |
-- Jacob Gardner 2014 | |
-- Challenge 1 (Convert hex to base64) | |
test1 = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" | |
real1 = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local index_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | |
function to_binary(integer) | |
local remaining = tonumber(integer) | |
local bin_bits = '' | |
for i = 7, 0, -1 do | |
local current_power = math.pow(2, i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local index_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | |
function to_binary(integer) | |
local remaining = tonumber(integer) | |
local bin_bits = '' | |
for i = 7, 0, -1 do | |
local current_power = math.pow(2, i) |
NewerOlder