Skip to content

Instantly share code, notes, and snippets.

View lehmannro's full-sized avatar

Robert Lehmann lehmannro

View GitHub Profile
@lehmannro
lehmannro / watermark.sh
Created December 14, 2018 15:07
Script to add simple text-based watermark to PDF
#!/bin/bash
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)
EOD
@lehmannro
lehmannro / nested_sections.py
Created July 16, 2015 06:50
Skipping section levels in Docutils
from docutils import utils, nodes, core
document = utils.new_document('<source>')
document.append(
nodes.section('', # bogus section
nodes.section('', # level 2 section
nodes.title('', 'second level'), # <h2>
),
),
)
@lehmannro
lehmannro / soundboard.py
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'
YOUTUBE = 'http://www.youtube.com/watch?v=%s'
@lehmannro
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">
<info/>
<controller id="VFX">
<scriptfiles>
<file functionprefix="MixvibesVFX" filename="Mixvibes-VFXControl-scripts.js"/>
</scriptfiles>
<controls>
<control>
<group>[Channel1]</group>
@lehmannro
lehmannro / shapes.py
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
lehmannro / http.py
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
lehmannro / zeik.sh
Created June 27, 2011 07:12
University of Potsdam WLAN-over-VPN wrapper
#!/bin/sh
# University of Potsdam WLAN-over-VPN wrapper
VPNUSER=$(read -p "Username:")
#VPNUSER=johndoe
WLANIFACE=wlan0
VPNIFACE=zeik.tun0
# kill all remaining Cisco AnyConnect VPNs
pkill openconnect
@lehmannro
lehmannro / django_html5_placeholder.py
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,
only_initial=only_initial)
BoundField.as_widget = as_widget
@lehmannro
lehmannro / interactive-builder.py
Created August 25, 2010 11:08
Debugging helper for Sphinx
# -*- coding: utf-8 -*-
"""
sphinx.builders.interactive
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drop to an interactive shell for debugging.
:copyright: Copyright 2010 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""