Archive for October, 2008

Ramblings of a man on paternity leave

Posted by on Sunday, 26 October, 2008

[cue Doogie Howser theme music]

Dear diary,

Google is probably one of the only companies in the U.S. that gives an actual paid paternity leave (7 weeks!)… why, it’s almost as civilized as living in Europe. It not only gives us a chance to bond with babies, but try to reset our lives as we walk around in a sleepless stupor. Highlights of my downtime so far:

  • When mommies and babies are sleeping, it’s still possible to practice the banjo with the magic of Mike’s Mute, the mostly highly rated of mutes on all of Banjo Hangout (where the cool kids are!). The photos don’t do it justice. It just clamps onto the bridge and makes your banjo as quiet as an unplugged electric guitar… yet it still sounds like a banjo!
  • Did you know that the bottom of a newborn baby’s foot, being completely unused, looks exactly like the bottom of a hand? Delicate little lines everywhere — the same ones palm readers look for. It’s amazing to think that those features are hiding under the thick dead layer of smoothness on the bottom of adult feet. In that same vein, did you know that when a newborn straightens out his arm, all one can see is a single puffy tube of flesh? There is no visible elbow, no indication of how or where the arm bends… thus proving my scratchy elbows are a product of nurture, not nature.
  • As the temperatures drop into the 40’s in Chicago, our pantry is overflowing from potatoes delivered by our local community supported farm. It’s time again to dig into my favorite recipe for potato leek cheese soup. Seriously: just boil some potatoes and leeks, add cream cheese, and you’re in heaven. Blending with a stick blender is strictly optional; I can’t get enough of the stuff. Go make this soup right now.

Back to the diapers.

a Mercurial “super client”

Posted by on Tuesday, 14 October, 2008

One of the cool trends I’ve seen is the use of distributed version control systems as “super clients” against Subversion. You suck down the entire history of a Subversion repository into a local, private repository, do all of your commits locally, make branches, experiment all you want, then “push” back up to Subversion again. On the internet, nobody knows you’ve been using DVCS (or that you’re a dog.) What’s particularly cool about these bridging tools is that they allow users to try out DVCS before deciding to officially convert a whole project over. Or, if a project happens to be using Subversion but you still want most of the power of a DVCS for local work, it’s a perfect solution.

For all the blabbing I’ve done about distributed version control systems, I’m still a big fan of Mercurial. Of all the DVCSes, I think it’s the easiest to learn for svn users. It has a small, tight set of commands, and the community which runs the project is polite and sane.

In any case, there have been a collection of Mercurial-Subversion bridges available for the last couple of years, but they’ve all been deficient in various ways: either not capturing svn history entirely, or being unable to push back to svn correctly (or only very awkwardly). So I’ve pretty much stayed away. But today I want to plug a new bridge written by a friend of mine (Augie Fackler) who finally did it Right: he wrote a bridge called hgsubversion which (1) uses the actual Subversion API to pull history down (which is faster, more accurate, and long-term sustainable), and (2) actually knows how to push changes back to Subversion correctly. I want the world to be aware of this tool, because I think it’s the first Mercurial-Subversion bridge which deserves to be promoted into the popular ranks with tools like git-svn.

The tool is still young and not generally installable by the public (i.e. you’re not going to find any magic .rpm, .dpkg, .zip or .dmg for it yet)… but here are my cliff notes if you want to start playing with it.

Requirements

  • The latest (unreleased) Mercurial
  • Local Subversion libraries, at least 1.5, with swig-python bindings built
  • A Subversion server that is 1.4 or later

To get the latest Mercurial:

$ hg clone http://selenic.com/repo/hg hg-latest
$ cd hg-latest
$ make
$ sudo make install

To get the latest Subversion python bindings:

$ # if you don't have a binary package for svn-1.5-python-bindings already,
$ # this is a summary of subversion/bindings/swig/INSTALL instructions:
$ svn checkout http://svn.collab.net/repos/svn/tags/1.5.3 svn
$ cd svn
$ ./autogen.sh && ./configure
$ make
$ sudo make install
$ make swig-py # make sure you have swig 1.3 installed already
$ make check-swig-py
$ sudo make install-swig-py

To get hgsubversion:

$ hg clone http://bitbucket.org/durin42/hgsubversion/ ~/hgsubversion
$ cat >> ~/.hgrc
[extensions]
rebase=
svn=/home/user/hgsubversion
^D

To make sure you’re ready to go, do a final sanity check:


$ python -c "import svn.core; print svn.core.SVN_VER_MINOR"
5
$ # if you get something less than 5, you may have conflicting
$ # versions installed, and may need to set PYTHONPATH

Now you can clone your favorite svn repository, and use it locally:


$ hg svnclone http://svn.example.com/repos hg-repos
converting r1 by joe
A trunk/
committed as 24dfb7b51d606a921333e2b8f19a9a6aa5661a69 on branch default
[...]
converting r100 by jane
M trunk/goo
M trunk/moo
committed as 54dfb7b51d6d6a931333e2b8f19a9a6005661a62 on branch default
$

The tool currently assumes a ‘standard’ svn layout of /trunk, /branches, /tags, and then tries to pull them into sane mercurial equivalents. After you’ve made a bunch of local commits, you can push the changes back to subversion:


$ # First merge the latest public svn changes into your repository:
$ hg svn pull
converting r101 by pinky
A trunk/awesomefile
committed as e85afd44dc83d5df2599157096a95b0868de6955 on branch default
$ hg up -C
3 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ # We now have two hg HEADs, because the public svn changes are
$ # considered a different line of development from my own.
$ # For now, rebasing is preferred to merging:
$ hg up -C 9985f017b3ab
3 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg svn rebase
saving bundle to /home/user/project/.hg/strip-backup/c4b9dfce6b09-temp
adding branch
adding changesets
adding manifests
adding file changes
added 4 changesets with 4 changes to 4 files
rebase completed
$ # At the moment, each changeset is pushed separately;
$ # changeset flattening not yet implemented
$ hg svn push

√2 is irrational: proof by poem

Posted by on Tuesday, 7 October, 2008

i found this scribbled in chalk one day, on the sidewalk outside the University of Chicago math department:

Double a square is never a square,
and here is the reason why:
If m-squared were equal to two n-squared,
then to their prime factors we’d fly.
But the decomposition that lies on the left
had all of its exponents even,
But the power of two on the right must be odd,
so one of the twos is “bereaven”!

Here’s my translation of this poem. It’s a simple proof by contradiction.

  1. Assume sqrt(2) is rational, so sqrt(2) = (m/n)
  2. By squaring both sides and dividing, we get m^2 = 2*n^2
  3. Reduce m and n into sequences of prime factors:

    (p1 * p2 * …. * pv)^2 = 2 * (q1 * q2 * …. * qw)^2

  4. Apply the square to each element in parenthesis:

    p1^2 * p2^2 * … * pv^2 = 2 * ( q1^2 * q2^2 * …. * qw^2)

  5. Examine the right side, remembering that all p’s and q’s are prime numbers. One of the following things must be true:
    • There exists a q = 2. In which case, we can combine our lone “2” into it, giving us a 2^3 term.
    • There is no q = 2. In which case, our power of 2 is simply 1, i.e. 2^1.

    Either way, we’ve proven the the right side contains an odd power of 2.

  6. But, the right side contains only even powers of primes. Contradiction.

Isn’t math fun?