Problems opening JPEGs with imageNew()

I’ve been having occasional problems processing uploaded JPEG images using the built in CFML image functions. It seems that ColdFusion didn’t like something in the image header because if I re-export the files using Fireworks they work just fine.

I’d read somewhere about a workaround and it seems to do the trick. Instead of:

myImage = imageNew( "#pathToImage#/#cffile.ServerFile#" );

Open the file as a binary object and then pass that to imageNew()…

binaryImage = FileReadBinary( "#pathToImage#/#cffile.ServerFile#" );
myImage = ImageNew( binaryImage );

Not sure what that’s all about, but it works so I’ll just run with it.

FCKEditor file upload permissions problem with CFML connector

I’ve been using the standard fckeditor rich text editor a lot recently instead of the built in option in ColdFusion. I ran into an issue when enabling the inline images and the file upload manager - I’d get a username/password dialog for the uploaded image as there was something wrong with the permissions.

Initially I thought this was something to do with the secuirty settings on the image library folder but after some more digging around I noticed that all files go into a temp directory first, the location for which is defined around line 64 in the config.cfm as:

Config.TempDirectory = GetTempDirectory();

The problem with this is that the this temporary directory will be outside the webroot and the uploaded file will inherit these permissions even after it’s transferred to the directory you specify in Config.ServerPath.

The workaround? Simply set Config.TempDirectory to a temp directory inside your webroot :-)

As with most things, perhaps this is common knowledge but I like to blog about it just so I can remind myself when I run into the same problem next time, and who knows maybe it’ll help someone.

Test from iPhone

Just a quick test post from the iPhone using Wordpress app. Haven’t blogged in quite a while and wanted to get back on track.

URL rewriting on IIS7 made easy

I needed to be able to rewrite some URLs for a site running on IIS7. I briefly tried the free and Ionics ISAPI Rewrite Filter and ISAPI_Rewrite but neither seemed to do anything. Before I rolled my sleeves up to see if I could get either to work, I stumbled upon the recently released URL Rewrite plugin for IIS7 from Microsoft.

A quick download and install later, and I have a simple URL Rewrite module in IIS MMC. It seems to work really well and is a breeze to configure. I think in this case, I have to congratulate Microsoft on a job well done (possibly for the first time ever?).

Time Machine restore and Apache

After doing my full restore from Time Machine everything seems to be in place, however, Apache didn’t seem to be working. I checked the config files and everything was OK. I opened up Console.app to check the output and noticed the line:

No such file or directory: httpd: could not open error log file
/private/var/log/apache2/error_log

The apache2 directory was indeed missing so I created it manually via the Terminal:

sudo mkdir /private/var/log/apache2
sudo chmod 751 /private/var/log/apache2
sudo chown root:wheel /private/var/log/apache2

Seemed to do the trick.

AppleCare + Time Machine = Lifesaver

A couple of weeks ago my MacBook was coming up to the end of it’s 1 year warranty so I purchased AppleCare to extend to 3 years. Not something I’d usually do but thought it was worth it as it covered my Apple Display too.

What a great decision that was!

Last Thursday night my MacBook froze and the only option was to power it off. Friday morning, trying to start it up I just got an error symbol. Some attempts at restarting and running Disk Utility didn’t sort it so I thought I’d try calling AppleCare. The chap was most helpful. We went through lots of options but without getting it going. We were convinced it was a hard drive problem, so he sorted me out an appointment at an Apple Store for that afternoon, and I took the machine in and left it with them over the weekend.

I got a phonecall on Sunday morning to say the HD had been replaced was was ready for pickup. I booked another appointment for 10am Monday to collect. The ~£140 repair bill was covered under AppleCare.

Returning to the office I plugged in the Time Machine disk and did a full restore and had everything back as it was on Thursday afternoon in an hour or so.

Moral of the story: maybe extended warranties aren’t all bad - and keep good backups.

Thanks Apple! :-)

Jumping on the iPhone bandwagon

Finally picked up an iPhone last week to replace my Nokia N95. While on paper the two phones have many features in common, the iPhone is so much easier to use and the range of 3rd party apps amazing.

I’m already noticing that it’s making me more productive as I can make use of those few minutes here and there to catch up on email or see what’s going on in omnifocus.

Just got to get used to this keyboard now with my big thumbs :-)

Vertical align with jQuery

Sometimes I need to centre dynamic content vertically within an area. This used to be a doddle with tables, valign=”middle” was all you needed. However, in the world of div tags and css this isn’t acceptable anymore.

So, I figured jQuery must be able to help out - why not, it can do everything else!

HTML

<div class="container">
    <div class="box">Vertical content of unknown height</div>
</div>

CSS

.container { float:left; width:380px; height:380px; }
.container .box { float:left; width:200px; margin-left:90px; }

jQuery

$(document).ready(function(){
    var top = ( $('.container').height() - $('.container .box').height() ) / 2;
    $('.container .box').css('margin-top', top);
});

jQuery: In at the deep end

I’ve been using a little jQuery on sites for a while now but hadn’t had chance to fully get to grips with it. However, I recently landed a project that needed a rich user-experience and after sitting through Neil Middleton’s presentation at Scotch it seemed that jQuery was the obvious choice.

The first place I started was with the jQuery Docs which I found to be mostly well written with some good examples provided. I was also truly amazed at the number of useful plugins available. The two I took advantage of were the jQuery Cycle Plugin and jCarousel. These saved me a lot of development re-inventing the wheel.

I also worked how to do a few things that previously I would have used the ColdFusion AJAX tags for, and it’s just as easy (when you know how) doing it all with jQuery.

All in all I’m pretty pleased with how it all worked out and I’ll definitely be using jQuery to add a little spice to projects in future.

Versions: A new Mac Subversion Client

I downloaded the beta of Versions a few days back and I really like it. It just feels… well.. Mac like. It’s easy to setup Working copy bookmarks, as it calls them, for your existing projects and just links right in.

I still use Subclipse within Eclipse for most things but I find it tends to hang when doing large commits so Versions is a real help.

Well worth a look