Git tagging a forked Ruby gem project for Bundler

If you ever have to customize or patch a Ruby gem and you are using Bundler, its a good idea when forking that project to create a branch and then tag new releases.

I found this out recently as I used and patched two Ruby gems, databasedotcom and salesforce_bulk, to sync data to Salesforce for reporting. I ran into showstoppers with both but luckily they are hosted on GitHub so I was able to fork them and make the necessary changes to resolve the issues I encountered while being able to contribute those changes back.

The project Gemfile was updated with my two forked git branches and then I ran bundle install. While Bundler does support specifying a git branch I found that as I made further code updates and would run bundle install again, Bundler wouldn't download those changes. I figured out that I should be tagging releases of that branch instead as that would require the Gemfile to be updated with a new tag name. After that running bundle install would download the latest changes I made.

Avoiding sudo when installing command line tools from source

Recently, I came across an excellent and detailed Node.js installation post that caught my attention since it focused on how to avoid using sudo. The "Long Version" part proved most helped as it goes into detail on the what and why of every action you perform. A great read if command line isn't your strongest area.

I realized a lot of what was discussed I had done earlier for installing the excellent rbenv tool so I deviated a little from the instructions by installing Node.js into a hidden folder in my home directory (e.g. ~/.node) and then updating my path in my ~/.bash_profile file. That last step I had to change to the following:

$ echo 'export PATH="$HOME/.node/bin:$PATH"' >> ~/.bash_profile

I've grown used to installing from source lately where in the past I wouldn't have but with enough of the projects I'm interested being hosted on GitHub (which I love) the workflow I know well and remains consistent so it makes sense. Its worth the effort rather than installing from a third party like Homebrew where it might not have the latest version (which I encountered when attempting to install Node.js).

For some of you this might seem trivial but a lot of this I didn't take the time to understand. Now though I know the difference that by installing into my home directory I can avoid using sudo and take control of the tools I depend on.

A Leap of Faith for my iPhone

With the outpouring over Steve Jobs recent passing I've read some touching and moving stories. While I don't have any Steve run-ins or early Apple experiences to share I did have an incident with my iPhone a few years ago that reminded me of how much I love using that device and how important it is to me.

Whenever I'm on the subway platform waiting I pull out my phone and start reading articles I have saved with Instapaper. One day I was rather careless and the phone slipped out of my hands. It fell on the edge of the platform and then on the tracks below.

For that second my heart sank but I knew better since I was near the end of the platform where their is a small gate into the tunnel. I figured from there I could walk on to the tracks, pick up my phone and come back the same way. One problem. The train was arriving in less than 2 minutes. I wouldn't make it back in time.

While that thought came to mind, two men just a few feet away had a better idea. They told me to jump. I didn't have much time. Did you honestly think I was going to leave my phone there? No way! So I jumped down onto the subway tracks, picked up my phone and the two men lifted me back up on the platform. Two complete strangers were kind enough to help without asking. I was very grateful.

What I left out though is that was an iPhone 3G. I have an iPhone 4 now. I dread finding out what crazy thing I'll do next if something happens to it. I love the iPhone. Thanks Steve.

On Learning Ruby

Having written so much code in AS3 I wanted to learn a similar language but that was simpler. Lighter. I had my own ideas of what I'd like in a language and I've found that Ruby has several of them. A simple example that stood out for me was defining a constant. In AS3 this requires a lot of typing that I felt could be implied.

public static const FIRST_NAME:String = "Javier"

In Ruby it's no different than declaring a variable but you type the name in all caps.

FIRST_NAME = "Javier"

Short and sweet. In another example I was impressed in how expressive Ruby can be. I had been figuring out the different ways I could repeat a string when I noticed in the documentation that operators were implemented as methods. Why can't I just multiply the string by the number of times I want to repeat it? For example:

"Ruby! " * 5

And that worked as expected! Simple things like this have made learning Ruby a joy.

Although I've written small scripts and re-written my site to learn Ruby I wanted something else that was structured. I had discovered two invaluable resources: Ruby Koans and Learning Ruby The Hard Way. While I'm half way through Learning Ruby The Hard Way I haven't enjoyed it as much as completing the Ruby Koans. The koans are a collection of units tests where you fill in the blanks or write scripts against pre-written unit tests. I don't remember ever learning a new language so much as I did by completing those koans. If you have any experience programming it is a great way to pick up Ruby fast.

If you have any resources you'd like to share I'd love to hear from you.

Recovering Deleted Files From SVN

Recently, I had accidentally deleted a project file from SVN that was still required. Searching on how to recover it I came across different methods (mainly using svn copy) but an example using svn merge is what worked for me. All you need is the revision number that deleted the file(s) that you want back.

The following is the command format you'll want to use:

$ svn merge -r [rev]:[rev-1] [file-path-or-current-dir]

As an example, lets say I wanted to retrieve a post I had deleted for my site and the revision number that deleted the file was 50. That would look something like this:

$ cd Projects/website/posts/
$ svn merge -r 50:49 .

If you made other changes that were part of that revision they will be retrieved but are not committed so you can modify them as you like. In my case I had deleted 2 other files so I just re-deleted them, kept the one I needed and committed my changes. The revision history for the file you retain is preserved.

Fork me on GitHub