And now, something slightly different

August 28th, 2008

Back in May, I was a manager.

I feebly attempted to direct 8 great guys and gals to further the goals of JBoss.org.  After the Codehaus, you’d think I’d be able to help build an opensource community with fun and flair.  But I came to realize that it’s hard to build a community as an active effort.  Instead, I think community develops as a by-product of a useful and well-run project.  And that’s under the control of the project leaders and contributors, not necessarily some external third party.

Back in May, I gave up being a manger.

Now, the day after Labor Day, fittingly enough, I’ll be jumping back into the world of JBoss.  But not as a manager. When I was burned out and felt like resigning, Mark Proctor and Sacha Labourey instead talked me into taking a sabbatical.  And I’m truly grateful to them.  Now, after unwinding for a few months, I asked to rejoin the team as an engineer. Through Sacha’s patience and budget manipulation, I’m once again excited to go to work.  I think JBoss should definitely be held up as a company that takes care of its people.  They could’ve easily given me the boot, but instead they’ve been extremely kind and accommodating.

So, what will I be doing?

After talking to Java developers and Rubyists alike, my first goals are to look at Rails as just-another-way to write J2EE apps (or “JEE” I reckon, these days…).  Yes, I know about (and plan to use) things like Warbler and JRuby-Rack.  Both are good things.

But I also have full control of the deployment environment, to build a stack to make it happier than “build and deploy a WAR”.

Through the miracle of AS5 built on JBossMicrocontainer, along with the awesome VFS bits, it should be possible to deploy a Rails app in-situ, right from your working directory.  There should be no reason to have to build a WAR while you’re hacking a rails app.  And deployment to a server should still involve capistrano (in my opinion).  Stick to the Rails way of doing things, but make it Java under the covers.

Various blog posts have shown Rails apps on Glassfish in 12, 10, or 5 steps.  My goal is to get it down to 1 step. And you should magically be able to pick up and use all the wonderful JEE bits that maps to the Rails functionality the Railers of the world enjoy, without having to be aware of the JEE bits.

Speaking with Mark Newton (the guy who runs JBoss.org now), it seems sensible to view Rails as simply yet-another-programming-model for writing Java apps.  The idea is to avoid leaky abstractions, so we’re not having to write some psuedo RubyJava application.

Once we’ve got that base covered, then we can make fun and exciting Ruby bindings to all the powerful JBoss tools, such as Drools, ESB, Cache or MQ.

I expect to have a bit of fun with this.  More fun than being a manager, certainly.

Raleigh RubyCamp

August 25th, 2008

Oh, fortuna!

I’m rejoining the Red Hat/JBoss mothership, doing rubyish things, and what do you know, but there’s a RubyCamp at the RHT HQ in Raleigh on October 18th.

37signals and Ruby Row are sponsoring the event.

Space is limited to 200, but at the time of this posting only 57 have signed up.  It’s an unconference, so bring your own good ideas, and you can lead a session

Be a smarter patch monkey

August 24th, 2008

A project I’m working on requires some hard-core monkey-patching of Rails internals.

Monkey-patching is a dangerous occupation, and liable to cause new and intriguing bugs into previously-tested sane code.

I’ve been working on a smarter patch-monkey, known as Lemur.

The goal is to allow monkey-patched methods (currently only instance methods are supported) to be written in modules that are mixed in (as modules are) but allowing redefinition of methods in the patchee by the patcher module.

I may be ignorant of some Ruby to make it happen, but I’ve resorted to alias_method and remove_method, along with a handful of Ruby’s reflection methods to swap methods in a reasonable, clean, and auditable fashion.

The specs demonstrate how it works. Assume a basic class:


class BasicClass
  def some_instance_method()
    # ...
  end
end

And a module to monkey-patch it


module PatchModule
  def some_instance_method()
    # ...
  end
end

Normally, Ruby will prefer a locally-defined method over a module mix-in, so you can’t just include your patch module in, even using class_eval.

So, invite in the Lemur.


Lemur.patch_class(BasicClass, PatchModule)

And voila! Your class is monkey-patched by the nicely self-contained module, plus, it’s tracked.


Lemur.patched_classes # [ BasicClass ]

And even more cool, you can get some patch-audit information for each patched class:


Lemur.patch_records( BasicClass ) # [ array of PatchRecords ]

Each PatchRecord keeps up with the patched class, the patched method name, the actual replaced Method object, along with the patch module and the patch method.

A total of 40min has been spent writing the code so far. The idea is to add better auditability, unpatching, and dealing with class methods, not just instance methods.

Now, when you encounter a weird bug, you can ask the Lemur where the oddness might’ve originated.

Want to pitch in and do some meta-programming to make future meta-programming less scary, fork my git repository and send me some pull requests.

GitHub Mirrors for some JBoss Projects

August 21st, 2008

In addition to the previously-mentioned JRuby mirror from Codehaus SVN to GitHub, I’m now also mirroring:

All are trunk-only mirrors, not picking up branches or tags. Since the JBoss repository path has about 77,000 subversion revisions, and at one point held any and all JBoss software ever written, I have not mirrored it in its entirety. Instead, I’ve only grabbed http://anonsvn.jboss.org/repos/jbossas/trunk back to revision 77,200. It’ll mirror going forward, but the github repository does not include any ancient history.

For those of you playing along at home, the way to fetch just a cauterized “tip” from SVN to a git repository is to mirror as before, but for the initial “git svn fetch” command, add a SVN-style revision range

git svn fetch -r77200:HEAD

For me, at least, trying to fetch the tip revision for the directory resulted in failure. Going back a few revisions, and using a range that includes HEAD worked much better. Then just push to GitHub has normal, and start your rebase/push cronjob.

The JBoss projects are updated from SVN every 15 minutes. But we’re updating from the anonymous SVN repository at JBoss, which itself is delayed from the developer repository by some amount of time. So, ultimately, the GitHub mirror should be mostly up-to-date, but could lag behind actual developer commits by up to and hour, I reckon.

If you’re wanting to track these repositories using my git mirror, only track the vendor branch. I make no claims about the stability or sanity of the ‘master’ ref at any point in time. I will make sure ‘vendor’ exactly matches the Subversion history, though.

Mirroring SVN repository to GitHub

August 20th, 2008

So, I’m gearing up to work on some Java+Ruby (via JRuby) stuff. The Java world still seems fairly entrenched in the cult of Subversion, while the Rubyists have gone with Git lately.

I’m still wrapping my mind around Git, but with GitHub, it’s fairly easy and straight-forward. I paid my $7 for the micro account, to give me room to screw around.

There’s quite a few posts about mirroring SVN to a Git repository, but I feel the need to add my own, of course.

My goal is mirror the trunk of the JRuby project from Codehaus SVN to my account on GitHub. By doing this, I can track the trunk development, and also work on my own patches.

I started by creating an empty repository on my GitHub account, called ‘jruby’.

http://github.com/bobmcwhirter/jruby/tree/master

Now, over on my always-on, Contegix-powered server, I create a brand new local git repository, also called jruby.

mkdir jruby

cd jruby

git init

Next I use ‘git svn init’ to setup the SVN repository as a remote code source to track. Using the -T switch points git to the trunk, and ignores branches and tags, which is fine for my purposes.

git svn init -T http://svn.codehaus.org/jruby/trunk/jruby/

That does not pull any code, but it lets my local working tree know that I’m going to be pulling from an SVN repository at some point. This setup only occurs in your local repository, and does not seem to ever get pushed to GitHub once we get to that point.

So, now we do the initial pull. Once again, this is on my always-on, Contegix-powered server, not my local laptop. I’m doing this on a server because towards the end, we’ll be setting up a cronjob to accomplish it all.

git svn fetch

It’ll think for a while, it’ll slurp down the SVN revision history, it’ll stop and ponder occasionally, and eventually, it’ll be done. Woo-hoo! Our local working tree is now up-to-date with the subversion HEAD as of that moment.

To reduce disk-space used by your local repository, go ahead and run the garbage collector

git gc

On my system, that reduced the space from over 600mb to under 70mb.

Now, that’s great, but it’s still just on my local repository. Time to push it to GitHub. We’re not going to follow their directions exactly, since this will ultimately be a cronjob and needs to use ssh. And I’m slightly paranoid about my ssh keys.

So, the first thing I do is create another keypair, for used only by my mirroring process, and only for pushing changes to github. It has no passphrase. This allows me to keep my top-secret keys off my shared, always-on server. If these keys are compromised, all an attacker can use them for is to push changes to GitHub. Which, being revision-control, is more annoying than dangerous. (Hooray for “git reset”).

ssh-keygen -t dsa -f .ssh/id_dsa_github_mirroring

Next, I edit my .ssh/config to add a “fake host” so that ssh connections invoked by git will use this new key.

As with all previous bits, this is still on my always-on server, not my local laptop.

Host githubmirror
User git
Hostname github.com
IdentityFile /home/bob/.ssh/id_dsa_github_mirroring

This will cause any invocation of “ssh githubmirror” into “ssh git@github.com -i .ssh/id_dsa_github_mirroring”.

I then installed id_dsa_github_mirroring.pub into my GitHub account.

Now, GitHub’s instructions say to run this command to add the GitHub repository as a remote named “origin”

git remote add origin git@github.com:bobmcwhirter/jruby.git

Instead, we teak it to use the “fake host” we added to .ssh/config

git remote add origin git@githubmirror:bobmcwhirter/jruby.git

We’re almost done, I promise.

Next, we need to do the first push from my server up to GitHub. We first push to the ‘master’ branch, since the repo really wants to have a master branch.

git push origin master

Now, GitHub doesn’t allow you to fork a repository you own, and since this mirror is owned by me, where can I do my own hacks and patches? The ‘master’ branch of course. But I still want an unmolested, straight-from-subversion mirror. So, I create a ‘vendor’ branch in my workspace. It’s initialized to match ‘master’ exactly.

git checkout -b vendor

Now, I push that to GitHub, too.

git push origin vendor

Awesome. I now have two branches, identical at the moment, called “vendor” and “master”.

Now, as far as I can tell, all the Subversion setup that we did only lives in the local repository on my always-on server. Anyone who clones from the GitHub repository will not have that stuff. They can of course do a ‘git svn init’ themselves, to add it to their local repository. But it doesn’t flow through GitHub.

But that’s fine, since I’ve been doing this on my always-on server anyhow. My workspace is sitting in the ‘vendor’ branch that’s tracking the vendor branch from github.

I can pull the latest changes from Subversion by typing

git svn rebase

The ‘rebase’ command is neat, in that any changes that exist in the git repository are floated to be applied to whatever the latest HEAD is. But since I’m only concerned with a one-way SVN-to-Git mirror, there will never be any changes to float, and this will just tack on subsequent SVN commits as Git commits onto the ‘vendor’ branch. It’ll leave the ‘master’ branch un-touched.

After rebasing, you gotta push the ‘vendor’ branch up to GitHub.

git push origin vendor

Now, type that every 15 minutes, and your ‘vendor’ branch will stay mostly up-to-date.

Or use cron.

I’ve cronned a script that fires every 15 minutes

#!/bin/sh

cd /home/bob/github-svn-mirrors/$1
git svn rebase
git push origin vendor

It’s run with the repository name as the first (and only) argument

*/15 * * * * /home/bob/github-svn-mirrors/bin/mirror jruby

Now, over on my laptop, finally, I can clone the repository, work on topic branches, push to master and have my own controlled environment and fork, while knowing the ‘vendor’ branch reflects the pure SVN state which I can also pull into my hackings as-desired.

When I submit a patch, if it ultimately floats back to me through the vendor branch, git is supposedly smart enough to realize that the same changes have arrived in my ‘master’ (assuming it’s applied verbatim) and keep things nice and tidy. Else, I can force a merge, trampling my half-assed patch with the official JRuby code.

Conjunction Something

August 13th, 2008

If you’ve spent time around a child as he’s developed language, you’ll notice how he starts with a string of similar statements:

  • I saw a dog
  • I saw a cat
  • I saw a bee
  • I saw another dog
  • I saw Don Henley

After a while, that can get a tad annoying, and you become grateful when they discover conjuctions.

  • I saw two dogs, a cat, a bee, and Don Henley.

Many web2.0 dealios these days (ahem, Spock) take the “listen to me talk” approach.

  • Jim joined NewThingr!, and thinks you should, too.
  • John joined NewThingr! and thinks you should, too.
  • Larry joined NewThingr! and thinks you should, too.
  • Don Henley joined NewThingr! and thinks you should, too.

Everyone wants to be viral, but annoyance doesn’t help the case. What’s the solution? Be stateful.

When Jim, John, Larry and Don join your service, still offer to let their contacts know about it. But the use-case is “let my friends know about it”, not “send my friends an email, right now, telling them I just joined, right now”.

At the end of the day, gather up everyone who wanted to let me know about NewThingr!, mix in a conjuction, and send me a single email.

  • Jim, John, Larry and Don Henley joined NewThingr!

Now I can be gently reminded about NewThingr! at most once-a-day. Plus, you get a chance to show me, in a powerful way, that 4 of my friends all signed up today. I’m thinking “wow, 4 of my friends signed up for NewThingr!” instead of “wow, I’m glad those emails from NewThingr! stopped for a while”.

Conjunctions don’t stop once you get someone to sign up, either. Allow and encourage me to tell you about all of my email addresses. Not so I can get more email, but so I can get less. Some people know me as Codehaus Bob, some as Shovelpunks Bob, others as JBoss Bob. If your service realizes I’m all of them (a big “and”), then you can prevent duplicate notifications and inviting-an-existing-member. LinkedIn does a great job on that front.

Behold the power of “and”.

Ye Olde Retro Heirloom Shoppe (Vintage Edition)

August 9th, 2008

I’ve been noticing lately, it seems that “heirloom” is popping up everywhere.

There are heirloom vegetables, of course. The tasty varieties of tomatoes your grandparents grew up on, instead of the red/orange globes that taste like nothing.

Then I noticed a store selling “heirloom sewing supplies”.

Some dictionary defines “heirloom” as

A valued possession passed down in a family through succeeding generations.

I read that, and I’m glad to see a resurgence of heirloominess. We surely go through “retro” ages, but that’s more about fashion than values. Retro pants, retro hair, retro music.

Vintage seems like a half-way point between “retro” and “heirloom”. Maybe.  Or maybe “vintage” is just “retro” with a longer time-horizon.  The 1960s are retro.  The 1920s are vintage.

But “heirloom” points to a valued possession (or craft) that has been kept up with through the generations, like a spoken history.  Something we’ve reflected upon and decide it’s worthwhile to keep alive.  Retro/vintage is more about looking back and cherry-picking something to bring back to life, if just for a little while.

“Ye Olde” on the other hand, is just kitsch.  Anyone who owns a Ye Olde Ice Cream Shoppe needs to be locked in Ye Olde Town Stocks for a fortnight.

Grab a snack, take a jaunt

August 1st, 2008

As my summer winds down, Lance and I are proud to launch Food Jaunt, a directory of local-food providers with reviews, ratings, and maps. Plus, we point out locavore news as we see it.

For my non-American readers, the US has a tendency to eat food that was grown at least 4 timezones away, and many times from the opposite hemisphere. That’s a long way for fruit to fly.

Food Jaunt aims to support the locavore/100-mile-diet movement. Plus, it was just fun to build.

How I’m spending my summer vacation

June 11th, 2008

I imagine word has gotten around some already, but I’m on sabbatical from my gig at JBoss/Red Hat.

I stepped down from my role at JBoss.org because I found that I wasn’t very good at it. I gave the idea of “management” the ol’ college try and have decided it just doesn’t really fit me. I think I’m still an engineer at heart.

At any rate, to clear my head, spend some time with the family, and pick up some more development chops, I bumped off on this leave-of-absence.

I’m spending a lot of time in my garden and planning an off-the-grid homestead/farm in Virginia.

But I’m no Luddite.

So I’m also pitching in on this local startup some friends have created, called Greenthumbr.

It’s a consumer-oriented social-network (yes, another one) for gardeners, farmers, homesteaders, or other organic/eco/green thinkers and doers.

Closed-source, written in Ruby. A nice change from being management in a Java-centric environment.

So, I’m taking the summer off, ignoring the whole open-source/enterprise world for a while, and broadening my horizons.

We’ll see where September finds me. Until then, you can find me in my garden.

Zefty: Online Banking for Kids

June 1st, 2008

It’s summer, which means no school for the kid. Which means I now have relatively cheap day-labor available for yard-work.

I am a capitalist, so I intend to pay my son for the work he does.

Growing up, mom got me a physical paper ledger, where I’d record the $15 I made mowing the lawn, or the $20 I took out to buy gas. Mom was the bank.

With Noah, we’ve started the same thing. And then came Zefty.

It’s a really nice, really simple site to allow Mom (or Dad) be the bank, and provide online-banking to their children. No, really, it’s actually useful.

As parents, you can login, setup an account, give it an initial balance. You can schedule recurring deposits (weekly or monthly allowance), or you can manage deposits manually ($15 for mowing the lawn).

Children can login and calculate how long it’d take to save for some item, or they can print checks to be redeemed by the parents to make a withdrawal.

Being a true capitalist and having a son who likes to wantonly and intentionally destroy things, I was glad to find Zefty supports negative balances and debt. And it doesn’t allow a child to bounce a check he can’t cover with funds in his account.

All in all, Zefty is small, but seems to perfectly fit the bill for a parent of an 11 year old.

Next »