Jan 25

Switching from Windows to Ubuntu

Posted by James Netherton | Sunday 25 January 2009 19:17 PM | In Linux

Last week my four year old Windows XP installation started creaking at the seams and doing all kinds of weird things so I decided to back up my data and give Ubuntu a try. I’ve been switching back and forth between operating systems for the last eight years, installing Linux, getting frustrated or missing certain aspects of Windows.

Not so this time! I can’t see myself making a permanent switch back to Windows, Ubuntu has everything I need. Anything that didn’t come pre-installed is easily installed with APT. Should I need Windows for anything, I’m running XP virtualised under VirtualBox (which so far seems superb).

Overall, OS X is my preferred operating system but I’m more than happy with Ubuntu. Hopefully I can stick with it for more than a few weeks this time.

Jan 23

Blog migrated to Wordpress

Posted by James Netherton | Friday 23 January 2009 23:01 PM | In Blogging

I toyed with the idea of converting the blog from BlogCFC to Wordpress in 2007 but ended up sticking with BlogCFC. I’ve now decided to migrate over to Wordpress. It’s been an interesting exercise and overall, quite a simple one. I had all of my blog data imported into Wordpress via my BlogCFC to Wordpress conversion tool (which I’ve updated to fix a few small issues).

Recreating the look and feel was also pretty simple. Writing Wordpress themes isn’t as daunting as it first looks. So long as you have a clean XHTML & CSS layout, it’s a simple case of marking up the required header, footer & sidebar layout templates.

Any other BlogCFC specific functionality (like CF syntax highlighting) I managed to cover off by installing a few Wordpress plugins. Finally, I have Apache 301 redirecting any BlogCFC / CF URL’s, so hopefully my search rankings wont be affected too much!

Dec 01

My final month working with ColdFusion

Posted by James Netherton | Monday 01 December 2008 2:12 AM | In Blogging

This month marks the end of my four years of (almost) day to day ColdFusion programming. In the new year I’m moving on to pastures new and will be working exclusively with Java from then onwards.

So why the change? In the main, it’s due to wanting a new challange and something to rekindle my motivation for software development, which has been waning over the past year. I also wanted to get some solid experience of another programming language as a sort of career protection thing.

I’m not planning on giving up CF programming entirely, I’ll definately be checking out CF 9 but I’ll be trying to post more about Java related stuff in future.

Nov 30

Disable windows indexing service to prevent VMWare Fusion maxing out CPU

Posted by James Netherton | Sunday 30 November 2008 7:11 AM | In Windows

A while back I posted about disabling the automated Windows hard drive optimisation service in order to save CPU time and prevent parallels from grinding to a halt.

I’ve since switched to VMWare Fusion and have noticed that every so often, the VMWare process consumes 100% of the CPU even though Windows is idle in the background. I figured out that the culprit was the Windows indexing service, which kicks in when the OS is idle to index files.

Simply disable the indexing service from the Windows services control panel area and that should solve the problem. I haven’t seen any negligible effect of doing this so far, Windows searches are usually pretty sluggish even with the indexer turned on!.

Nov 04

Make your XML look pretty

Posted by James Netherton | Tuesday 04 November 2008 11:11 AM | In Java

Credit goes to Joe Rinehart for most of this from this post.

ColdFusion ships with JDom which gives you full access to the JDom API. Many of the applications I work with have some kind of XML component to them and sometimes the XML is difficult to read if it’s not formatted nicely.

I’ve used Joe’s code example to create a simple interface on top of it. It also works with valid XHTML.

<cfparam name="form.submit" default=""/>
<cfparam name="form.xml" default=""/>
<cfscript>
function prettyXML(xmlString){

	var fileObj = "";
	var builder = "";
	var format = "";
	var out = "";
	var document = "";
	var fileInStream = "";
	var fileOutStream = "";
	var filePath = expandPath("./prettyXML.xml");

	try{
		fileWrite(filePath, arguments.xmlString);

		fileObj = createObject("java", "java.io.File").init(filePath) ;
		builder = createObject("java", "org.jdom.input.SAXBuilder").init() ;
		format = createObject("java", "org.jdom.output.Format").getPrettyFormat() ;

		format.setIndent("	");
		out = createObject("java", "org.jdom.output.XMLOutputter").init(format);
		fileInStream = createObject("java", "java.io.FileInputStream").init(fileObj );

		document = builder.build(fileInStream);

		fileInStream.close();

		fileDelete(filePath);

		return out.outputString(document);
	}
	catch(Any excpt){
		if(isDefined("fileInStream") and fileInStream neq ""){
			fileInStream.close();
		}

		writeOutput("<p>#excpt.message#</p>");
		writeOutput("<p>#excpt.stacktrace#</p>");
	}
}
</cfscript>
<html>
<head>
<title>Paste your ugly XML</title>
<style type="text/css">
	body, input{
		font-family:Trebuchet MS;
	}
</style>
</head>
<body>
<h3>Input your XML:</h3>
<cfoutput>
<form action="#cgi.SCRIPT_NAME#" method="post">
<p><textarea name="xml" rows="20" cols="100">#form.xml#</textarea></p>
<input name="submit" type="submit" value="Go"/>
</form>
<h3>Pretty XML</h3>
<cfif len(form.submit) and len(form.xml)>#htmlCodeFormat(prettyXML(form.xml))#</cfif>
</cfoutput>
</body>
</html>

Oct 16

London fashion – Reading whilst walking along

Posted by James Netherton | Thursday 16 October 2008 17:10 PM | In Blogging

Just one of many observations made on my commute to and from work……

Tis the current fashion in London to read a newspaper or book whilst walking along. While this does allow one to finish a chapter or complete the crossword whilst on the move, it does have the minor drawback of not being able to see where one is going.

This behaviour usually exhibits itself on crowded streets, busy tube platforms and station concourses. The effect of this is demonstrated thus…..

The unfashionable non reader walks by using the standard method of looking where he is going and thus avoids others:


Standard Walking

The alternate method of reading whilst walking along produces the following effect:

Reading While Walking

So absorbing is the book that the reader weaves from side to side while others take avoiding action until the inevitable collision occurs.

Oct 10

MySQL – Can’t connect to MySQL server on ’server’

Posted by James Netherton | Friday 10 October 2008 5:10 AM | In MySQL

I’ve just wasted a couple of hours trying to figure out why my mac keeps getting the response “Can’t connect to MySQL server on ’server’” when trying to connect to MySQL on my new vmware Ubuntu setup.

The solution is rather simple!

Open up your MySQL configuration file and find the –bind-address directive. It’s most likely that it’ll be set to 127.0.0.1 which makes MySQL listen for connections only via the loopback IP.

Comment out this line and save the configuration file. Restarting MySQL didn’t seem enough to make this work for me so I had to restart the OS.

Sep 13

Just married

Posted by James Netherton | Saturday 13 September 2008 11:09 AM | In Blogging

Just married nearly three weeks ago in fact! Hence my lack of blogging or interest in anything computer related over the past month or so, since there has been so much to do and organise.

My wife Sophia and I had a fantastic day. We were married at Romsey Abbey in Hampshire which proved to be a spectacular setting for the marriage service and a great backdrop for our (many) photographs.

The reception was also really enjoyable and my speech seemed to go down well with everyone, which was a relief considering I wrote it on the morning of the wedding!

There were some slight hiccups. Closer inspection of my marriage certificate revealed some embarrassing spelling errors on my father’s, Sophia’s and my occupation description. Not sure who the illiterate person was who filled out the details but I’m trying to get it changed.

Then there was the debacle over our (rather expensive) wedding cake. The staff at the reception cut portions of the cake so everyone could have a piece. Overnight it transpired that the reception venue staff had dumped the remainder of the cake in the bin, without any consultation with our parents or Sophia and I! Even worse, I recently found out that some of the staff had been helping themselves to bits of the cake while the evening party was going on.

For honeymoon we decided to go to Paphos in Cyprus for two weeks. The first five days were quite relaxing and then Sophia fell ill with a nasty stomach virus. Things got so bad that she ended up in hospital for three days. When she was released there was a strict diet for her to follow, so we were pretty much confined to the hotel for the remainder of the holiday. I didn’t expect to be tested on the ’sickness and in health’ vow quite so soon!

Problems aside, we still had a great time together and there’s still a day or so for us to enjoy together before we head back to work.

Aug 05

Call custom tags without cf_ or cfmodule

Posted by James Netherton | Tuesday 05 August 2008 8:08 AM | In ColdFusion

This may be common knowledge but I just stumbled upon it…..

The standard convention for invoking ColdFusion custom tags is to use:

<cf_mytag/>

or

<cfmodule template="mytag.cfm"/>

There’s a way in which you are able to dispense with cf_ prefix and the <cfmodule> call. Browse to your ColdFusion WEB-INF\cftags directory. You should see some files relating to ColdFusion tags such as <cfdump> and <cfsavecontent>. You can add your own custom tag to this directory and invoke it from any CF template. For example:

Custom Tag – mytag.cfm

<cfdump var="#attributes#"/>

Calling Template

<cfmytag attribute1="test1" attribute2="test2"/>

Note that the cf_ or <cfmodule> prefix wasn’t used. Instead the tag call looks like any normal ColdFusion tag invocation.

I doubt this has any real world usage but I thought it was worth blogging anyway.

Jul 08

Reserved ColdFusion function names

Posted by James Netherton | Tuesday 08 July 2008 15:07 PM | In ColdFusion

Most people are aware that you cannot give a name to a ColdFusion function that is equal to the name of one of the ColdFusion "built in" functions.

This started me thinking that as ColdFusion templates and CFC’s are compiled down to Java servlets, there must be additional function names that are ‘reserved’. Each template and CFC page will naturally extend java.lang.Object and therefore inherit all of Object’s public methods.

For example, try the following:

<cffunction name="getClass">
</cffunction>

The result is “The name getClass is the name of a built-in ColdFusion function". You get the same result when declaring a function with the names "wait", "notify" and "equals", all of which are public methods on java.lang.Object.

These are only a few examples, I’m assuming that there must be more reserved function names given the number of classes that ColdFusion template and CFC servlets could potentially extend from.

The getClass method opens up the potential for some fun with ColdFusion:

Get the current template class name

<cfoutput>#getClass().getName()#</cfoutput>

Get the current template class properties

<cfset fields = getClass().getFields()/>

<cfloop array="#fields#" index="field">
	<cfoutput>#field.getName()#<br/></cfoutput>
</cfloop>

Get the current template class methods

<cfset methods = getClass().getDeclaredMethods()/>

<cfloop array="#methods#" index="method">
	<cfoutput>#method.getName()#<br/></cfoutput>
</cfloop>

Get the name of the class that the current template extends from

<cfoutput>#getClass().getSuperclass().getName()#</cfoutput>

Jul 07

Flex coding standards and best practices

Posted by James Netherton | Monday 07 July 2008 8:07 AM | In Flex

Adobe have added a list of Flex standards and best practices on their open source wiki.

Apparently it’s not 100% complete yet but it’s a nice set of guidelines nonetheless.

http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

Jul 01

Air IIS log reader

Posted by James Netherton | Tuesday 01 July 2008 2:07 AM | In AIR

After an hour or so hacking, I’ve put together a very simple Adobe Air application to read IIS log files that are in the W3C extended log file format.

Usage of the application is fairly obvious once it’s up and running so I won’t go into any detail on how it works. Here are some screen grabs that explain the basics. Click the thumbnails to see the full sized images.

Viewing a log file

Viewing a log file

Show / hide data columns

Show / hide data columns

View data row (double click datagrid row)

View data row

Here is the Zipped Air file and MXML source:


WebLogReader.zip

Air File


WebLogReader-Source.zip

Source Code


Jun 28

Disabling the Firefox smart location bar

Posted by James Netherton | Saturday 28 June 2008 6:06 AM | In FireFox

I’ve finally upgraded to Firefox 3, and after 10 minutes, I’ve found that I can’t live with the "awesome" smart location bar.

Here’s how to disable it:

1. Navigate to about:config and continue past the warning message

2. Search for the setting browser.urlbar.matchOnlyTyped and change its value to true

3. Restart Firefox

Jun 12

Disabling ColdFusion administrator authentication

Posted by James Netherton | Thursday 12 June 2008 6:06 AM | In ColdFusion

I find having to log into the ColdFusion administrator a pain when I’m working on applications in my development environment. You can disable the authentication process by way of the following:

1. Open up WEB-INF\cfusion\lib\neo-security.xml on multiserver installations or cfinsntallationdir\lib\neo-security.xml on standalone installs

2. Edit the admin.security.enabled property so that it appears as follows:

<var name="admin.security.enabled">
	<boolean value="false"/>
</var>

3. Save the file and restart ColdFusion

Obviously you would not want to be doing this in a production or publicly accessible environment!

Jun 04

Using jrunx classes in ColdFusion

Posted by James Netherton | Wednesday 04 June 2008 15:06 PM | In ColdFusion

I’ve been screwing around with classes within the jrunx Java package that comes bundled with ColdFusion (not sure if it exists if you aren’t running CF on JRun). There are some useful and interesting utilities and I’ve put together a very brief set of demos for a few of them.


jrunx.util.NetUtil


Lookup an IP address from a DNS string:

<cfset variables.netUtil = createObject("java", "jrunx.util.NetUtil")/>

<cfset variables.ip = variables.netUtil.resolveIp("www.google.com")/>

<cfoutput>#variables.ip#</cfoutput>

Validate an IP address:

<cfset variables.netUtil = createObject("java", "jrunx.util.NetUtil")/>

<cfset variables.hostValid = variables.netUtil.validateHostIp("127.0.0.1")/>

<cfoutput>#variables.hostValid#</cfoutput>

jrunx.util.ZipTool


Zip a directory:

<cfset variables.zipUtil = createObject("java", "jrunx.util.ZipTool")/>
<cfset variables.zipUtil.zipDir("C:/Test", "C:/Test.zip", true)/>

Zip a single file:

<cfset variables.zipUtil = createObject("java", "jrunx.util.ZipTool")/>
<cfset variables.zipUtil.unZipSingleFile("C:/Test.zip", "C:/TestUnzip", "myHTMLFile.html")/>

Unzip an entire archive:

<cfset variables.zipUtil = createObject("java", "jrunx.util.ZipTool")/>
<cfset variables.zipUtil.unzipToPath("C:/Test.zip", "C:/TestUnzip")/>

jrunx.xml.XMLScript


Change an XML entity value within an XML file:
XML Input File

<root>
	<person id="1">
		<name>James</name>
		<age>00</age>
		<occupation>Developer</occupation>
	</person>
	<person id="2">
		<name>Bob</name>
		<age>00</age>
		<occupation>Developer</occupation>
	</person>
</root>
<cfset variables.xmlScript = createObject("java", "jrunx.xml.XMLScript").init()/>

<cfset variables.inputFile = expandPath("./input.xml")/>
<cfset variables.outputFile = expandPath("./output.xml")/>

<cfset variables.args = arrayNew(1)/>

<cfset variables.args.add("-i")/>
<cfset variables.args.add(variables.inputFile)/>
<cfset variables.args.add("-o")/>
<cfset variables.args.add(variables.outputFile)/>
<cfset variables.args.add("-s")/>
<cfset variables.args.add("/root/person[@id='1']/name/text()")/>

<cfset variables.args.add("Joe")/>

<!--- Hackery to create a java string array --->

<cfset variables.dummyString = repeatString(" : ", arrayLen(variables.args) - 1)/>
<cfset variables.stringArray = variables.dummyString.split(":")/>

<cfloop from="1" to="#arrayLen(variables.args)#" index="i">
	<cfset variables.stringArray[i] = variables.args[i]/>
</cfloop>

<cfset variables.xmlScript.command(variables.stringArray)/>

XML Output File

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<person id="1">
		<name>Joe</name>
		<age>00</age>
		<occupation>Developer</occupation>
	</person>
	<person id="2">
		<name>Bob</name>
		<age>00</age>
		<occupation>Developer</occupation>
	</person>
</root>

Admittedly that’s a very lame example, there’s a proper overview of what the class can really do on the Adobe Jrun guide
There’s a full overview of jrunx classes and packages here.