Unicorn Script/Spin

#!/usr/bin/env ruby

UNICORN_RAILS=”/var/www/apps/ruby/bin/unicorn_rails”.freeze
APP_PATH=”/var/www/apps/jjsingh/current/”.freeze

class Runner
class << self

def start
system "#{UNICORN_RAILS} -c #{APP_PATH}/config/unicorn.rb -E production -D"
end

def reload
system "kill -s USR2 #{pid}"
end

def restart
stop
start
end

def graceful_stop
system "kill -s QUIT #{pid}"
end

def stop
system "kill #{pid}"
end

def pid
File.read "#{APP_PATH}/tmp/pids/unicorn.pid"
end

end
end

case ARGV[0]
when "start"
Runner.start
when "reload"
Runner.reload
when "restart"
Runner.restart
when "stop"
Runner.stop
else
STDERR.puts "usage ./script/spin [start|stop|restart]"
exit(1)
end

Enable Tables View Inside The Console

This is very pretty and extremely useful

1. Install the Hirb gem
sudo gem install cldwalker-hirb --source http://gems.github.com

2. Fire up the console and type this
ActiveRecord::Base.logger = Logger.new(STDOUT)

3. Require the file like so
require 'hirb'

4. Enable Views
Hirb::View.enable

Of course you can always put it in a single file and just load it.
Enjoy

Cucumber is my leveler

So I moved into a small studio apartment on the upper east side with an efficiency kitchen,

I was not aware that there wasn’t any drawer under the counter.

Now I asked my self WHERE is the right place for y silverware, I can’t put them on the cabinet on top of the counter cause i would not see it, an i can’t put it under the sink cause that’s where the trash is.

So I said to myself I will build a new drawer by myself.

I went to Home Depot and got the material, cut the wood to size put together the drawer and then was the part I needed to mount the drawer in the rails( Slides) So I thought to myself ” I am very good with mechanic, I studied it for 5 yrs I can do this myself, I don’t need any tools for that, I will make it fit by myself”

3 and a half hours later, all sweating and scratched fighting with the drawer while half of me is lying under the sink like a plumber, I had no sucess, sure it was working, but it wasn’t perfect, there was this annoying gap left on the right side of the drawer

Frustrated I left it and went to sleep for an hour.

I got up, talk on the phone with a friend about non important thing, and then I realized “Hey this should be very simple, I have a leveler, and all I have to do is make sure I take the same measurement from both sides”

I dismounted everything I did, and it took me 15 minutes to measure, level and slide the drawer in smoothly and accurately.

Wow, sometimes we can be like that, too much obsessive compulsive to make our code FIT,yes we are programmers for years, sure we can do that, this should take us only 15 minutes…..

well I learned from that small experience not to be too confident about my abilities, and know my limitations.

This is why I decided I’m gonna use cucumber as my Leveler, and measurement tool so that things will slide into the rails smoothly.

my advice to you my friend, “Know your limitations, and don’t be too confident with your self, you may get too much OCD because of your pride…”

hope you find this somewhat true…

Ami

Welcome to Ruby NYC

my name is Ami Mahloof, and i have been a Ruby Developer for about a year plus

I started my coding with PHP, moved to Adobe SPRY, then to ExtJS and finally to Ruby

I love Ruby more then any other code.

this is my blog for Ruby, and my notes to coding i do.

If you are by new york city, we have a meetup group bi-monthly for everything about Ruby.

http://ruby.meetup.com/131/