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 bisect(suspects, victim) | |
return suspects[0] if suspects.size == 1 | |
pivot = suspects.size / 2 | |
suspects.partition {|file| suspects.index(file) < pivot }.each do |part| | |
command = %[ruby -r test/unit -I ./vendor/gems/dependency_detection-0.0.1.build/lib -r dependency_detection -r./#{part.join(' -r ./')} #{victim}] | |
print command + "\n" | |
if system(command) | |
puts "------ PASSED: #{$?} -------" |
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 AgentListener | |
def initialize(app, options = {}) | |
@app = app | |
end | |
def call(env) | |
if /^\/agent_listener/ =~ ::Rack::Request.new(env).path_info | |
[404, {}, ['']] | |
else | |
@app.call(env) |
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' | |
ENV['RAILS_ENV'] ||= 'development' | |
require_relative 'config/environment' | |
class DeferredQuery | |
def initialize(query) | |
@thread = Thread.new do | |
ActiveRecord::Base.connection_pool.with_connection do |connection| | |
connection.execute(query) |
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
## NewRelic instrumentation for Sequel | |
# | |
# This is based heavily on the DataMapper instrumentation. | |
# See data_mapper.rb for major differences compared to the ActiveRecord instrumentation. | |
# | |
DependencyDetection.defer do | |
depends_on do | |
defined?(::Sequel) | |
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
irb(main):018:0> RUBY_ENGINE | |
=> "jruby" | |
irb(main):019:0> RUBY_VERSION | |
=> "1.9.3" | |
irb(main):020:0> JRUBY_VERSION | |
=> "1.7.0" | |
irb(main):027:0> 'x'.tr('x', '_') # correct | |
=> "_" | |
irb(main):028:0> 'x'.tr('^x', '_') # incorrect | |
=> "_" |
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
digraph AlphaSoup { | |
"@state0" | |
"@state1" | |
"@state2" | |
node[shape=box] | |
"E.report" | |
node[color=green] | |
"A#ones" |
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 'socket' | |
require 'drb/drb' | |
module DRbSocketPair | |
def self.open(uri, config={}) | |
tag = parse_uri(uri) | |
parent_socket, child_socket = @parent.sockets[tag] | |
parent_socket.close unless parent_socket.closed? | |
Child.new(child_socket, config) | |
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
class TimeServer | |
def get_current_time | |
Time.now | |
end | |
end | |
################ | |
URI = 'druby://localhost:8787' |
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 simple(file) | |
histogram = Hash.new.tap{|h| h.default = 0 } | |
File.read(file).each_line do |line| | |
histogram[line.split(',')[1]] += 1 | |
end | |
histogram | |
end | |
def threading(file, thread_count=10) | |
histogram = Hash.new.tap{|h| h.default = 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
#!/usr/bin/env ruby | |
require 'yaml' | |
module Timmy | |
class Step | |
def self.priority | |
@priority | |
end | |
end |
NewerOlder