Skip to content

Instantly share code, notes, and snippets.

View tst2005's full-sized avatar

TsT tst2005

  • OpenPGP: 64785B92BBDD215F
  • Earth, ǝɔuɐɹɟ
View GitHub Profile
#! /bin/sh
# this is trying to mimick parts of GNU grep with busybox grep.
# We convert long arguments to short ones basically.
# this is all that busybox grep supports (with the GNU long argument version)
# -H --with-filename
# -h --no-filename
# -n --line-number
@tst2005
tst2005 / git-alias
Created May 3, 2022 15:57
git-alias
#!/bin/bash
# git alias [-p] [name[=value] ...]
# (bash) alias [-p] [name[=value] ...]
git_alias__show_help() {
echo 'Usage: git alias [-p] [name[=value] ... ]'
}
# safe quote (like the alias command do)
#!/usr/bin/env lua
-- pattern to disable as comment (in lua regexp % is the backquote character)
local pat1=[[<vmw:Config ovf:required="false" vmw:key="cpuAllocation%.shares%.shares" vmw:value="[^"]*"/>]]
local pat2=[[<vmw:Config ovf:required="false" vmw:key="cpuAllocation%.shares%.level" vmw:value="[^"]*"/>]]
-- pattern to enable a comment entry (in lua regexp % is the backquote character)
local patu=[[<!%-%-:Config ovf:required="false" vmw:key="[^"]*" vmw:value="[^"]*%-%->]]
-- read blocksize
KO: 0.17.32 ; base/info.json is 0.17.33
KO: 0.17.31 ; base/info.json is 0.17.32
KO: 0.17.30 ; base/info.json is 0.17.31
KO: 0.17.29 ; base/info.json is 0.17.30
KO: 0.17.28 ; base/info.json is 0.17.29
KO: 0.17.27 ; base/info.json is 0.17.28
KO: 0.17.26 ; base/info.json is 0.17.27
KO: 0.17.25 ; base/info.json is 0.17.26
KO: 0.17.24 ; base/info.json is 0.17.25
KO: 0.17.23 ; base/info.json is 0.17.24
@tst2005
tst2005 / jq-object-to-array
Last active June 1, 2018 14:14
how to convert json object to array
# wanted result:
# [
# [ "foo", "bar", "buz", "xx" ],
# [ "a1", "b1", "c1", null ],
# [ "a2", "b2", "c2", null ],
# [ "a3", "b3", "c3", null ],
# [ "a4", "b4", "c4", "undef" ]
# ]
printf '[
getrawdata() {
printf '[
{ "id": "bar", "info": "A babab" },
{ "id": "buz", "info": "B ububu" },
{ "id": "foo", "info": "A fofof" }
]';
}
rawdata_to_db() {
jq '{db: .}';
}
  • "uBlock Origin"
  • "uMatrix"
  • "Decentraleyes"
  • "Session Boss" / "Tab Session Manager"
  • "Stylus"
  • "Auto Tab discard"
  • "New Tab Override"
  • "Open Tabs Next to Current"

En test:

@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 $?
@tst2005
tst2005 / deadlink.sh
Last active April 12, 2018 13:16
shell script to search about deadlink
@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;;