FCKEditor not working in Firefox for you?

Posted by – January 29, 2010

Just came across a cracking little bug in the old FCKEditor 2 code that we use on a number of applications.  In the last few days we’ve noticed that it’s just randomly stopped working in Firefox across all applications that use the editor.

After doing a little digging, this was tracked down to a 2010 related bug, and the fact that the newest versions of Firefox were released this calendar year.  Take a look at my user agent:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2)  Gecko/20100115 Firefox/3.6

In the FCKEditor code, it’s checking to see if I have a compatible browser by checking the date of release of the Firefox, with the following code:

stResult = reFind( "gecko/(200[3-9][0-1][0-9][0-3][0-9])", sAgent, 1, true );

You’ll notice that this regex doesn’t work particulary well for anything that might start with 2010, so you need to update your regex to the following:

stResult = reFind( "gecko/(20[0-9][0-9][0-1][0-9][0-3][0-9])", sAgent, 1, true );

Once you’re done and dusted, this should give you another 10 years of happy FCKEditor usage (if you’re that committed).

UPDATE:  After some more digging it would appear that this is only a ColdFusion related issue, as it is the only library to use a regex to find the date, all of the others use a substring style extraction of the date.

Why I think that the Apple iPad is a very important product

Posted by – January 28, 2010

Unless you’ve been living under a rock for the last 24 hours, you’re no doubt aware of the Apple iPad – a device which is essentially a large iPhone, but in a neater form factor, and aimed at casual web and media use rather than being an in-your-pocket computer.

From the initial press coverage, it would appear that the masses are largely unimpressed with the iPad, particularly in the tech circles, slating is as a lot of “meh” and “big deal” as it doesn’t really do anything that a laptop can’t or the iPhone can’t have a good stab at.  However, I believe that there are three good reasons why the iPad is a product which changes things a lot more than people think:

1) It kills the domestic PC

OK, before I go into this point you need to remember one thing – we are techies, we are a minority, we are not normal users.  Normal users are those people who do not use computers as a hobby, and merely as a tool for getting something else done, be it looking at their facebook stream, surfing for bargains on Amazon or eBay, or just amusing themselves via email.  People who got hot and sweaty about this product for the previous few months do not see this product in the same way as, say, my Dad.

Put yourself in the shoes of my Dad (he’s a size 10) – he has a laptop for work, and that laptop is only ever used for work, it never leaves the office (as he can separate work from hobby unlike most techies), however, he does have an iPhone, as he fits the demographic of someone with a decent amount of disposable income, and a willingness to have stuff that just works right.  For him and my mum, they tend to use Facebook, and look up tee times at the local golf club.  Aside from that they’ll be looking for holiday deals or trying to book their timeshare.

For people like this, they would normally be looking at a desktop PC, or a laptop.   They are unlikely to buy a desktop due to the size, so will go for a laptop style machine. However, when looking for said laptop they see the iPad for sale.  One is a clunky laptop form factor, that requires you to buy Windows and have some sort of basic understanding of how the OS works, how to install their digital camera software etc etc etc, or you have the iPad, where you turn it on, and poke the things that you want to happen.

I strongly believe that once a few of these units are out and about, the user experience, and the desire to be one of the “cool” apple crowd will push people to buying the iPad rather than a notebook/laptop, and you shouldn’t underestimate the “cool crowd” peer pressure, look at sales of the BMW Mini or Fiat 500.

Having the iPad will change the way people see computers.  The iPad is a simple device that requires no technical knowledge whatsoever, it’s a poke and click interface that a complete moron can use, and what’s more, it’s no bigger than a large moleskin so you can keep it in a small drawer if you want.  Once tablet computers (note I mean like the iPad, not the Windows-in-a-small-box tablets out there) are more prolific, laptops I believe will be saved for power users only.

2) It boosts the use of open standards

iPad, as with iPhone is a very apple centric locked down device.  You have one OS, one hardware spec, and everything must go through the same process: write it in Objective-C, post it to Apple, get it approved, and let people download it.  It’s all good if you do it the Apple way.

However, let’s say you don’t want to do that – you only really have one more option, and that’s writing your application in open standards (JavaScript and HTML5), and deploying it to the device via the browser.  There’s no Flash / Silverlight here, so going with open standards is the only choice you have.

Now consider your average corporate website.  The boss will probably have an iPhone or iPad, and will want his website to work on those devices, purely from a marketing standpoint. He’ll also want to only pay to build his website once, which means that the use of Flash and Silverlight will drop as they re-use code and design across all platforms.  I can see the use of Flash dropping on the “grown-up” internet as the proliferation of iPhone and iPad grow.

So overall, these devices, as well as Apple (and others) adoption of technologies such as HTML5, can only serve to dwindle the use of the plug-in as we known it, which will cause companies such as Adobe some real big issues.

3) It saves the print industry

Bit of a smaller point this one, but I do think that the iPad will do a lot for the print industry.  The web is already killing print, and by providing your average home with a low cost way of consuming  the same content, with the same high advertising revenue is a huge boon for them.  The New York Times have already said that it would be cheaper for them to give all of their subscribers a free Kindle than it would to print every day, so I can only see the print media becoming “proper” online journalism sat behind a subscription model.

So, overall, will I get one, yes, but probably not the 3G one, as I’m nearly always at home or work, so Wifi will do me just fine.  Come March I’ll be interested to see how the personal computing market starts to change and what it might bring for us developers in the future.

Simulating a slow connection in OS X

Posted by – January 27, 2010

I didn’t realise how easy this was, but it is very easy to simulate a slow connection in Mac OS X, which will help with testing sites for users that don’t have the blazing fast connections that us developers tend to have.

Why would you want to do this?  Well, the primary use case I have is when testing sites that are heavy on Javascript, for instance, testing that everything is loaded up when it needs to be and that the latency of the connection isn’t breaking anything.

So how do we do it?  Simple:

In terminal.app run the following:

sudo ipfw pipe 1 config bw 30Kbit/s delay 350ms
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw add 2 pipe 1 dst-port 80

This will set rules to limit all traffic on port 80 to 30Kbit/s with a latency of 350ms.  Edit the commands to change the speed / ports as you require.

In order to undo this, simply run the following:

sudo ipfw delete 1
sudo ipfw delete 2

Simple when you know how ;)

(Note that f you are using  Safari to view the pages, you’ll need to use your Mac’s hostname or external IP address in the URL (for example, mymac.local rather than localhost).

Alt-tabbing in Firefox 3.6

Posted by – January 26, 2010

It’s a little known fact that you can CTRL-TAB between tabs in Firefox (in a similar way to ALT-TAB on your Windows).  What’s even more unknown is that you can set up Firefox to give you the previews in Firefox too.

In order to do this pop into your address bar and go to about:config.  After telling Firefox you like living dangerously, find

browser.ctrlTab.previews

and set it to true.

Once you’ve done this, CTRL-TAB and you’ll be able to preview and search all your open tabs.

The demise of the squirrel

Posted by – January 25, 2010

If you’ve ended up here from Google, expecting to see some sort of blog post on ColdFusion, Flash or Flex, the site you were expecting to see is no longer around, so you’re best off heading back to Google and trying another link.  Even better, stick around and have a browse, you never know, you might just like it.

After three years, and quite a few aggregated posts (over 100K at time of writing), I’ve decided finally to turn off feed-squirrel.com.  I’m not going to go into any nitty gritty of why, when and how, but basically just list out a few reasons in case anyone is bothered:

1.  Feed-Squirrel.com was largely a fully autonomous application, it sat there day in day out grabbing posts of various blogs out there, and turning them into a website.  Essentially the blog authors built it, I just supplied it with electricity.  Saying that though, one element wasn’t automated, which was adding new feeds and culling the old ones.  As I don’t really have the time to do this (or the inclination), I thought it best to stop.  There’s plenty of other aggregators out there (AXNA being one), or better yet, grab an RSS reader and make your own.

2.  Whilst, in 2006, ColdFusion was one of my main interests development wise, I now have moved on and no longer hold the same interest in the content.  I still use ColdFusion from time to time in a professional context when clients require it, but these days I much prefer to work with tools such as Ruby on Rails, jQuery and co.

3. Not having the site means not having to worry about uptime, backups, updates etc etc.  This blog is all I want to worry about.

If anyone really wants a copy of the database I’ll happily let them grab a copy, but don’t ask for the code, it’s too embarrassing.

So long, and thanks for all the nuts.

Using Git as a Subversion client

Posted by – January 25, 2010

Not many people know this, but if you work for a draconian empire who insists on using Subversion across the board and won’t let you move to something a little better like Git, then there’s actually a tool just for this task.

Built into Git is git-svn:

TO WORK WITH AN SVN REPOSITORY BUT WORK WITH GIT LOCALLY:

git svn clone [http location of an svn repository]

Now you can work with the checked out directory as though it was a git repository.

TO PUSH (COMMIT) CHANGES TO THE REMOTE SERVER

git svn dcommit

TO UPDATE YOUR LOCAL REPOSITORY FROM THE SVN REPOSITORY

git svn rebase

NOTE: make sure you have your perl bindings to your local svn installation.

I screwed up, how do I reset my checkout?

git checkout -f

* Note, I don’t work for a draconian empire, and I use Git.

JQuery script loading gotcha

Posted by – January 20, 2010

Today, I was working on some javascript using JQuery 1.3.2 and the lightbox plugin Colorbox.

Whilst most things were working perfectly, one special case I had wasn’t playing well.  From the following code I was getting a number of errors:

  $.fn.colorbox({
    iframe: true,
    href: 'url.php',
    innerWidth: 250,
    innerHeight: 400
  });

This was returning the following under different test conditions:

  $overlay is undefined
  settings is undefined
  a is undefined

etc etc etc.

This was causing me to start pulling me hair out as nothing I was doing from following the documentation was working. After a while I noticed that the colorbox.js file was being included AFTER my application js file which contained the calls to colorbox.

‘No problem’ I thought, as it’s all wrapped up nicely in $(document).ready… at least, until I started doing some digging.

Over the past few years I’ve read that ready() returns when your page is ready to rock, which is not correct. ready() tells you when the DOM is ready to be manipulated. Unfortunately for us, loading JS files does not constitute part of this process. Therefore, my application code was trying to do stuff before my colorbox code had loaded properly.

This leads me to think that it would be really handy in jQuery to have some sort of complete() event, whereby it returns when the DOM is ready(), AND all of the required elements on the page have finished loading.

In future, I’ll definitely be more careful with calling JS code from external files.

Merging a single commit using Git

Posted by – January 14, 2010

Today, I came across the need for a function that would make most source control mechanism’s cry.  Essentially I needed some work that was due to go into production in a few weeks, to go today, which meant I somehow had to grab some code that was deep down in my bleeding edge branch out into the limelight of the live server.

In Subversion, this would be pain, but luckily I’m using Git.

Out of the box, git comes with a very useful command cherry-pick.  Essentially what this does is take one single commit, and then merges just those changes into the other branch.  This is different to a regular merge in that it doesn’t pull ALL changes, so it’s much more precise.

git cherry-pick -n [The commit's SHA-1 Hash]

(Note that the -n option should be used when you don’t want Git to automatically commit the change into the new branch, but you should make sure your new commit message references the old commit for sanities sake).

Remember though, your newly merged into branch might not be working perfectly now, as you may now have unsatisfied dependencies, so test, test test!

BrowserCMS Gotcha – missing cms/application.js

Posted by – January 14, 2010

I came across an issue today whilst putting together a site using the BrowserCMS content management system for Rails (and if you need a CMS, look no further).

Essentially I was ending up with a situation whereby when I was trying to remove an item from a container I was getting the following error:

No action responded to show. Actions: cms_connectable_path,  cms_index_path_for, 
cms_index_url_for, cms_new_path_for,  cms_new_url_for, cms_toolbar, container, 
container_has_block?, create,  current_page, destroy, edit_cms_connectable_path, 
handle_access_denied,  handle_server_error, move_down, move_to_bottom, 
move_to_top, move_up,  new, page_title, render_breadcrumbs, and render_portlet

After a little digging, I discovered that this is not a rails bug, or a BrowserCMS issue, but a missing Javascript file that needs to be in all of your templates (as well as the cms_toolbar) cms/application.js.  This file attaches all the required js functions to the BCMS buttons, and thus turns the necessary GETs into POSTs etc etc etc.

However, you don’t want this included all the time, but only when you’re logged in as an adminstrator or someone who requires the use of those buttons.  Therefore, the following code is required in each of your templates:

< %= able_to? :edit_content, :publish_content, :administrate do
     javascript_include_tag ["cms/application"], :cache => true
 end %>

This will ensure that everything hooks up as it needs to, and only when it needs to.

links for 2010-01-12

Posted by – January 12, 2010