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
| #!/usr/bin/env ruby | |
| unless ARGV.count >= 2 | |
| puts "Please provide two files to perform diff..." | |
| exit | |
| end | |
| def load_file file | |
| arr = File.readlines(file).map(&:chomp).compact | |
| arr.shift if arr.first =~ /^#/ |
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 :db do | |
| namespace :data do | |
| desc "Dump data into sql script file: filename=[target filename]" | |
| task :dump => 'environment' do | |
| environment = (ENV.include?("RAILS_ENV")) ? (ENV["RAILS_ENV"]) : 'development' | |
| ENV["RAILS_ENV"] = RAILS_ENV = environment | |
| database = get_database(environment) | |
| user = database | |
| password = ENV['PASSWORD'] |
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 'ostruct' | |
| data = [] | |
| data << OpenStruct.new(:city => 'London', :qtr => 1, :sales => nil) | |
| data << OpenStruct.new(:city => 'London', :qtr => 1, :sales => 50) | |
| data << OpenStruct.new(:city => 'London', :qtr => 1, :sales => 50) | |
| data << OpenStruct.new(:city => 'London', :qtr => 2, :sales => 200) | |
| data << OpenStruct.new(:city => 'London', :qtr => 3, :sales => 300) | |
| data << OpenStruct.new(:city => 'London', :qtr => 4, :sales => 400) |
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 'benchmark' | |
| class CottonThread | |
| attr_reader :threads, :procs | |
| def initialize | |
| @threads, @procs = [], [] | |
| end | |
| def sow(proc) |
NewerOlder