January 2006

Accept What You Eat

I can’t stand people who can’t accept the realities of what they eat. If you can’t eat a dead cow and admit to yourself that it is cow flesh, then you probably shouldn’t be eating it.

When I ate beef, I had no problem with the truth about what it was I ate. I’m sure, however, that every one of us knows one of those people who tries to shush anyone who mentions the piece of meat having once been an animal.

I’m not asserting that every time we eat we have to consider every disgusting reality of how the food was prepared, transported, or created, but I think you need to at least have come to grips with the general idea that your food was an animal if you are going to eat it. There’s obviously an ethical question there: whether or not it is morally right to support the killing of animals for consumption. And while I’m not going to try and tell anyone what the right answer is, it’s not acceptable to simply avoid asking.

Uncategorized

Comments (0)

Permalink

dpkg Assertion `dependtry <= 4′ failed

If you happen to come across the following error while using dpkg (or apt-get):

dpkg: ../../src/packages.c:191: process_queue: Assertion `dependtry <= 4' failed
.
E: Sub-process /usr/bin/dpkg exited unexpectedly

The solution is as simple as:

# dpkg --configure -a --force-depends

According to Antti-Juhani Kaijanaho:

There are two known triggers for that bug:

  * A package depends on itself.  (This is a bug in the package.)

  * There is a dependency loop which involves a virtual package.
    (This would be valid use of the dependency fields, if this bug did
    not exist.)

Uncategorized

Comments (0)

Permalink

Adding Emacs / PyBlosxom Support for a Custom Format

In PyBlosxom, blog entries are stored in regular files rather than in a database. This means that I can write my entries in emacs (hurrah). PyBlosxom can handle posts in any format it has a parser for.

The simplest parser removes the metadata from the beginning of the file and passes the remainder of the file directly to the output webpage. Ergo, in the most simple format, the entries should be written in html (with a basic text header). More complicated parsers could be used for formats like xml or wiki markup. PyBlosxom uses a file’s file extension to determine what format the entry file is in.

For some unusual reason PyBlosxom associates the simple pass-through parser with .txt files (wouldn’t it make more sense to use .html?). In any case, I decided that I wanted to add my own file extension, .blog, so that I could easily distinguish my blog posts from other text files and html files on my system and so that my editor could treat the files specially.

The first step was to make PyBlosxom recognize the files as entries which it knows how to parse (anything PyBlosxom doesn’t have a parser for will simply be ignored).

On line 79 in pyblosxom.py, is a block of code which I modified as follows:

# entryparser callback is run here first to allow other plugins
# register what file extensions can be used
data['extensions'] = tools.run_callback(”entryparser”,
                {’txt’: blosxom_entry_parser, ‘blog’: blosxom_entry_parser},
                mappingfunc=lambda x,y:y,
                defaultfunc=lambda x:x)

This is sufficient to make PyBlosxom treat .blog files just like .txt files.

The next step was to make the files easier for me to write. First off, emacs should open the files in html-mode. Adding the following bit of code to my .emacs file accomplishes this task:

(add-to-list 'auto-mode-alist '("\\.blog\\'" . html-mode))

The next step requires a tiny bit of background information on the format of PyBlosxom entries. The basic format of a PyBlosxom entry looks like this:

Title Of Entry
#metadata-1 value-1
#metadata-2 value-2
(...)
#metadata-N value-N

Post line 1.
Post line 2.
(...)
Post line N.

Note: the blank line is not required, but it makes the file more (human-) readable.

I always use the same two metadata lines: #postdate (from my metadate.py), and tags (from Joe Topjian’s tags.py). Because of this there are a few lines which are similar across all of my blog posts. Why not have my editor enter these automagically, including entering the current #postdate (in the format YYYY-MM-DD HH:MM)? How convenient that emacs provides a mechanism just for this purpose: skeletons.

I wrote the following code and added it to my .emacs file:

(define-skeleton blog-entry-skeleton
  "Inserts a PyBlosxom-style blog entry skeleton into the current buffer.
This only makes sense for empty buffers."
  "Title: "
  str | "Untitled Entry" \n
  "#postdate " (insert-date-and-time) \n
  "#tags " ("Enter a tag: " str ",") '(delete-backward-char 1) \n \n
  "<p>" _ "</p>")

When executed, this skeleton prompts the user for a title (if the user simply presses RET it defaults to Untitled Entry), repeatedly prompts the user for tags (keywords) (until the user simply presses RET), enters the current #postdate automatically, and the leaves the cursor inside a new <p>.

The final touch is to make the skeleton automatically execute when a new .blog file is created:

(eval-after-load "autoinsert"
  '(add-to-list 'auto-insert-alist '("\\.blog\\'" . blog-entry-skeleton)))

It’s like magic!

Uncategorized

Comments (0)

Permalink