Ian Oxley

Notes on Web Development and other Miscellany

Using Dropbox as a Git Remote

If you’re working on a pet project and aren’t quite ready to share it with the world via GitHub, here’s a handy way you can backup your work to the cloud using Dropbox as a git remote:

  1. Create a new, empty folder in your Dropbox to house your project’s remote:
1
$ mkdir /path/to/Dropbox/gitremotes/yourproject
  1. Initialise a bare git repository in this newly created folder:
1
$ git init --bare /path/to/Dropbox/gitremotes/yourproject

NB A bare repository in Git is one that only contains the revision info and system files (the files you’d normally find in the hidden .git directory), and doesn’t contain the working tree. From Git version 1.7.0 and onwards, a repository has to be a bare repository in order to accept a push, so we must create our Dropbox remote as a bare repository.

  1. Add our new remote to our project:
1
$ git remote add dropbox /path/to/Dropbox/gitremotes/yourproject
  1. Push our work to our dropbox remote:
1
$ git push dropbox master

You can then interact with your Dropbox remote the same way you would with any other.

Node-encdec

A while back I wrote a gist for base58 encoding / decoding in Python, then ported it to JavaScript. The other day I thought it would be good fun to convert the JavaScript version to a npm module so it can run on Node.js, and here’s the result: https://npmjs.org/package/encdec

It’s essentially the same as the original version. The only real difference is the unit tests are now in nodeunit instead of QUnit.

You can install node-encdec via npm:

npm install node-encdec

# or to install globally

  npm install -g node-encdec

Book Review - Sinatra: Up and Running by Alan Harris and Konstantin Haase (O’Reilly Media)

Sinatra Up and Running is a good read both for web developers who want to start building web applications with Sinatra, and for experiencedRuby developers who want to learn how Sinatra works under the covers.

The book is organised with the above in mind, making it easy to find the information you need. The first part covers the basics of Sinatra and focuses on giving you the knowledge you’ll need to start writing your own Sinatra powered web applications. Part two gets more technical, and looks at how Sinatra works under the covers, how you can write your own helpers and extensions, how Sinatra can be used as Rack middleware, and you can use it to create modular applications. The final part ties everything together and walks the reader through creating a Sinatra powered blog.

I enjoyed reading Sinatra: Up and Running. It’s well written, and full of code samples to help give you a better understanding of the concepts discussed. If you’re looking for a book on Sinatra then I’d recommend this one without hesitation.

Sinatra: Up and Running

Disclaimer: This book was reviewed as part of the O’Reilly Blogger Review program.

Gitsvnscript

Since I’ve been using Git, git-svn has become my preferred way of using Subversion. To make that git svn clone command a bit easier for svn projects hosted on Google Code, I’ve created a Greasemonkey script / user script that:

  1. Finds the svn checkout command on the source checkout page e.g. https://code.google.com/p/bbc-radio-scrobbler/source/checkout
  2. Appends the equivalent git svn clone command, using the standard layout option -s.

The source code is available on GitHub, and you can install it directly from this link: https://github.com/ianoxley/gitsvnscript/raw/master/gitsvn.user.js