Where Are The Wise Men?

Mike's Ramblings

Zsh Completion Magic

| Comments

I'm a happy user of [zsh][]for a few years now and, while I don't know all the subtleties of it, I find it a indispensable tool. People I know and respect keep asking me "Why not bash?" One of the big reasons is [zsh's completion system.][]

Bash has a add-on version of this, called [bash-completion][], and I used that before moving over to zsh full-time. Bash-completion feels, well, added on and slow and not always working. Zsh's completion, however, keeps surprising me on how much it does do. As they say, a picture is worth a thousand words.

[caption id="attachment_722" align="aligncenter" width="300" caption="I typed "./manage.py TAB" and Zsh gave me all the arguments of a standard Django manage script."][![ZSH doing Django Completion][]][][/caption]

The above screenshot came with no configuration -- I didn't have to tell zsh about Django because, well, [someone already did][]. And I'm glad for it.

It's not just for Django, either. See what happened when I did "./configure " in PHP's source tree:

[caption id="attachment_724" align="aligncenter" width="300" caption="The top part is what I got when I did "./configure TAB". The part below my prompt is what I got when I did "./configure --with-TAB""][![Zsh when configuring soruce][]][][/caption]

So note that zsh helps me figure out the right options. What I want to know the exact options for MySQL?

[caption id="attachment_725" align="aligncenter" width="300" caption="Results of ./configure --with-mTAB"][![Results of ./configure --with-mTAB][]][][/caption]

Again, none of this stuff had to be configured -- I just told zsh I wanted completion and it gave it to me. I didn't have to tell it that this was a configure script -- it knew that! Just like it knew about the Django script.

This is just a taste. I hope you bite into zsh for more goodness.

"ZSH doing Django Completion"
"Zsh when configuring soruce"
"Results of ./configure --with-mTAB"

Cleaning Up With Hazel

| Comments

Anyone who knows me well knows that I'm not a neat-freak. If you know me well enough, you know that I can be an out-right slob. My wife has tried to train me in other ways, and it's sorta worked. But I still leave things laying around that need to be dealt with -- including things that should go straight to the trash.

I'm that way with files on my computers as well. I let files sit around long after I need them and then, surprise!, I have a problem with hard drive space. I end up having to scramble to find files to delete, and end up finding ISO images and tarballs of forgotten installs that I could have delete months, sometimes years go.

After [my clean install of Snow Leopard,][] I vowed I would be better at cleaning up after myself. I would delete files that I know longer needed, remove those MP3 files after I import them into iTunes, and empty my Trash periodicially. But, really, who am I fooling? I'm not going to do daily or weekly sweeps of my hard drive seeing these things. That's where [Hazel][]stepped into my life and made things much easier.

Hazel cleans up after you. Essentially, you tell it where to look, what to look for, and what do to. Want to import MP3 files automatically into iTunes? It will do that. Want to delete files that were downloaded more than a week ago? It will do that. Delete the Trash every month? Yep. Oh, and if the Trash bin gets large, it will delete it automatically -- but only if you tell it to. What if you want to do something weird with the file? Well, you can write an AppleScript or a shell script to handle that. And you tell it all this in a nice, mostly-intutive GUI. (Click on the Screenshots link [on the main Hazel page][Hazel] for an idea.)

And added bonus is that it can delete application files when you delete the application. What's that? You thought OSX did that for you when you moved an app from the Application folder to the Trash? Well, look in your user's Library->Preferences or Library->Application Support folder. Yeah, you see a lot of folders there for applications you no longer have installed. If you had Hazel installed, it would see that you have moved an Application to the Trash and it will ask you if you want to delete the user-level files as well.

I think Hazel is an application that every Mac owner should have. So, really, [at least try it out.][Hazel] Now. Go. It's worth far more than it's $21.95 price tag.

Build a Path for Elementtree Namespaces

| Comments

I really like using [ElementTree][]and it's [lxml][]and [xml.etree][] brethern. But one of my pet peeves is[how it deals with namespaces.][]I understand the reasoning -- it's just difficult and bulky. Combining the syntax of {namespace-uri} with [an XPath-like search string][]can be confusing.

I'm muddling over this while I'm writing yet another utility script to help me with some XML. I stop and decided I'm going to build a help class, wittingly called PathBuilder.

class PathBuilder:

def __init__(self,namespace_uri):

self._template=string.Template("{%s}$tag" %namespace_uri)

return "//"+self._template.substitute(tag=tag)

return ".//"+self._template.substitute(tag=tag)

def children(self,tag):

return self._template.substitute(tag=tag)


My methods above are all that I need at this point, but you can see how to build them all. I can put all my path building knowledge in that class and then just tell it what I want and it will give it to me.

Weight Watchers Mulligatawny

| Comments

I know -- I haven't had a recipe or talked about cooking for a long time. But this may make up for it -- Mulligatawny, but the Weight Watcher's version. One cup is one serving. We doubled this and will freeze the rest.

Weight Watchers Mulligatawny


  1. 2 T Canola oil
  2. 1 onion, finely chopped
  3. 1 carrot, chopped
  4. 1 celery stalk, chopped
  5. 1/2 green bell pepper, seeded and chopped
  6. 1 tart apple, peeled, cored, and chopped
  7. 1/4 cup all purpose flour
  8. 2 t curry power
  9. 1/8 t ground mace or nutmeg
  10. 1 whole clove
  11. 2 cups chicken broth
  12. 1 tomato, peeled, seeded and chopped
  13. 1 t lemon juice
  14. 1 1/2 cups diced cooked chicken breast
  15. 1/4 t salt


saucepan over medium heat, heat the oil. Saute the onion, carrot, celery, bell pepper, and apple until softened, about 5 minutes. Stir in the flour, curry, mace, and clove; cook, stirring 1 minute. Gradually stir in the stock. Add the tomato and lemon juice; bring to a boil, stirring occasionally. Reduce the heat and simmer, covered, stirring occasionally, 30 minutes. Put a stick blender in the soup and puree the chunks of carrot and apple that are left. Add the chicken and salt, heat to serving temperature.

Search, share, and cook your recipes on Mac OS X with [SousChef][]!

Adding Your Custom Fonts to Cygwin's XWin

| Comments

I decided to finally make the leap and install Cygwin's XWindows and run Emacs out of that instead of NTEmacs. There wasn't one big thing, but a bunch of little things, including:

If you read between the lines, you see a common theme -- control. In my entire Windows workstation, I have very little control over the environment. In my little Cygwin world, I have almost complete control.

I had installed and used Emacs within Cygwin/X before, but found that it was slow and clusmey. Now they've had a few years to work out the kinks and I have a much more powerful workstation. And so I tried it again. Yep, things are much better! However, I like some of the functionality of Emacs 22 but Cygwin doesn't have Emacs 22 -- they still have Emacs 21 as "stable" and Emacs 23 as experimental! So I jumped through the hoops to install the "unstable" Emacs 23 along with X-windows (XWin, the Cygwin/X world.)

And thus our story begins. Since I now have complete control on one part of my GUI and one of the things I'm picky about is fonts. I like to use [ProggyClean][]and, now, heck I can install it. So I downloaded it, move it to the right file, did the magic "xset fp rehash" and . . . nothing. Nadda. XWin couldn't find it.

I won't depress you with a play-by-play, but this is an overview:

What ended up working was that I added the following to the /usr/bin/startxwin.bat file just before the last command (an xterm, I believe):


%RUN% /usr/bin/xset +fp /cygdrive/h/.fonts &



[caption id="" align="alignnone" width="600" caption="Emacs using Proggy Clean"][![Emacs using Proggy Clean][]][][/caption]

"Emacs using Proggy Clean"