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 'rubygems' | |
# Only load paths from the folder 'gems' under the current | |
# dir - e.g. ./gems/ | |
# To freeze use gem install <name> -i gems | |
Gem.clear_paths | |
File dsl | |
Gem.path.unshift (PWD / 'gems').absolute_path | |
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
config.gem "rspec", :lib => false | |
config.gem "rspec-rails", :lib => false | |
config.gem "cucumber", :lib => false | |
config.gem "thoughtbot-factory_girl", :lib => false, :source => "http://gems.github.com" | |
config.gem "faker", :lib => false | |
config.gem "carlosbrando-remarkable", :lib => "remarkable", :source => "http://gems.github.com" | |
config.gem "haml" | |
config.gem "webrat" | |
config.gem "htmlentities" | |
config.gem "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 'benchmark' | |
bigstring = "bigstring" * 100 | |
n = 1000000 | |
Benchmark.bm do |x| | |
x.report("<<") { n.times { bigstring.dup << bigstring << bigstring } } | |
x.report("+") { n.times { bigstring + bigstring + bigstring } } | |
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 'gserver' | |
require 'rubygems' | |
require 'active_record' | |
dbconfig = YAML::load_file(File.dirname(__FILE__) + '/config/database.yml') | |
ActiveRecord::Base.establish_connection(dbconfig['development']) | |
# CREATE TABLE emails (id integer primary key autoincrement, mail_from, rcpt_to, subject, email, user_id integer); | |
# CREATE TABLE users (id integer primary key autoincrement, username, password, email); | |
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
$ time ruby1.8 bits.rb 16 > /dev/null | |
real 0m9.861s | |
user 0m8.977s | |
sys 0m0.872s | |
$ time ruby1.9 bits.rb 16 > /dev/null | |
real 0m1.742s | |
user 0m1.740s |
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
#--------------------------------------------------------------------------- | |
# The first one receives and prints a datagram: | |
#--------------------------------------------------------------------------- | |
require 'rubygems' | |
require 'eventmachine' | |
module A | |
def receive_data a | |
p a |
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 ruby1.9 | |
class Array | |
def powerset | |
# the bit pattern of the numbers from 0...2^(num_elements) can be used to select the elements of the set... | |
(0...2**size).map do |bitmask| | |
select.with_index{ |e, i| bitmask[i] == 1 } | |
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
require 'epitools' | |
class StreamedZip | |
## TODO: Use arrays instead of string munging, then join results. (Wrapper class! (Pathname?)) | |
def initialize(paths) | |
@paths = paths | |
end | |
def stream(opts={}, &block) |
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 'progressbar' | |
class Mechanize | |
class Chain | |
class ResponseReader | |
def handle(ctx, params) | |
params[:response] = @response | |
body = StringIO.new | |
total = 0 |
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
diff --git a/lib/autotest/rails_rspec.rb b/lib/autotest/rails_rspec.rb | |
index 2aa4f5f..df7f4cf 100644 | |
--- a/lib/autotest/rails_rspec.rb | |
+++ b/lib/autotest/rails_rspec.rb | |
@@ -25,6 +25,11 @@ $:.push(*Dir["vendor/rails/*/lib"]) | |
require 'active_support' | |
require 'autotest/rspec' | |
+Autotest.add_hook :died do |at, err| | |
+ puts "Died! Error: #{err.inspect}" |
OlderNewer