Skip to content

Instantly share code, notes, and snippets.

@hoehermann
hoehermann / remove_bash_history_duplicates.py
Created February 16, 2025 23:04
Remove duplicate lines from bash_history
#!/usr/bin/env python3
import fileinput
import sys
# TODO: buffer all lines, keep most recent (not first occurrence)
o = []
for line in fileinput.input():
if (line in o):
@hoehermann
hoehermann / mononolig.conf
Created July 31, 2024 15:29
fontconfig to disable ligatures on Monospace fonts
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<!-- This file wants to reside at ~/.config/fontconfig/conf.d/00-mononolig.conf -->
<description>Disable ligatures for monospaced fonts to avoid ff, fi, ffi, etc. becoming only one character wide</description>
<match target="font">
<test name="family" compare="contains" ignore-blanks="true">
<string>Mono</string>
</test>
<edit name="fontfeatures" mode="append">
@hoehermann
hoehermann / devsdx_protector.sh
Last active October 28, 2024 15:21
.bashrc lines to stop user from accessing block devices directly
# disallow accessing block devices directly
reject_devsdx () {
# check if being executed at the top-level (e.g. invoked by the user trying to execute a command, but not when doing tab completion)
if [[ -z "${FUNCNAME[1]}" ]]
then
blockdev_path=""
# check each argument if it is a path that refers to a block device
for arg in ${BASH_COMMAND}
do
# it is safe to use ${arg} without quotes here since the for loop has split it anyway
@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 November 13, 2024 00:22
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 / 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:

@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