Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Harrison pezholio

  • Birmingham / London
View GitHub Profile
View gist:6976492
"twix".pluralize
# => "twixes"
@pezholio
pezholio / WAT.rb
Last active Dec 18, 2015
I'm going slightly mad
View WAT.rb
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 Jun 13, 2013
What's wrong with this picure
View this_doesnt_work.js
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 Dec 16, 2015
Dashing Job to show total Soundcloud listens
View Readme.md
@pezholio
pezholio / import.rb
Last active Jan 15, 2020 — 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)
View import.rb
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
require 'find'
@posts = {}
@drafts = {}
View responsive-image-polyfill.php
<?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 Sep 21, 2012
Getting Jsonify templates working in Sinatra / Padrino
View jsonify_padrino.rb
# 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 Aug 29, 2012
Take a screenshot of any tweet using Casper.js
View tweetshot.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 Aug 17, 2012
More Mongomapper Geo problems
View app.rb
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 Jul 25, 2012
Capistrano deploy recipe for Padrino and Passenger with symlinked database.rb and Github hosting
View deploy.rb
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