Skip to content

Instantly share code, notes, and snippets.

View martin-v's full-sized avatar

Martin Vietz martin-v

View GitHub Profile
@martin-v
martin-v / berlin-terminator.user.js
Last active April 9, 2024 15:58 — forked from lopis/berlin-terminator.user.js
Script that automates hunting for a new Termin in Berlin. Requires a browser extension that can run user scripts., e.g. https://www.tampermonkey.net/
// ==UserScript==
// @name Terminator
// @description Automates finding appointments in Berlin Buergeraemter
// @namespace https://service.berlin.de/terminvereinbarung/termin
// @match https://service.berlin.de/terminvereinbarung/termin/*
// @version 5
// @grant none
// ==/UserScript==
'use strict'
@martin-v
martin-v / backup.sh
Last active January 17, 2023 10:20
Notebook backup script for fedora/rhel using borg
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
if [[ "${1-}" =~ ^-+h(elp)?$ ]]; then
cat << USAGE
Usage: ./$(basename "$0")
Backup this pc to a borg repository (https://www.borgbackup.org/). Handles pruning and desktop notifications.
@martin-v
martin-v / android-boot-img.sh
Created January 27, 2021 22:45
Snippets to create or write a img from current boot partition (with a bit of safety check)
# Create a boot image form active slot
bootctl is-slot-bootable 0 \
&& bootctl is-slot-bootable 1 \
&& bootctl is-slot-marked-successful 1 \
&& bootctl is-slot-marked-successful 0 \
&& dd if=/dev/block/by-name/boot$(bootctl get-suffix $(bootctl get-current-slot)) of=/sdcard/boot.img
# Write boot image to active slot
@martin-v
martin-v / syncgamma.py
Created January 22, 2021 08:28
Synchronize the gamma values on Gnome by majority vote
#!/usr/bin/env python3
import dbus
bus = dbus.SessionBus()
proxy = bus.get_object('org.gnome.Mutter.DisplayConfig',
'/org/gnome/Mutter/DisplayConfig')
iface = dbus.Interface(proxy, dbus_interface='org.gnome.Mutter.DisplayConfig')
resources = iface.GetResources()
serial = resources[0]
@martin-v
martin-v / upload-gpgkey.sh
Last active September 15, 2019 13:30
Script to upload a gpg key to currently relevant gpg keyserver (sks-keyservers.net, openpgp.org, keys.mailvelope.com)
#!/usr/bin/bash -ex
myFingerprint=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# send key to sks-keyservers.net
gpg --keyserver hkp://hkps.pool.sks-keyservers.net --send-keys $myFingerprint
# send key to keys.openpgp.org
gpg --export-options export-minimal --export $myFingerprint | curl -T - https://keys.openpgp.org
@martin-v
martin-v / slack-status.sh
Last active November 13, 2018 22:29
Set slack status based on wifi name
#!/bin/bash
#
# Add the script to your crontab, e.g.
## */20 6-22 * * 1-5 $HOME/bin/slack-status/slack.sh >> $HOME/bin/slack-status/cron.log 2>&1
set -o nounset
set -o errexit
set -o pipefail
STATUS_VAILD_FOR=1260 # 20min cron + 1min puffer
#!/usr/bin/sh
#
# Simpel shell snippet to share files
function httpShare() {
echo "link: http://`hostname`:8080/$1";
{
echo -e "HTTP/1.1 200 OK\r\nContent-Type: `file -b -i $1`\r\n\r\n";
cat $1;
} | nc -l 8080;
#!/usr/bin/zsh
baseurl="http://example.com/blog/"
cd "/home/user/public_html/blog/"
j=0
for i in `ls | sort -r`
do ;
j=`expr $j + 1`
if [ $j -gt 15 ]
@martin-v
martin-v / useful exiftool snippets
Last active December 16, 2015 10:59
useful exiftool snippets
#!/usr/bin/sh
# Show all relevant tags from file
exiftool -args -a -u -e -f -G1:2 test.jpg | grep -v "\-File" | grep -v "\-System"
# Remove all except some white listed useful tags
exiftool -all= -tagsFromFile @ -XMP-dc:Rights -XMP-dc:Creator -XMP-dc:Publisher -ExifIFD:ExposureTime -ExifIFD:FNumber -ExifIFD:ISO -ExifIFD:ExifVersion -ExifIFD:Flash -ExifIFD:FocalLength -ExifIFD:ColorSpace -ExifIFD:FocalLengthIn35mmFormat -IFD0:Artist -IFD0:Copyright -IFD0:Make -IFD0:Model -v0 -progress -overwrite_original