Skip to content

Instantly share code, notes, and snippets.

var BubbleChart, root,
__bind = function(fn, me){
return function()
{ return fn.apply(me, arguments);
};
};
BubbleChart = (function() {
BubbleChart.name = 'BubbleChart';
<!DOCTYPE html>
<html>
<head>
<title>GIA Button Example</title>
<link rel="stylesheet" type="text/css" href="gia-tabbed-buttons.css">
</head>
<body>
<h1>GIA Button Example</h1>
@nickjevershed
nickjevershed / Convert Google spreadsheet to JSON and save to S3
Created August 21, 2013 23:10
Converts Google spreadsheet to JSON and saves to an S3 bucket. Spreadsheet needs to be public or accessible with link.
#!/usr/bin/env python
import urllib2
import csv
import json
import boto
#Replace Google spreadsheet URL with your spreadsheet URL
url = "GOOGLE SPREADSHEET URL" + "&output=csv"
@nickjevershed
nickjevershed / getgreatarc.py
Last active August 6, 2020 12:20
Python code for getting the great circle distance between two lat/lon pairs from http://www.johndcook.com/python_longitude_latitude.html
import math
def distance_on_unit_sphere(lat1, long1, lat2, long2):
# Convert latitude and longitude to
# spherical coordinates in radians.
degrees_to_radians = math.pi/180.0
# phi = 90 - latitude
phi1 = (90.0 - lat1)*degrees_to_radians
@nickjevershed
nickjevershed / PDF scraper
Created October 10, 2013 05:12
Example of expenses PDF scraping
#!/usr/bin/env python
import scraperwiki
import urllib2
import lxml.etree
urls = ["http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/TROOD_Russell.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/TRUSS_Warren.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/VAN_MANEN_Bert.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/VASTA_Ross.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/WATERS_Larissa.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/ADAMS_Judith.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/BACK_Chris.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/BISHOP_Julie.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/BISHOP_Mark.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T30/CASH_Michaelia.pdf"
@nickjevershed
nickjevershed / PDF scraper
Created October 14, 2013 22:08
Another scraper for older expense PDFs
#!/usr/bin/env python
import scraperwiki
import urllib2
import lxml.etree
urls = ["http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/ABBOTT_Tony.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/ALBANESE_Anthony.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/ALEXANDER_John.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/ARBIB_Mark.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/BALDWIN_Bob.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/BISHOP_Bronwyn.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/BOWEN_Chris.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/BRADBURY_David.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/CAMERON_Doug.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T27/CLARE_Jason.pd
@nickjevershed
nickjevershed / rfs-fires-to-kml
Created October 22, 2013 02:43
Gets latest polygons of fires from RFS site, converts to KML for mapping
#NOTE: please do not DDoS the RFS site with a bunch of automated queries
import lxml.etree
import simplekml
import urllib2
import datetime
kml = simplekml.Kml()
date_string = datetime.datetime.now().strftime("%d-%m-%Y-%H-%M")
#open latest feed
<style type="text/css">
#gia-header div,
#gia-header h1,
#gia-header p,
#gia-header ul,
#gia-header li {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
@nickjevershed
nickjevershed / flight-scraper.py
Created December 19, 2013 04:13
Scraper for Australian politician's expenses
#!/usr/bin/env python
import scraperwiki
import urllib2
import lxml.etree
urls = ["http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/ABBOTT_Tony.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/ALBANESE_Anthony.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/ALEXANDER_John.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/ARBIB_Mark.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/BALDWIN_Bob.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/BIRD_Sharon.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/BISHOP_Bronwyn.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/BOWEN_Chris.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/BRADBURY_David.pdf","http://www.finance.gov.au/publications/parliamentarians-reporting/docs/T29/BURKE_Tony.pdf"
@nickjevershed
nickjevershed / classify-politician.py
Last active December 31, 2015 21:59
Takes a csv containing names of Australian politicians in the first column, and assigns them a party
#!/usr/bin/env python
# coding=utf-8
import csv
coalition = ["Judith Troeth","Alex Somlyay","Alexander Somlyay","Nick Minchin","Nigel Scullion","Alan Ferguson","Russell Trood","Guy Barnett","Chris Back","Eric Abetz","Judith Adams"," Chris Back","Cory Bernardi","Simon Birmingham","Ron Boswell","Ronald Boswell","Sue Boyce","George Brandis","David Bushby","Michaelia Cash","Richard Colbeck","Helen Coonan","Mathias Cormann","Sean Edwards","Alan Eggleston","David Fawcett","Concetta Fierravanti-Wells","Mitch Fifield","Mary Jo Fisher","Bill Heffernan","Gary Humphries","David Johnston","Barnaby Joyce","Helen Kroger","Ian Macdonald","Bridget McKenzie","Brett Mason","Fiona Nash","Marise Payne","Stephen Parry","Michael Ronaldson","Anne Ruston","Scott Ryan","Arthur Sinodinos","Dean Smith","John Williams","Patrick Secker","Barry Haase","Peter Slipper","Paul Neville","Alby Schultz","John Forrest","Mal Washer","Tony Crook","Judi Moylan","Sophie Mirabella","Alex Somlyay","Alan Tudge","John Alexander","Philip Ruddock","Ross