Friday, June 29, 2007

Camping for an iPhone

Yes, I actually am - I think this is the first tme I have ever camped for anything. Not sure if one can call sitting in line for 3 hours "camping", but is as close as I'll ever come :)

For those nearby - the AT&T store on Needham St in Needham MA, only has abou 40 people in line.

Friday, June 15, 2007

Web crawling with Ruby

Learned a little bit about scRUBYt! today (damn thats hard to type!).

It looks like a pretty cool way to do web crawlers. To use it, you define a "learning" crawler using the scRUBYt! DSL, which combined with the actual site at a specific point in time, creates the real crawler to do the dirty work - essentially, example text gets converted to xpath expressions. The cool thing about this is that when the site changes, one has to do minimal changes to create a new working crawler, not to mention that creating the crawler in the first place is a lot easier.

Custom loggers in rails

I ran into some problems trying to setup a custom logger in rails which I thought I would share to ease someone else's pain. Everything I read said that to setup a custom logger instance, I should set config.logger in my environment.rb, e.g.

environment.rb:

config.logger = MyLogger.new(config.log_path)

However, I just could not get this to have any effect! It turns out that this was because I was starting up my server using script/server using mongrel. Using "script/server webrick", or "mongrel_rails start" worked just fine.

I think this is caused by code in the mongrel.rb file that script/server uses which loads just the logging environment (but not my environment) in order to figure out which log file to tail


railties/lib/server/mongrel.rb:

require 'initializer'
Rails::Initializer.run(:initialize_logger)

Loading the environment here causes the RAILS_DEFAULT_LOGGER constant to get set, and thus when my config finally gets loaded when mongrel itself starts up, the config.logger I set gets ignored as the rails init code does nothing if RAILS_DEFAULT_LOGGER is set:


railties/lib/initializer.rb:

def initialize_logger
# if the environment has explicitly defined a logger, use it
return if defined?(RAILS_DEFAULT_LOGGER)
...
end


The patch on this bug report seems related, but didn't fix my problem.

I'm too much a rails newb to figure out the right way to patch this, hopefully someone with more of a clue will see this blog entry and submit a patch :)

Sunday, June 10, 2007

Life at a Startup (Mobicious)

So I've been working at Mobicious for a week now, and the task list just keeps getting longer :) Not really surprised by this, as it is a startup. Is actually kinda cool to have this much to do, especially when most of it is interesting. I guess that makes me a workaholic. :)

Of course, being mostly a Java dev at the last job, I'm having to do a lot of reading and catchup on Rails. We are using Ruby on Rails at mobicious and I can see no overwhelming reason to change this. Scalability will be a concern eventually, but from all I've read, Rails can scale, just not quite as well as Java yet. This is not surprising given their relative levels of maturity. If that hasn't changed by the time we need it to scale hugely (here's hoping), we'll re-evaluate then. One option will be to switch to java for running rails, but to do so we'll have to come up with alternatives to binary rails plugins like RMagick. For now though, I'm sticking with Rails as it does give us an advantage in development time - though not quite there for me personally yet :)

So far I'm really liking the startup environment, and the people are all really great, the work is interesting, and I'm having fun!