Wednesday, August 16, 2006

UK's Top Web 2.0

I thought I would mention this blog post on readwriteweb about top UK web 2.0 apps firstly to show we are doing it too and secondly so I can plug which is simply the best web 2.0 app currently in existence.

Not only does provide a service that is truly innovative not just in its use of technology but also in its business model. It also works really well (which cannot be said of all web 2.0 apps).

I love the fact that it utilises all the so many social software concepts such as tagging, networks and neighbours to solve the ever present problem of finding new and interesting music.

Did I mention I love :)

Thursday, August 03, 2006

Apache rewrite and case sensitivity

I had a problem, some might say that I have many problems but this one I found a solution to, so it thought it would be a good plan to share it.

It concerns case sensitivity when running Apache on unix and it comes in two parts.

Firstly we are using apache rewrite to create friendly URLs and this works fine you type in and this gets parsed through apache and the rewrite thingy checks the rules setup finds the correct piece of code to run and presents page.

To achieve this you put something like this in your .htaccess file

# check the RewriteEngine is switched on else this won't work
RewriteEngine on
#do a Rewrite rule
RewriteRule ^blog/(.+)$ /blogs.cfm?sParams=$1 [L]

and this works fine as long as your site users don't do this

Because unix being unix it will say sorry matey I can't BLOG I have a rewrite rule called blog but I won't tell you about that because BLOG and blog are different.

so to get the Rewrite rule to find

and another combinations of case you need to add 'NC' to the rule thus

RewriteRule ^blog/(.+)$ /blogs.cfm?sParams=$1 [L,NC]

FYI 'NC' means no case.

Now that's the first part of the solution and I can claim no credit for getting this far as this helpful fella did all the work and Riccardo even found the link for me all I had to do was read.

However, as I said this is a two part problem, while apache Rewrite handles the URL case sensitivity it can do nothing useful for physical files sooooooo....

when you links to physical files on your server such as
as long as the file is called postaboutmonkeydust.pdf that's fine but if it is called PostAboutMonkeyDust.pdf then it won't be found.

While there are a number of solutions to this you could put in place such always saving files on the system in lowercase or even just using a consistent naming convention, people being people means that somewhere along the way you are going to get broken links.

So the best solution I have found is mod_speling ( yes it is spelt incorrectly and yes the irony is not lost on me (but i am sure it is intentional )).

This module is available in Apache 1.3 and later and as an extranl module in prior versions and its cool. When enabled it cahecks for physical files on your system ignoring case and will even ignore a single spelling mistake, quite frankly it rocks and what's more its really simple to implement.
Simply slam this into the httpd.conf file

CheckSpelling on

and apply the changes and just sit back and watch in amazement :D

Friday, June 09, 2006

Using caller scope getting 500 null error

This post is pretty much like it says in the title, I was working on a project this week, where I was calling UDF's ( located in the Application.cfm ) from within a customtag.

Because of the nature of customtags you can't reference things outside of the tag using the variables scope, so I was using the caller scope and this initially worked.

However, for some reason I started to get 500 null errors ( which was very frustrating ) and I managed to narrow it down to the referenceing of UDF's using the caller scope. now I still not sure of exactly why this causes Coldfusion to fall over in a big heap with not so much as an exception but IU did find a work around.

The work around is this, when you declare your UDF's simple assign them to the request scope thus :

function isTheWorldFlat(dtDate){

var bResult = true;

//according to wikipedia people in the 1st century knew it was round.

if (datePart('YYYY',dtDate) GT 100){
bResult = false;

return bResult;
request.isTheWorldFlat = isTheWorldFlat;

So now in my Customtags I can refer to my UDF's using the request scope and no nasty errors, I get code re-use admittedly with a little reliance on code outside the customtag but that is a hit I'm willing to take.

I am still bugged by why using the caller scope made Coldfusion bomb so if anyone has any insight feel free to comment.

Tuesday, June 06, 2006

Slow SQL through Coldfusion

06/06/06 no matter what the date format seems to be day of the devil and he's been messing with my code.

On one of our customer sites there was a particular piece of functionality that was running incredibly slowly, like 90 seconds to render a page kind of slowly.
So slowly in fact that I had time to go and make a cup of tea before the page rendered ( i don't fill the kettle to the top ;) ).

Now this site has been unit tested with no problems.

It has under gone a lengthy UAT using realistic data and again no performance issues were evident.

Then on the Live install we get issues.

Through general debugging we managed to narrow it down to a particular SQL query.

We ran it directly against the live database using Query Analsyer in Enterprise manager and no problem,
We then run it through coldfusion MX and it ran like a three legged dog on crutches.

So what was the cause ?

It seems the MS SQL drivers were having trouble executing this particular query and the reason seems to have been a function call was doing in the Select Statement.

In order to get some code re-use going I had written a function in TSQL which I then called is various Select statements throughout the site and if I removed it from the query problem solved.

Simplfied example - before:
dbo.avgSomething(i.intItem) as avg_result
FROM tblItem

Simplfied example - after:
, (
SELECT ROUND(CAST (AVG(cast(sub_ra.intItem,Answer AS FLOAT)) as float),-0)
FROM tblUser sub_ur INNER JOIN tblItem_answer sub_ra
ON sub_ur.intUserRatingID = sub_ra.intUserRatingID
WHERE (sub_ur.intItemID = e.intItemID
OR sub_ur.intItemID IN ( SELECT sub_hs.intItemID
FROM tblsub sub_hs
WHERE sub_hs.intsubItemID = e.intItemID
) as avg_result
FROM tblItem

So the end result is I have lost a little bit of code re-use but at least the site works :D

Relates to SQL server 2000, Coldfusion MX 7

Tuesday, January 11, 2005

When is a select box not a select box

I have been revisiting that old chestnut form validation and found out that a select box is not always a select box, I was doing some dynamic form building an needed to know the type of the form element to clear its value (its a long story)

I started top play around and found that the typeof() function shows a select box as "undefined" and outputting the .type attribute displays one of two values "select-one" or "select-multiple" (the latter where multiple selecting is enabled on the select box).

Interesting (I thought) try it yourself with the code below and if anyone can explain this anomaly to me I would be most grateful.

<script type="text/javascript">
function clrFrm(){
var myfrm = document.frm;
for (var i=0; i < myfrm.elements.length; i++){
if (theElement.type == 'text'){
theElement.value = "";

<form name="frm" method="post">
<input type="text" name="textbox">
<input type="checkbox" name="chkbox">
<input type="radio" name="radiobtn">
<select name="selectthing">
<option value="fred">fred</option>
<option value="bill">bill</option>
<input type="button" onclick="clrFrm();">

NB. code was typed quickly and may not be 100% but it give you the general idea ;)

Wednesday, December 22, 2004

Bullets do the Metro

Last night the 21st December, Bullet Galloway did the Merto Club on oxford street, yes i know it sounds like a strip joint and to be fair it looks like on from the outside but rest assured it is your run of the mill grimey, live music venue with a slightly strange two tier stage and a cash only bar selling cans (just the way i like it).

Moving swiftly on; the music, i haven't seen the bullets for some months so this is the first time i heard a few of their new songs, most notably in my opinion "Been Around The Block" which is a gutsy proper rock song that you can bounce around to ... i like it.

looking forward to the next album in the new year ;)

Thursday, December 02, 2004


it tells me on that tabs are :-

1. Informal.
1. A bill or check, such as one for a meal in a restaurant.
2. Cost; price: The tab for upgrading the computers would be high.
2. A tabulator on a typewriter.
3. Computer Science.
1. A key on a computer keyboard that, when pressed, inserts a special ASCII character used for formatting text, as in indenting a line or block of text.
2. This special ASCII character.

intr.v. tabbed, tabĀ·bing, tabs

To press the tab on a typewriter or computer keyboard: Tab over to the next column.

keep tabs on Informal

To observe carefully: Let's keep tabs on expenditures.

I would just say they are a god send especially when you combine it with the range of really useful developer extentions you also get when you move over to firefox, add to this short cuts to book marks and funky themes and it all leads to one thing ...

grab your flak jacket the browser war is back on

backward browsers

i have a dream one browser one world...

but i live in reality with millions of people and loads of browsers none of which comply with w3c standards in totality; while i appreciate there right to freely express themselves, i curse them for the difficulties they cause me when blindly hacking away at my keyboard building sites.

A new tool in my arsenal (my stash of web-dev weapons not the football team) as from today what brought to me by taking the ideas of a putting them into easy to install format.

So will i ever get to point, ok i'm talking about running multiple versions of IE on one PC. So now when someone asks but does it work with ie5.5 and 6.o, no longer to you have to fight the urge slap them in face with the smoked kipper you keep in you desk draw, simply reply yes i've already tested that :D

Thanks as always to greg for finding quirkmode ... another gem in a the myriad of web spooge out there.