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 Capybara::Poltergeist | |
class Client | |
private | |
def redirect_stdout | |
prev = STDOUT.dup | |
prev.autoclose = false | |
$stdout = @write_io | |
STDOUT.reopen(@write_io) | |
prev = STDERR.dup |
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 Hash | |
def to_dotted_hash(recursive_key = '') | |
self.each_with_object({}) do |(k, v), ret| | |
key = recursive_key + k.to_s | |
if v.is_a?(Hash) | |
ret.merge!(v.to_dotted_hash(key + '.')) | |
else | |
ret[key] = v | |
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
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> | |
<s:Header> | |
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action> | |
</s:Header> | |
<s:Body> | |
<s:Fault> | |
<s:Code> | |
<s:Value>s:Sender</s:Value> | |
<s:Subcode> | |
<s:Value>a:DestinationUnreachable</s:Value> |
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
RSpec.configure do |config| | |
# If you're not using ActiveRecord, or you'd prefer not to run each of your | |
# examples within a transaction, remove the following line or assign false | |
# instead of true. | |
config.use_transactional_fixtures = false | |
config.before :suite do | |
DatabaseCleaner.clean_with :truncation | |
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_relative 'lib/memory_usage_monitor' | |
mm = MemoryUsageMonitor.new | |
mm.start | |
sum = 0 | |
items = [] | |
5_000_000.times do |n| | |
sum += n | |
items << n.to_s if rand > 0.8 |
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 'benchmark' | |
class Analyzer | |
def self.print_memory_usage | |
memory_before = `ps -o rss= -p #{Process.pid}`.to_i | |
yield | |
memory_after = `ps -o rss= -p #{Process.pid}`.to_i | |
puts "Memory: #{((memory_after - memory_before) / 1024.0).round(2)} MB" | |
end |
OlderNewer