Skip to content

Instantly share code, notes, and snippets.

View phiggins's full-sized avatar

pete higgins phiggins

View GitHub Profile
@phiggins
phiggins / gist:724102
Created December 1, 2010 19:55
"gem install activerecord" in windows xp
C:\Documents and Settings\Administrator>ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]
C:\Documents and Settings\Administrator>gem install activerecord
Successfully installed activesupport-3.0.3
Successfully installed builder-2.1.2
Successfully installed i18n-0.5.0
Successfully installed activemodel-3.0.3
Successfully installed arel-2.0.6
Successfully installed tzinfo-0.3.23
diff --git a/lib/em/spawnable.rb b/lib/em/spawnable.rb
index 2314213..ef64adc 100644
--- a/lib/em/spawnable.rb
+++ b/lib/em/spawnable.rb
@@ -45,15 +45,11 @@ module EventMachine
end
alias_method :resume, :notify
alias_method :run, :notify # for formulations like (EM.spawn {xxx}).run
- #attr_accessor :receiver
@phiggins
phiggins / gist:729819
Created December 6, 2010 03:52
eventmachine test speedups
### BEFORE
$ rake
(in /home/phiggins/projects/eventmachine-upstream)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
cp tmp/x86_64-linux/rubyeventmachine/1.9.2/rubyeventmachine.so lib/rubyeventmachine.so
cp tmp/x86_64-linux/fastfilereaderext/1.9.2/fastfilereaderext.so lib/fastfilereaderext.so
@phiggins
phiggins / deferrable_child_process.rb
Created December 6, 2010 16:55
DeferrableChildProcess
require 'eventmachine'
# Code adapted from EM's tests:
# https://github.com/eventmachine/eventmachine/blob/master/tests/test_processes.rb#L43
ls = ""
EM.run {
d = EM::DeferrableChildProcess.open( "ruby -v" )
d.callback {|data_from_child|
ls = data_from_child
@phiggins
phiggins / inactivity_timeout.rb
Created December 6, 2010 17:22
comm_inactivity_timeout
require 'eventmachine'
# Code adapted from here:
# https://github.com/eventmachine/eventmachine/blob/master/tests/test_inactivity_timeout.rb#L36
start, finish = nil
timeout_handler = Module.new do
define_method :unbind do
finish = Time.now
@phiggins
phiggins / pending_connect_timeout.rb
Created December 6, 2010 17:26
pending_connect_timeout
require 'eventmachine'
start, finish = nil
timeout_handler = Module.new do
define_method :unbind do
finish = Time.now
EM.stop
end
end
# running the benchmark as-is
$ ruby benchmarks/excon_vs.rb
[curb (persistent), em-http-request, Excon/home/phiggins/projects/excon/lib/excon/response.rb:12:in `readline': end of file reached (Excon::Errors::SocketError)
from /home/phiggins/projects/excon/lib/excon/response.rb:12:in `parse'
from /home/phiggins/projects/excon/lib/excon/connection.rb:98:in `request'
from (eval):2:in `get'
from benchmarks/excon_vs.rb:94:in `block (3 levels) in <main>'
from /home/phiggins/.rvm/gems/ruby-1.9.2-p0/gems/tach-0.0.7/lib/tach.rb:63:in `call'
require 'eventmachine'
require 'benchmark'
x = 0
t = Benchmark.realtime do
EM.run do
EM.add_timer(1.5) { raise "OMG" }
time = EM.current_time + 0.002
# encoding: utf-8
require 'hmac'
require 'hmac-sha2'
require 'base64'
require 'openssl'
class Sns
class AwsCredentials
attr_reader :access_key, :host
@phiggins
phiggins / gist:760668
Created December 31, 2010 03:05
EM tests not canceling timers
$ TESTOPTS="-v" rake | grep '^Test.*#' | awk '{ print $2 " " $1 }' | sort -n
no configuration section for specified version of Ruby (rbconfig-1.9.2)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
no configuration section for specified version of Ruby (rbconfig-1.9.2)
cp tmp/x86_64-linux/rubyeventmachine/1.9.2/rubyeventmachine.so lib/rubyeventmachine.so
cp tmp/x86_64-linux/fastfilereaderext/1.9.2/fastfilereaderext.so lib/fastfilereaderext.so
0.00 TestAttach#test_attach_pipe:
0.00 TestAttach#test_set_readable:
0.00 TestBasic#test_bubble_errors_from_initialize: