Skip to content

Index

Vim Syntax Highlighting for Rails

A couple of days I updated the font settings in terminal.app on my mac. It's now in line with textmate using Anti-Aliased 14 point DejaVu Sans mono.

Terminal Window Settings

I think you'll agree, it's pretty.

Vim Syntax Highlighting

Now I want to get my vim syntax highlighting to mirror that in Textmate. My vim doesn't currently understand rhtml. I also want it to use the same colorscheme (Sunburst) that my Textmate is using.Who will join my quest?

update big response from the lists.

Install rails.vim so it will recognize .rhtml files. It also touts "easy file navigation, enhanced syntax highlighting, and more"

Install vividchalk.vim, a colorscheme like Vibrant Ink for Textmate. Apparently it has a 16 color mode for remote terminal support. I still want to find Sunburst but at least I could always make one based on this.

The Rails Wiki has a page on HowtoUseVimWithRails

Stay tuned!

Deprec Plugins using gem_plugin

I just added automatic plugin loading to deprec2 using Zeds gem_plugin gem. Now, a number of people have been asking if deprec will support other linux distro's (and even other OS's!). While I'm not interested in implementing them myself (until I get sick of Ubuntu) I love freedom so decided to extract all Ubuntu specific functionality into a plugin and allow others to write their own plugins.

You can now write a plugin that will be loaded automatically by deprec2 with no manual intervention or configuration required by the user. Follow the tutorial on the gem_plugin site but here's the core of it:

  setup_gem(name, version) do |spec|
    spec.summary = "The deprec_ubuntu GemPlugin"
    spec.description = spec.summary
    spec.author="Mike Bailey"
    spec.add_dependency('gem_plugin', '>= 0.2.2')
    spec.add_dependency('deprec', '>= 2.0.0')
    spec.files += Dir.glob("resources/**/*")
  end

Make your gem dependent on gem_plugin and deprec. The way this works is clever. When deprec starts, it requires gem_plugin which goes and looks through the other locally installed gems. If it finds any gems that have gem_plugin and deprec as dependencies, it loads their init.rb file.

So installed a third party plugin to support a new distro for deprec be as simple as:

sudo gem install deprec_beos

Note: I'm still hacking on deprec2 - hoping for a preview release this week!

Pretty Code Samples in Presentations

Today is deprec day (well, the start of a deprec long weekend actually!).

I started the day with some procrastination. I decided to learn how to make super awesome eyecandy ruby slides in Keynote. I love presentations that include code samples and want to be able to make mine look good with as little effort as possible.

First I installed a Textmate bundle called Copy as RTF that copies a selection to the clipboard while preserving syntax highlighting and optimizing font size for pasting into Keynote.

Then I found the ultimate pretty font (slides 14 + 15) but can't work out it is. I tried all the fonts on my MacBookPro to no avail. Then it occurred to me that I want a fixed width font to display code. And my Mac has only four of them: Monaco (which is the default for textmate), Courier, Courier new and Andale Mono.

Make Resourceful Slide

So what font have they used?

update - I found the font! It's Sunday night and I decided to have another crack at matching the font. Adobe Reader lists the fonts used under 'Document Properties'. There's a Textmate page listing alternative fonts. Guess what? BitstreamVeraSans and DejaVuSans are listed in both the document properties and the list of free fonts! I installed both and I reckon the winner is DejaVuSans-mono (download).

I got my Apple MacBookPro using this font by copying it to /System/Library/Fonts.

update 2 I had a problem with CopyasRTF. When pasting onto a black background in Keynote, all white text is turned black. I managed to fix this by changing the default color_index to 45 (from 0) as shown below.

unless new_style[:color_index]
  new_style[:color_index] = 45
end

Enable SSH agent forwarding for Capistrano

Having to repeatedly enter passwords is a drag. And enabling password based SSH login to your SVN servers is a security risk. So I'm pretty excited that Chris Andrews implemented SSH agent forwarding into net-ssh-1.1.0.

Update to the latest version of net-ssh with:

$ sudo gem update net-ssh

To enable it, put the following into your ~/.caprc:

ssh_options[:forward_agent] = true

This stopped me getting prompted for a password by my subversion every time I ran 'cap deploy'.

Integrating Wordpress into a Ruby on Rails site

The first question you'll probably ask is why I didn't go with typo or mephisto. While I have to admit I haven't tried them myself, I decided to use WordPress based on the maturity of the software and size of the userbase. I think this is a pragmatic choice for a piece of software I want to use on my site.

WordPress has a nice feature packed management interface. It also supports themes and I found I could customize it to fit in with my site without editing any of the files that come with the main distribution. This means I can automate upgrading of WordPress when future versions (with security fixes) are released.