Skip to content

Instantly share code, notes, and snippets.

View breyten's full-sized avatar

Breyten Ernsting breyten

View GitHub Profile
@breyten
breyten / get_climates.py
Created August 9, 2016 09:37
Gets climate data from wikipedia country pages
#!/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
@breyten
breyten / authentication.py
Created December 9, 2013 16:08
Middleware for Django to authenticate a user with an OAuth token
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 ):
@breyten
breyten / hg-close-inactive-branches.sh
Last active February 22, 2019 11:17
Automatically close inactive mercurial branches (use with care!)
for i in `hg branches |grep -v 'default' |grep -v 'production' |grep inactive |awk '{print $1}'`; do hg update $i && hg commit -m "close branch" --close-branch; done