Latest Publications

Taking care of HTML comments in PHP

A little problem came up with some user submitted content on a platform I’m working with.

A form allows users to submit content with tinyMCE. If the content is pasted from MS Word, the source is then littered with HTML conditional comments that can have a detrimental effect on the the page that returns it.

After discovering what was going on, I thought that the best time to capture the offending content is when the text is submitted. Using a regular expression, I can capture the HTML conditionals as well as remove any unnecessary comments:


function clear_html_comments($html)
{
    return preg_replace('/<!--(.|\s)*?-->/', '', $html);
}

That’s it. Just pass in the content from tinyMCE and it should prevent any content being returns that is in HTML comments.

Getting Around the Sync Error: Google Outlook Sync Tool

I’ve been working with a client to migrate their email systems to Google Apps Premier, as most folks’ emails are being kept on their personal computers and there is a good chance of losing a chunk of work amongst other things.

The task for me was to personally help with uploading all of the disparate systems up to Google Mail, Calendar and Docs. We’ll also be moving some wiki content onto Sites over time but the main issue right now is that we need to get those emails up!

The Google Apps Sync for Microsoft Outlook tool is pretty good at getting everything working with Outlook directly, as well as uploading your existing emails.

Set up is straight-forward, but sometimes an error crops up that is commented in the forums and in the known issues page.

I found that the “Sync Errors” folder that is created doesn’t actually get synchronised. The easy fix is to either upload the folder with the Email Uploader tool, or simply create a label with the same name in Google Apps Mail. Once done, sync should continue to work.

rsync and the Hard Link Limitation

I’ve been setting up a new backup regime on a hosted server that I’m helping to maintain.

One of the key issues right now is that it is there isn’t a solid provided backup regime, so I’ve spent the day playing around with different Linux backup solutions trying to get to the bottom of a simple, yet robust way of backing up.

I like rsync, but the problem is that you can’t use it’s hard linking feature over secure shell. As such, incremental backups are a pain.

I was about to give up on it, and work out a convoluted tar process when it occurred to me that the hard links might still be possible.

And to that end, I wrote this script: (more…)

Life and Blogging is Hard

Plus.net have moved to the new CGI platform after some sort of disaster. As this was coming for almost a year, I’m shocked that the platform still seems in such a shoddy state.

This has meant that the site has been misbehaving for a few weeks. Most notably causing random Apache errors.

I think that it’s a wake up call to me that I need to get this blog living somewhere else. Letting it expand and breathe as it needs to.

Some of the way to that is getting a new hosting plan sorted out. I wanted to do this in an el-cheapo style by using SQLite instead of mySQL to power WordPress, but it seems like the database abstraction that it uses might as well be non-existant. mySQL or bust I’m afraid.

In a time when PHP provides a unified access library, and many frameworks have a respectable set of DB abstraction libraries – it’s frustrating to see the WordPress team get suckered into making new features the top of the development priority list, while failing to solidify or revisit programming fundamentals.

And what’s the point of having plugins at all if they don’t get approved in any way? After my trial with SQLite, I’m genuinely worried about any WP plugins now.

Moving soon folks!

How To Install Windows XP From the Hard Disk Drive

Installing Windows XP / 2003 from the hard disk drive is a bit of a bind, and I have had to do it a few times when there is no CD drive available.

To get it going – you need to have command line access to the target computer. In a situation where there is no CD drive, you can use WDS and a Windows RE WIM. I’ll not go into that right now, but here’s the command to copy the files to your target drive and install Windows onto it.

winnt32.exe /tempdrive:C: /syspart:C: /makelocalsource

Windows will start the first stage of the setup, and then will require a reboot. If setup carries on – then it was successful!

Quick Tagging and Renaming

Last week I recovered a friend’s mp3 library from a 2nd generation iPod. All was well except for that fact that any music put onto the iPod is given a random file name such as C00XY.mp3. Not helpful.

After scratching my head and thinking that we would have to rename most of the files manually, I started to look for re-tagging programs. A few were recommended on the internet but I found them to be too unwieldy or didn’t quite work right.

Thankfully, I discovered a lightweight tagging application called Ex Falso. A fairly simple to use tool which easily re-tags your music, or renames the files with much more ease than any others that I have come across. It only took a few minutes to read the tags of around 3500 songs and rename them all.

To install in Ubuntu, simply run the command:

sudo apt-get install exfalso

As an added bonus – it also fixed tags of .m4a audio files, meaning that preparing music to go on my iPod Touch in Linux is slightly easier. Wehey!