Skip to content

Instantly share code, notes, and snippets.

View jboynyc's full-sized avatar
🍜

John Boy jboynyc

🍜
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Bundestagswahl 2005
Endgültig
Nr;Gebiet;gehört;Wahlberechtigte;;;;Wähler;;;;Ungültige;;;;Gültige;;;;SPD;;;;CDU;;;;CSU;;;;GRÜNE;;;;FDP;;;;Die Linke.;;;;Offensive D;;;;REP;;;;NPD;;;;Die Tierschutzpartei;;;;GRAUE;;;;PBC;;;;DIE FRAUEN;;;;FAMILIE;;;;BüSo;;;;BP;;;;ZENTRUM;;;;Deutschland;;;;AGFG;;;;APPD;;;;50Plus;;;;MLPD;;;;Die PARTEI;;;;PSG;;;;Pro DM;;;;CM;;;;DSU;;;;HP;;;;HUMANWIRTSCHAFTS- PARTEI;;;;STATT Partei;;;;UNABHÄNGIGE;;;;Übrige;;;;
;;zu;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;Zweitstimmen;;Erststimmen;;
@jboynyc
jboynyc / eportfolio-media-xmlrpc.py
Created October 24, 2013 19:24
Get a list of all images attached to posts within a category. Uses WordPress' XML-RPC API, enabled by default in 3.5. Documentation for python-wordpress-xmlrpc: http://python-wordpress-xmlrpc.readthedocs.org/en/latest/index.html
config = {
'site' : 'doe13',
'user' : 'notarealname',
'password' : 'notarealpassword'
}
from wordpress_xmlrpc import Client
from wordpress_xmlrpc.methods import posts, media
def flatten(l):
@jboynyc
jboynyc / topsy-scraper.py
Last active February 16, 2016 13:33
This is a short Python script to scrape data from Topsy through their API and store it in MongoDB. (Now they require an API key, so some changes are necessary to get it to work.)
#!/usr/bin/env python
from urllib2 import urlopen, urlencode
from pymongo import connection
import json
from optparse import OptionParser
from time import sleep
verbose = 1
parser = OptionParser()
@jboynyc
jboynyc / idea_of_nature.md
Created March 1, 2016 23:21
Summary of R. G. Collingwood, "The Idea of Nature" (1945)

R. G. Collingwood, The Idea of Nature (Oxford: Clarendon Press, 1945).

Collingwood’s concern in this little book is to clarify the idea of nature as it underlies both natural science and philosophy. Saying that science is “based” on nature does not mean that the idea of nature is worked out first and all further scientific investigation proceeds from it. Rather, the conception of nature is subject to change along with scientific knowledge. Collingwood does not believe that there is one correct view of nature but rather seems to believe with Hegel that “the true is the whole,” that is, that the entire history of the concept and not just the “bottom line” of our modern

import requests
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
def reverse_geocode(lng, lat, zoom=18):
OSM_API_URL = 'http://nominatim.openstreetmap.org/reverse?'
_headers = {'User-Agent':
@jboynyc
jboynyc / ig_to_json.py
Last active March 30, 2016 13:53
Write an igraph graph to a JSON file for use with Sigma.js
import os
import json
import igraph as ig
def ig_to_json(graph, path):
assert isinstance(graph, ig.Graph)
nodes = []
edges = []
@jboynyc
jboynyc / sintenpietengilde_intochten.py
Created April 4, 2016 10:52
Find Dutch blackface parades
import re
import requests
import pandas as pd
from xml.dom.minidom import parseString as xml_parse
MAP_URL = 'http://sintenpietengilde.nl/Kaart.html'
KML_OUT = 'sintenpietengilde_kaart.kml'
XLS_OUT = 'sintenpietengilde_kaart.xlsx'
@jboynyc
jboynyc / snarf-all-pdfs.py
Last active June 8, 2016 10:23
Easily download all linked PDFs from a web page using the IPython/Jupyter console
from bs4 import BeautifulSoup as bs
r = !curl -s 'https://example.net'
s = bs(''.join(r))
for link in s.findAll('a', {'href': lambda x: x.endswith('pdf')}):
loc = link['href']
!curl -O $loc
@jboynyc
jboynyc / amsterdam_bounds.wkt
Created November 17, 2016 14:03
Amsterdam municipality bounds
MULTIPOLYGON (((4.7567178999999999 52.3778378000000020, 4.7564339000000002 52.3777635000000000, 4.7569860000000004 52.3770463000000030, 4.7575304999999997 52.3761888000000010, 4.7580470000000004 52.3750653000000030, 4.7583805000000003 52.3740153000000030, 4.7585170000000003 52.3732593000000010, 4.7585676000000001 52.3727554000000030, 4.7585964000000001 52.3722175999999990, 4.7585747999999999 52.3715943999999990, 4.7585107999999998 52.3712412000000000, 4.7584413999999997 52.3709575999999970, 4.7579834999999999 52.3692393999999980, 4.7578265000000002 52.3687134999999980, 4.7567178999999999 52.3778378000000020)), ((4.7590846000000004 52.3807575000000010, 4.7590851000000001 52.3807377999999990, 4.7590902000000002 52.3805027000000010, 4.7590915000000003 52.3804415999999970, 4.7590922000000004 52.3804074000000030, 4.7590925999999998 52.3803957000000010, 4.7591020999999998 52.3800388000000010, 4.7591023999999997 52.3800254000000010, 4.7591028000000000 52.3800136999999990, 4.7591124999999996 52.3797112000000030, 4.75
@jboynyc
jboynyc / mapillary.py
Last active November 18, 2016 10:52
simple Mapillary API wrapper (for Python 3.4+)
# coding=utf-8
import requests
from yaml import load as yaml_load
from functools import partialmethod
from urllib.parse import urlencode, quote
class Mapillary(object):
def __init__(self, token='token.yaml'):
self._base_url = 'https://a.mapillary.com/v2'