Google presentation at Clepy on August 6th, 2007

Tonight Brian Fitzpatrick (Fitz) from the Chicago Google office did a presentation for the clepy group on version control at Google. They use subversion on top of their own super-cool bigtable filesystem back end.

We had a good discussion on the merits of centralized vs. decentralized version control. According to Fitz, decentralized systems discourage collaboration. He made the joke, “Did you hear about the decentralized version control conference? Nobody showed up.” He made the point that centralized repositories encourage review and discussion. I agree with that.

Apparently subversion 1.5, which will be released in a few months, will have much improved merging facilities. We won’t need to use --stop-on-copy to figure out where we branched. Also, it will be safe to repeat a merge, because nothing will happen on the second attempt.

I don’t like the dispatching system in turbogears

I wanted to translate a(1).b(2)into the TurboGears URL /a/1/b/2. A browser making a request for /a/1/b/2 would trigger that code.

This page explains how to do it. You build a single default method that catches everything and then does introspection to figure out where to send the request.

It works fine, but it isn’t nearly as obvious or concise as the regular-expression approach I’ve seen in rails and Django.

Learning flex without spending $0.01, day one.

I downloaded the command-line compiler and lots of documentation PDF files from here earlier today.

Then I started working through the “getting started” tutorial PDF.

I made a few edits to my ~/_vimrc file so that working with mxml files would be a little easier:

” Do some specific maps for flex files (.mxml files).
” F10 rebuilds the swf.
autocmd BufNewFile,BufRead *.mxml map <F10> :! mxmlc %<CR>

” F11 executes the swf.
autocmd BufNewFile,BufRead *.mxml map <F11> :! start %<.swf<CR>

And I was able to build this do-nothing widget after about 15 minutes of goofing off:

flex1

That’s a screenshot of my homemade swf running above the vim session where I wrote it.

Next stuff to figure out:

  • Where do my trace statements go?
  • I need to figure out how to pass in locations of actionscript files when I compile my mxml files into swf files.
  • I need to learn the tags in MXML. They’re different than HTML.
  • I need to learn how to talk to a webserver.

Using dictionaries rather than complex if-elif-else clauses

Lately, I’ve been using dictionaries as a dispatching mechanism. It seems especially elegant when I face some fairly elaborate switching logic.

For example, instead of:
if a == 1 and b == 1:
log("everything worked!")
commit()


elif a == 1 and b == 0:
log("a good, b bad")
report_that_b_failed()


else:
log("a failed")
report_that_a_failed()

Do this:


d = {
(1, 1): commit,
(1, 0): report_that_b_failed,
(0, 0): report_that_a_failed
}


k = (a, b)
f = d[k]
f()

This approach is also really useful when you face the need to change logic based on runtime values. You can imagine that d might be built after parsing an XML file.

How to have a better cygwin terminal

Cygwin is a wonderful tool. However, I don’t really like the default terminal. This article shows how to set up an rxvt terminal instead.

This is a screenshot of the default cygwin bash prompt:

cropped-dos-terminal.png

Copying and pasting is not intuitive, you can’t stretch the box horizontally, and most importantly, it breaks the illusion that I’m on a Unix box. But a better terminal option exists! When you install cygwin, you can also install the rxvt package. After installing the rxvt package, try this in a DOS window:

C:\cygwin\bin\rxvt.exe -fg gray -bg MidnightBlue -fn "Lucida Console-14" -e bash --login -i

You should see a terminal like this:

cropped-rxvt-terminal

As far as I can tell from my experience, this terminal acts exactly like a regular rxvt terminal on a linux box. I can highlight some text with my mouse, and then paste it by hitting either shift+insert or by hitting the middle mouse button. I can resize the terminal horizontally and vertically.

I set up a taskbar icon so that I can get that rxvt very quickly. The icon before the right-most icon will start an rxvt terminal for me.

startbar

Setting it up was really simple. I made a new shortcut by right-clicking on my desktop, then I copied this text:

C:\cygwin\bin\rxvt.exe -fg gray -bg MidnightBlue -fn "Lucida Console-14" -e bash --login -i

into the target field:

shortcut

Then I hit OK, and then dragged the new shortcut into the taskbar, and that’s it!

Ubuntu and TurboGears

It shouldn’t be so hard to set up turbogears on ubuntu Feisty Fox. The easy_install-2.4 turbogears approach crashes when trying to install Cheetah.

So, here’s a list of everything I had to do:

  • I installed the Ubuntu package for Cheetah: sudo apt-get install python-cheetah
  • Then I could run the easy install: sudo easy_install-2.4 turbogears
  • I edited /etc/apt/sources.list and added multiverse to the list of available packages. In other words, I changed this section:

deb http://archive.ubuntu.com/ubuntu/ feisty universe
deb-src http://archive.ubuntu.com/ubuntu/ feisty universe

to look like this:

deb http://archive.ubuntu.com/ubuntu/ feisty universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ feisty universe multiverse

  • Then I installed the python profiler package: sudo apt-get install python-profiler.
  • I tried installing pysqlite2 through easy_install, but that blew up, so I installed ubuntu package for pysqlite2 instead: sudo apt-get install python-pysqlite2.

Now everything works.