Skip to content

Instantly share code, notes, and snippets.


Patrick Sinclair metade

View GitHub Profile
View spree.rake
namespace :spree do
task destroy_duplicate_shipments: :environment do
# These are the orders with duplicate shipments
orders = Spree::Order.
select(", spree_orders.number").
group(", spree_orders.number").
having("COUNT( > 1")
orders.each do |order|
metade / index.html
Created Mar 3, 2014
Local Birthchoice Widget
View index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""><head><title>Where to give birth - BabyCentre</title><meta content="Hospital or home birth? Our comprehensive guides will help you make the right decision for you. Find out more. - BabyCentre" name="description"/><meta content="hospital birth, home birth, birth choices, labour and birth" name="keywords"/><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<!-- thirdPartyIncludes -->
<!-- Begin comScore Tag -->
<script>var _comscore=_comscore||[];var bcComscoreAccount='6035600';_comscore.push({c1:"2",c2:bcComscoreAccount});(function(){var s=document.createElement("script"),el=document.getElementsByTagName("script")[0];s.async=true;s.src=(document.location.protocol=="https:"?"https://sb":"http://b")+"";el.parentNode.insertBefore(s,el);})();</script>
<img src="

= Testing embedding the Birth Choice image on a Baby Centre site.

metade / fetch_instagram_tag.rb
Created Dec 6, 2012
Fetch images from instagram for a particular tag
View fetch_instagram_tag.rb
require 'instagram'
require 'pp'
Instagram.configure do |config|
config.client_id = 'your-client-id-goes-here'
config.proxy = ENV['http_proxy'] if ENV['http_proxy']
p Instagram.tag '6musictshirtday'
metade / index.html
Created Oct 25, 2012
Best Bits listening experience (AKA Radio TV)
View index.html
<!DOCTYPE html>
<title>Radio TV</title>
<script src="require.js" type="text/javascript"></script>
<script type="text/javascript">
bbcRequireMap = {
'jquery-1' : '',
'swfobject-2' : '',
'demi-1' : ''
metade / gist:3952531
Created Oct 25, 2012
View gist:3952531
require 'open-uri'
require 'json'
require 'date'
require 'pp'
brand_pids = ['b0100rp6', 'b0072lb2', 'b006tmr6', 'b01mrh21', 'b006wr19']
brand_pids.each do |brand_pid|
now =
url = "{brand_pid}/episodes/#{now.year}/#{now.month}.json"
View prawn.rb
# encoding: utf-8
module CodeRay
module Encoders
class Prawn < Encoder
NBSP = ' '
register_for :prawn
def text_token text, kind
text.gsub!('<', '&lt;')
View nitro-mc.rb
require 'curb'
require 'openssl'
require 'nokogiri'
cert_path = "/Users/sinclp01/.certificates/dev.pem"
certificate =
curb =
curb.cert = cert_path
curb.cert_key = cert_path
metade / code2print.rb
Created Jun 29, 2011
Takes a source code repository and makes it into a PDF
View code2print.rb
require 'prawn'
dir = '../music-example'
files = Dir.glob("#{dir}/*") + Dir.glob("#{dir}/**/*")
pdf = => 'A4')
pdf.font "Courier"
stats = { :files => 0, :lines => 0, :chars => 0 }
View gist:1022439
require 'jsonpath'
require 'pp'
# TODO: is there a cleaner way of doing this?
class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
def post_body(url, body, headers = {})
if remote?(url)
process_remote_request(:post, url, body, headers)