Skip to content

Instantly share code, notes, and snippets.

View pezholio's full-sized avatar

Stuart Harrison pezholio

  • Birmingham / London
View GitHub Profile
"twix".pluralize
# => "twixes"
@pezholio
pezholio / WAT.rb
Last active December 18, 2015 12:09
I'm going slightly mad
require 'nokogiri'
require 'open-uri'
uri = "http://data.gov.uk/dataset/water-framework-directive-lake-waterbodies-wfs"
doc = Nokogiri::HTML(open(uri))
doc.search('link[rel=alternate]').each do |e|
if e[:type] == "application/rdf+xml"
puts "rdf should be #{e[:href]}"
@pezholio
pezholio / this_doesnt_work.js
Created June 13, 2013 16:19
What's wrong with this picure
switch(json.rights.dataLicense) {
case "http://opendatacommons.org/licenses/by/":
$('#r_22_answer_id').val(34)
break;
case "http://opendatacommons.org/licenses/odbl/":
$('#r_22_answer_id').val(35)
break;
case "http://opendatacommons.org/licenses/pddl/":
$('#r_22_answer_id').val(36)
break;
@pezholio
pezholio / Readme.md
Last active December 16, 2015 15:59
Dashing Job to show total Soundcloud listens
@pezholio
pezholio / import.rb
Last active January 15, 2020 14:03 — forked from dnagir/import.rb
Regenerate the source of an Octopress blog (if you're an idiot and forgot to commit the source like me)
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
require 'find'
@posts = {}
@drafts = {}
<?php
/*
* Plugin Name: PB Responsive Images
* Plugin URI: http://wordpress.org/extend/plugins/pb-responsive-images/
* Description: Adds support for the proposed responsive image format in post content, and helper functions for theme authors.
* Author: Phenomblue
* Version: 1.3
* Author URI: http://www.phenomblue.com/
*
* -------------------------------------
@pezholio
pezholio / jsonify_padrino.rb
Created September 21, 2012 10:01
Getting Jsonify templates working in Sinatra / Padrino
# Goes in app/helpers/jsonify_padrino.rb
require 'sinatra/base'
require 'jsonify/tilt'
class JsonifySinatra < Sinatra::Base
helpers do
def jsonify(*args) render(:jsonify, *args) end
end
end
@pezholio
pezholio / tweetshot.js
Created August 29, 2012 20:31
Take a screenshot of any tweet using Casper.js
var url = phantom.casperArgs.args[0]
var output = phantom.casperArgs.args[0]
var casper = require('casper').create({
pageSettings : {
userAgent : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11'
}
});
casper.start(url, function() {
@pezholio
pezholio / app.rb
Created August 17, 2012 13:32
More Mongomapper Geo problems
mapit = Mapit.GetPostcode(params[:postcode])
EARTH_RADIUS_M = 3959
query[:latlng] = {'$nearSphere' => [mapit["lat"], mapit["lng"]], '$maxDistance' => Float(params[:within].to_i) / EARTH_RADIUS_M }
applications = Application.where(query)
@applications = applications.paginate({:order => :receiveddate.desc, :per_page=> 10, :page => params[:page]})
@pezholio
pezholio / deploy.rb
Created July 25, 2012 16:58
Capistrano deploy recipe for Padrino and Passenger with symlinked database.rb and Github hosting
set :domain, "licensing.lichfield-001.vm.brightbox.net"
set :application, "licensing"
set :deploy_to, "/home/rails/#{application}"
set :user, "rails"
set :use_sudo, false
ssh_options[:forward_agent] = true
set :scm, :git