January 14

Merbivore and Merbivore Soft

I just posted two of my favorite, everyday themes to the TextMate Themes Gallery

These colors are based on the old Merbivore wiki site.

I’ve got an emacs color theme too on my github, get it here: color-theme-merbivore, that one is more a work in progress.

December 31

meta key xmodmap ubuntu w/ a mac keyboard fix

I like using the apple Command key as both Alt and Meta in ubuntu. This makes switching windows feel the same as it does in OS X and makes the Command key act as the Meta key in Emacs.

The current “Layout Options” dialog in the Keyboard Preferences is a nice GUI to xmodmap, unfortunately, when you remap Alt to the Command key, Emacs picks it up as the Super key, which is a huge bummer.

All I had to do in the end is create a ~/.Xmodmap file and use this configuration:

! set the proper order for keys mapped to the apple command key
clear mod1
add mod1 = Meta_L Super_L Alt_L

All fixed!

December 29

emacs-rails-kit

Inspiration

After watching the Meet Emacs screencast, I’ve been giving emacs another whirl. I’m a new-school programmer, ruby being the first language that I’ve actually programmed for a living. So TextMate has been pretty much all I’ve known.

emacs-rails-kit

I’ve started building an emacs configuration, that should be general enough for the uses of most ruby/rails programmers. The configuration is based primarily on technomancy’s emacs-starter-kit, I’m trying to keep it as stripped down as possible though. It can be found on github: emacs-rails-kit

It should be enough so that the ruby/rails programmer can be up and running in just a few minutes. Note, it is currently a work in development, but it IS certainly usable in it’s current state. I am using every day at work, and it’s been great. Have fun.

December 15

Setting Font in Carbon Emacs

Within emacs:

M-x mac-font-panel-mode

Choose your desired font

M-x describe-font

Copy the X font string

Then add a line to your emacs config

(set-face-font 'default "-apple-bitstream vera sans mono-medium-r-normal--14-0-72-72-m-0-iso10646-1")

December 9

Installing geoip-ruby on Leopard

Using GeoIP libraries in Ruby is easy….

curl -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.5.tar.gz
tar xvzf GeoIP-1.4.5.tar.gz
cd GeoIP-1.4.5/
./configure --prefix=/usr/local
make
sudo make install
sudo gem i geoip

curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

Then you can just do something like this in your application:

require 'rubygems'
require 'geoip'

g = GeoIP.new(PATH_TO + "/GeoLiteCity.dat")
g.city("google.com")
=> ["google.com", "209.85.171.100", "US", "USA", "United States", "NA", "CA", "Mountain View", "94043", 37.4192, -122.0574, 807, 650]

Easy

November 25

November 20

Using paperclip with ImageMagick on Leopard

Thoughtbot’s paperclip plugin does not need ImageMagick unless you want to start resizing and cropping image attachments.

After installing ImageMagick on leopard, I had to add this initializer to config/initializers in order for paperclip to find my ImageMagick binaries.

# config/initializers/paperclip.rb
Paperclip.options[:image_magick_path] = "/usr/local/bin"

After that, it worked fine.

Installing Ultraviolet Gem

Ultraviolet gem needs the oniguruma library installed.

In Leopard:

$ curl -O http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.8.0.tar.gz
$ tar xvzf onig-5.8.0.tar.gz
$ cd onig-5.8.0/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

Easy, you can then install the ultraviolet gem the normal way:

$ sudo gem i ultraviolet

In Ubuntu:

$ sudo apt-get install libonig2 libonig-dev
$ sudo gem i ultraviolet

November 18

acts_as_state_machine (AASM) and factory_girl

I was having trouble with initial states and factories on a recent project. I wanted to set the state of a factory object, but no matter what, it would be overwritten immediately.

The easiest solution I found is stubbing out set_initial_state on whatever model is carrying the state.

For example, if Order had state. In our order test:

require 'mocha'
class OrderTest < ActiveSupport::TestCase
  def setup
    Order.any_instance.stubs(:set_initial_state)
    @order = Factory(:order, :state => "other_state")
  end

  ...
end

Now, when you create your factory, the state will be set to whatever you pass it.

[Flash 9 is required to listen to audio.]

Beethoven - Piano Sonata No 8, Op 13