Skip to content

Instantly share code, notes, and snippets.

Avatar

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.id, spree_orders.number").
joins(:shipments).
group("spree_orders.id, spree_orders.number").
having("COUNT(spree_shipments.id) > 1")
orders.each do |order|
@metade
metade / index.html
Created Mar 3, 2014
Local Birthchoice Widget
View index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><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")+".scorecardresearch.com/beacon.js";el.parentNode.insertBefore(s,el);})();</script>
<noscript>
<img src="http://b.scorecardresearch.com/
View README.md

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

@metade
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']
end
p Instagram.tag '6musictshirtday'
@metade
metade / index.html
Created Oct 25, 2012
Best Bits listening experience (AKA Radio TV)
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Radio TV</title>
<script src="require.js" type="text/javascript"></script>
<script type="text/javascript">
bbcRequireMap = {
'jquery-1' : 'http://static.bbci.co.uk/frameworks/jquery/0.1.8/sharedmodules/jquery-1.6.2',
'swfobject-2' : 'http://static.bbci.co.uk/frameworks/swfobject/0.1.3/sharedmodules/swfobject-2',
'demi-1' : 'http://static.bbci.co.uk/frameworks/demi/0.9.8/sharedmodules/demi-1'
@metade
metade / gist:3952531
Created Oct 25, 2012
artists_played_by_a_programmes_brand.rb
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 = Time.now
url = "http://www.bbc.co.uk/programmes/#{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 = File.read(cert_path)
curb = Curl::Easy.new
curb.cert = cert_path
curb.cert_key = cert_path
@metade
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 = Prawn::Document.new(:page_size => '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)
else
register_local_request