Skip to content

Instantly share code, notes, and snippets.

wincentbalin /
Last active Jul 13, 2021
Generate German laws
import re
from html.parser import HTMLParser
RE_TEILLISTE = re.compile(r'/Teilliste_\w\.html$', re.IGNORECASE)
def get_url(attrs):
"""Find href attribute and join it with base URL"""
for key, value in attrs:
if key == 'href':
return urljoin(START_URL, value)
wincentbalin / giitotext.xsl
Last active Jul 20, 2021
Transform XML files from to text
View giitotext.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:output method="text" encoding="utf-8" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="newline"><xsl:text>
<xsl:variable name="space"><xsl:text> </xsl:text></xsl:variable>
<xsl:variable name="tab" select="concat($space, $space, $space, $space)"/>
<xsl:template match="/dokumente">
wincentbalin / Vagrantfile
Last active May 17, 2020
Vagrantfile for CouchDB with Python
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
required_plugins = %w( vagrant-vbguest vagrant-disksize )
_retry = false
required_plugins.each do |plugin|
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
View batch_tester.patch
--- export/batch_tester/ 2016-02-09 12:38:34.000000000 +0000
+++ export/batch_tester/ 2019-04-27 20:04:32.358891300 +0000
@@ -37,11 +37,11 @@
using thrax::GrmManager;
using thrax::InputBuffer;
using thrax::OpenOrDie;
-using thrax::Split;
+//using thrax::Split;
-typedef StringCompiler<StdArc> Compiler;
wincentbalin /
Created Jan 14, 2019
Mode switcher for USB armory
# Function switcher for USB armory
if [ $# -eq 0 -o $# -eq 1 -a \( "$1" != "stick" -a "$1" != "stick-win" -a "$1" != "stick-mac" -a "$1" != "host" \) ]
echo "Usage: $0 stick|stick-win|stick-mac|host"
exit 1
wincentbalin / abc2svg.html
Last active Oct 31, 2018
Convert ABC to SVG
View abc2svg.html
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>abc2svg test</title>
#output {
position: absolute;
top: 0;
right: 0
wincentbalin / audiobuttons.html
Last active Sep 17, 2018
Simple browser-based sampler
View audiobuttons.html
<!DOCTYPE html>
<title>Audio buttons</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
wincentbalin /
Created Aug 1, 2018
Text file rewrapping script
#!/usr/bin/env python3
"""Rewrap lines without breaking words"""
import sys
import argparse
import textwrap
argparser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
argparser.add_argument('infile', type=argparse.FileType('r', encoding='UTF-8'))
wincentbalin / KeyHistory.ahk
Created Jul 7, 2018
KeyHistory in AutoHotKey
View KeyHistory.ahk
import re
def clean_html(html):
Remove HTML markup from the given string.
:param html: the HTML string to be cleaned
:type html: str
:rtype: str