note to self programming ruby on rails technology tips work

OSX Passenger prefpane tip

I recently undid all my MacPorts and started using Homebrew for some software on my Macs. That meant uninstalling the Apache MacPort and switching back to the default Snow Leopard version of Apache. Everything went relatively smoothly but today a noticed that my Passenger prefpane wasn’t listing all the Rails sites it had previously been managing.

Turns out it was because in my original install of the prefpane I had used the “ports” version of a required ruby file, per instructions, since I was using the MacPort version of Apache. The easy fix is to just reinstall the prefpane. All of my sites now show up in the site listing and I can add the new site I’m currently developing.

git note to self programming tips

how to think of “git diff” using branch names

This post is more of a note to myself to remember how to think of certain git diff commands but it might be useful to other newbie-ish users of git. This is from my own experimentation, since I couldn’t find a good newbie-understandable explanation of this on the Interwebs.

git diff <branch name> – means what would change if we applied the current working HEAD of the branch we are on, including all unstaged/uncommitted changes, to the named branch.

git diff <branch 1> <branch 2> – means what would change if we applied <branch 2> onto <branch 1>

note to self programming ruby on rails technology work

log_buddy and Windows

I recently started playing around with the log_buddy gem for Rails and because my development machine is on windows, the “d” method wasn’t playing nice with some paths.  it didn’t like paths that included the drive letter.

this is a sample of a line that would cause log_buddy to barf.  it just so happens to also be the line that causes the error.  🙂

c:/ruby/lib/ruby/gems/1.8/gems/log_buddy-0.0.5/lib/log_buddy.rb:98:in `read_line'

the original line looked like this…

file, line_number = frame.split(/:/, 2)

the fix is to replace that line with

file, line_number = frame.reverse.split(/:/, 3)[1..2].map(&:reverse).reverse

yeah.  ugly, and maybe could be written better but it works for me.

now if only I could get log_buddy to output good inspections of objects I toss to it… like “current_user”.  I’m prolly using it wrong right now, but this isn’t helpful…

current_user = '#<User:0x47143d8>'

just saying.  🙂

UPDATE: I monkeypatched log_buddy to fix this functionality. I created a “RAILS_ROOT/lib/log_buddy_extensions.rb” file with the following code.

class LogBuddy


  # Return the calling line
  def self.read_line(frame)
    file, line_number = frame.reverse.split(/:/, 3)[1..2].map(&:reverse).reverse
    line_number = line_number.to_i
    lines = File.readlines(file)
    lines[line_number - 1]


and I figured out that the “current_user” line above shouldn’t be …

d { current_user }

it should be

d { current_user.inspect }

that outputs what I want …

current_user.inspect = '#<User id: 1, login: "matte", email: "matte@localhost", crypted_password: "...", salt: "...", created_at: "2007-08-30 18:23:32", updated_at: "2008-07-08 18:57:45", remember_token: "...", remember_token_expires_at: "2008-07-22 18:57:45", name: "...", password_reset_code: nil, company_id: 2, active: true>'

note to self programming technology tips work

XSendFile note

I coulda had a V8Note to everyone using Apache and the XSendFile module. If you’ve included the module and are getting 0-byte files, like I was today, make sure you have the following lines in your VirtualHost config

XSendFile on
XSendFileAllowAbove on

The website needs to know you want to use the module. Duh. 🙂

cool note to self tips wtf?

The # is a ….


Huh. Who’d a thunk it.

note to self technology tips work

Autostarting Mongrel clusters in FreeBSD 6.x on bootup

Update April 2, 2009: This post is REALLY old. Do yourself a favor and install Passenger. I have and it’s a life saver for my Rails sites. No more crashing mongrels, or mongrels that don’t want to restart. Just sites that know they need to spin up if they’re down.

Jeez this has been a confusing day. I’ve been trying to figure out why the mongrel clusters powering my websites weren’t starting after a reboot of my servers. I’m initializing the reboots so don’t worry that my servers are unstable. 🙂 they’re not. They’re well-behaved children.

FreeBSD has the /usr/local/etc/rc.d directory for shell scripts that will autostart services for you. Kinda like the “Startup” directory in windows. Great. So I found a shell script someone had written and sent in this email on the Mongrel-users mailing list. I copied that to the rc.d directory and placed the require mongrel_cluster_enable=”YES” line into /etc/rc.conf.


Nothing. Apache was starting. Mysql was starting. WTF.

note to self work

NTS: Changing the shell for a user in a Verio VPS

If you’re not hosted by Verio then move along. These are not the droids you’re looking for. (there ya go mom. the quote you were thinking of. heh)

NTS: Use “vedituser” when changing the shell for a user in a Verio VPS. You can’t just vi /etc/passwd to make the change. The change won’t resolve. Dunno what it does in the backend with vedituser that vi doesn’t accomplish but I’m sure it’s something that I don’t need to know how to do. 🙂