Skip to content

Instantly share code, notes, and snippets.

View rjmackay's full-sized avatar

Robbie Mackay rjmackay

View GitHub Profile
@rjmackay
rjmackay / gist:983085
Created May 20, 2011 14:58
Add gids parameter to node/XXX/edit urls - so noderelationships has context
/*
* Implementation of hook_nodeapi()
* Add gids parameter to node/XXX/edit urls - so noderelationships has context
*/
function og_country_nodeapi(&$node, $op) {
if ($op != 'prepare') return;
if (!empty($_REQUEST['gids'])) return;
if (arg(2) == 'edit' && $node->og_groups) {
@rjmackay
rjmackay / MY_Controller.php
Created May 10, 2012 04:56
Ushahidi MY_Controller
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Base Controller
* Enforces basic access control, ie. for private deployments
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/copyleft/lesser.html
*
@rjmackay
rjmackay / Upgrader.diff
Created July 24, 2012 22:34
Better table prefix handling in Upgrader
@ -319,19 +319,25 @@ class Upgrade_Controller extends Admin_Controller {
if ($table_prefix)
{
$find = array(
'CREATE TABLE IF NOT EXISTS `',
'INSERT INTO `',
+ 'INSERT IGNORE INTO `',
'ALTER TABLE `',
- 'UPDATE `'
+ 'UPDATE `',
@rjmackay
rjmackay / gen_update.sh
Created July 25, 2012 21:27
Gen update with commandline params
#!/bin/bash
# To check tags, run this in the browser
# https://api.github.com/repos/ushahidi/Ushahidi_Web/tags
if [[ $# -lt 2 ]]
then
echo "Usage: gen_updates.sh [previous-tag] [current-tag]"
exit 1
fi
@rjmackay
rjmackay / category_wildlife_block.php
Created August 8, 2012 02:14
Ushahidi Category Blocks
<?php blocks::open("reports");?>
<?php blocks::title(Kohana::lang('ui_main.reports_listed'));?>
<table class="table-list">
<thead>
<tr>
<th scope="col" class="title"><?php echo Kohana::lang('ui_main.title'); ?></th>
<th scope="col" class="location"><?php echo Kohana::lang('ui_main.location'); ?></th>
<th scope="col" class="date"><?php echo Kohana::lang('ui_main.date'); ?></th>
</tr>
</thead>
@rjmackay
rjmackay / upgrade65-66.sql
Created August 8, 2012 05:36
upgrade65-66.sql
ALTER TABLE `settings` ADD `allow_alerts` tinyint(4) NOT NULL DEFAULT '0';
UPDATE `settings` SET `db_version` = '66' WHERE `id`=1 LIMIT 1;
@rjmackay
rjmackay / gdk-pixbuf-2.26.2.og
Created August 20, 2012 05:33
Output from brew install -v gdk-pixbuf
==> Downloading http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.26/gdk-pixbuf-2.26.2.tar.xz
Already downloaded: /Users/robbie/Library/Caches/Homebrew/gdk-pixbuf-2.26.2.tar.xz
xz -dc "/Users/robbie/Library/Caches/Homebrew/gdk-pixbuf-2.26.2.tar.xz" | /usr/bin/tar xf -
==> ./configure --disable-dependency-tracking --disable-maintainer-mode --enable-debug=no --prefix=/usr/local/Cellar/gdk-pixbuf/2.26.2 --with-libjasper --enable-introspection=no --disable-Bsymbolic --without-gdiplus
./configure --disable-dependency-tracking --disable-maintainer-mode --enable-debug=no --prefix=/usr/local/Cellar/gdk-pixbuf/2.26.2 --with-libjasper --enable-introspection=no --disable-Bsymbolic --without-gdiplus
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
@rjmackay
rjmackay / gist:3521794
Created August 30, 2012 02:26
Ushahidi Reports API request
POST /api?task=report HTTP/1.1
Host: ushahidi.robbiemackay.com
Content-Length: 1177
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
Authorization: Basic cm9iYmllQHVzaGFoaWRpLmNvbTpFdjQ5WEpaTGRzeDBKNTg=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.82 Safari/537.1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBvVUFzEtkUIBzPxE
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
@rjmackay
rjmackay / Request
Created September 3, 2012 22:44
HTTP Response/Request when registering for crdmp3
POST /v1/session/register/ HTTP/1.1
Host: api.crdmp3.com
Content-Length: 94
Origin: http://crdmp3.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://crdmp3.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
@rjmackay
rjmackay / ushahidi_cron
Created September 5, 2012 01:31
Ushahidi Cron runner
#!/bin/bash
# Ushahidi cron script
if [ $# -lt 2 ] ; then
echo "Usage: ushahidi_cron [docroot] [baseurl]"
exit 1
fi
DOCROOT=$1
BASEURL=$2
LOCK_ID=`echo $BASEURL | sed -r -e "s#http[s]{0,1}://##g"`