WebDevelopment, ColdFusion, Railo, JS, Database and Tech-related by the Co-Founder and CEO of tunesBag.com

Tuesday 22 December 2009

NYCFUG - I was there ;-)

Some nice memories of my stay in NYC this summer - a picture with the famous CF blogger Ben Nadel at the NY CFUG! Two thumbs up!


Monday 14 December 2009

Amazon EC2 goes Lorem ipsum

"Lorem ipsum" is the typical dummy text so I was quite surprised to read it on the Amazon EC2 Console (Setup wizard for a new instance) just a few seconds ago (see screenshot below). I guess I was just using the interface during an upgrade ... at least it reminds me a little bit of the pain during my Latin lessons in school ... ;-)

Wednesday 2 December 2009

Add missing Array.indexOf to Internet Explorer

When dealing with JSON it comes in handy to get the position of a certain string in an array, image an array with column names returned by a SerializeJSON'ed CFQUERY.

Internet Explorer does not support this function, but just add the following snippet and you can use Array.indexOf( 'TITLE' ) in any browser without built-in support as well (We add a new function to the Array prototype!)

// make sure indexOf is supported
if(!Array.indexOf){
Array.prototype.indexOf = function(obj, start){
for(var i=(start||0); i<this.length; i++){
if(this[i]==obj){
return i;
}
}
}
}

Sunday 1 November 2009

Apache, Railo & mySQL Troubles after Upgrading to Snow Leopard

Odd. The upgrade to snow leopard just killed by Apache Resin Connector and the vhost config - that should not happen (read other reports here). So make sure you backup your vhost configs before upgrading. For the connector, I had to re-download XCode in order to build the connector ... (700 MB in total, take care!).

The mySQL server wasn't starting as well, a symbolic link seems to be broken after the update, see here. Furthermore, some programs like Cyberduck (SSH) and Nambu (twitter) aren't working any more. To be honest, a quite disapointing update so far.

Thursday 20 August 2009

Setup Mac OS X + Apache + Railo

A fews days ago I upgraded to a Macbook Pro and I already spent almost two days on reinstalling software, copying documents etc etc (An upgrade is an opportunity for me to get rid of old software and ballast).

Today I started with the Apache / railo setup using a guide by Luid Majano (I had to download the Apple XCode Setup file (almost 1 GB) in order to compile the connector for Apache and reset the httpd to 32 bit instead of 64 bit).

Further problems I had to solve:
  • I wasn't able to access my files until I executed a chmod a+x on every directory in the path to the webroot (apache log [error] [client ::1] (13)Permission denied:)
Now it's working like a charm.

Thursday 11 June 2009

Using the H2 database in ColdFusion

Railo is delivered with an embedded database called H2. The description on the homepage says:

Welcome to H2, the Java SQL database. The main feature of H2 are:

* Very fast, open source, JDBC API
* Embedded and server modes; in-memory databases
* Browser based Console application
* Small footprint: around 1 MB jar file size

Such a database fit's perfectly for a current task at tunesBag - the streaming servers should store some data on their own machines and mysql or postgresql just would be overkill for this task. So I decided to give H2 a look and it looks pretty nice.

On my local machine I'm working with ColdFusion 8 as well - the configuration to add H2 support for CF is very easy, just follow the following steps:

  • Download the latest version of H2
  • Drop the h2*.jar file in the WEB-INF/lib directory of your ColdFusion server (directory depends on your type of setup)
  • Restart CF
  • Add a new datasource
  • JDBC URL = jdbc:h2:file:%Path to Database file on your disk%
  • Driver Class = org.h2.Driver
  • Driver name = default
  • User name = sa

That's it - the files holding the data will be created automatically for you. Take a look at the H2 tutorial in order to find out more (e.g. server mode etc).

Wednesday 29 April 2009

Railo - Compatibility issues with scopes (URL etc)

I'm migrating my development environment to railo and found some issues that affected my code.

One of the most important ones is that railo always references the scope name when you use URL, FORM etc no matter if a local variable with this name exists or not. To give you an example, run this code in CF and in railo:

<cfparam name="url.step" type="string" default="1" />

<cfset a_call = PrintURL( 'http://tunesBag.com/' ) />

<cfdump var="#a_call#">

<cfscript>
function PrintURL( url ) {
return url;
}
</cfscript>
To make railo behave the same way, you've to add a full reference to the function -
return arguments.url

In ColdFusion you'll see http://tunesBag.com as output, in railo the URL structure. Some further explanations concerning the scopes and this "bug" can be found here (Adobe Livedocs) and here (Railo Bugtracker)

Having fun with railo: CFQUERY supporting complex objects

I just came across a cool feature of railo - it's possible to set query columns to complex objects, e.g. a java object or a structure.

An example:

cfset q = QueryNew('data');
querySetCell( q, 'data', { firstname = 'John', surname = 'Doe' }, 1);

cfdump var="#q#"

You can access the structure by using q['data'][1]!

cool!

Important: This complex data won't survive a query of queries operation, in this case the simple classname will be shown in the column.

Monday 23 February 2009

CFFEED not usable due to missing timeout property

I've always used CFFEED in order to read newsfeeds (e.g. display recent blog postings on the homepage); now we had serious problems with non-responding feeds - and as it seems there is no workaround (see posting by Ben Nadel as well). As solution I decided to go back to cfhttp and simple parsing of the XML document.

Sunday 15 February 2009

"Corrupt table" errors (ColdFusion 8, mysql)

We have to do a lot of caching in order to keep the performance of tunesBag.com, so cached queries are very important for our website. During the last two days a lot of "corrupt tables" errors showed up in the log and first I thought about a mysql database issue of course. It's a bug in ColdFusion, however, so in case you run into the same error use this hotfix: http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402583

I've updated our live servers and I hope we won't see this error again.

Sunday 25 January 2009

Enhance performance of Joins / Queries: Make sure all columns share the same collation

At tunesBag.com, we're storing most of the data in UTF-8 / Unicode because we've customers from all over the world. Some internal data like userkeys, entrykeys etc are stored in latin1 because it needs less space. I recently came accross a query which was very slow without any obvious reason and after some research I found out that in a left join, the column A from table A has a different collation than column B from table A.
I changed the collation for column B to the same as column A - and the query executive time dropped from about 1300 msec to 100 msec!

So always make sure you're using the same collation if possible when performing joins!

Friday 16 January 2009

JavaScript variables set in onclick - different behaviour in IE / FF

I recently discovered that the behaviour of internet explorer and Firefox is quite different when it comes to settings variables in an onClick event - in Firefox these variables will become global variables, in IE they are just "local" and will nur be available for other functions.

An example:

a onClick="variableA = 'peter';CallFunction();return false;" ...

function CallFunction() {
alert(variableA);
}

In FF, an alert box will show "Peter", in IE you'll receive an exception.

How to solve that? Simply declare variableA on top of your JavaScript file, this way IE will modify the global variable.

var variableA = '';

Tuesday 6 January 2009

Railo - important path placeholders

I'm playing around with railo, a full featured alternative CFML engine and so far, I'm very impressed. During testing my existing applications with this new environment I had to add some custom mappings in the administration (by the way, there are two admin engines, the first one is server-wide, the second one just for the current webroot).

When creating these custom mappings, there are some very interesting path placeholders you can use:
{railo-web}: path to the railo web directory typical "{web-root}/WEB-INF/railo"
{railo-server}: path to the railo server directory typical where the railo.jar is located
{temp-directory}: path to the temp directory of the current user of the system
{home-directory}: path to the home directory of the current user of the system
{web-root-directory}: path to the web root
{system-directory}: path to thesystem directory

This way you can create mappings without using the full path to the directory - very cool!