Latest Headlines

Find and Replace in mySQL with PHPMyAdmin

I recently developed a Drupal powered site for a client on a test sub-domain. We then went live and everything was fine since Drupal doesn’t use the domain name in any links. The only problem was that the TinyMCE WYSIWYG editor we had used had put the sub-domain in the URL of some images they had included in various pages. Since I wanted to remove the test sub-domain as it was no longer needed and since it would prevent Google finding duplicate content, I wanted to remove any mention of it from the database.

Turns out that it you know the name of the fields and tables that could contain a mention of text you need to remove or replace, you can issue the below SQL to find and replace it.

UPDATE table SET field = REPLACE(field, "oldtext", "newtext");

If you aren’t sure which table or field could contain your text, since this is an SQL statement, you could use PHP and DESCRIBE TABLE or similar to run the command across every table and field in your database.

Automated MySQL backup to SQL file on WIndows 2008 server

For years I’ve tried to use Linux web servers wherever possible especially when a dedicated server was required for the site. Unfortunately my latest major project needed to connect to a Filemaker database and the only connector available that we could use is Windows only. So we ended up running Windows Server 2008.

Normally on my Linux web servers as part of the backup setup I get it to do a daily mysqldump to the local hard disk in case something nasty happens. Since this was a managed Windows server and therefore has expensive built in backup systems as well as an external backup process I didn’t bother. I should have though.

The website is on Drupal and one of the users was trying to remove a duplicate menu item that had cropped up and ended up deleting a node, it’s webform and all the submissions. If you don’t know Drupal – that means retrieve required info from database backup. SO I went to the scheduled daily backup taken by Windows Server and tried to retrieve the files I needed. That’s when I found out that their idea of a backup has to backup the mysql .exe files and nothing else so there was no data!

Panic time and a quick call to the hosting company later I found out that they do an additional backup. But, our 200Gb server had gone over it’s 100Mb a week quota for daily backups! WTF!!!!

I ended up having to recreate the data from an old backup and applying new updates. Anyway, don’t trust Microsoft or anyone that thinks Microsoft is worth trusting your business to.

I’ve now created a batch file and scheduled task to do a mysqldump.

Skype for iPhone – a little flawed

I’ve got Skype on my iPhone bur haven’t used it much – which is probably a good thing.

I just tried a video call while lying on the bed and the slight floor is that while I can see the other person, all they can see is my feet because of the camera position.

Oh well.

Tags:

New levels of “robbing b@st@rd”-ness from Microsoft

Now that I’ve moved over to Linux and iOS for all my computing needs, I’ve grown to really, really, really, really hate Micro$oft but apart from occasionally borrowing my girlfriends laptop I can pretty much ignore them now – or so I thought.

Our Sky+ box has stopped been able to record – I think the hard drive has gone and since it’s out of warranty I can’t be bothered to replace it since the majority of what we would use it for is available on iPlayer. The few things I want to watch and don’t get chance to at the time, I’ve been watching through Sky Player on my Macbook. However this week I was planning on doing stuff on my laptop but unfortunately I couldn’t use my girlfriend’s laptop to watch stuff on Sky Player because she wanted to use it.

Luckily I remembered that I do have one remaining Windows device – my Xbox 360. It had completely slipped my mind that the Sky Player is available on Xbox and since that was already hooked up to the TV is was perfect. Except for Microsoft’s accountants getting in the way.

So here’s the deal. I bought an Xbox from Microsoft because I wanted to play some Need for Speed games and a few others. I don’t want to connect to the internet and play against a thirteen year old in Kansas. I’ve also paid for the Sky channels I want and Sky has provided the Sky Player so I can watch stuff I’ve missed for free. Brilliant.

Except that Microsoft says I can’t use the Xbox I paid for to watch Sky that I’ve paid for unless I pay an extra £6 a month to them for nothing!

I hate them so much!

Using Innerfade in Drupal: Error $ is not a function

If you are trying to to implement Innerfade in Drupal having used it on standard HTML websites (ike I have) you may come across a few problems getting it working. Here’s a quick how-to to get it running.

Drupal (or WordPress), jQuery and $
You’ll find that when trying to insert jQuery into Drupal you get the JavaScript error

error $ is not a function

This is because some other libraries also use the $ sign and Drupal uses such libraries. Luckily jQuery can handle this so within your code, just replace $ with jQuery (see below).

Only including Innerfade on a single page
If you want to use Innerfade only on a single page as I did, you can create (or edit) the tpl fiel for that particular node and insert your code in there. If that makes no sense to, go to drupal.org and start reading.

Adding JavaScript to Drupal
The best way to add JS to Drupal is to use it’s core function drupal_add_js. This can save problems so use it.

Putting it all together
The below code is what I added to my node’s tpl between PHP tags. I then added the Div with the below ID using the node edit form and added the images too. Save / upload everything and you’re good to go.

drupal_add_js(base_path() . ‘sites/all/libraries/innerfade/jquery.innerfade.js’);
drupal_add_js(‘
jQuery(document).ready(function(){
jQuery(“#home-rotate-3″).innerfade({
speed: 1000,
timeout: 5000,
type: “sequence”,
containerheight: “398px”
});
});
‘, inline);

You will obviously need to download the innerfade js file and upload it to the above directory (or another of your choice) but it should work.

Outlook 2007 and Image Float

I’ve just designed some email templates and sent tests to the client who informed me that the images I had floated to the right of a paragraph of text were showing above the paragraph. A bit of digging turned up that Outlook 2007 has reverted to using Word 2007 as it’s HTML rendering engine which doesn’t support quite a few of the basics – one of which is the Float property.

What the hell. Since it’s no longer 1994 and we’re not using table based layouts, how are you supposed to do anything without Float? I know that M$ loves to ignore standards for it’s own rediculous business reasons but that is fucking stupid. Really stupid.

Luckily as per usual there is a work around for Microsoft stupidity and for once it’s not Mac OS X or Linux. Put this in your image tag:
align="right"
I hate Microsoft. I really, really do.

BBC causing fear among iPhone users

I’ve just read a story from the BBC about the iPhone tracking users movements. It’s a normal BBC story that doesn’t really take sides and conforms to corporate policy. But.

But, what is the point? It says in the article that the information stored isn’t uploaded to Apple. Ok, fine. It also says that the data is only stored locally and therefore can only be accessed if you have the actual phone (in so many words). So what information are they trying to give us?

They say that there is no indication to the user that this information is being stored. Really? I figured it out using the Pictures app – it tells you where you took the various photos on your phone. How do they think it knows that? Magic?

But my big problem with it – the reason I’m on a rant is the headline “iPhone tracks users’ movements”. For a supposedly impartial organisation like the BBC why have they chosen a simple 4 word sentence that will grab the attention of every iPhone user and scare them a little? What are they doing to help people? Nothing.

The BBC is behaving no better than a tabloid newspaper. But unlike the tabloids we are forced to pay for it.

Apple drops Xserve. That’s why I love ‘em

Apple announced towards the end of last year that it was dropping the Xserve – it’s rack mounted server that runs OS X Server. Although Apple hasn’t given a specific reason, a lot of people are saying it’s because the Mac Pro and Mac Mini are quite capable alternatives to the Xserve. And this sounds very sensible to me.

Rack mount servers are used in large organisations where you need a lot of server power and need to save space. But in this kind of environment you would be unlikely to find every user on the network to be using a Mac – they’re likely to be on Windows and if not, more likely to be on Linux than all on Macs. So if most users are on Windows or Linux, the rack mount servers are likely to be running either Windows or Linux (or Unix). I can’t see anyone wanting to pay the extra for an Xserve to use in a mixed network.

So the Xserve is only likely to be used in an environment where most of the machines on the network are Macs and they want a central server for file sharing and other services that can be easily set up and used. There are a few problems with this as well though. Firstly, in this environment – most likely creative studios – there’s only likely to be ten or twenty client machines so the only piece of equipment that would be rack mountable would be the Xserve. Secondly, it’s not likely that a network of this size would require the hardware provided by an Xserve to meet their needs. That’s why most people are saying that the effectiveness of the Mac Pro or Mac Mini as server hardware when the server software is available for these (and other) hardware configurations, is a sensible way to go. It saves on hardware costs, fits in with their office network setups and in some cases the Mac in question can be used as someones desktop machine – we used our old Mac Mini running Server as a way of showing clients websites on the board room TV!

I like that Apple hasn’t tried to push the Xserve onto existing customers but let in die in favour of letting us use what we want to use. This fits with the way I’ve set up networks in the past (confession time). I’m actually relatively new to the Mac world – I’ve been using them since I started working here about 8 months ago. Before that it was Windows and Linux. In most of the past networks I’ve been in charge of I’ve opted for using Linux on a relatively cheap and low spec PC to provide network services instead of getting expensive dedicated hardware. At the last place I was at we had an ex-display Campaq desktop from Dixons bought for £70 and it’s been running Linux and doing it’s job for about 6 years.

So good bye Xserve – I am slightly gutted I never convinced any of my managers to let me have one but that’s OK. Next week I’ll be getting one of our old iMacs that isn’t useful any more and installing Snow Leopard Server on it.

Tags: , ,

Angry birds on a 21″ iMac – oh yes!

I don’t think I’ve mentioned this before but like many I’ve got a bit of an Angry Birds addition. I probably haven’t mentioned it because I was busy playing Angry Birds. I’ve finshed every version released on my iPhone meaning that the thing never has any charge in it.

Since I’ve been so busy lately with finishing the Helping Hands website and promoting the Chantry Court website I completely missed the fact that they’ve released a version of Angry Birds for the Mac until someone in the office told me.

Only problem, you need OS X 10.6.6 to ply the damn thing and I was still on Leopard. After digging around I managed to find our upgrade discs for Snow Leopard which got me up to 10.6.3 and then a quick Software Update got me to where I needed to be.

So I’ve just spent a few hours playing it on my MacBook and it’s…. well it’s like holding your iPhone really close to your face. Let’s see how big those piggys are on my 21″ iMac tomorrow.

Drupal Webform – getting Date field using UK format

I’m working on a major project with Drupal – bigger than any I have done before so there’s obviously a bit of a learning curve to go through.

The latest problem was using the excellent Webform module. Although it works perfectly in my Drupal 7 install, all the dates are in the US mm/dd/yyyy format and I want the UK dd/mm/yyyy format.

All you have to do is go to Admin > Configuration > Date and Time and you can choose from a list of date and time formats to suit your needs.

Simples