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
Xzibit = Object clone do( | |
dawg = method(what, | |
"yo dawg" print. | |
what print. | |
"clone" print. | |
self | |
). | |
so_you_can = method( | |
"so you can print" print. |
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 'rubygems' | |
require 'eventmachine' | |
require 'socket' | |
module RPCServer | |
include EM::P::ObjectProtocol | |
def post_init | |
@obj = Hash.new | |
end | |
def receive_object method |
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 "benchmark" | |
open('gdb-script', 'w') do |f| | |
f.puts <<-EOS | |
p ((unsigned int)rb_gc_stack_start - (unsigned int)$esp) | |
detach | |
quit | |
EOS |
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
# Playing with it in irb: | |
>> (class << Widget; self; end).ancestors | |
=> [BazWrapper, BarWrapper, FooWrapper, Class, Module, Object, Kernel] | |
>> widget = Widget.new | |
=> #<Widget:0x11771f8> | |
>> (class << widget; self; end).ancestors | |
=> [BazWrapper::WrappingB, BazWrapper::WrappingA, BarWrapper::Wrapping, FooWrapper::Wrapping, |
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
APTGET = "apt-get install -qqy" | |
RUBY19 = "ruby-1.9.1-p129" | |
SRC = "/usr/local/src" | |
WGET = "wget -q" | |
namespace :ruby do | |
desc 'download and compile Ruby 1.9' | |
task :install_19 do | |
deps = %w'zlib1g-dev libopenssl-ruby1.9' |
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
# Monkey-patch for Passenger to use the EventMachine reactor. | |
# This allows the use of EM timers, EM.system/popen, and other async libraries (amqp, em-http-request, etc) inside a Rails process. | |
# This requires EM.watch which was added to EM's git repo recently. Build an EM gem first: | |
# git clone git://github.com/eventmachine/eventmachine | |
# cd eventmachine | |
# gem build eventmachine.gemspec | |
# sudo gem install eventmachine-0.12.9.gem | |
# Please do not use this in production =) |
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
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
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
Rails CMS alternatives | |
====================== | |
Note: project activity was checked on 11/26/09. | |
Active projects: | |
--------------- | |
adva-cms | |
repo: http://github.com/svenfuchs/adva_cms/ | |
site: http://adva-cms.org/ | |
Last update: 11/24/09 |
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
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) or do 'rvm reload' | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.1 | |
# Switch to 1.9.1 and gemset rails3, create if it doesn't exist. | |
∴ rvm --create use 1.9.1@rails3 |
OlderNewer