RailsConf 2008 was a few weeks ago, and I didn’t go. I made babies instead. But if you ignore the whoohaa of MagLev and DHH’s Surplus talk, there was one piece of genuine, new awesomeness that came out of RailsConf. This awesomeness, plus Twitter created at least 6 new projects in the last month. These apps are going to make RailsCamp awesome.
That is if RailsConf never happened this piece of delicious coding happiness never would have occurred. It was built at RailsConf, by RailsConf attendees. It was built to solve a problem that only happens at conferences. Crappy internet.
The answer is gitj… no wait, I have more introductory story. [skip it]
Instead of going to RailsConf this year I “get” to go to RailsCamp, which is like a conference for Rails developers, but without the conference part. What’s left without the conference? Hacking, Guitar Hero3, rejectconf-esque talks, and alcohol. Its’ the Lord’s way of saying “you’re in the right profession.”
RailsCamp has two minor drawbacks, since it is held out in the country. One, there is no internet connection. Two, there is no internet connection. Now I know that is only one draw back but I thought it was such a big one it was worth mentioning twice [oh I miss Red Dwarf].
So, 6 months ago we solved one internet-related problem: we turned to Git and
git-svn clone to take all our svn repositories with us camping. 6 months on, git has taken over the Ruby OSS world, thanks mostly to GitHub which made remote hosting of git repos easy peasy. But, Github won’t be with us at RailsCamp. So we’re back to where we were 6 mths ago – being gumbies at hosting remote git repos.
So the question to be solved: how do you host a git repository, or indeed, lots of git repositories from your development machine; and conversely, how do you find someone else’s git repositories on their machine and clone it?
And whilst we’re at it… how do you easily share the RubyGems you have installed on your machine with other people, and how do you easily find gems on other people’s machines that you don’t currently have, if you don’t have access to rubyforge.org or github.com to get them?
And furthermore… if you’re running a fun little web app off your dev machine, how can you easily advertise it and other people find it and use it? “Hey, what’s your machine’s name?” “drnic-mac” “Thanks. ..pause… Um, what port’s the app on?” “4050”…
Same problem. Local devs, running local services, but how to share with everyone in the room?
The core solution is a technology created by the boffins at Apple that is now completely open-source (afaik): Bonjour. From wikipedia:
Bonjour, formerly Rendezvous, is Apple Inc.’s trade name for its implementation of Zeroconf, a service discovery protocol. Bonjour locates devices such as printers, as well as other computers, and the services that those devices offer on a local network using multicast Domain Name System service records.
In the Ruby world there are two RubyGems to integrate Bonjour into your app: dnssd and net-mdns. The former is only for Mac OS X, and the latter is a Ruby-only implementation that can be used anywhere. Bingo.
So, Chad Fowler, Evan Phoenix, Rich Kilmer and a cast of others started a humble project to solve the first problem: sharing git repositories across a local network, called gitjour.
This project became a happy hack place for many many people.
NOTE: I’ve included all the installation instructions that should work. If they don’t then try building the gems from src.
On OS X:
sudo gem install dnssd sudo gem install gitjour or from source sudo gem install dnssd git clone git://github.com/chad/gitjour.git cd gitjour rake install_gem
sudo gem install net-mdns sudo gem install_gem nogoth-gitjour --source=http://gems.github.com or from source sudo gem install net-mdns git clone git://github.com/nogoth/gitjour.git cd gitjour rake install
The gitjour project uses dnssd gem, with mac os x dependencies, and GitHub user ‘nogoth’ has ported the project to use the net-mdns gem for Linux/Windows.
Now, open up two terminal windows so you can emulate both sides of “serving” and “finding” a git repository.
cd a/git/project gitjour serve
gitjour list gitjour clone project
In Window 1, you can also serve an entire folder of repositories. Lots of them all at one time. Go into your project’s parent folder and run
gitjour serve and you’ll see it
Registered dr_nic_magic_models on port 9418. Starting service. a lot. In Window 2, you just
gitjour clone xxx the project you want.
See, genius. No mucking around with Apache or setting up local “remote” repositories in your public folder so people can pull from it. Just run
gitjour serve from your parent folder and you are instantly hosting ALL of your git repositories. Top Tip: move any private work into another folder first wink
So, that’s the git-sharing problem fixed.
After RailsConf, twitter was alive with the coolness of gitjour, and very quickly John Barnette created pastejour to publish and find single pastie’s of code, given that without the internet you don’t have pastie websites.
To install on OS X:
sudo gem install dnssd sudo gem install jbarnette-pastejour --source=http://gems.github.com or install from src: sudo gem install dnssd git clone git://github.com/jbarnette/pastejour.git cd pastejour rake install
sudo gem install net-mdns sudo gem install nogoth-pastejour --source=http://gems.github.com or install from src: sudo gem install net-mdns git clone git://github.com/nogoth/pastejour.git cd pastejour rake install
Pastejour publishes a single block of text until one person retrieves it. Essentially, you yell at the person that there is a paste for them and they get it.
pastejour <<< "Hello Window 2"
$ pastejour -f Searching for servers (3 seconds) Found pastejour at 'drnic' $ pastejour drnic (drnic from drnic-mac.local.:42424) Hello Window 2
After John’s announcement on Twitter, I asked “do we have a gemjour yet for sharing gems?”
This gem serves up all your gems to anyone who wants to install them from you. Don’t have merb but want to try it? Grab it from someone else.
To install on OS X:
sudo gem install dnssd sudo gem install evanphx-gemjour --source=http://gems.github.com or install from src: sudo gem install dnssd git clone git://github.com/evanphx/gemjour.git cd gemjour rake install
sudo gem install net-mdns sudo gem install nogoth-gemjour --source=http://gems.github.com or install from src: sudo gem install net-mdns git clone git://github.com/nogoth/gemjour.git cd gemjour rake install
gemjour list gemjour list someuser gemjour diff someuser -- shows diff btw you and them sudo gemjour install someuser newgem -- install newgem from someuser sudo gemjour install_diff someuser -- installs all gems from someuser you don't have
Go around the room and steal everyone gems in a few minutes.
To install on OS X:
sudo gem install dnssd sudo gem install lachie-appjour --source=http://gems.github.com or install from src: sudo gem install dnssd git clone git://github.com/lachie/appjour.git cd appjour rake install
To use it, after you’ve started a web app that you want to publish, open another window to run
cd some/web/app script/serve -p 4000 # or whatever for your framework appjour leet_app 4000
$ appjour Searching for servers (3 seconds) found web app called 'leet_app' $ appjour leet_app ... app loaded into browser
Mongrel publishing bonjour events
Courtenay hacked in a few lines to
mongrel_rails so that each mongrel publishes itself to Bonjour.
The magic of this is that mongrels, or the applications behind them, could use Bonjour to self-discover each other within a mongrel cluster, and then talk to each other.
One man’s solution is another man’s problem
As new people join the circus, new gems, git repositories, web apps and pasties are added and the new problem is: how to keep in touch with the newness?
On Mac OS X:
sudo gem install dnssd sudo gem install aaronp-dejour --source=http://gems.github.com or install from src: sudo gem install dnssd git clone git://github.com/aaronp/dejour.git cd dejour rake install
There is no fork of dejour for Linux/Windows yet.
All your current services should appear as Growl notifications (from Windows 1, 3, 5 and 7 above).
But Growl notifications fly-by pretty quickly. How to keep track?
Finally, *jour to the rescue (starjour)
I really felt that this problem was best solved with a GUI. Mostly cause I was keen to try out RubyCocoa. I don’t think I did productive work for a week, whilst I read books, tutorials and anything I could find on RubyCocoa, Cocoa, Xcode + Interface Builder, Objective-C and after trying and failing a few times starjour was created. By Lachie Cox (who also wrote
Really, I just couldn’t get my head around Cocoa Bindings at the time, but my experience of using RubyCocoa was very positive, once I’d learnt the underlying framework and the thinking-patterns of a Cocoa developer. Best book to read to learn Cocoa/RubyCocoa? The book is by Aaron Hillegass – Cocoa Programming for Mac OS X (3rd ed). After struggling with other people’s books and tutorials this one was wonderful. The “CollectionView” message in the image above was me telling Lachie that I’d figured out and used CollectionViews to replace his TableView. Now i just need to bind the bonjour message type (gitjour/gemjour etc) to an image. And more.
starjour (read: *jour as all these apps were collectively named on Twitter) did one job: it sat there showing which services were currently available.
Unlike all the others, this one used the native Cocoa framework for Bonjour, fwiw, and is doomed as an OS X-only app.
On Mac OS X, we don’t really have a place to download and run it, so grab it from src:
git clone git://github.com/lachie/starjour.git cd starjour rake run
This requires Xcode and RubyCocoa (available on OS X Leopard or via rubycocoa.com on sourceforge)
Wow! What just happened last month?
Chronologically: gitjour, pastejour, gemjour, dejour, starjour and appjour. And I think there are others. Its incredible.
Firstly, it is going to be an awesome RailsCamp – these tools are killer apps for an internet-less hackfest like RailsCamp, or massive internet-starved conferences like RailsConf.
Secondly, it has been very exciting to watch the creation of these projects over the last few weeks, with the *jour meme bubbling through twitter and irc. Another happy month for our open source communities.