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
| some_variable = begin | |
| if some_condition? | |
| some_value | |
| else | |
| another_value | |
| 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
| some_variable = if some_condition? | |
| some_value | |
| else | |
| another_value | |
| 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
| development: &global_settings | |
| database: textual_development | |
| host: 127.0.0.1 | |
| port: 27017 | |
| test: | |
| database: textual_test | |
| <<: *global_settings | |
| production: |
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
| // DOM Builder plugin for jQuery | |
| // (c) Dan Webb ([email protected]) | |
| // | |
| // $.build(function() { | |
| // | |
| // div({ 'class': 'module' }, | |
| // h1('A list of stuff'), | |
| // ul( | |
| // li('item 1'), | |
| // li('item 2'), |
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
| it "should time how long it takes to find a number in a set of 100" do | |
| # when uniq! is executed the number of items in the array is roughly halved, so I need to double the seed | |
| seed = [] | |
| (1..200).each { |num| seed << rand(num)} | |
| seed.uniq!.sort! | |
| index_found = search(81, seed) | |
| x.report("elight's:") { bchop(81, seed).should == index_found} | |
| end | |
| #linear search function to compare against |
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 transform_hash(original, options={}, &block) | |
| original.inject({}){|result, (key,value)| | |
| value = if (options[:deep] && Hash === value) | |
| transform_hash(value, options, &block) | |
| else | |
| value | |
| end | |
| block.call(result,key,value) | |
| result | |
| } |
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 BinarySearch | |
| attr_accessor :index_tracker, :times_split | |
| def initialize | |
| @index_tracker= @times_split = 0 | |
| end | |
| def search(search_for, list) | |
| return -1 if list.size == 0 || (list.size == 1 && search_for != list[0]) | |
| #location_of_number = list.index(search_for) | |
| #if location_of_number != nil |
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 Array | |
| def map_e(elz, &block) | |
| results = [] | |
| if length > 0 | |
| each do |o| | |
| block.call(o) | |
| end | |
| else | |
| elz.call | |
| 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
| require 'open-uri' | |
| # url dsl -- the ultimate url dsl! | |
| # | |
| # You just can't beat this: | |
| # | |
| # $ irb -r url_dsl | |
| # >> include URLDSL | |
| # => Object | |
| # >> http://github.com/defunkt.json |
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
| require 'open-uri' | |
| # url dsl -- the ultimate url dsl! | |
| # | |
| # You just can't beat this: | |
| # | |
| # $ irb -r url_dsl | |
| # >> include URLDSL | |
| # => Object | |
| # >> http://github.com/defunkt.json |