Skip to content

Instantly share code, notes, and snippets.

View haraldh's full-sized avatar
☀️
🍻

Harald Hoyer haraldh

☀️
🍻
View GitHub Profile
#!/bin/bash
#
# How to prepare:
# - ensure that the lvm thin pool is big enough
# - backup any (most likely /boot and /boot/efi) device with:
# # mkdir /restoredev
# # dev=<device>; dd if="$dev" of=/restoredev/$(systemd-escape -p "$dev")
# - make a thin snapshot
# - remove /restoredev
@haraldh
haraldh / Schildbach-BCH.md
Last active October 2, 2018 09:07
HOWTO: move Bitcoin Cash BCH from your Schildbach/bitcoinj wallet
  1. Empty your BTC wallet for safety reasons and transfer it to a newly created BTC HD Wallet. If you know your HD master private key or the 12 words of the old wallet, go to step 5
  2. Backup: save the encrypted wallet (Safety -> Back up wallet) and move the backup file to your computer (e.g. via file transfer, Dropbox, e-mail...).
  3. Decrypt: open the bash, move to your data directory and use
    $ openssl enc -d -aes-256-cbc -md md5 -a -in bitcoin-wallet-backup > bitcoin_decrypted
    
    as stated above, which will ask for the encryption password.
  4. Install bitcoinj:
import string
fo = open("syslog", "r")
lines = fo.readlines()
fo.close()
syslog_d = []
syslog_s = []
for line in lines:
s = line.split()
@haraldh
haraldh / module-setup.sh
Created December 20, 2017 14:20
modules.d/02systemd-networkd/module-setup.sh
#!/bin/bash
# called by dracut
check() {
[[ $mount_needs ]] && return 1
if ! dracut_module_included "systemd-core"; then
if ! dracut_module_included "systemd"; then
derror "systemd-networkd needs systemd in the initramfs"
fi
@haraldh
haraldh / microcodedate.py
Created January 23, 2018 11:33
Prints the date of the microcode in /lib/firmware/intel-ucode/
import os
import datetime
from struct import unpack
for file in os.listdir("/lib/firmware/intel-ucode/"):
f = open(os.path.join("/lib/firmware/intel-ucode/", file), "rb")
(a, b, c) = unpack('III', f.read(12))
f.close()
print("%s: %04x-%02x-%02x" % (file, c & 0xFFFF, c >> 24, (c>>16) & 0xFF))
@haraldh
haraldh / intelmicrocodedate.sh
Last active January 23, 2018 12:07
Print the intel microcode firmware filename, revision and date
getbyte () {
local IFS= LC_CTYPE=C res c
read -r -n 1 -d '' c
res=$?
# the single quote in the argument of the printf
# yields the numeric value of $c (ASCII since LC_CTYPE=C)
[[ -n $c ]] && c=$(printf '%u' "'$c") || c=0
printf "$c"
return $res
}

Keybase proof

I hereby claim:

  • I am haraldh on github.
  • I am haraldhoyer (https://keybase.io/haraldhoyer) on keybase.
  • I have a public key ASD6KZy4D2yMtf2UGBRDBS7tuckvlI1AVs0pn_Ifc3VkbAo

To claim this, I am signing this object:

@haraldh
haraldh / org.surfsite.access.varlink
Last active August 22, 2018 09:56
RFC: interface org.surfsite.access
@haraldh
haraldh / closure_vec.rs
Last active October 21, 2019 08:47
Rust Closure Vec
type Mutator<T, R> = Box<dyn for<'a> Fn(&'a mut T) -> R + 'static>;
fn mutator<T, R, F>(f: F) -> Mutator<T, R>
where
F: for<'a> Fn(&'a mut T) -> R + 'static
{
Box::new(f) as Mutator<T, R>
}
type Validator<T, R> = Box<dyn for<'a> Fn(&'a T) -> R + 'static>;