Latest Posts

Next 10 posts:

Dreaming in Code

I recently picked up Dreaming in Code which chronicles the Chandler project while investigating the general difficulties of building software on time and under budget. I'll give the book an enthusiastic two thumbs up, with the caveat that the intended audience is the lay public, not those of us who write software daily.

My favorite chapter, Engineers and Artists, opens thusly:

From a panel of experts assembled at a conference on software engineering, here are some comments:

"We undoubtedly produce software by backward technologies."

"Particularly alarming is the seemingly unavoidable fallibility of large software, since a malfunction in an advanced hardware-software system can be a matter of life and death."

"We build systems like the Wright brothers built airplanes -- build the whole thing, push it off a cliff, let it crash, and start over again."

"Production of large software has become a scare item for management. By reputation, it is often an unprofitable morass, costly and unending."

"The problems of scale would not be so frightening if we could at least place limits beforehand on the effort and cost required to complete a software task... There is no theory which enables us to calculate limits on the size, performance, or complexity of software. There is, in many instances, no way event to specify in a logically tight way what the software product is supposed to do or how it is supposed to do it."

...

"Some people opine that any software system that cannot be completed by some four or five people within a year can never be completed."

I nodded along in agreement with each quotation. The author goes on to explain that the conference that produced the words above took place in, ... wait for it... 1968. The event was organized by NATO to address, in their words, "The Software Crisis".

Depending upon how your coding went today, you'll either be heartened by that, or depressed at the state of the field.

I take back my caveat, the book will entertain and provide solice to professional software people. And it should be required reading for anybody thinking about getting into software.

In case you didn't know it already, Rosenberg reminds us, software is hard. Yes it is, yes it is.

Technorati tags for this post:

Re: Classical learning curves for common editors

While I'm on my Vim theme - here's a set of graphs showing learning curves for common editors.

Hilarious!

Technorati tags for this post:

Multi-file Editing in Vim 7.0

Vim supports editing many files at once. That's a great feature for programmers like me. I can copy and paste text between files, search for identifiers in other files, and view 2 (or more) files on one screen. Vim provides copious commands to list, add, delete, cycle through, and split buffers. And then Vim 7.0 comes along and adds tabs to the mix.

Help! I'm drowning in options.

I find myself wishing for a simpler model for multi-file editing. Maybe a tab-per-buffer model where you could glance at the tab names to know which buffers are open. But why give up splits? I use :stselect <ident> to follow tag references all the time. All I really want to do is know what files I have open, and move between them without wrecking my tab and window layout.

To help untangle these options, let me summarize vim's data model - the primary elements are buffers, windows and tabs.

Buffers

A buffer is a file that has been loaded into memory for editing. A buffer is modified during your editing session but isn't saved to disk until you do :w. New buffers are created with :e <filename>.

The :ls command lists all my buffers. I often rotate through buffers with :bn (buffer next). You can change to a specific buffer with :b<buffer number>, but I find that tedious, as you first have to use :ls to find the buffer number. Plugins like bufexplorer and minibufexpl can make switching buffers more intuitive.

Windows

A window is nothing more than a view of a buffer. Multiple windows can view one buffer so edits in one window are displayed in all windows on that buffer - try :split and make some edits. But more commonly, you use windows to view different buffers at the same time

I tend to use windows ephemerally - I'll use a split command to quickly reference another file and then close the new window. Programmers like to be able to view lots of text at once, and windows cut down on viewable lines.

I also find the stock commands to flip between windows cumbersome so I have mapped <leader>w to Ctrl-W w, which lets me toggle through the window list.

Tabs: new for Vim 7.0!

A tab is a full-screen collection of windows. Tabs let you partition your windows into any scheme you like. A 'tabline' at the top of the vim window lets you know which tab you are in. :gt moves you to the next tab. Sometimes I prefer one tab per buffer (try :tab sball), or you could have a C header file and its implementation per tab.

Frustrations and switchbuf to the Rescue

All this brings me to my problem - I have too many ways to move between buffers. The :ls command lists all the buffers and their buffer numbers; :b<number> replaces the contents of the current window with the requested buffer; :gt moves to the next tab; and I configured <leader>w to move to the next window (within a tab). That's a lot of options.

Generally, I want a way to move between 'files' without disturbing my current window and tab layout. As I finally learned, a combination of :sb and switchbuf makes this possible.

The :sb <buffer> (split buffer) command usually opens a new window with the requested buffer. You can give the command a buffer number or a filename. With the set switchbuf=usetab option, you can tell vim to first search the tab and window list for the requested buffer - if the buffer exists is in a window or tab, the focus goes right to that window. The :sbn (split buffer next), when used with switchbuf, lets me flip through the list of my open files.

Problem solved!

Technorati tags for this post:

Vim 7.0 Is Here

Vim 7.0 has been released and I'm ever so pleased. I've been waiting for the tabs feature for a long time. Here's the release announcement.

Yes, I'm serious. This is the sort of thing I get exiced about.

Technorati tags for this post:

Creative Commons Metadata

This site is licensed under a Creative Commons Attribution License, and I wanted to mark each page to somehow indicate that fact. CreativeCommons.org recommends that we mark our pages using RDF data embedded in our HTML (commented out). However, embedding the RDF in each page has a few downsides:
  1. It increases the size of each page by a several hundred bytes.
  2. In xhtml pages, it potentially hides the copyright information from xml parsers.
As an alternative (which I didn't invent, I'm just describing), I link to the copyright information with metadata attributes to indicate its role. The pages on this site use 2 methods of specifying the copyright. In the <head> section, I included a <link> to the copyright URL with a rel="copyright" attribute. The copyright link type is defined in HTML4. For example:

<link rel="copyright" href="http://creativecommons.org/licenses/by/2.5/" />

The second method can be used within the body of the document. My footer section includes a link to the CC license. I added a rel="license" attribute to that link. The license relation is a common microformat.

To guarantee that search engines understand the licensing of my site, I ran a few of my URLs through Creative Commons License Validator tool. Everything checks out!

Finally, I also wanted my RSS feed to be covered by the CC license. There is a Creative Commons RSS Module defined for this purpose: you insert a


<cc:license>http://creativecommons.org/licenses/by/2.5/</cc:license>

line into the <channel> section of your feed. I use XML::RSS to generate my feeds (this is a mod_perl/HTML::Mason site) to generate my feed, so I added code like this (new code is bolded):

my $rss = new XML::RSS (version => '1.0'); 

# add the creative commons namespace
$rss->add_module(prefix=>'cc', uri=>'http://web.resource.org/cc/');

$rss->channel(
       title        => "littleredbat/mk: blog",
       link         => "http://www.littleredbat.net/mk/blog/",
       description  => "Matt Keller's Blog",
       dc           => { language => 'en-us', },
       cc           => { license => 'http://creativecommons.org/licenses/by/2.5/', },
     );

There you have it - my site has been CreativeCommonsIfied.

Technorati tags for this post:

Redesign!

It's looking rather fresh around here, isn't it? Perhaps it was the spring weather that brought it on, but I've reworked the xhtml and css underlying this site.

Here's what's new:

  • Fresh new colors!: blue, green and red. The header graphic is always going to be in black and white to allow maximum flexibility in color choice.
  • New header graphics: black and white images that tickle me.
  • Site menu: Where are you? You're either Home, in the Blog, in the Articles, in the Photos, or at the About page. The site menu will let you know.
  • Variable sidebar: the sidebar's contents now change with the section.
  • Search w/ Google: as much as I like coding, it's hard to beat google at the text indexing game.
  • A Fluid layout: go ahead and resize your browser window or increase the text size! The site should be pretty accomodating.
  • Better source ordering: the "contents" of a page now show up before the sidebar in the html source. This is nice for text-based browsers or folks who don't have CSS.

The design was partialy inspired by Tim Bray's site. I liked his clean look.

Enjoy!

Technorati tags for this post:

What I Believe But Cannot Prove

For a fantastically stimulating afternoon, I recommend drinking a pot of coffee while reading What I Believe But Cannot Prove.

I especially enjoyed the hopeful comments of Carlo Rovelli and Lee Smolin's thoughts on Quantum Mechanics.

Link to story

Technorati tags for this post:

How to fix Subversion errors after upgrading your Berkeley DB library

After a routine "apt-get upgrade" of Debian testing, I found myself unable to use my Subversion repository. I got an error message when trying to commit a file:

svn: Berkeley DB error while opening environment for filesystem db:
DB_VERSION_MISMATCH: Database environment version mismatch
svn: bdb: Program version 4.3 doesn't match environment version

A note from the Subversion FAQ had this to say:

After upgrading to Berkeley DB 4.3, I'm seeing repository errors.

Normally one can simply run svnadmin recover to upgrade a Berkeley DB repository in-place. However, due to a bug in the way this command invokes the db_recover() API, this won't work correctly when upgrading from BDB 4.0/4.1/4.2 to BDB 4.3.

Use this procedure to upgrade your repository in-place to BDB 4.3:

  • Make sure no process is accessing the repository (stop Apache, svnserve, restrict access via file://, svnlook, svnadmin, etc.)
  • Using an older svnadmin binary (that is, linked to an older BerkeleyDB):
    1. Recover the repository: 'svnadmin recover /path/to/repository'
    2. Make a backup of the repository.
    3. Delete all unused log files. You can see them by running 'svnadmin list-unused-dblogs /path/to/repeository'
    4. Delete the shared-memory files. These are files in the repository's db/ directory, of the form __db.00*

The repository is now usable by Berkeley DB 4.3.

As the instructions note, you need a copy of subversion linked with a pre-4.3 version of the Berkeley database library. Subversion uses Berkeley via the APR Library. So we need to install appropriate verions of Berkeley, APR and Subversion.

My notes are below. Note that I installed the APR and Subversion software into a local directory (/home/mk/proj/svn_db/local in my case). Also, my Subversion repository is in /data/svnroot.

# export LD_CONFIG_PATH=/home/mk/proj/svn_db/local

# wget 'http://downloads.sleepycat.com/db-4.2.52.tar.gz'
# tar -xvzf db-4.2.52.tar.gz
# cd db-4.2.52
# cd build_unix
# ../dist/configure
# make
# make install

# wget 'http://archive.apache.org/dist/apr/apr-0.9.5.tar.gz'
# tar -xvzf apr-0.9.5.tar.gz
# cd apr-0.9.5
# ./configure --prefix=/home/mk/proj/svn_db/local
# make
# make install

# wget 'http://archive.apache.org/dist/apr/apr-util-0.9.5.tar.gz'
# tar -xvzf apr-util-0.9.5.tar.gz
# cd apr-util-0.9.5
# ./configure --prefix=/home/mk/proj/svn_db/local --with-apr=/home/mk/proj/svn_db/local --with-berkeley-db=/usr/local/BerkeleyDB.4.2/

# make
# make install

# wget 'http://subversion.tigris.org/downloads/subversion-1.2.3.tar.bz2'
# tar -xvjf subversion-1.2.3.tar.bz2
# cd subversion-1.2.3
# ./configure --prefix=/home/mk/proj/svn_db/local --with-apr=/home/mk/proj/svn_db/local --with-berkeley-db=/usr/local/BerkeleyDB.4.2/
# make
# make install

# su
# /home/mk/proj/svn_db/local/bin/svnadmin recover /data/svnroot
# tar -cvf ~/svnroot_backup.tar /data/svnroot

Then I executed steps 3 and 4 from the FAQ. At this point, I was able to commit files to my repository again.

Link to story

Technorati tags for this post:

Human, All Too Human

New security vulnerability! As seen on Bruce Schneier's Blog: Human's aren't secure. Ha!

Link to story

Technorati tags for this post:

Food and Class

Accidental Hedonist (what a fantastic site!), turned me on to an excellent article about food and class. The Slow/Organic/Good food movement does have a class problem. The article ponders the problem and possible solutions. Also, buried within the comments to the article, I found a link to Growing Power which looks like a fantastic org.

Link to story

Technorati tags for this post:

« earlier :: later »