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
#!/usr/bin/env ruby | |
# Ruby Logger multi-process concurrency test. | |
# In an attempt to answer my own question at: | |
# http://stackoverflow.com/questions/13908745/can-rubys-stdlib-logger-class-safely-handle-writers-from-multiple-proceses | |
# | |
# Every line in each log file should begin with 'W,', and this string should | |
# appear in no other places in each line. To check results: | |
# | |
# grep -l '.W,' *.log |
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
def start_command(queue, pid) | |
"cd #{current_path} && RAILS_ENV=#{rails_env} QUEUE=\"#{queue}\" \ | |
PIDFILE=#{pid} BACKGROUND=yes VERBOSE=1 NEWRELIC_DISPATCHER=resque INTERVAL=#{interval} \ | |
#{fetch(:bundle_cmd, "bundle")} exec rake resque:work" | |
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
#!/usr/bin/env ruby | |
text = "</script></head>\n" | |
outpath = 'text.txt' | |
File.open(outpath, 'w') { |f| f.write(text) } | |
text_read = File.read(outpath) | |
puts "text == text_read => #{(text == text_read).inspect}" | |
puts "text.index('</head>') => #{text.index('</head>')}" |
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
#!/usr/bin/env ruby | |
text = "</</h" | |
outpath = 'text.txt' | |
File.open(outpath, 'w') { |f| f.write(text) } | |
text_read = File.read(outpath) | |
puts "text == text_read => #{(text == text_read).inspect}" | |
puts "text.index('</h') => #{text.index('</h')}" |
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
# Here's the script I'll use to demonstrate - it just loops forever: | |
$ cat test.rb | |
#!/usr/bin/env ruby | |
loop do | |
sleep 1 | |
end | |
# Now, I'll start the script in the background, and redirect stdout and stderr |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# This file is distributed under New Relic's license terms. | |
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details. | |
require 'tempfile' | |
require 'rbconfig' | |
def fail(msg, opts={}) |
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
#!/usr/bin/env ruby | |
require 'logger' | |
logger = Logger.new("/dev/null") | |
logger_thread = Thread.new do | |
loop do | |
logger.debug("hey" * 80) | |
sleep 0.01 |
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
#!/usr/bin/env ruby | |
require 'logger' | |
logger = Logger.new("/dev/null") | |
logger_thread = Thread.new do | |
loop do | |
logger.debug("hey" * 80) | |
sleep 0.01 |
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
#!/usr/bin/env ruby | |
Thread.new do | |
loop do | |
Thread.list.each do |t| | |
puts "Got a nil backtrace for thread #{t}" if t.backtrace.nil? | |
end | |
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
# Redis memory dump tool | |
https://github.com/sripathikrishnan/redis-rdb-tools | |
# Generate dump csv | |
rdb -c memory dump.rdb >dump.csv | |
# Filter out unique IDs from Redis key names | |
time cat dump.csv | ruby -pe '$_.gsub! /:\d+:/, ":"' >keys.csv | |
# ... or in Perl |
OlderNewer