Skip to content

Instantly share code, notes, and snippets.

View tst2005's full-sized avatar

TsT tst2005

  • OpenPGP: 64785B92BBDD215F
  • Earth, ǝɔuɐɹɟ
View GitHub Profile
-- inline=false
local cfgl =
{ indent='' -- like parentindent
, prefixindent="" -- use indent
, prefix="{\n"
, suffixindent=nil -- use indent
, suffix="}\n"
, itemindent='\\t ' -- use indent
, itemprefix=""
, itemsuffix=",\n"
@tst2005
tst2005 / longcomment.lua.txt
Created February 21, 2018 17:35
lua long comments ...
--[[ print("a")
print("b")
]]-- print("c")
print("D") --[[
print("e")
print("f") ]]--
--[[-- print("a")
print("b")
--]]-- print("c") --[[--
@tst2005
tst2005 / c_info
Last active February 19, 2018 15:26
openssl 1.1.x remove the /usr/lib/ssl/misc/c_info and change the issuer/subject text output format
#!/bin/sh
# source: https://gist.github.com/tst2005/797af97fd263677da9e3eede873887ac
for i in $*
do
echo "$i"
openssl x509 -subject -issuer -enddate -noout -in $i \
| sed -e 's#, \([^ ]\+\) = #/\1=#g' -e 's,^\(subject\|issuer\)=\([^ ]\+\) = ,\1= /\2=,g'
echo "--------"
@tst2005
tst2005 / hello.c
Created September 7, 2017 13:00
Hello World in C in C
#include <stdio.h>
int main(void) {
printf("C C CCCCC C C CCC C C CCC CCCC C CCCC\n");
printf("C C C C C C C C C C C C C C C C\n");
printf("CCCCC CCCC C C C C C C C C C CCCC C C C\n");
printf("C C C C C C C C C C C C C C C C C\n");
printf("C C CCCCC CCCCC CCCCC CCC C C CCC C C CCCCC CCCC\n");
return 0;
}
@tst2005
tst2005 / var.lua
Created June 14, 2017 17:31
FR portée des variables
local a = 1
local function a() return a end
assert( type( a() ) == "function" )
local a = 1
local a; function a() return a end
assert( type( a() ) == "function" )
local a = 1
local a = function() return a end
@tst2005
tst2005 / funny.lua
Last active May 19, 2017 13:17
happy unicode
--[[
local function ✆(✕,✖)
local ☻ = ✕+✖
return ☻
end
return ✆
]]--
local function 🐅(😸, 😹)
local 😼 = 😸 + 😹
@tst2005
tst2005 / sshtmp.sh
Created March 10, 2017 12:48
wrapper for ssh and scp to connect to temporary servers
#alias sshtmp='ssh -oUserKnownHostsFile="$HOME/.ssh/tmp_known_hosts"'
#alias scptmp='scp -oUserKnownHostsFile="$HOME/.ssh/tmp_known_hosts"'
alias sshtmpreset='>$HOME/.ssh/tmp_known_hosts ;#'
alias sshtmp='__sshtmp_cmd ssh'
alias scptmp='__sshtmp_cmd scp'
__sshtmp_cmd() {
local cmd="$1";shift
local host="$1"
local user=''
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 / 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; }
@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