Capistrano: use git repository on the same server you deploy to

November 23, 2009 Leave a comment

I ran across an interesting problem the other night. I finally convinced myself that I need to set up automated deployment for a personal website I was working on. The website is written in Ruby on Rails and I decided to use capistrano for deployment like ever other person I know that uses rails. The first problem I had was the capistrano docs are really really lacking in details. The tutorial covers the basics but that only works if you aren’t doing something wacky.

I’m using git for version control which isn’t all that odd. What is odd is that I don’t have a remote repository. I don’t really need to because I backup my laptop almost every night.  I don’t want capistrano to use the copy method for deployment because I don’t want to be trying to push several hundred kilobytes of data over a coffee shop’s overloaded public wifi for every deployment.

I didn’t want to use a git host like github or any one of a hundred others because I already rent a Virtual Private Server from (256 slice to be specific) So I decided to just use git over ssh and store a copy of my repository on my server. It was pretty easy to create an empty repository on my server and push my local copy over. Capistrano however did not like this. My website needed to deploy to the same sever my remote repository was sitting on. There is no tutorial or examples for doing this. I googled for over an hour and read all the docs on capistrano.

The problem with capistrano is that by default the :repository variable only paths to urls or files on your local machine. I couldn’t find a way to tell capistrano to look on the deployment server for the repository.

The solution:

set :repository, "file:///srv/git/repository.git"
set :local_repository, "file://."

The above works because setting undocumented variable :local_repository tells capistrano that :repository is a location on the app server. Suddenly, I’m able to deploy using export instead of copy. I hope I saved someone else hours of searching to figure out how to do this.

Categories: Uncategorized

Applescript to start screensaver.

October 13, 2009 Leave a comment

It’s pretty easy. You’ll “Show Script menu in menu bar” checked in the general preferences of AppleScript Editor.


tell application id “” to launch

end try

Create the applescript then drop in ~/Library/Scripts

Categories: Uncategorized Tags:

Create Service for “Launch Terminal from Here”

August 30, 2009 Leave a comment

I upgraded to Snow Leopard and as many people have discovered input managers have been be trashed. As annoying as it is I understand why Apple got rid of them. I had used “On My Command” to add menu items to my Finder context menu. One of these commands was “Launch Terminal from Here”. Basically I would right click on any file or folder choose “More > Launch Terminal from Here” and I would instantly get a terminal window at that location.

Snow Leopard has introduced improved services which replaces On My Command. To recreate “Launch Terminal from Here”.

  1. Start Automator (You can find it in the Applications folder)
  2. Created a new service (File > New or Cmd+N, then select Service and click Choose).
  3. Just under the record button you want the service to receive “files or folders” in “any application” (or just Finder).
  4. Create a Run Applescript object. (in the sidebar Utilities > Run Applescript or search for Applescript)
  5. Use the following code in the Applescript object
  6. on run {input, parameters}

    (* Your script goes here *)

    set s to POSIX path of input

    set subcmd to “if [ -f \”” & s & “\” ]; then dirname \”” & s & “\”; else echo \”” & s & “\”; fi”

    tell application “Terminal” to do script “cd \”`” & subcmd & “`\””

    end run

  7. Save the service under “Launch Terminal from Here”

And there you go. This can be used to replace a number of actions that formerly where handled by On My Command.

If this is not detailed enough for you, I can create a visual step by step article. Just leave a comment on my blog or email me at epochwolf on gmail.

Categories: Uncategorized Tags:

Get every new post delivered to your Inbox.