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 / 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 / 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 / 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 / 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") --[[--
-- 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 / pipesum.sh
Last active April 4, 2018 11:02
curl URL | ./pipesum.sh hashvalue | bash
#!/bin/sh
sumfile="$(mktemp)"
tmpfile="$(mktemp)"
trap "rm -f -- '$tmpfile' '$sumfile'" EXIT
verbose=false
cmd='auto'
hashvalue=''
while [ $# -gt 0 ]; do
case "$1" in
('-v') verbose=true;;
@tst2005
tst2005 / deadlink.sh
Last active April 12, 2018 13:16
shell script to search about deadlink
@tst2005
tst2005 / filters.sh
Created April 17, 2018 16:47
chained grep with friendly syntax
#!/bin/sh
filters() {
if [ $# -le 1 ]; then
local grepopt=''
case "$1" in
('no '?*) set -- "${1#no }"; grepopt='-v' ;;
esac
case "$1" in
(*'=ANY')
grep $grepopt -- '\<'"${1%=*}"'=ANY\>'; return $?
  • "uBlock Origin"
  • "uMatrix"
  • "Decentraleyes"
  • "Session Boss" / "Tab Session Manager"
  • "Stylus"
  • "Auto Tab discard"
  • "New Tab Override"
  • "Open Tabs Next to Current"

En test:

getrawdata() {
printf '[
{ "id": "bar", "info": "A babab" },
{ "id": "buz", "info": "B ububu" },
{ "id": "foo", "info": "A fofof" }
]';
}
rawdata_to_db() {
jq '{db: .}';
}