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.
I’ve make a bookmarklet out of David Gouch’s Javascript implementation of John Gruber’s Title Case Perl script.
Drag this link to your bookmarks bar: Title Case
Seems to work ok in Firefox, IE 6 has issues.
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.
Randall Munroe proposed the awesomely geeky idea of geohashing via the xkcd comic and blag recently. The idea basically involves using the MD5 hash of a date combined with the opening value of the Dow Jones Index for that date to derive a latitude and longitude relative to a (generally your own) location.
However there is a problem for those of us residing in Australia (and other locations with a time zone significantly different from EST). With the Dow Jones Index operating on US time its not possible to determine a geohashed location in Australia until about 23:00 AEST for a given date. No doubt others have thought of this but I suggest we use the All Ordinaries Index instead. With that out of the way we just need some enterprising sole with some spare time to implement a version of the map based on this.
Update: More info on geohashing in Melbourne on the Visible Procrastinations blog.
Another Update: Using the Dow on the weekend works well though. As over the weekend everyone is more or less synced to the same index.
Final Update: The xkcd blag has a follow up article that clarifies the behaviour for Europe, Asia and Australia. It boils down to using the previous day’s Dow Jones Index.
Can people please stop using the ‘feed:’ URI scheme for links to feeds on web pages. Its annoying and unnecessary.
From what I can tell this URI scheme was proposed around Dec 2003 as an unofficial pre-draft RFC. The reasoning behind the proposal was:
…to provide a straightforward way for end users to subscribe to the data feed for a particular online resource while browsing the World Wide Web. The expectation is that clicking on a hyperlink that points at a “feed” URI will cause the Web browser to invoke the specified handler for the “feed” URI scheme which SHOULD provide the user with information about the data feed as well as the possess the ability to subscribe to the feed.
Fast forward to 2008 and all the major browsers have support for discovery of feeds specified by the link tag and a user interface to access them. Additionally they are able to auto-detect a feed when specified with the normal http URI scheme. With the built in support the browser is able to launch the appropriate feed reader on the system, be it within the browser or an external application; thus removing the need for the URI to be specified with the ‘feed:’ scheme.
Continue reading »
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
For my current software project I have the need to decode MP3 files for the purpose of producing an audio waveform. It doesn’t need to be overly accurate as the decoded samples will be displayed, not played. However it does need to be fast, as a typical use case for the application will be MP3 files of around 100Mb (full length CDs). The application is for Mac OS X, although the results of my testing below could be useful for other platforms.
Assisted by a code sample from Apple I wrote an initial version of the decoder that would read the source MP3 file and write the raw linear PCM data out to a file. I did this using the Core Audio framework built into Mac OS X. Once the program was working I tested it against some sample files and came to the conclusion that 4 seconds to decode a 3 min track was great but over 100 seconds for a full length CD, not so great.
I did some searching and came up with two other libraries that seemed well suited to the task of MP3 decoding, they were mpg123 (libmpg123) and MAD (libmad). mpg123 had claims of being very fast, mad claimed it was very accurate.
Methodology
I built the two additional libraries with the default configuration options, except for libmad, which I added the --enable-speed option. With the help of example code I made programs out of each that were comparable to the first version for Core Audio. I.e. MP3 file in, 16-bit Linear PCM audio samples out.
To provide a benchmark I wrote a script that would run each of the three programs against a source MP3 file. Each program reported the elapsed time (via time(3)) and the processor time (via clock(3)) when it finished decoding. The programs were run one after another on the source file 10 times. Their PCM output was written to a new file for each invocation.
Continue reading »
I snapped this with my my phone whilst I was shopping at Safeway last Sunday. It seems the Australian Women’s Weekly are Linux fans or aren’t aware that they may be infringing Larry Ewing’s copyright. Who wouldn’t want a Tux cake though.
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.
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.
