This file contains 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
responses = | |
ExceptionalSynchrony::ParallelSync.parallel(EventMachine) do |parallel| | |
messages.each do |message| | |
parallel.add { message.send } | |
end | |
end | |
responses.each { ... } |
This file contains 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
queue = LimitedWorkQueue(EventMachine, 2) | |
messages.each do |message| | |
queue.add do | |
message.send # no more than 2 of these will run at the same time | |
end | |
end |
This file contains 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' | |
#require 'rubygems/user_interaction' # Required with some older RubyGems | |
require 'isolate/now' | |
require 'eventmachine' | |
require 'em-websocket' | |
require 'em-http' | |
require 'nokogiri' | |
require 'json' | |
require 'pp' |
This file contains 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
# -*- immutable: string -*- | |
require 'benchmark' | |
class Request | |
def initialize(first, last, city, state, country) | |
@hash = | |
{ | |
'first' => first, | |
'last' => last, |
This file contains 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
Without magic comment: 3.93 seconds | |
With magic comment: 1.93 seconds | |
2X faster! |
This file contains 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
build_numbers = [4036, 4037, 4041, 4044, 4045, 4048] | |
build_stats = build_numbers.map { |i| YAML.load_file("../shared/builds/#{i}/test_stats.yml") } | |
failing = build_stats.map do |run| | |
run.reduce([]) do |a, t| | |
t.last.each { |test_case, attrs| a << [t.first, test_case] if attrs.is_a?(Hash) && attrs['last_result'] != 'success' } | |
a | |
end | |
end | |
all_failing = failing.inject(&:|).sort | |
sometimes_failing = all_failing - failing.inject(&:&) |
This file contains 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 Math | |
def self.min *args | |
args.min | |
end | |
def self.max *args | |
args.max | |
end | |
end |
This file contains 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 Elevation | |
attr_reader :elevations | |
def initialize(elevations) | |
@elevations = elevations | |
highest = 0 | |
@highest_lefts = @elevations.map { |elevation| | |
highest = Math.max(highest, elevation) | |
} |
This file contains 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 RRMonitoring | |
class Statistic | |
STATS_HOST = "stats.ringrevenue.net" | |
STATS_PORT = 8125 | |
def timing(name, &blk) | |
start = Time.now | |
yield | |
finish = Time.now |
This file contains 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 User < ActiveRecord::Base | |
fields do | |
first_name :string, :ruby_default => 'First' | |
last_name :string :ruby_default => 'Last', :null => false, :default => '' | |
name_addr :string, :ruby_default => lambda { "#{full_name} <#{email}>" } | |
email :string :ruby_default => lambda { organization.default_email } | |
level :enum, :limit => [:Basic, :Admin, :Super], :default => :Basic, :null => false | |
end | |
def full_name |