Skip to content

Instantly share code, notes, and snippets.

View dougal's full-sized avatar

Douglas F Shearer dougal

View GitHub Profile
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@dougal
dougal / gist:4634679
Created January 25, 2013 14:03
Reduce size of vagrant boxes before packaging.
apt-get clean
rm -r "$(gem env gemdir)"/doc/*
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
Type of complaint:
BBC Online
What is your complaint about:
BBC Sport Online
URL:
http://www.bbc.co.uk/sport/olympics/2012/live-video/p00w2rlr
Complaint category:
@dougal
dougal / gist:2827706
Created May 29, 2012 11:04
Apple iPad 16GB Wi-Fi, 9.7in - Black

Apple iPad 16GB Wi-Fi, 9.7in - Black

With original box, charging lead, charger and U.S plug.

U.K plugs are available for only a few pounds. http://tinyurl.com/apple-uk-plug

Front: A few minor scratches, see annotated photographs below.

Back: One small crease running diagonal top-left in the photograph. One small point-dent above the Apple logo. See photographs below.

class ClassificationSet < ActiveRecord::Base
mount_uploader :reference_file, ReferenceFileUploader
validates :reference_file, :presence => { :message => "must have a file selected" }
end
Factory.define :classification_set do |c|
c.images_zip { File.open(Rails.root.join('spec', 'file_fixtures', 'images.zip')) }
c.reference_file { File.open(Rails.root.join('spec', 'file_fixtures', 'reference_file.txt')) }
end
# Controller
def edit
@user = User.find...
@user.birthday = 18.years.ago if @user.birthday.nil?
end
@dougal
dougal / url_validator.rb
Created June 28, 2011 13:03 — forked from kuahyeow/url_validator.rb
URL validator for Rails 3 - kuahyeow
# Require this file, or put this in where Rails will auto load it.
# = Usage
# validates :attribute, :url => true
# Allow nil values
# validates :attribute, :allow_nil => true
# Allow empty values
# validates :attribute, :allow_empty => true
@dougal
dougal / benchmarks.txt
Created May 25, 2011 22:43
Factory Girl vs User.create
phoenix:stats [master*]$ rails runner 'Benchmark.bm {|x| x.report { 1000.times { Factory.create(:user) } } }'
user system total real
5.050000 0.890000 5.940000 ( 7.895676)
phoenix:stats [master*]$ rails runner 'Benchmark.bm {|x| x.report { 1000.times { |i| User.create(:email => "me@example#{i}.com", :name => "bob", :password => "password1") } } }'
user system total real
5.110000 0.920000 6.030000 ( 8.807853)
$('#select_all').change(function(){
$('input[type=checkbox]').attr('checked', $(this).attr('checked') == 'checked')
return false;
})
Some contendors are - based on estimated ‘Apple self-package’ of 11 x 9 x 3 and weight 2.5 lb; with declared customs value of $500. Info taken from respective websites. All costs in $.
1.  FEDEX
1.1  International Priority - 2 days : 88.94
1.2  International Economy - 5/6 days : 85.67
2.  UPS