tested on cygwin. runs smoothly..

original article :http://blog.hungrymachine.com/2007/10/31/super-fast-ip-to-lat-lng-in-rails-part-2
wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz tar -zxvf GeoIP.tar.gz cd GeoIP ./configure && make && sudo make install  wget http://rubyforge.org/frs/download.php/27077/geoip_city-0.1.gem sudo gem install geoip_city-0.1.gem wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoLiteCity.dat.gz sudo mkdir /usr/local/share/GeoIP sudo mv GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
Then the ruby part:
>> require 'geoip_city' >> g = GeoIPCity::Database.new('/usr/local/share/GeoIP/GeoLiteCity.dat') >> res = g.look_up('') >> puts "lat: #{res[:latitude]} lng: #{res[:longitude]}" lat: 38.0 lng: -97.0


cygwin, Rails2, OpenID 2

Hi, I've been googling about a week to solve a ruby-openid problem. And found a working example on Rama McIntosh's blog. http://myutil.com/2007/12/29/openid-2-0-2-with-rails-2-0-2

At first, I thought rails Ticket #10604 patch worked. But it was more complicated than that. Since Rails, ruby-openid, and open_id_authentication plugin versions were not consistent. And Rama McIntosh went through all. You can find Dr. Nick’s example application fully ported to rails 2.0.2.
Here is my development environment. 
LG LW25 advanced laptop IntelCore2 T5600, Mem 2G
XP Pro version2002 SP2
Cygwin + CygPutty 
Ruby ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-cygwin]
Rails 2.0.2
ruby-openid (2.0.3)
rake (0.8.1)
mongrel (1.1.3)
mongrel_cluster (1.0.5)
ruby-yadis (0.3.4)
app db : sqlite3
Besides his README, some extra typing was needed to run the app.
1. svn co http://drnicwilliams.com/svn/openid/demos/apps/openidauth_multiopenid/trunk openidauth_multiopenid
2. Do not erase some svn directories because he made some rake tasks related with svn.
3. rake freeze TWICE!
4. mkdir log
5. require_gem => gem
6 rake db:create
7. gem install mocha
8. rake test
9. config/environment.rb
  config.action_controller.session = { :session_key => "_openidauth_multiopenid_session", :secret => "mocramagic" }
  Replace to other {key, secret} like this,
    config.action_controller.session = {
    :session_key => '_foo_session',
    :secret      => '4747ba80asdfqwertwertwee5y4365345ertf gadrtvrwebterwvd653b65tyt93c45cb53242eb43'
10. mongrel_rails start!!



How I deployed to my slice. 
1. Peepcode tutorials 
capistrano and git screencast helped me. 

He really help me out. Any one who's struggling with capistrano & git, I higly recommand his tutorial. I was able to deploy my app via Cygwin.


1. In environment.rb, uncomment 
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION

2. deploy.rb
set :mongrel_servers, 3
set :mongrel_port, xxxx
set :rails_env, 'production'

3. /u/apps/appname/current/config/mongrel_cluster.rb
user: deploy
group: deploy
log_file: log/mongrel.log
cwd: /u/apps/appname/current
port: xxxx
environment: production
pid_file: tmp/pids/mongrel.pid
servers: 3

4. cap deploy:migrate RAILS_ENV=production


grep mongrel pid

 ps -ef | grep mongrel

kill -9 xxx


ps aux | grep [m]ongrel

ps aux | grep [m]ongrel | awk '{ print $2 }' | xargs kill -9


ActiveRecord::StatementInvalid (Could not find table '

ActiveRecord::Base.allow_concurrency = true
It's just amazing that the bug is still there...


cygwin ssh.

If you're using capistrano or webistrano and developing on cygwin environment, you better set server's ssh port to 22. Capistrano does not change it's port number when cap deploy:cold. I googled this problem for 3 days. And this is what I got so far.

edit .git/hooks/pre-commit and comment out the following lines:
if (/\s$/) {
bad_line("trailing whitespace", $_);

below article was written by stevie, at capistrano : google groups.

A better Cygwin package manager: 
1. run setup.exe again, but this time use the GUI and install only 
wget (if you're installing Cygwin on a bunch of machines, it would 
probably be easier to install wget on one machine and then copy over 
then necessary files for wget on the others so you're not having to 
fire up the GUI on each machine) 
2. get Stephen Jungels' apt-cyg and copy it into /bin:  wget 
3. Now you can install any cygwin package with a "apt-cyg install 
".  *MUCH* easier than using that horrible GUI. 
one cent tips
1. Can't see the welcome page?
sudo chown -R www-data:www-data /var/www/rails/learnkorean.kr/current

2. If you cannot deploy production mode, try this
%> RAILS_ENV=production rake db:migrate
%> set RAILS_ENV=production
%> rake db:migrate


Gusty, Nginx, Rails and Mongrel_cluster howto

Here are the articles where I learned proper way to do this.

sudo cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/mongrel_cluster

Next, add a path statement to mongrel_cluster file just above the CONF_DIR variable:
sudo vi /etc/init.d/mongrel_cluster

USER=mongrel to USER=www-data

sudo chmod +x /etc/init.d/mongrel_cluster
sudo update-rc.d mongrel_cluster defaults

In our rails app directory we need to create our mongrel config and then symlink it to where our mongrel config directory located at /etc/mongrel_cluster.

nano config/mongrel_cluster.yml

cwd: /var/www/rails/coredrill
log_file: log/mongrel.log
port: 8000
environment: production
group: www-data
user: mongrel
pid_file: tmp/pids/mongrel.pid
servers: 3

ln -s /var/www/rails/coredrill/config/mongrel_cluster.yaml /etc/mongrel_cluster/coredrill.yaml

Starting nginx: 2008/01/15 23:17:19 [warn] 3238#0: conflicting server
name "coredrill.wowdns.com" on, ignored
You have to add this to your default vhost:

server_name _ *;
listen 8080 default;

Finally, check your vhost config.
 listen; => listen 8080;
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default

mongrel_rails start -d -e production -p 8000 -P log/mongrel8000.pid 
mongrel_rails start -d -e production -p 8001 -P log/mongrel8001.pid 
mongrel_rails cluster::start 
mongrel_cluster_ctl status


another logo

Core Drill

Well, I'm developing a site with my friend. My rails stack is on Xen(slicehost).
  • Ubuntu 7.1.0 Gusty
  • Mogrel_cluster
  • Capistrano
  • Rails2.0.2


one cent tip.

Fount this from google groups

 I installed mini magick correctly and 
thumbnails are still not generated.

You need to have a 'parent_id' column in your photos table.  This one 
had me scratching my head for a few hours too until I stumbled across 
this requirement of the plugin. 

attachment_fu on Windows

Code :   fold - unfold
  1.       def uploaded_data=(file_data)
  2.         return nil if file_data.nil? || file_data.size == 0
  3.         self.size = file_data.size
  4.         self.content_type = file_data.content_type
  5.         self.filename     = file_data.original_filename if respond_to?(:filename)
  6.         if file_data.is_a?(StringIO)
  7.           file_data.rewind
  8.           self.temp_data = file_data.read
  9.         else
  10.           self.temp_path = file_data.path
  11.         end
  12.       end
and added conditionals for the size

Code :   fold - unfold
  1.       def set_size_from_temp_path
  2.           self.size = File.size(temp_path) if save_attachment? && (self.size == 0 || self.size.nil?)
  3.       end

Posted by Adam (Guest) 
on 10.04.2007 01:34
To get things working with S3 and windows, I changed:        def temp_data         if save_attachment?           f = File.new( temp_path )           f.binmode           return f.read         else           return nil         end       end (before, the method body was save_attachment? ? File.read( temp_path ) :  nil  ) 


Rails2.0 and heroku the awesome rails app hosting

Check it out. It's free and looks cool. I was frustrated by googling free rails hosting all day. Of course there're many hosting sites with shining options. But for testing, it's too expensive. Anyway I found the heroku.com. With Rails2.0 and Amazon S3, this site will dominate all the other hosting sites. Why? because they'll support Gems & Plugins Manager which made me annoying.

There're also some screencasts.

So, for now you'd better freeze your gems by using Dr Nic's Gems on Rails.

To install the plugin:

> gem install gemsonrails > cd rails-app-folder > gemsonrails 


rake gems:freeze   GEM=gem_to_freeze rake gems:link     GEM=gem_to_link rake gems:unfreeze GEM=gem_to_unfreeze_or_unlink
gem install gemsonrails cd app-folder gemsonrails rake gems:freeze GEM=ruby-net-ldap

(Though freezed gem does not work properly now)