Recently I’ve been looking at using the NHS Business Service Authority’s Dictionary of Medicines and Devices for my own nefarious purposes. The Information (data that has meaning) is distributed as XML files.
I haven’t come across a database design for the data so I’ve come up with my own and to import the data into it I’ve been using PHP’s XML DOM functionality (a different technique than I described in my earlier post …). Because the files are published according to specified standards I decided to save myself some programming time by adopting their terminology for my database design so that I could write very little code to prepare the data and insert it into the database.
However, I wanted to test that the nodes I was expecting were what was being prepared for insertion into the database. One reason it may not is if the XML file has been reformatted with indents (mentioned in this post) What I needed was an equivalent to SQLs IN statement. The solution is to use PHP’s in_array() function like so…
$desirable_values = array(’CD’, ‘CDDT’, ‘CDPREV’, ‘DESC’);
if ( in_array( $variable_to_test, $desirable_values) ) {
//Do Your Stuff
}
It saves you having to test if your variable is equal to each of the variables you want to test thus making your code cleaner and shorter.
Removing the Tilde (~) Character From the Address of Locally Hosted Sites on Mac OS X
Internet, Mac No Comments »I’ve been working on some sites locally on my Mac but by default the files are stored in a directory in the individuals user account called Sites and the address you’ve got to type into your browser is http://localhost/~username/etc… this annoyed me because I didn’t want to have to type the tilde character in the address and also that I had to have the files showing in a subdirectories of my user. I couldn’t be doing with it, I wanted to have addresses like ‘http://localhost/subdomain/’ and the solution of course is to use symbolic links.
I’ve recently registered for accesss to the NHS’s dictionary of medicines and devices (dm+d). This was primarily to see what format the data was stored in and then to see if there was a way of utilising it in a cool webapp.
I downloaded the current release (its updated weekly) and unpacked the 5MB archive to reveal some XML and related files. Some of the files are huge (up to 32MB each and ~70MB in total) and there was no way a traditional program was going to mannage. I tried a few in fact and they all devastated my 2GB RAM and were generally unusable.
Time for a command line solution… VIM the open source text editor. Its extremely powerful and customisable but using it takes a little getting used to. VIM was able to open with only a slight delay and navigate these huge files. The next problem for me was being able to read them.
In theory it shouldn’t matter what indenting there is in an XML file as it doesn’t contain any data but I find its a lot easier to read the files if they’re ‘cleanly’ indented. I began wondering how I was going to solve the problem and thought of a few ideas… a script (PERL, PHP, shell, other…) but none of those came to fruition. After some searching I came across libxml.
You can download and compile from source if you wish but I decided to download a pre-built version from explain.com it was pretty good and another page I came across on entropy.ch explained how to use it within Vim to indent my files super quick.
Here’s what you do…
- To format type this sequence
- :%!xmllint –format -
- Or mark the area visually and then type
- !xmllint –format -
…what I know now!
Today I’ve been having a conversation with my mother and we were talking about relationships and personality. We’re both of the opinion that its futile to attempt to change yourself in order to please someone else. If only I knew then, what I know now cropped up.
A paradox. The epiphany can never be true. I find in conversation that this phrase usually refers to attitudes and not knowledge. I have now the attitude I do only because of the experiences between then and now so it becomes impossible to ever have the vogue attitude without the requisite experience.
Jase
I want to hold you close to me.
I want to feel your warmth embrace me.
I want to feel your heart beat.
I want to smell your scent, sweet.
Your touch is all I need.
Your attention my only greed.
When all I wanted was for you to stay.
It wasn’t right, now, you’ve gone astray.
I recently got hold of a Hewlett-Packard Mini Note 2133 but couldn’t get it to hibernate at first. I’m a huge fan of hibernation I’ve always used it because I think it makes sense to have the computer in a useable state as left more quickly.
Normally when its enabled there’s a hibernate tab to the Power Options Properties where you can enable and disable the feature. The tab only appears if the hibernation facility has been switched on and that is done with the following command.
- Open the Command Prompt
- Start > Run > “cmd” > OK
- To Turn Hibernation On
- powercfg.exe /H ON
- To Turn Hibernation Off
- powercfg.exe /H OFF
Now with hibernation turned on I’m a happy bunny again.
Today I came across an error whilst trying to install Microsoft Office 2007 on an XP machine with service pack 3. The error occured part way through the installation process and caused the installer to roll back and give the following message.
Microsoft Office 2007 encountered an error during setup. The Windows Installer service cannot update one or more protected Windows files.
Well that’s not very useful is it! I did a bit of searching as you do when you have a problem and came across the solution. Read the rest of this entry »

I’ve been meaning to try Joomla for some time and a friend mentioning it last night was the impetus for me to give it a go. I downloaded the latest stable version just now and decided to give it a go.
I was very impressed by the installation script and how it guides you through the installation process with handy guidance, however, I feel it falls down in one area.
Read the rest of this entry »

Recent Comments