Monday, April 5, 2010

apr_poll timeout while running ab

If you get this error while running ab (ApacheBench) on your mac:

apr_poll: The timeout specified has expired (70007)

It may get fixed with:

sudo sysctl -w net.inet.ip.portrange.first=32768
sudo sysctl -w net.inet.tcp.msl=100

Friday, April 2, 2010

New Ruby gems

Oops! It's been a while since the last time I updated my blog.
I promise I'll try to get back to business and write more often whenever I find some time.

First of all, many months ago I joined Cubox, a new uruguayan startup that works for many US clients including partnership and offshore work with renowned Rails shops. We are continuously growing and we are always happy to add talented developers to our team so if you are interested and are passionate about Ruby, Rails and agile development just email us.

We believe in open source, we use it in all our projects and we also contribute to the community. Here is an update of my latest new gems which were not covered in this blog. I hope you find them useful, click on the links for more info:
  • Preforker: Easily create preforking servers (like Unicorn architecture)
  • Rankable Graph: Calculates the pagerank of medium sized graphs (some millions of nodes).
  • State Pattern: A classical implementation of the state pattern.
  • Active Record State Pattern: State pattern applied to Rails models.
  • Stubborn: Helps finding missing external API stubs in your tests.
  • Google Set: API for Google Sets.
  • Change Watcher: Helps keeping a log of changes. Useful to store scraped info from cron scripts.
So check them out and contribute!

Friday, May 22, 2009

Gem to send mails through Gmail

I made this little gem, gmail_sender that I find useful to log things when I'm running some script in my VPS, I use it for things like this:

require 'rubygems'
require 'gmail_sender'

g = GmailSender.new("gmail_account", "password")
begin
#Some interesting script that returns some interesting results in script_results
g.send("dcadenas@gmail.com", "It worked!", script_results.to_yaml)
rescue => e
g.send("dcadenas@gmail.com", "It didn't work :(", "#{e.message}\n#{e.backtrace}")
raise e
end


So all you need to pass to the send method is an email address, the subject and the email content.


Source code is here and you can install it with sudo gem install dcadenas-gmail_sender (remember to add github to your rubygems sources).

Some useful bash functions

I use this bash functions to open vim with splits for each file in which grep or rak find the pattern I'm searching for:

grepvim(){
grep -rl "$1" $2| xargs mvim -o +/"$1"
}

rakvim(){
rak -l "$1" $2| xargs mvim -o +/"$1"
}

Monday, April 20, 2009

Tunneling through SSH

To tunnel through ssh do:
ssh -v -nNT4 -R :4007:localhost:3000 linode


which maps the remote port 4007 to the local port 3000.linode is the host you want to connect to which should be properly configured in your ssh config.

Tuesday, March 10, 2009

Joined ENTP!

Oh I just realized that I never wrote a post about me joining ENTP 4 months ago!!
I'm thrilled about this great chance I'm having working with some of the most talented Ruby developers the world has to offer and I wish that osmosis does its magic and maybe I get at least some tiny part of their mojo. I'm really happy!

RSpec fun

So I was there, running a huge and slow rspec test suite on my Mac and thought "god, I wish I could make it run faster just by tilting my laptop right and make those damn dots fall" so... the most awesome rspec optimization was born :p