So you’ve pushed a few (or more) bad commits in a row, and you want to throw away those changes. Sometimes it helps to jump straight back to a previous commit.

Try it out:

# Check that "git status" is clean:
$ git status
# Set the index (staging area) to be as it was at commit db0bc:
$ git read-tree db0bc
# Create a commit based on that index:
$ git commit -m "Going back to the state at commit db0bc"
# Your working tree will still be as it was when you started, so
# you'll want to reset that to the new commit:
$ git reset --hard

We needed tab views that look and feel just like the ones in XCode 4. Our first attempt trying to override NSTabView’s styles failed. Instead, we found it easier to make NSTabView tabless and control it using a customized NSSegmentedControl. What’s nice is we can set it all up inside Interface Builder.

Instructions:

Open the nib file that will contain the tab view

Drag a NSTabView from the Object Library onto the stage

Change its class from NSTabView to WILLTabView

Add however many tab items you want and edit their labels to match up with an image filename

I needed to run some code after a period of time after an asynchronous remoting call completed. Normally you’d use NSObject’s performSelector:withObject:afterDelay:, but I wanted to use blocks instead so the code could be inline. Grand Central Dispatch’s dispatch_after method did exactly what I needed.

So you’ve built your awesome shiny new RESTful Rails app. You’ve been developing the client and find it pretty tough to unit test it against your service. The problem is that data on your service persists causing inconsistent test results. The solution is to usually mock requests on the client which can be sometimes difficult. When that’s the case, I’ve found it easier to mock the service instead using Sinatra — a light-weight web server. This easy-to-setup server can leverage your existing ActiveRecord models using a temporary in-memory database enabling you to mock requests to responses consistently in any manner required.