IE "Operation Aborted" problem 

This took a little while to debug. Basically, IE was loading a page fine and then alerting a message that "Internet Explorer cannot open the Internet Site . . ." and " Operation aborted". This was impossible to debug correctly as the debugger never got a chance to run... plus the code was working fine in FireFox and a slightly modified version was ok in IE.

To cut to the chase, I was running some JavaScript at the end of the page that was messing with the DOM (the DynArch 'coolest DHTML calendar widget', specifically). By wrapping the calendar setup code in a function call, it was possible to delay the execution until the page had finished loading (by using the onload parameter of the BODY tag).


  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3.1 / 50 )
Shaded Borders - curved DIV elements with drop shadows 

Some ideas are so obvious that you never think of them. Like this guy who has written a lean JavaScript library which wraps 1-pixel DIV elements around your content elements to make rounded corners and drop shadows possible without any images. The elements' colours can be styled with CSS and there are a few other configuration options like corner radius, drop shadow size etc. Overall, a fine effort (although I had some trouble getting mulitple boxes to render correctly in IE6, which may have been due to interference with all my other JavaScript libraries - Rico, Prototype, Scriptaculous, Prototype Windows - I use them all :)


  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 47 )
Prototype 1.51 Component Error 

This is related to my previous post on getting Rico to work with Prototype 1.5x. I found an alternate piece of code that works equally as well at http://rvalyi.blogspot.com/2007/02/prot ... ward.html. My proposed solution is a combination...

for (var name in headers) {
if (typeof headers[name] != 'function'){
try {
this.transport.setRequestHeader(name, headers[name]);
} catch (e) {
//do nothing
}
}
}


This is at line 1094 in v1.51 final...
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 43 )
The new proceduralists! 
I have become very fond of my OO PHP code. I even have classes that generate other classes. But every now and then I come up against a problem that requires a procedural solution. Today I profiled a search script that was taking a bit too long (20 seconds actually!) only to discover (well,I already knew it, but I had been avoiding running the profiler) that over 300 queries were being run against the database.

Even after memcached kicked in, there were still 80 quereies or so that needed to be addressed. These queries were embedded in low-level data access objects that ran a handful of database calls each time they were being instantiated. When you have 25 search result objects per page, that adds up pretty quickly.

Now, purists would say I had written poor OO code. Of course I had. So now I am writing methods for my search class that grab multiple records for all my search objects simultaneously. Then the objects are pieced back together to resemble the originals. The upside is much faster page execution. The fact of the matter, though, is that I am hacking my OO code to run procedurally, which is totally fine by me. Procedural code is always faster and OO code is always easier to maintain, it just that sometimes you need a bit of both...
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 45 )
xajax beforeProcessing and afterProcessing callbacks 
I scratched my head over this for awhile... the beforeProcessing array of callback functions in xajax 0.5 works a treat. I use it to run a security check on the request before allowing it access to my logic and data classes. Then, in certain function calls, I wanted to use the afterProcessing callback array to process the data sets being returned. This may be to filter, order, concatenate or simply double-check the data. Strangely, nothing I did seemed to work... so I dug into the xajax code a little only to discover that afterProcessing hasn't been implemented yet - although it is documented!

I guess that's what happens when you use beta software! Now, I could write it myself and submit it to the repository, couldn't I? That would be a nice way of saying thanks to the kind folks who developed the rest of the code.
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 2.9 / 50 )
Being held to ransom by your ISP 
It's been quiet around here lately, mainly because I've had about 5 days of broadband in the last 5 weeks. While I should have been reading Kafka, I didn't have to because my life became The Trial. First iinet (my isp whom i now hate with a passion, but more on that in a moment) told me it was my equipment/phone line/ house that was causing the problem. Then they sent Telstra who, of course, turned up within an hour of the connection coming back online and who, of course, said there was nothing wrong. Then the connection died again and now I was going to have to pay a call-out fee to get Telstra back again because 'everything is working fine'. Even though I have no sync.

Eventually, after a month of "<quote>"customer support"</quote>" calls and an infinite number of line isolation tests, Telsta reappear last Friday to inform me that no, my equipment is fine and yes, the phone line is crystal clear (I am 200m from the exchange, I challenge you to find a better phone line!) and <drumroll> the problem is with the iinet dslam port</drumroll>.

Well, "3 to 5 working days" later and still nothing. Then, at 8pm on a wednesday evening, the modem lights up in ways I remember it used to do way back in late March... I have ADSL (not ADSL 2+, which is what I have been paying $100 a month for, but it is a form of ADSL nevertheless).

Now, the first thing I do is queue up my downloads and start my backups for my Web sites and databases. And, instead of just watching progress bars all night I decide to go onto my blog, dust away the cobwebs and COMPLAIN ABOUT MY ISP. :)

WHY I HATE IINET

Now onto the juicy stuff. I am technically a journalist. I write for illustrious titles such as PC User, NetGuide, Australian Personal Computer - the list goes on. I even told my friendly iinet customer support people that my job is to review broadband services. Did that get me anywhere?

I even told them I had already decided to cancel ALL my services - line rental, VOIP, ADSL etc etc and did they care? They just want to get off the damn phone as fast as they can so they can get off the phone to someone else as fast as they can...

So I decide that even a mainstream supplier like Optus has got to be better than this so I say to them "Get me out of iinet as quickly as you can, put me on your most expensive plan and get me OUT."

I get through the credit check without breaking a sweat. I sign up the next 2 years of my life to inferior upload speeds...

(aside - Optus won't give you ADSL if they have cable in your area. Why? because "cable is a superior product". I said, I am an uploader, not a downloader, I need 500k UPLOAD!!! They push the "superior product" button again... and again... aand eventualy I say "I don't care, just sign me up!!!")

Right, so now I'm down for 2 years of cable even though I want ADSL. I can cope with that. Then, just as I'm drawing the blood I intend to use as ink on the parchment, I am informed that "we don't have an agreement with iinet" to transfer phone numbers. In other words, my phone munber (and the phone number of my company, house mate and family) which I have had for over 10 years will have to change if I want to change ADSL providers.

Apparently it's in the fine print when you sign up to iinet. No-one brought it to my attention and now I'm being held to ransom over my phone number.

If you've made it this far I thank and congratulate you. I have now re-learned that the power of large companies is bolstered by their own lack of internal responsibility and accountability. It doesn't help that Telstra is a perfect scapegoat, either. Like all bureaucracies, they endure because the hatred they create amongst their customers is diffused by the same bureaucracy that protects them. I had one excellent tech support person but all the others were utterly unhelpful. The Telstra guy was helpful when the link was down but not much help when it worked... all because it's always somebody else's problem.

When the technology works, everything is shiny. But when there's a problem you'll be made to suffer - especially if it's not your fault. These are the lessons I have learned. By the way, did I mention that even the dial-up connection didn't work 9 times out of 10? Ok, at least I still had a landline - and one of the best landlines in the country, apparently. This time, however, being back online isn;t going to shut me up, I'll just have more places to throw the hair that I've been pulling out these last few weeks.
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 2.9 / 47 )
Not all days are created equal 
Some days just suck. Especially the ones that aren't 24 hours long. You see, there I was calculating all the names and dates for the next 28 days, as you do when building a calendar or something. The obvious way to do it was to loop from 1 to 14 adding 60x60x24 seconds per iteration and then formatting the timestamp accordingly.

So, being PHP, I did something like this:

$timestamp=time();
for($i=1;$i<=28;$i++){
$timestamp += 60*60*24*$i;
$dates[] = date("Y-m-d",$timestamp);
}


Why not? That's the way everyone does it, right? Well, lo and behold I was getting an array with 2 copies of "2007-03-25" in it. At first I thought it was an integer rounding bug, so I started using this: 60.0*60.0*24.0*$i. Needless to say that didn't fix it. Anyway, to cut a long story short you already know what was happening don't you?

The 25th of March marks the end of daylight savings in Sydney, Australia which is the default timezone of my server. It just so happens that this day is 25 hours long, which means adding 24 hours to midnight gives me 11pm on the same darn day. Hence two copies of the date in my array.

Now I know better than to perform my own timestamp calculations on anything other than GMT, where every day really is 24 hours long. Anywhere else and you need to do something like this instead:

$date = new DateTime(date("Y-m-d",$timestamp));
for($i=1;$i<=28;$i++){
$date->modify("+1 day");
$dates[] = $date->format("Y-m-d");
}


[ Note that here the $date variable is a PHP5 date object]

  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 41 )
domTT and Firefox Uncaught Exception  
domTT is an excellent cross-platform DHTML tool-tip library which I have used for about 2 years on a range of projects. While building a custom AJAX interface for my current project I came across a weird error for the first time...

In FireFox under Windows, the domTT library sometimes throws an exception "Permission denied to get propertyHTMLDivElement.tagName".


After scouring the Web I see I am not the only one to have experienced this, but no-one has posted a solution. Well, if you found this page on Google then you are in luck! Open up domLib.js and change this: if (typeof(in_bannedTags) != 'undefined' &&
(',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
{
return false;
}

to this:
try {
if (typeof(in_bannedTags) != 'undefined' &&
(',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
{
return false;
}
} catch(err) {
return false;
}

Your page will now be catching the exceptions and FireBug will stop giving you those nasty red lines that ruin your day...
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 44 )
Multiple PHP versions in a single Apache installation 
For some time now I have been two versions of Apache - one for PHP4 and the other for PHP5. This has been satisfactory except that my SVN repository was only installed for the Apache 2 install (the other install was 2.2 which doesn't support SVN).

So after a forced rebuild of my server I had trouble getting the 2 Apache's coexisting again so I went looking for another solution - and I found one that is way more elegant than having to stop-start every time I switched between projects....

Thanks to lukasz who posted a tip on php.net I have set up php5 as the default CGI handler for my Apache server with PHP4 set to override the default for specified directories. It works like a charm. I can now have specific PHP versions with specific extensions loaded for each project in the one Apache instance. Here's what it looks like:
ScriptAlias /php5/ "C:/Program Files/Apache Group/php-5.2.0/"
ScriptAlias /php4/ "C:/Program Files/Apache Group/php-4.4.2/"

AddType application/x-httpd-php .php
Action application/x-httpd-php "/php5/php-cgi.exe"

<Directory "C:/inetpub/wwwroot/BestAdsRebuild">
Action application/x-httpd-php "/php4/php.exe"
SetEnv PHPRC "C:/Program Files/Apache Group/php-4.4.2/"
</Directory>

<Directory "C:/inetpub/wwwroot/">
SetEnv PHPRC "C:/Program Files/Apache Group/php-5.2.0/"
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>

  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 53 )
Rounded Corners - Pure CSS 
It's been done a million times, but the fastest way to do it is to use the online rounded corner generator at:

http://www.roundedcornr.com

You get the CSS, the DIV tags and the four corner images all dynamically generated and ready to copy into your code....
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 49 )

Back Next