Skip to content

Instantly share code, notes, and snippets.

View henare's full-sized avatar

Henare Degan henare

View GitHub Profile
@henare
henare / .gitignore
Created September 29, 2010 02:02
Regularly checks APH to see if Hansard has been posted yet
0000
@henare
henare / main.rb
Created October 1, 2010 01:18
A skeleton Sinatra app
require 'rubygems'
require 'sinatra'
require 'haml'
get '/' do
@answer = question
haml :index
end
helpers do
@henare
henare / add_nsw_parties.sql
Created January 27, 2011 01:47
Stuff we need to do after electionleaflets hacking
INSERT INTO `party` VALUES
(21,'Independent',13,NULL,NULL,'independent',NULL,NULL),
(22,'Australian Labor Party (ALP)',13,NULL,NULL,'australian_labor_party_(ALP)',NULL,NULL),
(23,'Building Australia Party',13,NULL,NULL,'building_australia_party',NULL,NULL),
(24,'Liberal Democratic Party',13,NULL,NULL,'liberal_democratic_party',NULL,NULL),
(25,'Secular Party of Australia',13,NULL,NULL,'secular_party_of_australia',NULL,NULL),
(26,'The Climate Sceptics',13,NULL,NULL,'the_climate_sceptics',NULL,NULL),
(27, 'Country Labor Party', 13, NULL, NULL, 'country_labor_party', NULL, NULL),
(28, 'No Parking Meters Party', 13, NULL, NULL, 'no_parking_meters_party', NULL, NULL),
(29, 'Outdoor Recreation Party', 13, NULL, NULL, 'outdoor_recreation_party', NULL, NULL),
@henare
henare / mw-to-gollum.rb
Created March 10, 2011 02:41
Imports a MediaWiki XML export into a Gollum wiki
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'gollum'
wiki = Gollum::Wiki.new('openaustralia.wiki')
file = File.open("OpenAustralia-20110309232515.xml", "r")
doc = Hpricot(file)
@henare
henare / find_state.php
Created March 31, 2011 01:43
Function to determine Australian state from a postcode, from http://waww.com.au/ramblings/determine-state-from-postcode-in-australia
/**
* Returns the state for a postcode.
* eg. NSW
*
* @author http://waww.com.au/ramblings/determine-state-from-postcode-in-australia
* @link http://en.wikipedia.org/wiki/Postcodes_in_Australia#States_and_territories
*/
function findState($postcode) {
$ranges = array(
'NSW' => array(
@henare
henare / el-189_migration.sql
Created April 5, 2011 03:27
The database "migration" we need to run on production for EL-189
CREATE TABLE `category_election` (
`category_election_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`category_id` INT( 11 ) NOT NULL ,
`election_id` INT( 11 ) NOT NULL
) ENGINE = MYISAM ;
INSERT INTO `category_election` (category_id, election_id) SELECT category_id, 1 FROM category;
INSERT INTO `category_election` (category_id, election_id) SELECT category_id, 2 FROM category;
@henare
henare / check_stats.rb
Created June 13, 2011 03:59
Scrape your Linksys AM300 to get line stats (should be available via SNMP!). Now available as a repo https://github.com/henare/linksys_am300_statistics
require './dslmodem.rb'
raise "Incorrect number of arguments supplied. Need URL, username and password" if ARGV.size != 3
modem = DSLModem.new(ARGV[0], ARGV[1], ARGV[2])
while true
modem.get_stats_page
statistics = modem.statistics
@henare
henare / github_issues_to_csv.rb
Created July 26, 2011 05:00
Exports Github issues to CSV so it can be imported into Jira
require 'json'
require 'open-uri'
require 'csv'
require 'date'
# Github credentials to access your private project
USERNAME="myusername"
PASSWORD="mypassword"
# Project you want to export issues from
@henare
henare / el_qld.sql
Created November 20, 2011 03:25
Election Leaflets DB migration for 2012 QLD election
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Albert',6,'QLD','albert');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Charters Towers',6,'QLD','charters_towers');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Hinchinbrook',6,'QLD','hinchinbrook');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Mount Coot-tha',6,'QLD','mount_coot-tha');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('South Brisbane',6,'QLD','south_brisbane');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Algester',6,'QLD','algester');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Chatsworth',6,'QLD','chatsworth');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Inala',6,'QLD','inala');
INSERT INTO constituency (name,constituency_type_id,area_code,url_id) VALUES ('Mount Gravatt',6,'QLD','m
We can't make this file beautiful and searchable because it's too large.
"Pcode","Locality","State","Comments","DeliveryOffice","PresortIndicator","ParcelZone","BSPnumber","BSPname","Category"
"0200","AUSTRALIAN NATIONAL UNIVERSITY","ACT","PO Boxes","AUSTRALIAN NATIONAL UNI LPO","150","N2 ","019","CANBERRA","Post Office Boxes "
"0221","BARTON","ACT","LVR Special Mailing","CANBERRA SOUTH DC ","150","N2 ","019","CANBERRA","LVR "
"0800","DARWIN","NT",,"DARWIN DELIVERY CENTRE","085","NT1","001","DARWIN","Delivery Area "
"0801","DARWIN","NT","GPO Boxes","DARWIN GPO DELIVERY ANNEXE ","085","NT1","001","DARWIN","Post Office Boxes "
"0804","PARAP","NT","PO Boxes","PARAP LPO ","085","NT1","001","DARWIN","Post Office Boxes "
"0810","ALAWA","NT",,"DARWIN DELIVERY CENTRE","085","NT1","001","DARWIN","Delivery Area "
"0810","BRINKIN","NT",,"DA