Skip to content

Instantly share code, notes, and snippets.

View mperham's full-sized avatar

Mike Perham mperham

View GitHub Profile
# Using RVM and Bundler to test 3rd party gems
# Clone the source
git clone <gem repo> && cd <gem repo>
# will install 1.9.2 if not installed already
rvm use 1.9.2
# Create the gem sandbox
rvm use 1.9.2@<gemname> --create
gem install bundler --pre
@mperham
mperham / gist:558145
Created August 30, 2010 22:23 — forked from zzak/gist:558001
get '/' do
dc = Dalli::Client.new('localhost:11211')
@info = dc.fetch("info-#{userid}-#{repoid}") do
HTTParty.get("#{base_uri}/repos/show/#{userid}/#{repoid}"))
end
@collaborators = dc.fetch("collaborators-#{userid}-#{repoid}") do
HTTParty.get("#{base_uri}/repos/show/#{userid}/#{repoid}/collaborators"))
end
--- a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb
+++ b/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb
@@ -48,7 +48,9 @@ module ActionView
self.erb_trim_mode = '-'
def compile(template)
- src = ::ERB.new("<% __in_erb_template=true %>#{template.source}", nil, erb_trim_mode, '@output_buffer').src
+ location = nil
+ location = "<!-- #{template.filename} -->\n" if !Rails.env.production?
+ src = ::ERB.new("<% __in_erb_template=true %>#{location}#{template.source}", nil, erb_trim_mode, '@output_buffer').src
gcc -dynamic -bundle -o ../../.ext/x86_64-darwin10.5.0/zlib.bundle zlib.o -L. -L../.. -L. -L/usr/local/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -lruby.1.9.1 -lz -lpthread -ldl -lobjc
making ruby
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -L. -L/usr/local/lib -Wl,-u,_objc_msgSend main.o -lruby.1.9.1 -lpthread -ldl -lobjc -o ruby
Generating RDoc documentation
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ./tool/runruby.rb --extout=.ext -- "./bin/rdoc" --no-force-update --all --ri --op ".ext/rdoc" "."
/Users/mike/.rvm/gems/ruby-1.9.2-p0/gems/rdoc-2.5.11/lib/rdoc/rdoc.rb:58: warning: already initialized constant GENERATORS
Parsing sources...
0% [ 1/515] array.c
Before reporting this, could you check that the file you're documenting
compiles cleanly--RDoc is not a full Ruby parser, and gets confused easily if
@mperham
mperham / hello.js
Created March 9, 2011 23:08
Node.js stops responding
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
~> ruby foo.rb
hello!
~> rvm use jruby
Using /Users/mperham/.rvm/gems/jruby-1.6.0
~> jruby -v
jruby 1.6.0 (ruby 1.8.7 patchlevel 330) (2011-03-15 f3b6154) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java]
~> jruby foo.rb
NoMethodError: undefined method `synchronize' for nil:NilClass
timed_pop at foo.rb:5
@mperham
mperham / ex1.rb
Created April 19, 2011 02:43
Simple ping/pong with Actors
require 'actor'
# Execute with Rubinius: rbx ex1.rb
def error_loop(&block)
loop(&block)
rescue Exception => ex
puts ex.message
puts ex.backtrace.join("\n")
end
@mperham
mperham / ex2.rb
Created April 19, 2011 03:07
More complex supervisor with worker pool example
require 'actor'
require 'rubinius_fix'
Ready = Struct.new(:this)
Work = Struct.new(:msg)
processor = Proc.new do |msg|
raise msg.to_s if msg % 7 == 0
print "Doing some hard work for #{msg}, boss!\n"
end
@mperham
mperham / gist:996566
Created May 28, 2011 03:28
jruby and rdoc
> rvm use 1.9.2
Using /Users/mperham/.rvm/gems/ruby-1.9.2-p180
> rdoc --version
rdoc 2.5.8
> rvm use jruby-1.6.2
Using /Users/mperham/.rvm/gems/jruby-1.6.2
> rdoc --version
RDoc V1.0.1 - 20041108
> rake bench
rake aborted!
@mperham
mperham / Profile
Created May 28, 2011 03:58
dalli on rbx-hydra
#
# Appears to show no time spent in IO (>50% of this benchmark should be spent in IO.select)
# and pretty slow core library functions (Hash and String stuff)
#
> rbx -Xprofile -Ilib:test test/benchmark_test.rb
Testing with Rails 3.0.3
Using standard socket IO (rubinius 1.2.4dev (1.8.7 25a8922d yyyy-mm-dd JI) [x86_64-apple-darwin10.7.0])
Loaded suite test/benchmark_test
Started