Skip to content

Instantly share code, notes, and snippets.

View lehmannro's full-sized avatar

Robert Lehmann lehmannro

View GitHub Profile
lehmannro /
Created December 14, 2018 15:07
Script to add simple text-based watermark to PDF
if [[ $# -lt 3 ]] || [[ $# -gt 4 ]]; then
cat > /dev/stderr <<EOD
usage: $(basename $0) <src> <dst> <text> [opacity]
src: input file to be watermarked
dst: output file with watermark applied
text: watermark text
opacity: transparency, 10-99 (light-dark)
lehmannro /
Created July 16, 2015 06:50
Skipping section levels in Docutils
from docutils import utils, nodes, core
document = utils.new_document('<source>')
nodes.section('', # bogus section
nodes.section('', # level 2 section
nodes.title('', 'second level'), # <h2>
lehmannro /
Created November 12, 2014 16:43
Video board for terminal use
import csv
import itertools
import os
import subprocess
import sys
import termios
import tty
CONFIG_FILE = 'videos.cfg'
lehmannro / Mixvibes VFXControl.midi.xml
Created November 1, 2014 15:35
Mixxx configuration for Mixvibes VFXControl
<?xml version='1.0' encoding='utf-8'?>
<MixxxControllerPreset mixxxVersion="" schemaVersion="1">
<controller id="VFX">
<file functionprefix="MixvibesVFX" filename="Mixvibes-VFXControl-scripts.js"/>
lehmannro /
Created January 4, 2013 17:16
Experiment how far we can go in teaching OOP with turtle.
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division
from turtle import Turtle
import math
import random
class ShapefulTurtle(Turtle):
lehmannro /
Created July 14, 2011 05:46
Simple HTTP Server in 512 bytes
#!/usr/bin/env python2.6
Task: implement a rudimentary HTTP server in Python. It needs to support the
GET method to serve static HTML files. Requests to ``/`` shall be
automatically resolved to ``/index.html``. All invalid requests shall be
answered with a ``400 Bad Request``. Queries on a non-existing file shall
terminate in a ``404 Not Found``. The serving port shall be passed through the
command line. The server must be threaded. Use the socket APIs.
This implementation is *just a single Python expression,* and only 512 bytes.
lehmannro /
Created June 27, 2011 07:12
University of Potsdam WLAN-over-VPN wrapper
# University of Potsdam WLAN-over-VPN wrapper
VPNUSER=$(read -p "Username:")
# kill all remaining Cisco AnyConnect VPNs
pkill openconnect
lehmannro /
Created September 23, 2010 07:15
HTML5 placeholder for Django forms
from django.forms.forms import BoundField
boundfield_as_widget = BoundField.as_widget
def as_widget(self, widget=None, attrs=None, only_initial=False):
if attrs is None:
attrs = {}
attrs['placeholder'] = self.label
return boundfield_as_widget(self, widget=widget, attrs=attrs,
BoundField.as_widget = as_widget
lehmannro /
Created August 25, 2010 11:08
Debugging helper for Sphinx
# -*- coding: utf-8 -*-
Drop to an interactive shell for debugging.
:copyright: Copyright 2010 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.