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'],
@mhl
mhl / coords.csv
Last active December 26, 2015 10:39
lon lat
0.119 52.205
-3.188889 55.953056
@mhl
mhl / gist:6182881
Last active December 20, 2015 19:28
#!/usr/bin/env ruby
require 'iconv'
require 'tempfile'
unless ARGV.length == 2
STDERR.puts "Usage: <INPUT-PDF> <OUTPUT-PDF>"
exit 1
end
@mhl
mhl / switch-mzalendo.py
Last active December 19, 2015 09:29
A simple script to switch between Mzalendo setups for different countries
#!/usr/bin/env python
import os
import sys
mzalendo_directory = os.path.join(os.environ['HOME'], 'mzalendo')
available_mzalendi = ('nigeria', 'kenya', 'south-africa')
def usage_and_exit():
#!/usr/bin/python
import lxml.html
from lxml import etree
import urlparse
import dateutil.parser
import datetime
import re
import sys
import urllib
Sukhumi (Abkhazia)
browse on MapIt Global: http://global.mapit.dev.mysociety.org/point/4326/41.016,43.00165.html
In these level 2 areas:
Абхазия - Аҧсны
საქართველო
Abyei_(town) (Abyei)
browse on MapIt Global: http://global.mapit.dev.mysociety.org/point/4326/28.4333,9.6.html
In these level 2 areas:
جمهورية السودان
South Sudan

Alaveteli Theme Upgrade Checks

RAILS_ROOT/RAILS_ENV

Example

Check your theme for instances of:

  • RAILS_ROOT replace with Rails.root
  • RAILS_ENV replace with Rails.env
#!/usr/bin/ruby -w
require 'json'
require 'net/https'
require 'pp'
usage_message = <<EOUSAGE
Usage: #{$0} <OWNER> <RESPOSITORY-NAME> <REF>
For example, you could run:
(mzalendo-virtualenv)mz-nigeria@vulcan:/data/vhost/nigeria.mzalendo.mysociety.org/mzalendo/mzalendo$ ./manage.py core_set_area_parents senatorial-district:state constituency:state
No MapIt area corresponded to ABIA CENTRA (Senatorial District) - skipping
Looking for parents of SEN ABIA NORTH
GEOS_NOTICE: Self-intersection at or near point 7.37569 5.86569
The child area's multipolygon was invalid; simplifying it
proportion overlap was 1.00 with STA Abia
proportion overlap was 0.00 with STA Akwa Ibom
proportion overlap was 0.00 with STA Anambra
proportion overlap was 0.00 with STA Cross River
proportion overlap was 0.00 with STA Ebonyi
#!/usr/bin/env python
import os, re, sys, xml.sax
from lxml import etree
from collections import defaultdict
from xml.sax.handler import ContentHandler
from guess_mp_genders import *
import datetime
since = datetime.date(2010, 5, 6)