Skip to content

Instantly share code, notes, and snippets.

View henare's full-sized avatar

Henare Degan henare

View GitHub Profile
@henare
henare / postcodes.rb
Created December 21, 2011 02:37
Ruby method to return an array of Australian Postcodes
# Returns an array of Australian Postcodes
def australian_postcodes
# Postcodes that look like integers
nsw = (1000..1999).to_a +
(2000..2599).to_a +
(2619..2898).to_a +
(2921..2999).to_a
act = (2600..2618).to_a +
(2900..2920).to_a
vic = (3000..3999).to_a +
@henare
henare / CHANGELOG.md
Created March 3, 2012 03:06
debian-squeeze.box

debian-squeeze-64

A Debian Squeeze 64-bit Vagrant base box that is designed to be as vanilla as possible so that you can add your own configuration in Chef recipes or Puppet manifests.

http://dl.dropbox.com/u/174733/debian-squeeze-64.box

Changelog follows:

2012-03-03

@henare
henare / register.txt
Created March 10, 2012 03:19
OCR of the QLD Register of Members' Interests
This file has been truncated, but you can view the full file.
FIRST REPORT' X 't~ ,
ON THE
REGISTER OF MEMBERS' INTERESTS
I
,I
II
'I
:1
Laid upon the Table of the House
pursuant to theResolution of
@henare
henare / gist:3141164
Created July 19, 2012 06:37
Use output buffering to capture output from var_dump()
ob_start();
var_dump($an_object_or_something);
$object_contents = ob_get_contents();
ob_end_clean();
echo ($object_contents);
@henare
henare / fix_urls.patch
Created July 23, 2012 07:35
Patch for fixing CiviCRM Wordpress URLs
--- a/civicrm/CRM/Utils/System/WordPress.php
+++ b/civicrm/CRM/Utils/System/WordPress.php
@@ -227,10 +227,10 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
}
else {
if (isset($query)) {
- return $base . '?page=CiviCRM&q=' . $path . $pageID . $separator . $query . $fragment;
+ return $script . '?page=CiviCRM&q=' . $path . $pageID . $separator . $query . $fragment;
}
else {
@henare
henare / fix_civi_wordpress_test_drive.patch
Created July 23, 2012 08:41
Patch to fix CiviCRM Wordpress contribution form test-drive mode
--- a/WordPress/civicrm.php
+++ b/WordPress/civicrm.php
@@ -730,6 +730,10 @@ function civicrm_shortcode_handler( $atts ) {
switch ( $component ) {
case 'contribution':
$args['q' ] = 'civicrm/contribute/transact';
+ // Set test drive mode. Civi calls this 'preview' and the shortcode calls it 'test'
+ if ( $mode == 'test' ) {
+ $args['action'] = 'preview';
+ }
@henare
henare / nsw_poeo_licences.rb
Created August 19, 2012 02:08
Scraper for NSW POEO Licences
require 'mechanize'
require 'date'
agent = Mechanize.new
base_url = 'http://www.environment.nsw.gov.au/prpoeoapp/'
first_page = agent.get base_url
form = first_page.form_with(name: 'form1')
form.radiobutton_with(value: 'optIssuedLicences').click
mysql> show processlist;
+-------+----------+-----------------+---------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+----------+-----------------+---------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| 16 | jira | localhost:51978 | jira | Sleep | 3759 | | NULL |
| 31 | collectd | localhost | NULL | Sleep | 8 | | NULL |
| 913 | jira | localhost:53048 | jira | Sleep | 889 |
@henare
henare / australian_federal_foi.csv
Created August 31, 2012 00:56
Australian Alaveteli Public Bodies
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Moved to: https://docs.google.com/spreadsheet/ccc?key=0AuZS_5EqTU80dGd2ZUNtd3A5Q3RvUGg1SFFJV0hJSWc#gid=0
@henare
henare / strace
Created September 11, 2012 09:41
henare@alaveteli:/srv/www/alaveteli_staging/current$ RAILS_ENV=production strace ./script/rebuild-xapian-index
execve("./script/rebuild-xapian-index", ["./script/rebuild-xapian-index"], [/* 23 vars */]) = 0
brk(0) = 0x8afd000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7875000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=30113, ...}) = 0
mmap2(NULL, 30113, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb786d000
close(3) = 0