Archive for March, 2007

Mysql & ORDER BY with an Array

On one of our sites, Find Derby, I wanted a way to expand the listings so that categories with low numbers of entries would include listings from other towns. Since they include postcodes and we have a database to convert a given postcode to national grid coordinates, calculating which the nearest towns are and therefore creating the mysql query was easy.

It was only after I’d done it that I thought of a problem. Since I was using

... ORDER BY RAND()

it meant that listings from other towns were being listed before ones from that town. Ideally it should list them with that towns first and then those from other towns next.

Turns out that the solution was fairly simple using the FIELD function:

... ORDER BY FIELD(field_name,'town1','town2','town3');

Simple and useful!

Time to switch to a Mac

Well it’s only 6 months until my birthday and 9 months until Christmas so I’m knocking together my birthday/xmas list. Top of the list is going to be a MacBook Pro. There’s a couple of reasons for this:

  • Portability
  • Security
  • Style

As far as portability goes, I’m not fussed about weight, dimensions or battery life when it comes to choosing a laptop since I don’t do that much travelling, I’m usually not too far from a power point and I’d rather have a full sized keyboard than a laptop that would fit in my pocket.

What I am more concerned about is being able to do some work wherever I am. For me this means being able to write a PHP script, test it on a development server running L.A.M.P and then finally uploaded to one of our production servers. This is easy enough to get up and running on a Windoze laptop as there are XP versions of the W.A.M.P components (and for Vista too) but the problem is that a lot of what I develop interacts with the Linux operating system in some way.

For this reason I usually need to be on a network with a Linux box. If I had a MacBook Pro, I could just turn it on wherever I was, have all my files permenantly stored locally running on L.A.M.P. so I can develop, test and then use whatever internet connection is near by to upload them and then run a quick live test. Simple.

The other good thing is that there are Mac versions of all the major bits of software I use (FireFox, Dreamweaver, Fireworks, … iTunes) and for the few bits that don’t have Mac versions, there’s something that’s easily as good if not better. Perfick.

As far as the second point goes, the only reason I can think of to upgrade to Vista and finally get away from XP is security. Apparently Vista will be a lot better than XP, but it’s still going to be the focus of every nasty thats created. Why not switch to something that is not only based upon a secure operating system to start with, but has been improved upon as well.

Finally, style. This is a bit of a no-brainer. Considering they are a computer company in essence, there’s got to be very few companies in the world that can claim to be as stylish. People don’t buy iPods because they prefer the AAC format after all. And yes, Vista might be full of new eye candy, but even after ditching the playmobile themes Microsoft will always be playing catch-up with Apple.

Time to start saving!

Automatically complete forms

As I’ve mentioned many times before, we’ve got several thousand domains. This weeks boring, monotonous task was to alter the DNS settings for all the ones we don’t use so they point to one of our new servers. With 1and1, this involves going into the Control Panel and then clicking on the DNS settings and entering the new IP address for it. Easy.

Well, it would be if 1and1′s “Award Winning” Control Panel wasn’t so useless for people with more than a few domains, and forced you to do them one at a time. Luckily, that’s where the FireFox extension, FireForm comes in. I know that the Google Toolbar will let you automatically fill in forms, but it’s only intended for filling in your standard information like name and address.

The good thing about FireForm is that you can create profiles and then customise them to fill in any form fields you want. This is brilliant for 1and1 as a quick look at the page source lets me set up FireForm with the IP address fields and the IP address of my server. Brilliant, this should save me about 12 hours over the next few days plus I can watch repeats of TOp Gear at the same type as I don’t need to type now!

cancelling 1and1 domains

Once again 1and1′s control panels have annoyed the crap out of me. This time it was when I wanted to cancel a few domains that we didn’t need any more since they had the year as part of the domain name.

It basically comes down to the fact that we have over a thousand domains in a single package and so when I went to contract.1and1.co.uk to cancel them, I scrolled through to page 137 of 156 and it wouldn’t let me procede to the next page! Very annoying.

After that I chose another package with less domains, got half way through choosing the domains I wanted at which point it decided to log me out as I’d been logged in for a whole hour!

At times I really hate 1and1

Free solution to eliminate spam

One of the disadvantages of being a Web Developer / Sys Admin is that my email address is published on a lot of our websites. As we have over 4000 domains this means that I end getting quite a lot of spam!

Last week I had a few days off and when I got back on day four to check my email, I had about 3500 emails, most of which had to be spam. Outlook’s spam filter took care of about half and the few rules I’ve set for common, easily identified spam got rid of about a third of the rest. This still left me with over 1000 messages to sort through. Annoying…

After I’d done this I decided to take a two-pronged approach to making sure this didn’t happen again. First, I went to all our major sites and replaced every email address I could find on them with a peice of JavaScript that uses

document.write()

within a function to write the email address after the page loads. This should stop our email addresses from ending up on any more spam lists.

The next step was to take all the catch-all email accounts we have and instead of forwarding them all to my real email addresses, forward them to the best FREE Spam Filter in the world, Gmail. This allows me to run them through Gmail’s spam filter and then forward them on again to my real email account. Genius.

This second change means that I’ve gone from 200 spam messages getting into my Inbox every day to about a dozen. Perfick!

Read the Vista Home EULA!

Just in case you were planning on getting a copy of Vista Home and you upgrade your own PC every now and again, beware and read the EULA…

Microsoft have now decided to make a few changes in EULA (which no-one reads) and hope no-one will notice (which we won’t until it’s too late) which means that if you buy a brand spanking new PC with an EOM version of Vista on it, you can only transfer the licience for that copy of Windows to another PC only once.

This might not seem like a problem at first glance but there are a couple of points to remember:

  • Hardware upgrades will cause a New Machine event
  • Windows Activation is now mandatory

The firat point is most important for those who upgrade a lot as a year down the line, swapping out the hard disk and adding more RAM could be enough to cause a New Machine point. A year later you might want to replace the MOBO and CPU and this might trigger another event but due to the terms of the EULA, means your copy of Windows is now invalid. And knowing Microsoft, Vista might lock you out at this point…

The second point will only affect those who are trying to use Vista legally but have been caught by the point above. It’s not a major issue but for those who are caught and decide to stick it out, it’ll be harder to keep your machine running. Even if windows doesn’t lock you out, since you are now in breach of the EULA, chances are that the daily Windows Activation thingy they’ve introduced will prevent you from getting all the security fixes that will (inevitibly) be coming out.

Watch yourselves gamers!