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
# | |
# Created by Eric Lindvall <[email protected]> | |
# | |
# WHAT: Provides a simple overview of memory allocation occuring during a | |
# require. | |
# | |
# For a longer explanation, see my post at: | |
# | |
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby | |
# |
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
# Oleg Andreev <[email protected]> Oct 16, 2009 | |
# | |
# This demonstrates how to perform a request to the same Rails instance without hitting HTTP server. | |
# Note 1: this does not boot another Rails instance | |
# Note 2: this does not involve HTTP parsing | |
# Note 3: dispatch_unlocked and rack.multithread=true are used to prevent deadlock on a dispatch mutex, | |
# NOT to make inner requests operate concurrently as one may think. | |
# Note 4: inner request is created by merging outer request with some HTTP headers and rack options. | |
# This may probably lead to strange effects, so be aware of it. | |
# Perhaps, we shouldn't use outer request at all. I don't know. |
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 ruby 1.8.x, what is the functional difference between rb_thread_schedule and rb_thread_select? | |
rb_thread_schedule() is the guts of the thread scheduler, it traverses | |
over the linked list of threads (several times) to find the next one | |
to switch into. The function is long (250 lines) and messy, and covers | |
all the combinations of thread status (RUNNABLE, TO_KILL, STOPPED, | |
KILLED) and wait state (FD, SELECT, TIME, JOIN, PID). | |
If there are no threads doing i/o or waiting on a timeout, | |
rb_thread_schedule() picks another thread from the list (considering |
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 |
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
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
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
# 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
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
# 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, |