Newsflash: The promised new version of M-Space has now finally been launched. More details to follow soon in the blog, but why not take a look for yourself.
Over the past few days I've found small but useful programming tasks to do with 3 different programming languages, all of them (the languages, not the tasks) beginning with 'P'.
I've recently been doing a fair bit of website work, both on my own site and on the church website that I maintain. Both of those sites are largely driven by PHP, mostly fairly simple stuff with one or two slightly fancier bits thrown in. The most recent change to the church website, involving some of the gnarliest PHP work I've had to do, is an update to the scripts driving the songs database page so that it's possible to select which year you look at songs from. Last year it wasn't a problem since 2007 was the first year that the database appeared on the website. Since today is the first day of services at the church this year, the 2008 database doesn't yet have any songs in it but that situation will be changing in the next day or so. The database itself is in XML, with PHP used to extract the data and turn it into a webpage according to the preferences specified by the user.
While I use a PC running Linux (most of the time) at home and a PC running Windows XP at the church office, my other job entails the use of a Mac. One of my favourite things about MacOS is the terminal emulator, which enables me to work using text-based unixesque commands that I generally find a lot more satisfying (as well as efficient) to use than any graphical interface. A couple of days ago, I was tidying up some files from various meetings over the past few years, and decided the time had come to institute a properly systematic naming convention for minutes, agendas and other documents. In the past I've tried to be systematic, but the system has varied quite a bit with the result that it had become quite difficult to trawl through the collection of documents to find the one I was looking for. In Linux, I would run the 'rename' command, using a simple regular expression to describe a collection of filenames under one system and convert them to the new standard format. Unfortunately the Mac OS version of rename seems to be altogether more simplistic and entirely lacking in support for regular expressions. Undaunted, I decided to try and knock together a perl script to do the renaming I wanted (perl being the obvious choice since regular expressions are an integral part of the language and there is a fairly complete implementation installed on my Mac). While Googling for hints as to how to proceed, I came across a rename script by Larry Wall, the creator of perl, which seems to offer all the core functionality of the Linux command and certainly more than enough to get my job done. Granted, this particular bit of programming wasn't done by me in the sense of actually writing any new code (other than the regexes needed to describe my file names), but it embodies the important programming precept of Don't reinvent the wheel. Incidentally, I'll probably be blogging more about regexes (i.e. regular expressions) soon, as the more I learn about them the more I consider them a really groovy and decidedly useful tool.
My third programming task for the week was a script to facilitate publishing blog entries. The individual posts for this blog are kept as separate text files and the directory structure in which they reside provides the categories for the blog. In order to be able to preview the files locally and then upload them when they are ready but have them appear on the blog at some appropriate future date, it's necessary to slightly change the filenames either before or after uploading them, which makes it slightly tedious to do the job by hand. I decided to write a script to automate the process as far as possible, so that I only have to invoke the script and pass it the source filename and it will take care of working out the correct target filename, opening an ftp connection, switching to the appropriate directory and uploading the file. For this particular programming task I turned to Python, largely because my Python reference books were nearer to hand than my perl ones and also because I'm probably a bit less rusty at it. The script I've put together so far seems to work ok, although it doubtless could be tightened up a little bit.
Perhaps tomorrow I should dig out the Prolog textbook I have stashed away somewhere, or revisit my first post-BASIC programming language, Pascal, just so I can keep the trend going...
: Go to
blog home : Go to
M-Space home