Skip to content

Instantly share code, notes, and snippets.

@ge0rg
ge0rg / usb-pd.py
Last active April 12, 2024 16:01
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
Created January 5, 2023 20:42
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 blend_modes import darken_only, lighten_only
from argparse import ArgumentParser
import numpy
import re
import sys
@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;

Keybase proof

I hereby claim:

  • I am ge0rg on github.
  • I am ge0rg (https://keybase.io/ge0rg) on keybase.
  • I have a public key whose fingerprint is CE57 348B 6A53 7B58 6ADF 991D B334 D308 962F D2DE

To claim this, I am signing this object:

@ge0rg
ge0rg / gist:290840
Created January 31, 2010 01:57
System.setProperty("smack.debugEnabled", "true");
01-31 02:55:30.303 1597 1597 I MainWindow: getConnectionState(): 1
01-31 02:55:30.783 1597 1606 I global : Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
01-31 02:55:30.803 1597 1606 I global : Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
01-31 02:55:30.823 1597 1606 W System.err: java.lang.NoSuchMethodException: AndroidDebugger(XMPPConnection,Writer,Reader)
01-31 02:55:30.833 1597 1606 W System.err: at java.lang.Class.getMatchingConstructor(Class.java:674)
01-31 02:55:30.833 1597 1606 W System.err: at java.lang.Class.getConstructor(Class.java:486)
01-31 02:55:30.843 1597 1606 W System.err: at org.jivesoftware.smack.XMPPConnection.initReaderAndWriter(XMPPConnection.java:1095)
01-31 02:55:30.843 1597 1606 W System.err: at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:920)
01-31 02:55:30.843 1597 1606 W Syst