Skip to content

Instantly share code, notes, and snippets.

@davbo
davbo / nowatch.py
Created October 3, 2012 17:42
Stop watching WebLearn repos
import requests
auth = (USER, PASS)
for repo in requests.get('https://api.github.com/user/subscriptions', params={'per_page': 100}, auth=auth).json:
if repo['name'].startswith('wl-'):
requests.delete('https://api.github.com/user/subscriptions/%s/%s' % (repo['owner']['login'], repo['name']), auth=auth)
@davbo
davbo / places.py
Created August 15, 2012 15:54
Content negotiation
from flask import Blueprint
from .helpers import template_or_json
from .views import ServiceView, register_mimetype
places = Blueprint('places', __name__, template_folder='templates')
@places.route('/')
@template_or_json('places/search.html')
@davbo
davbo / gist:2907608
Created June 10, 2012 23:04
New vs. Old
>>> class Old():
... pass
...
>>> class New(object):
... pass
...
>>> type(Old())
<type 'instance'>
>>> type(New())
<class '__main__.New'>
>>> class IdentifierList(list):
... def by_namespace(self):
... return None
...
>>> class Locality():
... @property
... def identifiers(self):
... return IdentifierList(self._identifiers)
... @identifiers.setter
... def identifiers(self, value):