This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "Converting integers to roman numerals" do | |
| describe "with simple conversions" do | |
| Then { 1.should be_converted_to 'I' } | |
| Then { 5.should be_converted_to 'V' } | |
| Then { 10.should be_converted_to 'X' } | |
| end | |
| describe "with additive conversions" do | |
| Then { 3.should be_converted_to 'III' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe RomanNumeralCalculator do | |
| describe "with simple conversions" do | |
| Then { RomanNumeralCalculator.convert(1).should == 'I' } | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def phone_number | |
| o = [(0..9)].map{|i| i.to_a}.flatten; | |
| (0..9).map{ o[rand(o.length)] }.join | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec::Matchers.define :be_a_ripple_document do | |
| match do |doc| | |
| doc.class.included_modules.include?(Ripple::Document) || | |
| doc.class.included_modules.include?(Ripple::EmbeddedDocument) | |
| end | |
| failure_message_for_should do | |
| "#{actual.class.to_s} should be a Ripple::Document" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var links = value.values[0].metadata.Links; | |
| links.filter(function(element, index, array){ return element[0] == 'tag'}).length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Riak::MapReduce.new(Ripple.client). | |
| add(@bucket_to_filter, | |
| [ | |
| [:tokenize, "-", 1], #Note: 1 based index | |
| [:between, start_time.to_s(:key), end_time.to_s(:key)] | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyModel.find_by_index('$key', '20121001'..'20130117') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def log(string) | |
| string.split(/\n/).each do |line| | |
| puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{line}" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :b2b2dot0 do | |
| namespace :magento do | |
| desc "Imports some stuff from one place to another" | |
| task :import_stuff => :environment do | |
| benchmark = Benchmark.measure do | |
| # The import stuff here | |
| SomeStuff.import do |stuff| | |
| stuff.do_something_more | |
| end | |
| end.real |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FasterCSV | |
| def <<(row) | |
| # make sure headers have been assigned | |
| if header_row? and [Array, String].include? @use_headers.class | |
| parse_headers # won't read data for Array or String | |
| self << @headers if @write_headers | |
| end | |
| # Handle FasterCSV::Row objects and Hashes | |
| row = case row |