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 / 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
@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 ""
#!/bin/sh
#set -x
#elapsed=12345600
while true; do
s=$(( ${elapsed:-0} / 100 ))
d_=$(( $s / 86400 ))
s=$(( $s % 86400 ))
h_=$(( $s / 3600 ))
@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)
# 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 / 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
--]]--
@tst2005
tst2005 / split.lua
Created February 20, 2017 13:33
20170220
local data = ???
for line in data:read("*l") do -- OR data:match("([^\n])\n") do
for word in line:match("(%S+)") do
i=i+1
end
i=i+10
end
@tst2005
tst2005 / pdfkeepn.sh
Created February 21, 2017 09:18
copy a pdf by keeping the N first pages
#! /bin/bash
if [ $# -ne 3 ]; then
echo "Usage: $0 <n> <orig.pdf> <new.pdf>"
exit 1
fi
command -v pdfseparate >/dev/null || { echo >&2 "require pdfseparate"; exit 1; }
command -v pdfunite >/dev/null || { echo >&2 "require pdfunite" ; exit 1; }
local function test(f)
local function pack2end(a1, ...)
return a1, {...}
end
local ok, t_result = pack2end(pcall(f))
if not ok then
return("error="..t_result[1] )
else
return("ok="..#t_result )
@tst2005
tst2005 / funny.lua
Last active May 19, 2017 13:17
happy unicode
--[[
local function ✆(✕,✖)
local ☻ = ✕+✖
return ☻
end
return ✆
]]--
local function 🐅(😸, 😹)
local 😼 = 😸 + 😹