SyntaxHighlighter

Sunday, October 19, 2008

Telecommuting

This is an interesting article on telecommuting from WIRED.

Basically - saves $15,000 on office space, $1200 on gas, most managers think employees are more productive at home. Unlike the office where a typical office worker is interrupted or switches tasks every three minutes.

Personally, I love telecommuting - not only do you save the gas, but also the hour getting ready for work and commuting to and from seems like a waste. I've found that I can get a lot more done at home in a shorter period of time.

There's other benefit - you can get a little house work resolved, too. In fact, doing a little laundry at home even has a meditative quality.

It's a good diversion for those times when you need to think out a solution before you get started.

Thursday, October 16, 2008

Adding Memcached to a Rails 2.1 Application in Mac OSX 10.5

I just couldn't find anything explicit on the web about this, but it turns out to be really easy.

Libevent
Install libevent: http://www.monkey.org/~provos/libevent/

cd to libevent directory
Run: ./configure; sudo make; sudo make install;

Memcached
Install memcache: http://www.danga.com/memcached/download.bml

cd to memcached directory
Run: ./configure; sudo make; sudo make install;

I don't know if all the sudo's are required, but it failed do to permissions without it. I suspect it's just required on the 'make'.

The run memcache:

> memcache

It is started with defaults for the ip and port of 127.0.0.1:11211

In my environment.rb - I added

config.cache_store = :mem_cache_store, 'localhost', '127.0.0.1:11211'

Then - restarted my web app and started using Rails.cache.

To use it, in the controller do something like this:

@list_of_items = Rails.cache.fetch('list_of_items', :expires_in => 60*60 ) { Item.find(:all, :conditions => ['column = ?', @value]) }