Skip to content

Instantly share code, notes, and snippets.

Avatar

TsT tst2005

  • OpenPGP: 64785B92BBDD215F
  • Earth, ǝɔuɐɹɟ
View GitHub Profile
View 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)
View inline-ova70-fixer.lua
#!/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
View factorio-release-check.txt
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 Jun 1, 2018
how to convert json object to array
View jq-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 '[
View jq-select
getrawdata() {
printf '[
{ "id": "bar", "info": "A babab" },
{ "id": "buz", "info": "B ububu" },
{ "id": "foo", "info": "A fofof" }
]';
}
rawdata_to_db() {
jq '{db: .}';
}
View my-firefox-201805.md
  • "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 Apr 17, 2018
chained grep with friendly syntax
View filters.sh
#!/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 Apr 12, 2018
shell script to search about deadlink
View deadlink.sh
@tst2005
tst2005 / pipesum.sh
Last active Apr 4, 2018
curl URL | ./pipesum.sh hashvalue | bash
View pipesum.sh
#!/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;;
View li.lua
-- 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"