Tag Archives: tech


If there is one thing I like it is setting up ssh to use my public key so that I don’t have to type a password when login to a server. This wasn’t too hard, but since OSX does not have ssh-copy-id by default I would have to pull up the instructions every time to make sure I remembered the file names and permissions just right.

So last night I made a ruby gem to remember how to do it for me, ssh-keyput

Now all I’s got to do to copy my public key is:

$ ssh-keyput chris@server.com

To install all you need is a simple gem install:

$ gem install csexton-ssh-keyput -s http://gems.github.com

It is nothign bu a gloafied wrapper for a few shell commands, but it is much easier to remember

Programming for fun?

I’ve been working on the cookbook application for the wife and couple interesting things.

I use Dreamhost, and while they rock in alot of ways they won’t let me have any long running processes. I wanted to add full text search to my cookbook (because if you can’t find the recipe you want, what good is a cookbook) and I couldn’t use the likes of Sphinx or Ferret. But if I changed my DB to MySQL (which dreamhost does provide) I can use the built in fulltext search. It is a little hackish, and MySQL specific but it works and is plenty fast for my needs.

I had to do two things:
1) Add a FULLTEXT index to my migration

def self.up

execute 'ALTER TABLE recipes ENGINE = MyISAM'
execute 'CREATE FULLTEXT INDEX ft_idx_recipes ON recipes(title,ingredients,directions)'

def self.down

execute 'ALTER TABLE recipes DROP INDEX ft_idx_recipes'
execute 'ALTER TABLE recipes ENGINE = InnoDB'
drop_table :recipes


2) In my recipes controller in the search action I have the following line

@recipes = Recipe.find_by_sql(“SELECT * FROM recipes WHERE MATCH (title, ingredients, directions) AGAINST (‘#{query.gsub(/’/, ”‘’“)}‘);”)

The gsub bit is to sanitize the sql. Pretty simple really, and if I ever want to replace it all I need to do is modify the controller.

I found out today that the Bort guys added OpenID support to the project. Which would normally involve some obscure svn/patch hijinks to deal with, but thanks to git I can just grab their changes (I did fork my project from theirs to start with).

git branch openid # incase I screw things up
git checkout openid # use the new branch
git pull git://github.com/fudgestudios/bort.git master
# Fix any conflicts and merge back to master

Finally, did everyone know you can put alias in the .gitconfig file? Well, you never told me.

co = checkout
ci = commit
st = status

Instiki 0.13 Installation on Dreamhost with Passenger

Running Instiki on Dreamhost has gotten much easier since they have added Passenger (mod_rails).

Create a new fully hosted domain on dreamhost. Something like wiki.domain.com.

Check the “Ruby on Rails Passenger (mod_rails)” box.
In the Specify your web directory enter “wiki.yourdomain.com/instiki/public”

This will create the wiki.domain.com folder in the user’s home directory. Login to your shell account and do the following:

cd wiki. yourdomain.com
svn checkout svn://rubyforge.org/var/svn/instiki/instiki/trunk/ instiki
cd instiki
rake db:migrate RAILS_ENV=production
Open wiki. yourdomain.com in your browser and set up the wiki.


Building Visual Studio Projects with Rake

We are building a Rails applicaiton that has a C++ client developed under windows, and needed a nice way to script things.  Since the web side of the project was in rails it seemed natural to use rake to build the C++ stuff.  Pretty simple, but in order for the devenv to get loaded we had to load some of the envorment varables up for rake. Once that was done everyting has been easy.

My Rakefile:

Visual Studio 2008 Environment Settings:

ENV[“VSINSTALLDIR”] = ‘C:Program FilesMicrosoft Visual Studio 9.0’
ENV[“VCINSTALLDIR”] = ‘C:Program FilesMicrosoft Visual Studio 9.0VC’
ENV[“DevEnvDir”] = ‘C:Program FilesMicrosoft Visual Studio 9.0Common7IDE’
ENV[“PATH”] = ‘C:Program FilesMicrosoft Visual Studio 9.0Common7IDE;C:Program FilesMicrosoft Visual Studio 9.0VCBIN;C:Program FilesMicrosoft Visual Studio 9.0Common7Tools;C:WINDOWSMicrosoft.NETFrameworkv3.5;C:WINDOWSMicrosoft.NETFrameworkv2.0.50727;C:Program FilesMicrosoft Visual Studio 9.0VCVCPackages;’ + ENV[“PATH”]
ENV[“INCLUDE”] = ‘C:Program FilesMicrosoft Visual Studio 9.0VCATLMFCINCLUDE;C:Program FilesMicrosoft Visual Studio 9.0VCINCLUDE;C:Program Filesboostboost_1_35_0’
ENV[“LIB”] = ‘C:Program FilesMicrosoft Visual Studio 9.0VCATLMFCLIB;C:Program FilesMicrosoft Visual Studio 9.0VCLIB;C:Program Filesboostboost_1_35_0lib’
ENV[“LIBPATH”] = ‘C:WINDOWSMicrosoft.NETFrameworkv3.5;C:WINDOWSMicrosoft.NETFrameworkv2.0.50727;C:Program FilesMicrosoft Visual Studio 9.0VCATLMFCLIB;C:Program FilesMicrosoft Visual Studio 9.0VCLIB’

WiX Environment Settings

WIX_PATH=“”C:/Program Files/Windows Installer XML v3/bin”“
CANDLE= WIX_PATH + “candle”
LIGHT = WIX_PATH + “light”

desc “Build the project in release”
task ‘release’ do
system ‘VCBuild path/to/project.vcproj Release /rebuild /nologo’

task :default => [:release]

Using sqlite as a production DB

I wanted to use sqlite3 as my production DB for a little web app that I am working on.  Wasn’t sure exactly what was going to be needed, but turns out if you add the following to your cap recipie you are all set.  Shiny!

  task :after_update_code do 
    run “ln -s #{deploy_to}/#{shared_dir}/db/production.sqlite3 #{current_release}/db/production.sqlite3″ 

You might notice I am using bort as the starting point for cookbook. They really have done everything I need, in the way I need. Since I am using it with Dreamhost (read: Passenger) and git I really didn’t need to undo ANYTHING.

Git on OS X

I’ve been tinkering with git, and git-svn. Starting to figure out how to cope, and am hopeful that the real coolness of distributed systems will become apparent soon.

The real trick, was finally getting it to install with the options I had hoped for: svn integration, command completion and a custom bash prompt.

First, to install it via Mac Ports (other articles I read had either “+svn” or “+ bash_completion”, but not both)

sudo port install git-core +bash_completion +svn +doc

Set up Arya Asemanfar’s bash prompt and add git command completion.

I added the following to .bash_login

Command Completion

source /opt/local/etc/bash_completion.d/git

Custom Prompt

parse_git_branch() {
git branch 2> /dev/null | sed -e ‘/[*]/d’ -e ’s/ (.)/(git::1)/’
parse_svn_branch() {
parse_svn_url | sed -e ’s#‘“$(parse_svn_repository_root)”’##g’ | awk -F / ‘{print “(svn::”$1 “/” $2 “)”}’
parse_svn_url() {
svn info 2>/dev/null | grep -e ‘URL*’ | sed -e ’s#URL: (.)#1#g ’
parse_svn_repository_root() {
svn info 2>/dev/null | grep -e ‘Repository Root:’ | sed -e ’s#Repository Root: (.*)#1/#g ‘
export PS1=“[33[00m]u@h:[33[01;34m]w [33[31m]$(parse_git_branch)$(parse_svn_branch)[33[00m]$[33[00m] ”

Once you get to that point, I recommend heading over to Intridea’s Getting Rogue with git-svn, it has been a great help for me.

CBT Error

I was trying to complete some of the mandentory online training required by my company and got the following error on their website:


Best part is they support IE, Firefox under windows and Navigator under Linux. Not really sure why Safari and Firefox on OS X wouldn’t work for them.

Javascript Code Prettifier

I really liked the idea of the Javascript Code Prettifier, and I really like my personal color scheme, so I wanted to combine them. I thought it was turned out pretty neat, espcially since it only took about 20 min of tinkering to get everything sorted out, so I wanted to contribute back to the author — but he provides no simple way to do that, so I will tell you about it. You who are prolly only coming here for the pics of Leah (see previous post).

Here is my color scheme for JS Prettifier:

/ Pretty printing styles. Used with prettify.js. /
/ Modifying to match RistoInk, with thanks to VibrantInk /
.str { color: #66FF00; }
.kwd { color: #AAAAAA; }
.com { color: #AA66FF; }
.typ { color: #DDE93D; }
.lit { color: #339999; }
.pun { color: #AAAAAA; }
.pln { color: #FFFFFF; }
.tag { color: #AAFFFF; }
.atn { color: #FF6600; }
.atv { color: #66FF00; }
.dec { color: #FF6600; }
pre.prettyprint { padding: 2px; border: 1px solid #888; background-color: #000000;}

The only other change is, I wanted the tags surrounding the code to be

You can see those files directly:


Check out some fun ruby code (and it’s whitespace independence):

hash = { :water => ‘wet’, :fire => ‘hot’ }
puts hash[:fire] # Prints: hot

hash.each_pair do |key, value| # Or: hash.each do |key, value|

puts "#{key} is #{value}"


Prints: water is wet

fire is hot

hash.delete :water # Deletes :water => ‘wet’
hash.delete_if {|k,value| value==‘hot’} # Deletes :fire => ‘hot’

Dynamic Cheese Grater

I decided I’d like to access my home computer from work, specifically I wanted to be able to ssh into the machine. I used to do this by setting up a dynamic host name and just leaving my computer on all day long, but that hardly seemed like the best way to deal with it. More specifically, I didn’t really want to pay for the electricity of running that thing all day long. So I decided to look into what I needed to do to get Wake-on-LAN to work with my Power Mac and FiOS modem.

First was to go back to Dyndns.com and get a hostname for my compy. I like the “homeip.net” ones, cause, it is in my home. 
Configure my router to port forward ssh (tcp on port 22) 
And wake-on-lan (udp on port 9) to my desktop.
Configure OS X to allow ssh (System Prefrences –> Sharing –> Check “Remote Login”) 
And to allow wake-on-lan (System Prefrences –> Energy Saver –> Show Details –> Check “Wake for Ethernet…”

Now I just needed a way to wake it up. First I played with this web page, which worked, but required me to type in my Desktop’s MAC address every time. Uncool. Then I found a little perl script that could do it, sorta. At that point I realized this was a job for ruby. And lo and behold I found K. Kodama WOL Class, which did nearly exactly what I wanted. I took that and hacked it up so my settings were all hard coded, added a she-bang, made it executable and linked to it from somewhere in my path. Now I can simply type “wakebold” and it will wake up my desktop at home (whom have affectionally named “bold”).

My changes were really easy:

Configure the IP and MAC address for the computer you want here:

SETTINGS = { :mac_addr => “00:00:00:00:00:00”, :host_name => “example.homeip.net”}

if $0 == FILE
wol.wake(SETTINGS[:mac_addr], “”, SETTINGS[:host_name])
puts “Waking up #{SETTINGS[:host_name]}”

My hacked version can be found in my svn repo.

To do all this, you can do the following:

svn co http://www.fuzzymonk.com/svn/wakeywakey
chmod +x wakeywakey/wakey.rb
ln -s wakeywakey/wakey.rb /usr/local/bin/wakebold # or elsewhere in your path

The next post will be better.

I’ve been out in Oregon at RailsConf. As you might have noticed from twitter, I’ve been here three days now. The Conference has been outstanding, and the people here make up one of the coolest communities I have ever been exposed too. The problem with the first few days out here was the happening going on back home. Three things really sucked the joy out of this otherwise awesome geektopia, a client at work who thinks fire alarms are the proper way to do business, getting my credit card number stolen, and the programming contest at work.

Lets touch on these in reverse order. The contest was optional, but I have a teammate who worked very hard and I was not about to leave him hanging. Unfortunately I was out of town (here, in OR) when they were presenting the projects in the office. To handle this I created a screen cast. Which is not the quickest or easiest thing in the world to do. I quickly got a copy of QuickTime Pro and iShowU and threw something together. A few tries through and I was pretty happy. Figured one more try and I’d be set. But nothing worked that time, it was 4 AM my time, and I had a decent run. So I uploaded it and crashed. It was just time to be done with that.

It sucks to get your CC stolen. If the thief reads my blog: I canceled the account. And you are a mean jerk.

The fire alarm as a development methodology is really starting to wear me out. I had been running strong with with the “my project, my baby” feeling, but as I have been reminded it isn’t. Which really removes the desire to meet the—artificial—deadlines at all cost. I still want to succeed, but it is hard when the people who are helping you don’t help. Sorta like the curly haired helper, but not cute nor do they give out hugs so happily.

I am just burnt out on the project, and need something fresh. Or a vacation. Or a few weeks paternity leave.

OK, a much happier post on the way, stay tuned.