Skip to content

Instantly share code, notes, and snippets.

View metade's full-sized avatar

Patrick Sinclair metade

View GitHub Profile
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 March 3, 2014 10:48
Local Birthchoice Widget
<!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/
@metade
metade / README.md
Last active December 29, 2015 17:29

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

@metade
metade / fetch_instagram_tag.rb
Created December 6, 2012 16:19
Fetch images from instagram for a particular tag
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 October 25, 2012 16:33
Best Bits listening experience (AKA Radio TV)
<!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 October 25, 2012 13:25
artists_played_by_a_programmes_brand.rb
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"
@metade
metade / prawn.rb
Created May 7, 2012 19:52
coderay-prawn
# encoding: utf-8
module CodeRay
module Encoders
class Prawn < Encoder
NBSP = ' '
register_for :prawn
def text_token text, kind
text.gsub!('<', '&lt;')
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 June 29, 2011 07:39
Takes a source code repository and makes it into a PDF
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 }
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