Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# This utility helps reconstructing mailboxes that we recreated after a botched upgrade
# to cyrus 3.6
# This code automates the suggestion from ellie timoney here: https://cyrus.topicbox.com/groups/info/T9d294f89a3d1d260-M2f194782b7c5b5b01e200409
# and reconstructs mailboxes that were recreated (and the old content lost) during an update from cyrus 3.4 to cyrus 3.6
#
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1007965 for the related Debian bugreport
#
@larsimmisch
larsimmisch / crc64.py
Created April 1, 2014 14:53
crc64 implementation in Python (slow)
from __future__ import print_function
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# (Any use permitted, subject to terms of PostgreSQL license; see.)
# If we have a 64-bit integer type, then a 64-bit CRC looks just like the
# usual sort of implementation. (See Ross Williams' excellent introduction
# A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
# ftp://ftp.rocksoft.com/papers/crc_v3.txt or several other net sites.)
@larsimmisch
larsimmisch / gadget.sh
Created July 5, 2023 20:53
USB gadget on a Raspberry Pi 4 for iPad
#!/bin/sh
# I wanted to use a Raspberry Pi as a USB gadget for audio and ethernet, but got error messages on the iPad
# when I extended the camera connection kit with a Lightning extender.
#
# I managed to avoid this by making sure that the USB gadget announces itself as self-powered (see configs/c.1/bmAttributes)
# With this, the Pi 4 and a Hifiberry Amp supplies audio out and ethernet.
#
# For audio out, alsaloop or similar must also be running.
@larsimmisch
larsimmisch / avr-binutils-size.patch
Created December 2, 2012 20:38
avr-binutils size patch
AVR only; support -C for AVR memory usage
Source: http://git.makehackvoid.com/cgi-bin/gitweb.cgi?p=mhvavrtools.git;a=blob_plain;f=mhvavrtools/patches/binutils-001-avr-size.patch;h=e80d28eae46217551d996a2253256c97d10aa4b5;hb=refs/heads/master
===========================================================
--- binutils/size.c 2007-08-06 13:56:14.000000000 -0600
+++ binutils/size.c 2007-09-13 09:13:10.281250000 -0600
@@ -36,10 +36,31 @@
#include "getopt.h"
#include "bucomm.h"
@larsimmisch
larsimmisch / ringbuffer.h
Created March 15, 2014 16:13
C++ implementation of a ringbuffer from @mrdk
// ringbuffer.h
// Author: Markus Redeker
#pragma warning(disable:4786)
#ifndef __RINGBUFFER_H__
#define __RINGBUFFER_H__
// Use:
// ringbuffer r;
@larsimmisch
larsimmisch / mISDNcapid.service
Created December 3, 2016 00:42
systemd service definition for mISDNcapid
[Unit]
Description=mISDN capi daemon
After=network.target
[Service]
ExecStartPre=/bin/mkdir -p /var/run/mISDNcapid
ExecStart=/usr/local/sbin/mISDNcapid -f
Restart=always
[Install]
@larsimmisch
larsimmisch / wp_merge_comments.py
Created December 2, 2015 21:22
Python script to merge comments from one wordpress instance to another
#!/usr/bin/env python
# I recently had to merge the comments from an old instance of wordpress to
# a new one (long and boring story).
# The posts had already been manually merged, but not the comments.
# So I wrote this script to merge the comments
# Warning: while this has worked (once) this may not be a good way to do it.
# Also, it is slow, so, for repeated operation, it creates a stats.json so it doesn't
import os
import click
def prompt_and_invoke(ctx, fn):
# This is a workaround for a bug in click.
# See https://github.com/mitsuhiko/click/issues/429
# This isn't perfect - we are probably ignoring some information
kw = {}
import os
import click
@click.command()
@click.option('--site-title',
default="Notizen",
prompt='Enter site title.')
@click.option('--user-backend',
default="db",
type=click.Choice(['db', 'ldap']),
opam install eliom
The following actions will be performed:
∗ install uutf 0.9.4 [required by tyxml]
∗ install calendar 2.03.2 [required by eliom]
∗ install dbm 1.0 [required by ocsigenserver]
∗ install conf-pkg-config 1.0 [required by conf-libpcre]
∗ install cryptokit 1.10 [required by ocsigenserver]
∗ install lwt 2.4.6 [required by js_of_ocaml, ocsigenserver]
∗ install reactiveData 0.1 [required by eliom]
∗ install optcomp 1.6 [required by deriving]