Skip to content

Instantly share code, notes, and snippets.

@hoehermann
hoehermann / devsdx_protector.sh
Created September 1, 2023 00:22
.bashrc lines to stop operator from referring to /dev/sd? directly
# disallow accessing /dev/sd? directly
reject_devsdx () {
if [[ ${BASH_COMMAND} =~ "/dev/sd" ]]
then
echo "Stop being stupid. Use one of these:"
find /dev/disk -type l -printf '%p -> ' -exec readlink -f {} ';' | grep "$(echo ${BASH_COMMAND} | grep -Po '/dev/sd\S+')$"
return 1
fi
}
shopt -s extdebug
@hoehermann
hoehermann / condargparse.py
Created July 27, 2023 21:32
partial and conditional argument parsing
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--format', required=True, choices=['binary', 'xml', 'text'])
args, rem_args = parser.parse_known_args()
if (args.format == "text"):
parser.add_argument('--encoding', required=True)
parser.parse_args(rem_args, namespace=args)
# this does not work since required argument has already been consumed
@hoehermann
hoehermann / spotisilencer.py
Last active September 7, 2022 21:51
This script mutes Spotify when it plays advertisements.
#!/usr/bin/env python3
# encoding: utf-8
import sys
import dbus
import dbus.mainloop.glib
import subprocess
import time
import re
from gi.repository import GLib
@hoehermann
hoehermann / gist:5d33055be2364fd6a49c
Last active December 6, 2019 23:54
The Witcher 2 Linux crashes on old Intel graphics driver
User's notes
===============================================================================================
Witcher 2 does not support this Intel graphics driver.
Console output is witcher2: /mnt/Storage/Development/Projects/eon2-witcher2/src/dlls/directx/d3d9/uniformBuffer.cpp:71: void eON_UniformBufferStreamed::MakeNewBuffer(): Assertion `mBufferPtr' failed
===============================================================================================
Output of command: ''/media/EXTRA/Spiele/SteamLibrary/SteamApps/common/the witcher 2/crash_reporting/minidump_stackwalk' '/home/hermann/.local/share/cdprojektred/witcher2//3cd0cb0f-df91-ef2b-0cd7a362-420f4d0e.dmp' '/media/EXTRA/Spiele/SteamLibrary/SteamApps/common/the witcher 2/crash_reporting/symbols/''
===============================================================================================
Operating system: Linux
0.0.0 Linux 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64
CPU: x86
@hoehermann
hoehermann / keybase.md
Created October 3, 2016 10:49
Gist for keybase.io identification

Keybase proof

I hereby claim:

  • I am hoehermann on github.
  • I am hehoe (https://keybase.io/hehoe) on keybase.
  • I have a public key whose fingerprint is 3042 CEF6 6876 4CC1 FFFA 95E6 BAA2 AC67 4D2E C9D1

To claim this, I am signing this object: