Skip to content

Instantly share code, notes, and snippets.

@stefanw
stefanw / termin_corona_impfung_nrw.py
Last active April 3, 2021 14:43
mitmproxy script to accelerate vaccination appointment page. Replace ... with content from API.
from mitmproxy import http
OK_URL = 'https://termin.corona-impfung.nrw/api/impfling/buchung/backend/ok'
LIST_URL = 'https://termin.corona-impfung.nrw/api/impfzentrum/list'
STATUS_URL = 'https://termin.corona-impfung.nrw/api/impfling/buchung/status'
BENUTZER_URL = 'https://termin.corona-impfung.nrw/api/benutzer/benutzer'
def request(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url == OK_URL:
@stefanw
stefanw / fds_reconciliation.md
Last active February 25, 2019 15:59
FragDenStaat OpenRefine Reconciliation

OpenRefine Reconciliation with FragDenStaat.de

Preparations

FragDenStaat.de uses letsencrypt for HTTPS certificates. Unfortunately, the standard Java installation doesn't recognize that authority and the reconciliation will be stuck in the "Working" screen. Here's how to fix this.

  1. Download the cross-signed certificate: https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem.txt
  2. Import the certificate into the keystore of OpenRefine
keytool -import -alias letsencrypt -keystore /Applications/OpenRefine.app/Contents/PlugIns/jdk1.8.0_60.jdk/Contents/Home/jre/lib/security/cacerts -file ~/Downloads/lets-encrypt-x3-cross-signed.pem.txt
@stefanw
stefanw / cluster_streets.py
Created November 2, 2015 15:43
OSM Shapefile exports to streets in GeoJSON MultiLineStrings
# -*- encoding: utf-8 -*-
'''
Reads in OSM export Shapefile (e.g. from http://download.geofabrik.de/),
clusters by street name and distance and outputs a geojson FeatureCollection
with MultiLineStrings.
python cluster_streets.json berlin.roads.shp
(c) Stefan Wehrmeyer, 2015
License: MIT
@stefanw
stefanw / index.html
Last active August 29, 2015 14:09
500 Error page of old OpenSpending
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>500</title>
@stefanw
stefanw / bundestag-api.md
Last active June 13, 2018 14:41
Bundestag XML API description

Bundestag XML API

The German parliament iPhone app "Bundestag" uses XML endpoints at bundestag.de to get fresh data. This guide lists them.

Authentication

Since version 4.2 the iPhone app requires an HTTP basic auth header for new endpoints. For backwards compatibility some old endpoints don't require authentication.

The authentication credentials are:

@stefanw
stefanw / btw2009.py
Created September 13, 2013 02:50
BTW 2009 Seat Calculator. Do not use if your democracy relies on it.
# -*- coding: utf-8 -*-
from collections import defaultdict, Counter
year = 2009
default_mandates = 598
mandates = default_mandates
sperrklausel = 0.05
laender = ['berlin']#, 'bayern']
@stefanw
stefanw / immoscoutapi.py
Created September 7, 2013 11:56
ImmoScout24 API class
import urllib
import oauth2 as oauth
import json
class ImmoScout24Api(object):
def __init__(self, auth, domain='http://sandbox.immobilienscout24.de', headers=None):
"""
auth must be a dictionary with the following keys:
consumer_key, consumer_secret, access_token, access_secret
@stefanw
stefanw / main.debug.css
Created April 16, 2013 10:51
CKAN's main debug css for debug=true
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section {
@stefanw
stefanw / 039_add_expired_id_and_dates.py
Created April 14, 2013 17:40
CKAN db migration 039 compatible with Postgres 8.3. No proper db upgrade, just init.
from migrate import *
import uuid
import datetime
def upgrade(migrate_engine):
id = uuid.uuid4()
make_missing_revisions = '''
@stefanw
stefanw / tiefbauaemterberlin.csv
Created March 12, 2013 23:52
Tiefbauämter Berlin from https://gist.github.com/johnjohndoe/5147647, now in Froide Import Format
name contact address email jurisdiction__slug topic__slug classification
Tiefbauamt Berlin-Mitte (Wedding, Tiergarten) Tel.: 9018-0 Fax: 22783 Karl-Marx-Allee 31, 10178 Berlin Mathilde-Jakob-Platz 1, 10551 Berlin strassen-gruenflaechenamt@ba-mitte.verwalt-berlin.de berlin verkehr-und-bau Tiefbauamt
Tiefbauamt Berlin-Friedrichshain-Kreuzberg Tel.: 90298-0 Fax: 8015 Hallisches Ufer 80, 10963 Berlin Frankfurter Allee 35/37, 10247 Berlin Helmut.Schulz-Hermann@ba-fk.verwalt-berlin.de berlin verkehr-und-bau Tiefbauamt