Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

To claim this, I am signing this object:

<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
//
// CLLocation_GeohashExtensions.m
// geohash
//
// Created by Jonathan Wight on 10/28/10.
// Copyright 2010 toxicsoftware.com. All rights reserved.
//
#import "CLLocation_GeohashExtensions.h"

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

<?php
if($enable_graphite)
{
$fp = @fsockopen('127.0.0.1', 2003, $errno, $errstr, 1);
if($fp)
{
$out = array();
<?php
$tubeLines = array(
'bakerloo' => array (
'short' => 'B',
'long' => 'BAK',
'color' => 'b06010',
'stops' => array(
'BST' => 'Baker Street',
'CHX' => 'Charing Cross',
'ERB' => 'Edgware Road (Bakerloo)',
@sweeney
sweeney / gist:359549
Created April 7, 2010 22:48
Use the function 'TagColour' to create a 6 character hex code for a colour that isn't too bright (ie, shows up against white) for any input string. Or, supply an existing colour name (red, blue, green etc) and get it back as a usable code.
<?php
function TagColour($name){
$colours = array('red', 'blue', 'green', 'black', 'brown', 'cyan', 'gold', 'yellow', 'grey', 'gray', 'indigo', 'lime', 'navy', 'yellow', 'orange');
if(in_array(strtolower($name), $colours)){
return strtolower($name);
}
$hex = substr(md5($name), 1, 6);
$intensity = (HexIntensity($hex) / 255) * 100;
$i=0;
while(($intensity > 70) && ($i<10)){
@sweeney
sweeney / gist:356481
Created April 5, 2010 15:40
A Class Wrapper for various CURL methods from php, super useful
<?
Class Rest {
public $Gets;
public $Posts;
public $Url;
public $return;
public $responseHeader;
public $info;
public $Headers;
@sweeney
sweeney / gist:356470
Created April 5, 2010 15:33
A way to turn your Dopplr trip feed into a php array of place, start and end timestamps, and lat/lon coordinates. Ugly coding, but it works.
<?php
$url = "YOUR_DOPPLR_FEED_URL"; //Available from http://www.dopplr.com/account - "Atom feed of all your trips"
//-------
$old = array('xmlns=', 'gml:', 'georss:', 'gd:'); //super hack for lack of proper namespace support
$new = array('ns=', 'gml-', 'georss-', 'gd-');
$xml = new SimpleXMLElement(str_replace($old, $new, file_get_contents($url)));
<?
//There we go, that's better now
$countries = array();
$countries[1] = array(
'code' => 1,
'name' => "Canada (+1)" );
$countries[2] = array(
'code' => 86,
'name' => "China (+86)" );