Streaks

Yesterday, my 124-day blogging and open-source coding streak came to an end.  I’ll continue to keep the same goals, and am sad to see it go – but hopefully we’ll build it back up

Do It.

# of People who do nothing is greater than

# of People who make excuses to not do something is greater than

# of People who talk about doing something is greater than

# of People who attempt to do something is greater than

# of People who do something

Git Bash Completion and Detail

One of the things I can’t live without is git bash integration in my $PS1.  This gives me feedback on the branch and status of my current directory.  Here’s an example screenshot:

So how do you get this set up?  Here’s how I do it (in ~/.bash_profile):

GIT_COMPLETION_PATH=/etc/bash_completion.d/git
if [ -f $GIT_COMPLETION_PATH ]; then
  . $GIT_COMPLETION_PATH
  GIT_PS1_SHOWDIRTYSTATE=true # */+ for dirty
  GIT_PS1_SHOWSTASHSTATE=true # $ for stashes
  GIT_PS1_SHOWUNTRACKEDFILES=true # % for untracked
fi

And then you can just include the git completion function in your $PS1 where you want it. My $PS1 is super simple, and just has this and the current path (and some nice colors):

export PS1="\e[0;33m\w\e[0;91m\$(__git_ps1 ' (%s)')\e[0;96m \$\e[0m "

Note: the location of your git bash_completion directory may be different (especially if you installed git via homebrew).  I like to solve that with a symbolic link, instead of changing this configuration (I just find it cleaner that way – much nicer for upgrades too):

git -> /usr/local/Cellar/git/1.7.9.6/etc/bash_completion.d/git-completion.bash

If you like this – read more of my dotfiles

Git Tip: Viewing a Git Stash

I use `git stash` very often to set some code aside while I work temporarily in another branch.  Sometimes, I want to peek at what I have stashed instead of taking it out.  You can do that very easily with `git stash show`:

git stash show -p  # view a diff

Quick Tip: Testing Multipart Uploads with RSpec

I couldn’t find this practically anywhere, so I thought I’d write a quick post on how to test multi-part uploads with RSpec.  The problem is that if you try to write something like:

post :photo, :file => File.open(path)

You’ll actually be sending the string “<File:…>” down as a request parameter.  What you actually want is a bit more obscure, but works perfectly:

post :photo, :file => Rack::Test::UploadedFile.new(path, mime_type) # text/jpg