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 'atomic' | |
atomic1 = Atomic.new([ -1, 0 ]) | |
atomic2 = Atomic.new(0) | |
array = [] | |
1000.times do |idx| |
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 ObjectDiagnostics | |
extend self | |
def display(method, options = {}) | |
res = format(method, options) | |
res.each { |l| puts l } | |
end | |
def format(method, options = {}) |
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 KestrelQueueMonitor < Scout::Plugin | |
OPTIONS=<<-EOS | |
host: | |
label: Host | |
notes: Kestrel host | |
default: localhost | |
port: | |
label: Port | |
notes: Kestrel admin HTTP port | |
default: 2223 |
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
# | |
# by Eric Lindvall <[email protected]> | |
# | |
class LruGenerationalHash | |
attr_reader :max_size | |
def initialize(max_size, generations = 2) | |
@generations = generations.times.collect { Hash.new } | |
@max_size = max_size |
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
# | |
# Eric Lindvall <[email protected]> | |
# | |
# Update the process name for the process you're running in. | |
# | |
# This will allow top, lsof, and killall to see the process as the | |
# name you specify. | |
# | |
# Just use: | |
# |
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
::Kestrel::Client.class_eval do | |
add_method_tracer :get, 'Kestrel/get' | |
add_method_tracer :set, 'Kestrel/set' | |
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/perl -w | |
# | |
# take a 1 second average of bandwidth | |
# eric lindvall <[email protected]> | |
# | |
use strict; | |
$| = 1; |
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
$ sudo gem install memcached -v 1.3.4 | |
Building native extensions. This could take a while... | |
ERROR: Error installing memcached: | |
ERROR: Failed to build gem native extension. | |
/usr/bin/ruby extconf.rb | |
Touching aclocal.m4 in libmemcached. | |
touch -r libmemcached-0.32/m4/visibility.m4 libmemcached-0.32/configure.ac libmemcached-0.32/m4/pandora_have_sasl.m4 | |
Configuring libmemcached. | |
env CFLAGS='-fPIC -g -O2 -g -O2 ' LDFLAGS='-fPIC -L. -rdynamic -Wl,-export-dynamic -L. -rdynamic -Wl,-export-dynamic -L/usr/lib' ./configure --prefix=/usr/lib/ruby/gems/1.8/gems/memcached-1.3.4/ext --without-memcached --disable-shared --disable-utils --disable-dependency-tracking CC="gcc" 2>&1 |
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
$ sudo gem install memcached -v 1.3.4 | |
Fetching: memcached-1.3.4.gem (100%) | |
Building native extensions. This could take a while... | |
ERROR: Error installing memcached: | |
ERROR: Failed to build gem native extension. | |
/usr/bin/ruby extconf.rb | |
Touching aclocal.m4 in libmemcached. | |
touch -r libmemcached-0.32/m4/visibility.m4 libmemcached-0.32/configure.ac libmemcached-0.32/m4/pandora_have_sasl.m4 | |
Configuring libmemcached. |
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
irb(main):036:0> Encoding.default_external | |
=> #<Encoding:UTF-8> | |
irb(main):037:0> data | |
=> "one two three 32\xC2\xB0\n\xEE\x80\x8E\xEE\x80\x97\xEE\x91\x81\xEE\x81\x94\n\xFF" | |
irb(main):038:0> data.encoding | |
=> #<Encoding:ASCII-8BIT> | |
irb(main):039:0> data.valid_encoding? | |
=> true | |
irb(main):040:0> encoded_data = data.encode('utf-8', :invalid => :replace, :undef => :replace) | |
=> "one two three 32��\n������������\n�" |