Published May 15th, 2008
OK so I haven’t really done much with Flash for a few years now but I’ll admit I was taken aback when I saw this morning that Adobe has released a beta of version 10. The tenth version!
Don’t worry, I’m not going to get bogged down in all the nostalgia stuff. But looking at Flash now — with streaming audio and video, built-in 3D effects, advanced text manipulation and on and on — and thinking about some of the ‘amazing’ techniques that I (and others) experimented with back in the the day, makes me feel very old.
Category: Flash, General | Tags: | 1 Comment »
Published May 15th, 2008
I’ve been running this blog-based iteration of my site for almost three years now, and recently — after numerous on-the-fly software updates — I’ve found that WordPress had become rather unstable and slow. So yesterday I decided that I’d had enough and it was time to start again with a clean slate.
The basic process was relatively painless: I created a temporary subdomain and installed a fresh copy of WordPress, then used its built-in export/import facilities to transfer all the existing articles and comments over. Then I had to install all the various plugins I’d accumulated over the years (Akismet, Bad Behavior, Code Markup, Google XML Sitemaps, OpenID Registration) and configure them appropriately. I couldn’t find an up-to-date version of the old theme I was using, so I spent a while browsing before finding this one, which I’m fairly happy with although I might tweak here and there as time goes on.
Finally I had to do some work to re-integrate the various ad spots and a few other bits and bobs (e.g. point the RSS links to FeedBurner) before the installation was complete. All in all, it was probably half a day’s work, which I think is acceptable for a complete restart.
So I hope you like the new look. If you spot any problems then please let me know via the comments form below.
Category: General | Tags: | Be the First to Comment »
Published April 24th, 2008
This is one of those silly little PHP quirks that catches me out from time to time, but apparently not often enough to avoid doing it again on occasion.
Let’s say you have a function (we’ll call it getSomeData())that returns an array, or false if there is a problem (yes you should probably be using exceptions, but let’s just say for argument’s sake that this is a third-party library over which you have no control). So you use a conditional to test whether the function had a problem or not:
// Try to get data
$data = getSomeData();
if( $data ){
//...do something
} else {
// There was a problem
error_log( "There was a problem getting data!" );
exit;
}
For the uninitiated the if() here calls the function and assigns its return value to $data. If the return value is any non-false value, the condition evaluates to true.
The quirk, if you want to call it that, is PHP’s understanding of what constitutes a ‘non-false’ value. You probably already know that null, 0 (zero) and ” (empty string) all evaluate to false. But the one that still catches me out now and then is that an empty array will evaluate to false, too. So in our above example, we’ll get an error if the getSomeData() function returns successfully, but with no data.
You could fix this with strict evaluation:
// Try to get data
$data = getSomeData()
if( $data === false ){
//...do something
} else {
// There was a problem
error_log( "There was a problem getting data!" );
exit;
}
…or alternatively (and better, in my opinion) check the return value’s type:
// Try to get data
$data = getSomeData();
if( is_array( $data ) ){
//...do something
} else {
// There was a problem
error_log( "There was a problem getting data!" );
exit;
}
If you want to know more, check out this blog post that goes into more detail — and points out a couple more unexpected ‘false’ values (the string ‘0′ and an object with no properties) that I wasn’t aware of.
Category: PHP | Tags: | Be the First to Comment »
Published April 18th, 2008
I’ve spent the last few days re-writing our login process to handle a switch to using a third-party server for user tracking. Specifically, where before the login and tracking was handled by the same domain, now the login is processed at one domain but the tracking cookie is served on a subdomain (for technical reasons that aren’t really important here).
Getting this to work has had me (metaphorically at least) banging my head on the desk. For a start, the login process uses an iframe to call across to the subdomain so that it can set a cookie. This works fine (in some browsers anyway) but then you run into cross-domain security issues when trying to communicate between the iframe and its parent document (’permission denied’ in IE/FF, ‘Security error: attempted to read protected variable’ in Opera, ‘Unsafe JavaScript attempt to access frame’ in Safari). On top of that, Internet Explorer just flat out refuses to register the cookie because it classes it as ‘third-party’*.
I was getting close to giving up and reconsidering the whole set-up, when I stumbled across the magic bullet: document.domain. This property — which instantly fixed all the browsers I was testing — effectively allows you to ‘broaden’ the domain of a third-party document, so that the browser treats all documents as originating from the same domain. So for example whereas my parent document is at www.mydomain.com and the iframe is on auth.mydomain.com, the following JavaScript code (in both the parent and iframe documents):
document.domain = 'mydomain.com';
…tells them both to use the same domain.
Just thinking of the hours I’ve wasted trying to work around these problems, when the fix was so simple, makes me want to cry. Hey ho.
FYI it only works when the domain is the same — you couldn’t use this to allow communication between frames from, say www.mydomain.com and www.yourdomain.com.
[* The third-party cookie problem with IE also required setting a compact domain policy.]
Category: Web Development | Tags: | Be the First to Comment »
Published April 11th, 2008
Just got a tip-off about this rather neat idea: CushyCMS is a third-party, hosted CMS for your own (or your clients’) sites. It works by embedding class definitions in editable elements, and then using FTP (you have to supply FTP details for your own host) to make changes.
The CMS software itself is very simple easy-to-use, and I think would be ideal for clients who don’t have much technical experience. It’s free, too, although it’s unclear if/how that will change.
Check out the video presentation to see how it works.
Category: Web Development | Tags: | 2 Comments »