Working with the ODS templates and styles when batch processing
8th December 2008I ran into some trouble with creating new templates and styles while running a SAS job in batch mode. The cause was the user of the RSASUSER switch on the SAS command. This sets the SASUSER library to be read-only, and that is what is used to store new templates and styles by default. The fix is to switch these to another library to which there is write-access, WORK, for example. Here's the line of code that achieves the manoeuvre:
ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);
Apparently, the same change might be needed for stored processes too, so it's one to keep in mind.
Work locally, update remotely
4th December 2008Here's a trick that might have its uses: using a local WordPress instance to update your online blog. While there are plenty of applications that promise to edit your online blog, these need permissions to access the likes of xmlrpc.php. Along with the right database access credentials and the ability to log in remotely, adding the following two lines to wp-config.php does the trick:
define('WP_SITEURL', 'http://localhost/blog');
define('WP_HOME', 'http://localhost/blog');
These two constants override what is in the database and allow it to update the online database from your own PC using WordPress running on a local web server (Apache or otherwise). One thing to remember here is that both online and offline directory structures are similar. For example, if your online WordPress files are in blog in the root of the online web server file system (typically htdocs or html for Linux), then they need to be contained in the same directory in the root of the offline server too. Otherwise, things could get confusing and perhaps messy. Another thing to consider is that you are modifying your online blog, so the usual rules about care and attention apply, particularly regarding using the same version of WordPress both locally and remotely. This is especially a concern if you, like me, run development versions of WordPress to see if there are any upheavals ahead of us like the overhaul that is coming in with WordPress 2.7.
An alternative use of this same trick is to keep a local copy of your online database in case of any problems while using a local WordPress instance to work with it. I used to have to edit the database backup directly (on my main Ubuntu system), first with GEdit but then using a sed command like the following:
sed -e s/www\.onlinewebsite\.com/localhost/g backup.sql > backup_l.sql
The -e switch uses regular expression substitution that follows it to edit the input, with the output being directed to a new file. It's slicker than the interactive GEdit route but has been made redundant by defining constants for a local WordPress installation as described above.
An early glimpse of Ubuntu 9.04
27th November 2008Ubuntu development is so gradual these days that there's almost no point getting too excited about new versions. Its maturity means that updates aren't that much of an upheaval, and I must admit to liking it that way. Having a look at the first alpha release of Ubuntu 9.04, otherwise known as "Jaunty Jackalope", it appears that there isn't a change to that gradual, some may call it glacial, approach. The most significant change that I noted was the addition of an encrypted private area to your home user area. In the times in which we live, I can certainly see that coming in useful, though it may not set pulses racing in some quarters. OpenOffice is still at 2.4 and things don't appear very different on the surface at all. Of course, things like kernel changes and such like could be going on under the bonnet without many of us noticing it. Saying that, it played well with VirtualBox and I seem to remember virtual machine trouble with early builds of 8.10 so that can be taken as a plus point. I suppose that it is a case of wait and see before there is anything more obviously defining about 9.04. Anyway, they've got until April next year...
No disruption here
12th November 2008It was just over a year ago that I gave Linux a go after Windows XP gave me a torrid time of it. Since then, I have been able to work more than happily with it and have picked a few new and useful tricks along the way too. All in all, it has been a good experience and I have been able to resolve most of the issues that I have seen. The various Ubuntu upgrades along the way have been taken in their stride, too. Version 7.04 was the first one, with version 7.10 coming immediately afterwards. 8.04 went in equally seamlessly as did 8.10. Some may decry what they might perceive as the glacial nature of any changes, but the flip-side is that change can cause disruption, so my vote is for the more gradual approach, whatever others might think. In line with this, I haven't noticed too many changes in Ubuntu's latest release, and any that I have seen have been of the pleasant kind. Saying that, it's so much better than the contortions surrounding Windows upgrades. All in all, Linux is being kind to me and I hope that it stays that way.
Photoshop Elements 7 first impressions and technical issues
10th November 2008Lately, I have been playing around with Photoshop Elements 7, doing the same sort of things that I have been doing with Elements 5. Reassuringly, I can still find my way around, even if the screen furniture has been moved about a little. My Pentax K10D is recognised, and I am able to set the white balance to get sensible results. On the images that I was testing, things started to look too warm in the Cloudy and Shade settings, but that's all part and parcel of processing photos taken in early November. The results of my exertions look decent enough, and you can see them in a post on my hillwalking blog.
While I realise that Adobe has been promoting the ability to easily airbrush unwanted objects from images and enhance blue skies, there's no point having all of that if functionality available in previous versions does not work as expected. Thankfully, this is largely the case, albeit with a few niggles.
Since I have been working with the new Elements on a Windows XP SP3 virtual machine running in VirtualBox 2.04 on Ubuntu 8.10, I wonder if that contributed in any way to what I encountered. One gigabyte of memory is allocated to the VM. The files were stored in the Ubuntu file system and accessed using VirtualBox's functionality for connecting through to the host file system. File access was fine, apart from the inability to directly open a file for full editing from the Organiser, something that I have doing very happily with Elements 5.
In addition, I noted a certain instability in the application and using the hand tool to get to the top left-hand corner of an image sent the thing into a loop, again something that Elements 5 never does. Otherwise, things work as they should, even if I saw points to the need for an update to correct any glitches like these, and I hope that there is one. For now, I will persevere and see if I can make use of any additional functionality along the way.
Remove Revisions 2.2
3rd November 2008There is already a post on here devoted to version 1.0 of this plugin, which clearly tells you what it does. The new version will work with the forthcoming WordPress 2.7 (itself a release that's had a development cycle with such upheavals that it would make you want to watch from the relative safety of the sidelines) and has been made to be a little more user-friendly in its actions; in fact, it behaves more like any other plugin now.
SAS Macro and Dataline/Cards Statements in Data Step
28th October 2008Recently, I tried code like this in a SAS macro:
data sections;
    infile datalines dlm=",";
    input graph_table_number $15. text_line @1 @;
    datalines;
    "11.1           ,Section 11.1",
    "11.2           ,Section 11.2",
    "11.3           ,Section 11.3"
    ;
run;
While it works in its own right, including it as part of a macro yielded this type of result:
ERROR: The macro X generated CARDS (data lines) for the DATA step, which could cause incorrect results.  The DATA step and the macro will stop executing.
A bit of googling landed me on SAS-L where I spotted a solution like this one that didn't involve throwing everything out:
filename temp temp;
data _null_;
    file temp;
    put;
run;
data sections;
    length graph_table_number $15 text_line $100;
    infile temp dlm=",";
    input @;
    do _infile_=
    "11.1           ,Section 11.1",
    "11.2           ,Section 11.2",
    "11.3           ,Section 11.3"
    ;
        input graph_table_number $15. text_line @1 @;
        output;
    end;
run;
filename temp clear;
The filename statement and ensuing data step creates a dummy file in the SAS work area that gets cleared at the end of every session. That seems to fool the macro engine into thinking that input is from a file and not the CARDS/DATALINES method, to which it takes grave exception. The trailing @'s hold an input record for the execution of the next INPUT statement within the same iteration of the DATA step so that the automatic variable _infile_ can be fed as part of the input process in a do block with the output statement ensure that all records from the input buffer reach the data set being created.
While this method does work, I would like to know the underlying reason as to why SAS Macro won't play well with included data entry using DATALINES or CARDS statements in a data step, particularly when it allows other methods that using either SQL insert statements or standard variable assignment in data step. I find it such a curious behaviour that I remain on the lookout for the explanation why it is like this.
Harnessing the power of ImageMagick
26th October 2008Using the command line to process images might sound senseless, only for the tools offered by ImageMagick certainly prove that it has its place. I have always been wary of using bulk processing for my digital photo files (some digitised from film prints with a scanner) but I do agree that some of it is needed to free up some time for other more necessary things. With this in mind, it is encouraging to see the results from ImageMagick and I can see it making a major difference to how I maintain my online photo gallery.
For instance, making thumbnail images for the gallery certainly seems to be one of those operations where command line bulk processing comes into its own, and ImageMagick's own convert command is heaven sent for this one. For resizing images, all that's needed is the following:
convert -resize 40% input.jpg output.jpg
Add a spot of further shell scripting and even a dash of Perl and the possibilities for this sort of thing become clearer, and this is but the pinnacle of the proverbial iceberg. The -rotate switch will do what the name suggests, while there are a whole plethora of other options on tap. So long as you have Ghostscript on your system, conversion of graphics to Postscript (and Encapsulated Postscript too) and PDF files is possible with the -page option controlling the margin around the image itself in the resulting outputs. Unfortunately, portrait is the sole orientation on offer, yet a bit of judicious post-processing will turn things around. Here's a command that'll do the trick:
convert -page 792x612+72+72 input.png ps2:output.ps
For retrieving image metadata like its resolution and size, the identify command comes into play. The -verbose option invokes the output of all manner of image metadata, so using grep or egrep is perhaps advisable, especially for bulking processing with the likes of Perl. Having the ability to stream image metadata makes loading databases like MySQL less of a chore than the manual data entry that has been my way of doing things until now.
Fixing Alt-Click problems in Ubuntu-hosted VirtualBox Windows guests
24th October 2008
The Alt-Click keyboard-mouse combination is a very common way of working with various flavours of Adobe Photoshop. So, it was with some frustration that I couldn't use it while working in Photoshop Elements (still on version 5, by the way; the temptation of newer versions has not struck) on a Windows XP guest in VirtualBox on my main Ubuntu system.
A quick google later and a proposed solution was for me a surprising one: going to System -> Preferences -> Windows on the host OS and changing the setting of the Movement Key from Alt to Super (Windows key on many keyboards). That was enough to set all in order. It appears that a setting on the host operating system was preventing a piece of software running on the guest from behaving as expected. That's all in the past now that I have got my clone brush functionality back and can work as normal again.
Another way to control line breaks in (X)HTML
22nd October 2008While you can use <br /> tags, there is another way to achieve similar results: the   or non-breaking space entity. Put one of them between two words, and you stop them getting separated by a line break; I have been using this in the latest design tweaks that I made to my online photo gallery. Turning this on its head, if you see two words together acting without regard to normal wrapping conventions, then you can suspect that a non-breaking space could be a cause. There might be CSS options too, but their effectiveness in different browsers may limit their usefulness.