Skip to content

Instantly share code, notes, and snippets.

View hilbix's full-sized avatar
🐢
I may be slow to respond.

Valentin Hilbig hilbix

🐢
I may be slow to respond.
View GitHub Profile
@hilbix
hilbix / update-yarn-key.sh
Created March 24, 2019 19:07
Safely update apt's yarn GPG key
#!/bin/bash
STDOUT() { local e=$?; printf '%q' "$1"; [ 1 -lt $# ] && printf ' %q' "${@:2}"; printf '\n'; return $e; }
STDERR() { STDOUT "$@" >&2; }
OOPS() { STDERR OOPS: "$@"; exit 23; }
x() { "$@"; }
o() { x "$@" || OOPS fail $?: "$@"; }
ID=72ECF46A56B4AD39C907BBB71646B01B86E50310
RING=/etc/apt/trusted.gpg.d/yarnpkg.gpg
@hilbix
hilbix / debug.inc
Created September 2, 2018 15:52
No-Brainer function to debug with `gdb` from shell level
# This function keeps IO redirection and commandline arguments
# when you want to debug some executable.
#
# Just type "debug" in front of the call:
# "b u g" "${p[@]}" < <(in) 1> >(out) 2> >(two) 3> >(three)
# debug "b u g" "${p[@]}" < <(in) 1> >(out) 2> >(two) 3> >(three)
#
# All you need is a /dev/tty
debug()
@hilbix
hilbix / googleauth.php
Last active July 8, 2018 09:02
PHP RFC4648-base32 to hex conversion for Google Authenticator
# $key = hex2bin(rfc4648tohex('AAAAAAAAAAAAAAAA')); # Your secret Auth-Key
# $token = googleauth($key, floor(time()/30));
function googleauth($key, $stamp)
{
$mac = hash_hmac('SHA1', substr(chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).pack('N', floor($stamp)),-8), $key, true);
$val = unpack('N', substr($mac, (ord(substr($mac, -1)) & 15), 4));
$val = $val[1]&0x7fffffff;
return substr("000000$val", -6);
}
@hilbix
hilbix / mongoexportall.sh
Created March 9, 2018 16:13
Export complete MongoDB as JSON files with one record a line
#!/bin/bash
#
# mongoexportall [directory [connection-options..]]
#
# This Works is placed under the terms of the Copyright Less License,
# see file COPYRIGHT.CLL. USE AT OWN RISK, ABSOLUTELY NO WARRANTY.
# (CLL is more free than Public Domain, as it disallows Copyrights.)
OOPS() { { printf 'OOPS:'; printf ' %q' "$@"; printf '\n'; } >&2; exit 23; }
@hilbix
hilbix / download-debian-netinstall.sh
Last active July 13, 2019 23:55
Download an verify Debian netinstall ISO
#!/bin/bash
VERS="$1"
OOPS() { echo "$*" >&2; exit 23; }
o() { "$@" || OOPS "exec $?: $*"; }
v() { local -n __var__="$1"; __var__="$("${@:2}")" || OOPS "exec $?: $*"; }
[ -n "$VERS" ] || read -p 'Version (like: 9.3.0): ' VERS || exit
@hilbix
hilbix / tmux.md
Created July 25, 2017 08:12
Fix garbled tmux

https://unix.stackexchange.com/a/253369

stty sane; printf '\033k%s\033\\\033]2;%s\007' "`basename "$SHELL"`" "`uname -n`"; tput reset; tmux refresh

tmux list-windows -a | while IFS=: read -r a b c; do tmux set-window-option -t "$a:$b" automatic-rename on; done
@hilbix
hilbix / heap.h
Created June 23, 2017 12:17
Untested C heap include
/* completely untested */
struct _heap_data
#if 0
{
struct _heap_cnt cnt;
const char *cwd;
..
}
#endif
@hilbix
hilbix / fakejournal.sh
Created December 14, 2016 08:43
Prevent systemd-logind from spamming dmesg
#!/bin/bash
#
# Public Domain
#
# Prevent systemd-logind to spam dmesg
#
# Run this from something which catches the output, like
# https://github.com/hilbix/ptybuffer/blob/master/script/autostart.sh
mkdir -pm755 /run/systemd/journal
@hilbix
hilbix / openssl.md
Last active November 9, 2016 12:59
Some obscured OpenSSL infos

I really do not get it. The defaults of OpenSSL are always set to the worst, not recommended and often broken things. Why?

As my CMS is down currently, I note it here.

Why this here?

Because pages like https://wiki.openssl.org/index.php/EVP leave you completely in the dark what is best for you. They often make it even harder to choose the right thing.

Hardware AES

@hilbix
hilbix / VM-Protect.md
Last active November 9, 2016 08:26
Ein nicht ganz fertiges Pamphlet zum Thema Speicherschutz von VMs

Ich arbeite an dem Text gerade, das hier sind Zwischencommits

Leider musste ich den Edit-Vorgang unterbrechen. Keine Ahnung, wann ich wieder dazu komme. Sorry.

Im uneditierten Bereich steht eigentlich schon alles. Bis auf kleinere Details, die man aber leicht lösen kann. Was leider noch fehlt ist die Gesamtbetrachtung, also der Beweis, dass das Verfahren genau das leistet, was es behauptet. Das aber ist lediglich die Nagelprobe, ob das, was hier steht, überhaupt sinnvoll ist. Es ändert nichts an der "Erfindungshöhe". Sprich: All das hier braucht lediglich Transpiration, und keinerlei Inspiration.

VM-Protect