Skip to content

Instantly share code, notes, and snippets.

View robwilliams's full-sized avatar

Rob Williams robwilliams

View GitHub Profile
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
# Example:
# def shipping_name
# if different_shipping_method?
# super
# else
# name
# end
# end
def self.delegate_shipping(*attrs)
attrs.each do |attr|
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.prepend_before(:each) do |example|
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start
end
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
fizz = -> i { (i % 3).zero? }
buzz = -> i { (i % 5).zero? }
fizzbuzz = -> i { fizz.(i) && buzz.(i) }
(1..100).each do |i|
puts case i
when fizzbuzz
"FizzBuzz"
when fizz
"Fizz"
class Turnstile
attr_accessor :state
def initialize
@state = :locked
end
def coin
if locked?
$(document).on('focus', '.typeahead', function(){
$(this).attr('autocomplete','off');
});
Dear {salutation},
Thank you very much for your recent order which has been shipped today.
If you chose our next day service you can track your delivery here: {TrackingURL}
This is not a VAT invoice, but one will follow in the post
Order Number {ordernumber}
def as_json(options = {})
super(:only => [:id, :name, :slug, :popular, :updated_at, :created_at], :methods => :full_name_with_category, :include => [ { :families => { :only => [:name, :slug, :popular], :methods => [ :category_name ] } } ])
end