Category: ruby

How I Organize Posts In Jekyll

Since November 2010, I have been running Jekyll to power this blog. Before Jekyll, I was on self-hosted Wordpress, which could explain some of my decisions around how I organize my posts because I didn’t want to break any existing links. You can find some interesting resources on Jekyll that...

Read more...

Capistrano Auth Trick

This past summer, we needed to automate testing of several failure scenarios for VPN-Cubed. Having asked the LazyWeb about any frameworks that could help us and having gotten no response, our dev team had a short chat in the office. We decided that ultimately we were going to have to...

Read more...

Why I Sometimes Prefer Shell To Ruby or Python

Shell was among the first things I got familiar with when I was introduced to Linux. It’s not a typical programming language, primarily due to lack of easy-to-use high-level data structures such as hashes and arrays (anticipating your objection to this - note I said “easy-to-use”). This may explain why...

Read more...

Adjustable Per-URI Backend Capacity in Rabbitbal

I recently pushed a Rabbitbal update to Github - http://github.com/somic/rabbitbal. The biggest enhancement (IMHO) is ability to increase or decrease the number of backend consumers based on any HTTP request headers. In “table” routing mode (see rabbitbal.yml), you can now specify array of tests against which incoming request headers will...

Read more...

RabbitMQ and Rails

A quick note. This blog is getting a lot of google referrals for people looking for “rabbitmq rails”. I just wanted to say that I do not have good up-to-date material on the subject. Instead, check out this thread on ruby-amqp mailing list and consider tmm1-amqp gem for your project....

Read more...

Introducing Rabbitbal

Inspired by Nanite, a very interesting project by Ezra Zygmuntowicz of EngineYard that uses RabbitMQ and eventmachine-based ruby amqp library by Aman Gupta, I sat down and wrote Rabbitbal, a reverse proxy for Rails (as well as other web frameworks, not necessarily limited to Ruby) on top of RabbitMQ. It’s...

Read more...

Forking Supervisor Daemon in Ruby

Here is my implementation of a forking supervisor daemon in ruby.

Read more...

Rails update_attribute vs update_attributes

In Rails, update_attribute method bypasses model validations, while update_attributes and update_attributes! will fail (return false or raise an exception, respectively) if a record you are trying to save is not valid. This means that if at certain point during the project you adjust validations such that some records that used...

Read more...

Selecting "FIELD AS NAME" in ActiveRecord Always Returns String

If I select “field as alt_field_name”, the value will always come out as String, not what the field actually is. >> User.find(:first, :select => :created_at).created_at => Wed Jan 24 00:04:59 UTC 2007 >> User.find(:first, :select => "created_at").created_at => Wed Jan 24 00:04:59 UTC 2007 >> User.find(:first, :select => "created_at as...

Read more...

Ruby + AMQP + RabbitMQ Example

In this post I would like to show how one can exchange messages using AMQP protocol from Ruby, using RabbitMQ as a broker. I posted the original version of this script to rabbitmq-discuss mailing list back in September 2007. Prerequesites: RabbitMQ broker configured, up and running on 127.0.0.1 (localhost) on...

Read more...