Skip to content

Instantly share code, notes, and snippets.

View mschmitt's full-sized avatar
🥾
Busier than a one-legged man in an ass-kicking contest.

Martin Schmitt mschmitt

🥾
Busier than a one-legged man in an ass-kicking contest.
View GitHub Profile
@mschmitt
mschmitt / ansible-results.yml
Created February 24, 2025 09:30
Ansible Hausaufgabenhilfe
#!/usr/bin/env ansible-playbook
---
- hosts: localhost
gather_facts: true
connection: local
tasks:
- name: Do some things
block:
- name: A few non-invasive apt actions
apt:
@mschmitt
mschmitt / virtualwall_irremote.pde
Created May 24, 2010 08:56
A trivial Arduino sketch to mimic iRobot Virtual Wall for Roomba
/*
A trivial Arduino sketch to mimic iRobot Virtual Wall for Roomba
----------------------------------------------------------------
Based on information found at:
http://sites.google.com/site/irobotcreate2/createanirbeacon
Uses "A Multi-Protocol Infrared Remote Library for the Arduino":
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
@mschmitt
mschmitt / lslrmdate
Created January 22, 2025 11:11
Remove the date field from a redirected ls -l output
#!/usr/bin/env python3
import sys,re
date=re.compile(r" (\S|\D){3} ( \d|\d\d) (\d\d:\d\d| \d{4}) ")
for l in sys.stdin:
l = date.sub(' xxxxxxxxxxxx ', l.rstrip())
print(l)
@mschmitt
mschmitt / Reload-At-Wallclock.user.js
Last active November 22, 2024 12:08
Reload-At-Wallclock.user.js
// ==UserScript==
// @name Reload at Wallclock
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Reload at Wallclock
// @author You
// @match https://mschmitt.github.io/timestamp-tester/
// @match https://tickets.events.ccc.de/*
// @grant none
// ==/UserScript==

"Mobilnummern zwecks Pseudonymisierung hashen"

Gültige Mobil-Prefixe besorgen:

lynx --dump https://www.bundesnetzagentur.de/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/MobileDienste/zugeteilte%20RNB/MobileDiensteBelegteRNB_Basepage.html | sed -n 's/(0)/+49/p' | sed 's/-//' | awk '{print $1}' | grep ^+49 > numbers.prefixes.txt

Beispieltelefonnummern generieren mit 7 Stellen nach der Vorwahl:

for i in $(shuf numbers.prefixes.txt); do printf "%s%.7i\n" "${i}" "${RANDOM}"; done > numbers.randomnumbers.txt

/*
Casually working on a shelly script to automatically restart
an unstable connection based on something.
In this case, floating average of ping measurements from an URL.
Very early prototype.
*/
const act_if_over_ms = 4.0;
@mschmitt
mschmitt / prometheus-exporter.conf
Created August 23, 2024 06:25
Iobroker -> Telegraf -> Prometheus -> Grafana
# /etc/telegraf/telegraf.d/prometheus-exporter.conf
# Subscribe to relevant MQTT topics from ioBroker
[[inputs.mqtt_consumer]]
servers = ["tcp://[::1]:1881"]
username = "***"
password = "***"
topics = [
"0_userdata/0/sensor/einpersonensauna/+",
"0_userdata/0/stromzaehler/+/+",
@mschmitt
mschmitt / routing.md
Last active July 30, 2024 06:52
Multi-WAN routing (damit Port Forwards funktionieren) mit iptables/iproute2

Auf Basis der MAC-Adresse der Fritze, über die das Paket reinkam, ein Connection Mark an die Verbindung schreiben:

iptables -t mangle -A INPUT -i eth0 -m mac --mac-source a7:bc:5d:23:53:a3 -j CONNMARK --set-xmark 0x1/0xffffffff
iptables -t mangle -A INPUT -i eth0 -m mac --mac-source e3:c0:f9:f1:8d:76 -j CONNMARK --set-xmark 0x2/0xffffffff

Das Connection Mark in ein Routing Mark umschreiben:

#!/usr/bin/env bash
rm -f cookie.txt
rm -f trace_curl.* trace_krb5.*
# source url sets the $URL1 environment. Confidentiality something something.
source url
# Test case 1: No authentication, no cookies, allow redirect.
# Expected behaviour: Application server at $URL1 redirects to oidc server, oidc server returns error/login page.
@mschmitt
mschmitt / betterpasswords
Created January 25, 2011 09:54
Dictionary-based password generator in Perl
#!/usr/bin/perl -w
use strict;
use diagnostics;
# https://gist.github.com/794727
# Dictionary-based password generator in Perl
usage() if ($ARGV[0] and ($ARGV[0] eq '-?'));
my $wordlist = '/usr/share/dict/words';