Jul 02

Here’s tip for something I worked out today. WordPress blogs generally have an RSS feed available for the comments on a post. This is handy for when you want to see other comments posted without having to remember to check back. The problem is many WP themes don’t provide a link to the feed. The solution is to add /feed to the URL of the post, so for this post the comment feed is at:
http://www.wezm.net/2008/07/02/comment-feeds-in-wordpress/feed.

May 23

I use vim coupled with the SuperTab plugin for my text editing and auto-completion needs. In some vim setups (E.g. Mac OS X) it is configured by default to search included files when completing words. This sounds like a useful feature but it turns out not to be. It has a habit of searching the include files of system libraries and modules, the keywords of which you rarely want. Its also quite a slow operation as it trawls through all the files. The solution is to add the following in your .vimrc file.

set complete=.,w,b,u,t

This is the same set of flags as the default except with the ‘i‘ option removed. See the help for the ‘complete’ option for an explanation of what each flag means.

Apr 24

I had the need today to read in a list of patterns from a file, expand them and then operate upon each file all from within a shell script. Apparently there is a shell built-in for csh, but I didn’t want to learn csh at that point. The eventual solution was to run an extra shell with the -c argument.

Example:

#!/bin/bash
FILES=`cat patterns.txt`
for pattern in $FILES; do
    bash -c "ls -l ${pattern}"
done
Mar 27

Strangely enough I had the need to determine if it was possible to create a valid but empty tar file. Turns out it is. The method varies slightly depending on your flavour of tar program, here’s how to do it on three of the big ones:

BSD
tar cvf empty.tar --from-file /dev/null

GNU (Linux)
tar cvf empty.tar --files-from /dev/null

Solaris
tar cvf empty.tar -I /dev/null

Now if you wondering why I would want this, here’s the explanation. I work on a batch processing system that processes files delivered from other systems. In some cases its necessary to wait for a file to arrive but give up after some time. In order to give up we copy and empty file (automatically) so that the processing proceeds normally. Ordinarily this is an empty plain file but for the system I’m working on I’m expecting a tar file, hence the need for an empty one.