Skip to content

Instantly share code, notes, and snippets.

View pezholio's full-sized avatar

Stuart Harrison pezholio

  • Birmingham / London
View GitHub Profile
@pezholio
pezholio / gist:364477
Created April 13, 2010 10:08
A helper function for UK Postcodes, adapted from the original function I wrote for the Ernest Marples service
<?php
function ernest_marples($postcode) {
$postcode = str_replace(" ", "", $postcode);
$url = "http://www.uk-postcodes.com/postcode/". urlencode($postcode) .".csv"; // Build the URL
$file = file_get_contents($url);
if (strpos($file, "html") === FALSE) { // Some error checking - if the file contains html, then we've been redirected to the homepage and something has gone wrong
<?php
function ernest_marples($postcode) {
$postcode = str_replace(" ", "", $postcode);
$url = "http://www.uk-postcodes.com/postcode/". urlencode($postcode) .".csv"; // Build the URL
$file = file_get_contents($url);
if (strpos($file, "html") === FALSE) { // Some error checking - if the file contains html, then we've been redirected to the homepage and something has gone wrong
@pezholio
pezholio / planningalerts_widget.php
Created April 28, 2010 10:56
Planning Alerts Widget - Provides a widget showing the latest planning applications around a given postcode area. Based on Philip John's Opening Times Widget (http://philipjohn.co.uk/category/plugins/opening-times/)
<?php
/*
Plugin Name: Planning Alerts Widget
Plugin URI: http://www.pezholio.co.uk
Description: Provides a widget showing the latest planning applications around a given postcode area. Based on Philip John's Opening Times Widget (http://philipjohn.co.uk/category/plugins/opening-times/)
Author: Stuart Harrison
Version: 0.11b
Author URI: http://www.pezholio.co.uk
*/
/* This program is free software; you can redistribute it and/or modify
@pezholio
pezholio / councillors.php
Created May 24, 2010 15:52
An example project using Lichfield District Council open data to show a user's councillors and ward
<?php
// Two Custom functions to parse XML from external feeds. The first one is used to return an associative array from an XML document, and the second one gets the data via CURL and returns the array. The rest is up to you!!
function xml2array($contents, $get_attributes=1) {
if(!$contents) return array();
if(!function_exists('xml_parser_create')) {
//print "'xml_parser_create()' function not found!";
return array();
@pezholio
pezholio / ga.php
Created August 11, 2010 15:58
A (slightly hacky) script to return the page title, url and number of pageviews from the Google Analytics API as a tab-separated CSV file. No guarantee that it'll work, but worked for me!
<?php
/* A (slightly hacky) script to return the page title, url and number of pageviews from the Google Analytics API as a tab-separated CSV file. No guarantee that it'll work, but worked for me! */
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"analytics.csv\"");
function xml2array($contents, $get_attributes=1) {
if(!$contents) return array();
if(!function_exists('xml_parser_create')) {
@pezholio
pezholio / fatc.html
Created October 19, 2010 12:03 — forked from tomger/fatc.html
<!DOCTYPE html>
<html><head>
<title>Fork-A-Twitter-Client</title>
<!--
Basic OniApollo/StratifiedJS Twitter Client application scaffold.
See http://fatc.onilabs.com/
THIS FILE IS IN THE PUBLIC DOMAIN.
@pezholio
pezholio / TileLayer.Bing.js
Created October 14, 2011 09:18 — forked from pagameba/TileLayer.Bing.js
Leaflet Bing layer
L.TileLayer.Bing = L.TileLayer.extend({
supportedTypes: ['Road', 'Aerial', 'AerialWithLabels'],
attributionTemplate: '<span style="display:inline-block">' +
'<a target="_blank" href="http://www.bing.com/maps/">' +
'<img src="{logo}" /></a><br><span>{copyrights}' +
'<a style="white-space: nowrap" target="_blank" '+
'href="http://www.microsoft.com/maps/product/terms.html">' +
'Terms of Use</a></span></span>',
@pezholio
pezholio / GAAAAAAAH!
Created December 9, 2011 09:21
GAAAAAAAH!
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/Stuart/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... yes
@pezholio
pezholio / gist:1669948
Created January 24, 2012 12:16
RVM / Passenger weirdness
stuart-harrisons-macbook-pro:~ Stuart$ sudo gem install passenger
Password:
Successfully installed passenger-3.0.11
1 gem installed
Installing ri documentation for passenger-3.0.11...
Installing RDoc documentation for passenger-3.0.11...
stuart-harrisons-macbook-pro:~ Stuart$ sudo passenger-install-apache2-module
/Users/Stuart/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find passenger (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
from /Users/Stuart/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/Stuart/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
/Users/Stuart/.rbenv/versions/1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:314:in `bin_path': can't find gem rails ([">= 0"]) with executable rails (Gem::GemNotFoundException)
from /usr/bin/rails:19:in `<main>'