Skip to content

Instantly share code, notes, and snippets.

@wincentbalin
wincentbalin / aktuellparser.py
Last active Jul 13, 2021
Generate German laws
View aktuellparser.py
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
wincentbalin / giitotext.xsl
Last active Jul 20, 2021
Transform XML files from gesetze-im-internet.de to text
View giitotext.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>
<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
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}"
_retry=true
View batch_tester.patch
--- export/batch_tester/batch_tester.cc.orig 2016-02-09 12:38:34.000000000 +0000
+++ export/batch_tester/batch_tester.cc 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
wincentbalin / make_me.sh
Created Jan 14, 2019
Mode switcher for USB armory
View make_me.sh
#!/bin/sh
#
# 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" \) ]
then
echo "Usage: $0 stick|stick-win|stick-mac|host"
exit 1
fi
@wincentbalin
wincentbalin / abc2svg.html
Last active Oct 31, 2018
Convert ABC to SVG
View abc2svg.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>abc2svg test</title>
<style>
#output {
position: absolute;
top: 0;
right: 0
@wincentbalin
wincentbalin / audiobuttons.html
Last active Sep 17, 2018
Simple browser-based sampler
View audiobuttons.html
<!DOCTYPE html>
<html>
<head>
<title>Audio buttons</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
html,
body
{
@wincentbalin
wincentbalin / rewrap.py
Created Aug 1, 2018
Text file rewrapping script
View rewrap.py
#!/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
wincentbalin / KeyHistory.ahk
Created Jul 7, 2018
KeyHistory in AutoHotKey
View KeyHistory.ahk
#Persistent
#InstallKeybdhook
KeyHistory
View clean_html.py
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