Just upgraded from Ruby 1.9.1 to 1.9.2 and Passenger (mod_rails) was throwing some crazy errors. The “gem” command was also throwing some errors. Turns out rubygems is trying to read your gems from an old 1.9.1 directory. The fix is to delete everything rubygem-related in /usr/local/lib/ruby/site_ruby/1.9.1/.
Some links for further reading on the issue:
http://www.ruby-forum.com/topic/215219
http://bhuga.net/2010/08/gem-problems-when-upgrading-ruby-192-macports
http://www.ruby-forum.com/topic/213689
The Passenger (mod_rails) error:
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:103: warning: already initialized constant VERSION
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:103: warning: already initialized constant RubyGemsVersion
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:147: warning: already initialized constant MUTEX
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:149: warning: already initialized constant RubyGemsPackageVersion
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:155: warning: already initialized constant WIN_PATTERNS
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1040: warning: already initialized constant MARSHAL_SPEC_DIR
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1045: warning: already initialized constant YAML_SPEC_DIR
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:635:in `path': undefined local variable or method `default_path' for Gem:Module (NameError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:68:in `installed_spec_directories'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:883:in `source_index'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:13:in `initialize'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:841:in `new'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:841:in `block in searcher'
from :10:in `synchronize'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:840:in `searcher'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:479:in `find_files'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:983:in `load_plugins'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1139:in `'
from :29:in `require'
from :29:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.7/lib/phusion_passenger/utils.rb:25:in `'
from :29:in `require'
from :29:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.7/bin/passenger-spawn-server:64:in `rescue in '
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.7/bin/passenger-spawn-server:29:in `'
[ pid=2450 file=ext/apache2/Hooks.cpp:725 time=2010-09-03 23:57:34.206 ]:
Unexpected error in mod_passenger: Cannot spawn application '/home/admin/yapruby.simande.com': The spawn server has exited unexpectedly.
Backtrace:
in 'virtual boost::shared_ptr<:application::session> Passenger::ApplicationPoolServer::Client::get(const Passenger::PoolOptions&)' (ApplicationPoolServer.h:471)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:521)
You get this error message when running “gem” command:
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:68:in `installed_spec_directories': undefined method `path' for Gem:Module (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:883:in `source_index'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:13:in `initialize'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:841:in `new'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:841:in `block in searcher'
from :10:in `synchronize'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:840:in `searcher'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:479:in `find_files'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:983:in `load_plugins'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1139:in `'
from :29:in `require'
from :29:in `require'
from /usr/local/bin/gem:8:in `'
I personally guarantee that this is the best Twitter hash tag regex in the world, until you prove me wrong.
This is my fool-proof methodology:
I tweeted a string with randomly placed hash tags, saw what Twitter did with it, and then tried to match it with a regular expression. Here’s what I got:
/\B#\w*[a-zA-Z]+\w*/


A little word game my friend, Matthew Moore, and I made for An Event Apart competition to create an HTML5/CSS3/JavaScript application under 10K.
http://10k.aneventapart.com/Entry/400

Sometimes you’re on the run and just don’t have time to deal with Google Analytic’s fancy JavaScript charts. This will give you the number of unique IP addresses in a log file:
grep "" mylogfilename.access.log | awk '{print $1}' | sort | uniq | wc -l
This will get you the number of uniques on August 2nd.
grep "2/Aug" mylogfilename.access.log | awk '{print $1}' | sort | uniq | wc -l
My favorite kind of ice cream, taro (from Chinatown Ice Cream Factory), is displayed prominently in this Ally ad:

How to set up monit on Linux
sudo aptitude install monit
sudo nano /etc/monit/monitrc
Make sure to change the default apache location to:
check process apache with pidfile /var/run/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
and here are the additional lines I comment out / add:
set daemon 60
set logfile /var/log/monit.log
set mailserver localhost
set alert sjobs@apple.com
check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host 127.0.0.1 port 3306 protocol mysql for 2 cycles then restart
if 5 restarts within 5 cycles then timeout
Thanks to mattmcman.us for help with this.
Tried to install Rails CKEditor w/ image/file upload today:
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/... is not recognized by the 'identify' command.>
Turns out the default code on Rails CKEditor tells Paperclip to auto-generate a thumbnail image for you, which requires ImageMagick.
:styles => { :content => '575>', :thumb => '100x100' }
Since I don’t need auto-generated thumbnails, nor do I feel like installing an entire library, I just took out that line in the Picture model (picture.rb) and everything worked.


