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
Apr 06
Recently I wanted a to quickly lookup how to do something in sed. As headed for the man page once again I wished I had a quick reference on hand, like the Perl Pocket Reference I have. In a slight diversion I did some searching to see if there was a pocket reference for sed, there is, and as a bonus it covers awk too.
Armed with the knowledge that the sed reference exists I searched for bookshops in Melbourne to buy it from. This is where it became difficult. No one had it in stock and even if they did it would take at least a whole day to arrive if I had ordered it right then. It was here that I wished there was a delivery service for technical books that could see them delivered with the promptness and low cost of a pizza delivery.
The need for a technical book, in particular those that are mainly reference material tends to come about with a need-it-now urgency to satisfy whatever the pressing enquiry is. Typically the desired information is available via online documentation or a simple Google search however I tend to prefer references to be in dead tree form and I don’t believe I’m alone in this.
Given the relatively huge lead time in actually getting a reference book delivered, the online documentation usually wins and the books remain unordered. For a nominal fee I think if it were possible to have a book delivered within the CBD in an hour or so from ordering many more books could be sold to satify the immedaite need for the reference.
Now an hour is a long time to wait if you need to look something up now, but it would allow you to look up whatever it is you’re after online then for the rest of the day refer to your new reference that arrived a little later. So bookstores, pizza style delivery for technical books, who’s up for it?
On a side note, its extremely lame that the Australian Borders website doesn’t have the ability to search for books they stock.
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.