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
| #http://grosser.it/2011/08/31/splitting-1-big-csv-file-into-multiple-smaller-without-parsing-it/ | |
| require 'rubygems' | |
| require 'rake' | |
| # split giga-csv into n smaller files | |
| def self.split_csv(original, file_count) | |
| header_lines = 1 | |
| lines = `cat #{original} | wc -l`.to_i - header_lines | |
| lines_per_file = (lines / file_count) + header_lines | |
| header = `head -n #{header_lines} #{original}` |
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
| # Turtle shapes | |
| # Not at all necessory, but just to show that you can define attr_accessor from module as well | |
| module AttrLoader | |
| def attr_loader(*attrs) | |
| attr_accessor *attrs | |
| 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
| # Prism shapes - naive implementation | |
| counter = 1 | |
| stars = 5 | |
| (1..20).each do |row| | |
| if counter == stars * 2 - 1 | |
| counter = 1 | |
| else | |
| if counter > stars | |
| puts '*'*(stars * 2 - counter) |
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
| module Goodness | |
| def great? | |
| @language == 'Ruby' | |
| end | |
| def self.included(base) | |
| base.extend ClassMethods | |
| def interesting | |
| 'there are thousands of spoken languages around the world' |
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 2.0 syntax Cheet Sheet by http://ApproachE.com | |
| # defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
| module Player | |
| describe MovieList, "with optional description" do | |
| it "is pending example, so that you can write ones quickly" | |
| it "is already working example that we want to suspend from failing temporarily" do | |
| pending("working on another feature that temporarily breaks this one") |
NewerOlder