Skip to content

Instantly share code, notes, and snippets.

// Input jobs
var jobs = [
{'hash': 'abc', 'initial': 0, 'final': 99},
{'hash': 'abc', 'initial': 100, 'final': 199},
{'hash': 'abc', 'initial': 200, 'final': 299},
...,
];
// Task definition
var task = function(description) {
#!/bin/sh
ip -o addr \
| awk '
$2 ~ /:$/ {
i=$2;
sub(/:$/,"",i);
status[i]=$9
}
$3 == "inet" {
@dualbus
dualbus / README
Last active November 26, 2020 17:48
How to detach processes from bash properly.
Relevant section from ''man bash'', SIGNALS:
> The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all jobs,
> running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP. To prevent the shell from send‐
> ing the signal to a particular job, it should be removed from the jobs table with the disown builtin (see SHELL BUILTIN
> COMMANDS below) or marked to not receive SIGHUP using disown -h.
>
> If the huponexit shell option has been set with shopt, bash sends a SIGHUP to all jobs when an interactive login shell
> exits.
11 bash: 2
8 dash: 0
3 dash: 3
10 jsh: 0
1 jsh: 3
11 ksh: 3
11 mksh: 0
11 zsh: 2
#!/bin/bash
python -c '
import sys
x = sys.stdin.readlines()
try:
print(x[0].decode("utf-8"))
except Exception as e:
print(repr(e.object))
' <<< $'\xed'
#!/bin/sh
channel_group=$HOME/.services
channel=$channel_group/xinit
parent=$$
unset pids
trap 'kill $pids; rm -f "$channel"' INT TERM
VBoxClient -d --clipboard & pids="$pids $!"
sed '/./!be;s/"/""/g;/[, \t"]/s/.*/"&"/;H;$!d;:e;x;s/\n//;s/\n/,/g'
#!/bin/sed -f
# unary to binary converter tool
#
# Converts an input resembling a number in a unary base (for example,
# 5 represented as ..... i.e. 5 dots), to the representation of the
# number in a binary base (using 1 and 0 as the symbols for the
# base).
#
#
alienino 3511c0997339cfcccccca39f214322eb22e8fc43
all'equipaggio 14555555ec8dcf1400db9b375c5b8ca836362d8b
Anacyclus 182c40fc4df5b4d997feeeeee22c4dbf059a95d4
bajar 1352a687f6840df8801aaaaaadf71de84b816f86
bandwagon's f6e6deb71111110839bc14dd9cbab6eb7b16f09c
barbihecho bc45de24f03f2a086666668e2a0812a5f270c8cb
calcitrant 86d4ffffff9aae00ace440e93c1d87bb4ec8b56c
cornetti 000000f636f0d7cbc963a62f3a1bc87c9c985a04
crépir a21303cfa9b7c6f0cccccc19cc59556a188ccac7
cyclosporin's b5baaaaaa744f480586a905f692cdec2fa0a1919
#!/bin/sh
log_file=$1
reopen() {
exec > "$log_file" 2>&1
}
trap reopen HUP
reopen
while IFS= read -r line; do
printf '%s\n' "$line";