Skip to content

Instantly share code, notes, and snippets.

View tst2005's full-sized avatar

TsT tst2005

  • OpenPGP: 64785B92BBDD215F
  • Earth, ǝɔuɐɹɟ
View GitHub Profile
@tst2005
tst2005 / word-rev.lua
Last active February 14, 2017 13:30
word-rev.lua
for word,space in io.stdin:read("*l"):gmatch("(%S+)(%s*)") do
io.stdout:write( word:reverse()..space )
end
io.stdout:write("\n")
--[[--
-- $ echo 123 456-789 | lua word-rev.lua
-- 321 987-654
--]]--
# https://en.wikipedia.org/wiki/ISO_8601
date_to_iso8601() {
date ${1:+-d "$1"} -u +'%Y%m%dT%H%M%SZ'
}
iso8601_to_date() {
local yyyymmdd="${1%%T*}"
local hhmmss="${1#*T}"
hhmmss="${hhmmss%Z*}"
@tst2005
tst2005 / bytecode-test-for-sandbox
Created November 19, 2015 16:47
safe bytecode, unsafe reusable
local bytecode
do
local A="a"
local f1 = function()
return A
end
bytecode = string.dump(f1)
end
local env = {}
local f2 = load(bytecode, "", "b", env)
#!/bin/sh
#set -x
#elapsed=12345600
while true; do
s=$(( ${elapsed:-0} / 100 ))
d_=$(( $s / 86400 ))
s=$(( $s % 86400 ))
h_=$(( $s / 3600 ))
@tst2005
tst2005 / gist:17d9d6e7f02bc821b3d9
Created September 9, 2015 09:18
argument code generator
local function t1(n)
local t = {}
for i = 1, n do
t[i] = "a" .. i
end
return table.concat(t, ',')
end
local function t2(n)
local a = n>0 and "a1" or ""
@tst2005
tst2005 / gist:52e3589a8b11158b5b06
Created March 13, 2015 10:22
my list visited list of code.google.com projects
code.google.com/p/address-sanitizer
code.google.com/p/andors-trail
code.google.com/p/android-scripting
code.google.com/p/ankidroid
code.google.com/p/chromium
code.google.com/p/corkami
code.google.com/p/crypto-js
code.google.com/p/csipsimple
code.google.com/p/dnscapy
code.google.com/p/dukto