Skip to content

Instantly share code, notes, and snippets.

@raphiz
raphiz / suspend.service
Created September 19, 2016 11:17
Lock screen on suspend - i3 - /etc/systemd/system/
[Unit]
Description=User suspend actions
Before=sleep.target
[Service]
User=rzi # Replace with your user id - %I does not work somehow :/
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/blurlock # Or i3lock
ExecStartPost=/usr/bin/sleep 1
@raphiz
raphiz / nsupdate.sh
Last active February 2, 2020 12:53
Update script for nsupdate.info (For Synology NAS systems)
#!/usr/bin/env sh
DOMAIN="domain.nsupdate.info"
TOKEN="MYTOKEN"
# Evaluate the current remote IP and the one that is currently registerd
CURRENT=$(curl -s https://ipv4.nsupdate.info/myip)
SAVED=$(python2 -c "import socket; print socket.gethostbyname('$DOMAIN')")
LOGFILE=$( cd "$( dirname "${0}" )" && pwd )/log.txt
TEMPFILE=$( cd "$( dirname "${0}" )" && pwd )/tmp
@raphiz
raphiz / us_umlauts
Created June 13, 2016 10:50
My custom xkb keyboard layout (/usr/share/X11/xkb/symbols/us_umlauts/us_umlauts)
default partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {
name[Group1]= "English (German Umlauts)";
key <TLDE> { [ grave, asciitilde ] };
key <AE01> { [ 1, exclam ] };
key <AE02> { [ 2, at ] };
key <AE03> { [ 3, numbersign ] };
key <AE04> { [ 4, dollar ] };
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "us_umlauts"
Option "XkbModel" "pc105"
Option "XkbVariant" ""
Option "XkbOptions" "terminate:ctrl_alt_bksp,grp:alt_shift_toggle"
EndSection
@raphiz
raphiz / android-backup-extractor.sh
Created December 28, 2014 21:56
Converts the contents of a .ab android backup file into a .tar archive
#!/usr/bin/env bash
#
# Converts the contents of a .ab android backup file into a .tar archive
#
# Usage: android-backup-extractor.sh SOURCE <DESTINATION>
#
# Requirements: dd, openssl
# License: MIT
# Autor: Raphael Zimmermann (http://raphael.li)
#
@raphiz
raphiz / http4k-wiremock-alternative.kt
Created November 15, 2023 12:39
A simple http record/replay proxy powered by http4k. It's so much faster than wiremock in my case
import org.http4k.client.JavaHttpClient
import org.http4k.core.Filter
import org.http4k.core.Request
import org.http4k.core.then
import org.http4k.filter.DebuggingFilters
import org.http4k.filter.RequestFilters
import org.http4k.filter.TrafficFilters
import org.http4k.server.SunHttp
import org.http4k.server.asServer
import org.http4k.traffic.ReadWriteCache
@raphiz
raphiz / pdf_remove_watermark.py
Created September 28, 2015 19:52
PDF watermark removal
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.pdf import ContentStream
from PyPDF2.generic import TextStringObject, NameObject
from PyPDF2.utils import b_
wm_text = 'Persönliches Exemplar von'
replace_with = ''
# Load PDF into pyPDF
source = PdfFileReader(open('input.pdf', "rb"))
@raphiz
raphiz / build-sound.gradle
Created February 10, 2024 20:33
Gradle build sound
# ~/.gradle/init.d/build-sound.gradle
allprojects { project ->
project.gradle.buildFinished { result ->
if (result.failure != null) {
project.exec {
# Notification sounds from here: https://github.com/jamesshore/livestream/tree/rot13-cli%2Bservice/build/sounds
commandLine 'sh', '-c', 'mpg123 /home/raphiz/music/notifications/fail.mp3 > /dev/null 2>&1'
}
} else {
project.exec {