Skip to content

Instantly share code, notes, and snippets.

@ge0rg
ge0rg / dhcpv6-firewall.rsc
Last active August 26, 2026 16:54
MikroTik DHCPv6 client script to update firewall address-lists
# DHCPv6 script to create firewall address-lists for the parent and the delegated network
#
# Preparation:
# /ipv6 firewall address-list add list=delegated_net
# /ipv6 firewall address-list add list=parent_net
#
# change the prefix of your parent network:
:local parentPrefix 59
:global stripNetmask do={ :return ([:toip6 [:pick $1 0 [:find $1 "/"]]]); }
@ge0rg
ge0rg / print-wg-bgp-route-counts.rsc
Created July 18, 2026 22:20
Print the active route numbers for each BGP-over-WireGuard tunnel (DN42)
# function to format-print name ($1), count ($2) and percentage of total ($3)
:local format do={ :put ($1 . ": " . $2 . " (" . ((100*$2)/$3) . "%)"); }
:local total [ /ipv6/route/print count-only as-value where active bgp ]
$format "total" $total $total
# iterate all wireguard interfaces matching "wg-dn42-"
:foreach interface in=[/interface/wireguard/print proplist=name as-value where name ~ "wg-dn42-" ] \
do={
:local ifname ($interface->"name")
@ge0rg
ge0rg / pidstate.py
Created June 17, 2026 17:25
Poll a PID's state at 1ms resolution and aggregate the numbers
#!/usr/bin/env python3
import math
import sys
import time
states = "RSDZTtWXxKWPI"
def get_state(pid):
stat = open(f"/proc/{pid}/stat", "r").read().split(' ')
@ge0rg
ge0rg / usb-pd.py
Last active June 4, 2026 13:56
USB-PD pretty-printer for data exposed over Linux sysfs
#!/usr/bin/env python3
#
# Pretty-Printer for USB-PD data exposed in /sys/class/typec/
#
# Based on https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-typec
#
# (C) Georg Lukas <georg@op-co.de>
#
from pathlib import Path
@ge0rg
ge0rg / mpo2diptych.sh
Last active June 20, 2023 17:44
Convert left+right pictures from a stereo MPO into a left-right diptych picture
#!/usr/bin/env bash
#
# ***** Warning: this is not production-quality! *****
#
# this will extract the left + right images from all passed
# .MPO files, crop them to a percentage of the width (75% by
# default), and stitch them together into a diptych.
#
# Based on https://photo.stackexchange.com/a/100402/57928
@ge0rg
ge0rg / lighten.py
Last active October 29, 2025 10:33
Script to combine a set of images in "darken" or "lighten" mode, using PIL, rawpy, blend_modes
#!/usr/bin/env python3
import rawpy
from PIL import Image
from blendmodes.blend import blendLayers, BlendType
from argparse import ArgumentParser
import numpy
import re
RAW_FORMATS = ['SRW']
@ge0rg
ge0rg / spam-pow.md
Created October 8, 2019 10:43
Anti-Spam Proof-of-Work

Can you solve the IM spam problem by Proof-of-Work?

(data is from 2017)

  1. PoW is much more energy-expensive on a mobile CPU than on a GPU cluster.
  2. unless we make PoW prohibitively expensive for normal users, spammers won't be slowed / stopped by it.
  3. spammers will either distribute PoW to their botnet, where you will be paying for the PoW, or rent some gigahashes.

The numbers

@ge0rg
ge0rg / MAM-Sub.md
Created September 19, 2019 16:43
XMPP MAM Subcsription, no need for Bind 2.0

MAM Subscription

A client wants to connect, synchronize and have a chat history without holes starting from a client-defined event.

This is the anticipated flow:

  1. connect, authenticate, bind
  2. client: fetch everything(*) from MAM
    • this can be based on a start date (e.g. last 2 days) or the last known archive ID.
  • (*) After completing this, the client will know the latest MAM-ID from that fetch (last_id), but maybe some messages arrived in between
@ge0rg
ge0rg / References.md
Last active September 10, 2019 12:11

Types of XMPP "References"

  • Thread (in-reply-to); largely off-scope for our discussion
  • References of things mentioned in the payload/body of a message (0372)
    • nicknames, URLs, old messages by means of xmpp: URI, etc.
    • multiple Reference elements are allowed
    • Can be used inside Attach-To to add References to a previous message
    • Can be sent by anyone
    • is irrelevant to MAM 2.0
  • Attach-To for content that only makes sense in the context of another message
@ge0rg
ge0rg / invite.php
Last active June 14, 2016 11:04 — forked from iNPUTmice/invite.php
<?php
$url_parts = preg_split('/@|\/|;|\?/',$_SERVER["REQUEST_URI"]);
if (count($url_parts) < 4 || empty($url_parts[3])) {
header('Location: https://yaxim.org');
die();
} else {
$localpart = strtolower(urldecode($url_parts[2]));
$domainpart = strtolower(urldecode($url_parts[3]));
$contact = htmlentities(ucwords($localpart,"-."));
$jid = $localpart.'@'.$domainpart;