Skip to content

Instantly share code, notes, and snippets.

KlausBrunner /
Last active May 19, 2022
Running Rspamd with redis and unbound in Podman

Quick notes on running Rspamd in a Podman pod

This includes three containers:

Ideally, all of this should work in both rootless and rootful mode.

KlausBrunner /
Created Apr 5, 2022
Given a sequence of pairs (A, B), return a list of 3-tuples (A, B, T) where T is a boolean that marks whether the sequence contains the inverted pair (B, A) as well.
from typing import Sequence
def mark_bidirectionals(pairs: Sequence) -> list:
"""Given a sequence of pairs (A, B), return a list of 3-tuples (A, B, T) where T is a boolean that
marks whether the sequence contains the inverted pair (B, A) as well. Order is preserved, but all
identical and inverted pairs to the right of (i.e. on higher indexes than) the original pair are removed.
Implementation note: pairs must be immutable (usable as dict keys)."""
marks = dict()
for a, b in pairs:
if (b, a) in marks:
KlausBrunner /
Created Dec 10, 2019
Java byte array to hexdump. Format similar to default of hexdump(1).
static String hexDump(byte[] bytes) {
Formatter format = new Formatter(new StringBuilder());
for (int j = 0; j < bytes.length; j++) {
if (j % 16 == 0) {
format.format((j > 0 ? "\n" : "") + "%08X ", j);
format.format("%02X ", bytes[j]);
return format.toString();
KlausBrunner / sshd_config
Last active Apr 13, 2020
Minimal, secure sshd_config (OpenSSH 8.2)
View sshd_config
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key
ChallengeResponseAuthentication no
UsePAM yes
# Allow client to pass locale environment variables
KlausBrunner /
Created Aug 12, 2019
Generate a basic parent POM from all subfolders that contain Maven projects.
#!/usr/bin/env python3
import os
import argparse
parser = argparse.ArgumentParser(description='Generate a Maven parent pom for existing Maven projects in a folder.')
parser.add_argument('root', default='.', nargs='?',
help='root (parent) folder')
parser.add_argument('--group', default='localhost',
help='groupId for parent POM')
KlausBrunner / hls-distances.html
Created Mar 21, 2019
Trivial example to calculate route distances from a fixed point to location(s) specified as user input, using HERE Location Services.
View hls-distances.html
<!DOCTYPE html>
<meta charset="utf-8" />
<script src="" type="text/javascript" charset="utf-8"></script>
<script src="" type="text/javascript" charset="utf-8"></script>
KlausBrunner /
Last active Oct 3, 2016
Track a repo manifest's project count over time using GitPython. Prints simple "datetime count" table.
import os
from git import Repo
import datetime as dt
import xml.etree.ElementTree as ET
repo = Repo('/home/klaus/stats/manifests')
target_file = 'manifest.xml'
assert not repo.bare
KlausBrunner /
Created Dec 10, 2015
Accessing the gerrit SSH interface using Python (via ssh config entry)
#!/usr/bin/env python
import paramiko
import sys
import os
client = paramiko.SSHClient()
config = paramiko.SSHConfig()
KlausBrunner /
Created Jun 1, 2015
Finding commits by SHA-1 hash on Github repos forked from a given root repo.
""" Finding commits by SHA-1 hash on Github. This is a simple
brute-force search for a specific usecase: you assume that the commit is
within all repos forked from a certain root repo within the past n days.
This may result in many calls to the GitHub API, which in turn may result
in GitHub's rate limiter kicking in and forcing you to take a break. You
have been warned.
Built with Python 3.4 and 0.9.4.
KlausBrunner /
Created Oct 7, 2014
Elasticsearch boolean multifield silently ignored #6587
curl -XGET 'http://localhost:9200/'
# "status" : 200,
# "name" : "Spider-Man",
# "version" : {
# "number" : "1.3.2",
# "build_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",
# "build_timestamp" : "2014-08-13T14:29:30Z",
# "build_snapshot" : false,
# "lucene_version" : "4.9"