Skip to content

Instantly share code, notes, and snippets.

from pygeocoder import Geocoder
def our_geocoder(country, query):
print "### in our_geocoder"
components = 'country:' + country
response = Geocoder.geocode(query, components=components)
return [
{
"address": entry['formatted_address'],
"latitude": entry['geometry']['location']['lat'],
from django.contrib.contenttypes.models import ContentType
from pombola.core.models import OrganisationKind
for ok in OrganisationKind.objects.filter(name__icontains='committee'):
print ok
for o in ok.organisation_set.all():
print " ", o
for i in Identifier.objects.filter(
object_id=o.id,
content_type=ContentType.objects.get_for_model(Organisation)
#!/usr/bin/python
import mailbox
import os
import re
from subprocess import check_output
import sys
top_level_mail_directory = os.path.join(os.environ['HOME'], 'Mail')
@mhl
mhl / example.js
Last active August 29, 2015 14:04
var popitURL = 'http://za-new-import.popit.mysociety.org/api/v0.1';
var today = new Date().toISOString().substring(0, 10);
function endDateAfter(endDate, whenDate) {
if (!endDate) {
/* A falsy endDate indicates that the end date is 'future' */
return true;
}
return endDate > whenDate;
@mhl
mhl / gist:06edb1415c6609e1d109
Last active August 29, 2015 14:14
find constituencies with missing SNP candidates
In [1]: from candidates.static_data import MapItData
In [2]: from candidates.popit import create_popit_api_object
In [3]: api = create_popit_api_object()
In [4]: scottish_cons = [m['id'] for m in MapItData.constituencies_2010.values() if m['country'] == 'S']
In [15]: for post_id in scottish_cons:
....: p = api.posts(str(post_id)).get(embed='membership.person')['result']
=====================================================
3 party:103 Alliance - Alliance Party of Northern Ireland
--
Emblem 1
http://yournextmp.popit.mysociety.org/organizations/party:103/image/54ce61a895590a102032012e
--
Emblem 2
http://yournextmp.popit.mysociety.org/organizations/party:103/image/54ce61a895590a102032012f
--
Emblem 3
diff --git a/data/all-parties-from-popit.json b/data/all-parties-from-popit.json
index 8f97cf7..b313e9f 100644
--- a/data/all-parties-from-popit.json
+++ b/data/all-parties-from-popit.json
@@ -1260,21 +1260,21 @@
"slug": "the-monmouth-party"
},
{
"classification": "Party",
"contact_details": [],
@mhl
mhl / download-emusic.py
Created May 4, 2015 14:45
An old script for downloading albums from EMusic, no idea if it still works
#!/usr/bin/env python
import sys
import os
from subprocess import check_call
from lxml import etree
if len(sys.argv) != 2:
print >> sys.stderr, "Usage: %s [EMX-FILE]" % (sys.argv[0])
sys.exit(1)

Keybase proof

I hereby claim:

  • I am mhl on github.
  • I am mhl (https://keybase.io/mhl) on keybase.
  • I have a public key whose fingerprint is 74D7 CE8D ADB3 E542 93A5 D25D FEBF 4CC4 8EE8 9E5A

To claim this, I am signing this object:

@mhl
mhl / ynr-transifex.md
Last active August 29, 2015 14:23
draft YNR Transifex update procedure