This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import re | |
from pprint import pprint | |
import json | |
from time import sleep | |
import requests | |
from BeautifulSoup import BeautifulSoup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import re | |
import codecs | |
from lxml import etree | |
def parse_big_xml(filename, item_tag=u'item'): | |
with codecs.open(filename, 'r', 'utf-8') as in_file: | |
output = u'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for SET in `wget -q -O - 'https://api.datapunt.amsterdam.nl/gebieden/' |jq '.[]' |sed -e 's/"//g;'`; do | |
echo $SET | |
for PART in `wget -q -O - $SET |jq '.results[] |._links.self.href' |sed -e 's/"//g;'`; do | |
echo "* $PART" | |
wget -q -x $PART | |
done | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
party_counts = sorted([ | |
{'party': p, 'count': get_party_count(p, session)} for p in parties], | |
key=lambda x: x['count']) | |
pprint(party_counts) | |
all_people = politicians + executives | |
politician_counts = sorted([ | |
{'politician': p, 'count': get_politician_count(p, session)} for p in all_people], | |
key=lambda x: x['count']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
from BeautifulSoup import BeautifulSoup | |
NPO_BACKSTAGE_BASE_URL = 'http://backstage-api.npo.nl' | |
NPO_BACKSTAGE_ENDPOINT_SEARCH = '/v0/search' | |
def get_politician_count(politician, session): | |
SEARCH_DATA = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
from BeautifulSoup import BeautifulSoup | |
def get_politicians(session): | |
url = u'http://www.tweedekamer.nl/kamerleden/alle_kamerleden' | |
resp = session.get(url) | |
if resp.status_code != 200: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GithubNewIssueDefaults | |
// @namespace http://yerb.net/ | |
// @version 0.1 | |
// @description Make a new issue have sane defaults -- milestone & assignee | |
// @match https://github.com/*/*/issues/new | |
// @copyright 2013, Breyten Ernsting | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name HNBitcoinHider | |
// @namespace http://yerb.net/ | |
// @version 0.1 | |
// @description Hide bitcoin news items on Hacker News | |
// @match https://news.ycombinator.com* | |
// @copyright 2013, Breyten Ernsting | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import re | |
from django.utils import translation | |
from django.middleware.locale import LocaleMiddleware | |
class LocaleNoHTTPAcceptMiddleware(LocaleMiddleware): | |
def process_request(self, request): | |
request.LANGUAGE_CODE = translation.get_language() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
import re | |
from django.conf import settings | |
from django.contrib.auth.models import User, check_password | |
from django.contrib.auth import authenticate, login | |
from apps.api.authentication import verify_access_token, OAuthError | |
class OAuth2Middleware( object ): |
NewerOlder