Tuesday, January 31, 2012

Regular Expression (RegEx) Remove illegal ones

Yesterday I was working on a site which pulled data from a third party xml file. We were having problems with illegal characters and as we have no control over what was being entered we decided to handle it on our end. Just thought I would post up a handy RegEx which cleaned it up for us.

cleanXML = reReplaceNoCase(xml, "[^-a-zA-Z0-9@`!""##$%&'()*+,-./:;\[{<\|=\]}>^~?_ ]", "", "ALL");

Tuesday, August 2, 2011

How I Got Started in ColdFusion

My 'How I got started' is going to be a lot shorter than most people but here it is none the less.
Since a younger age (I say younger cause some might say I still am young :P) I've always been interested in programming. It started with a close friend giving me simple programming task in C++, then VB.NET in high school and other side projects and languages I dabbled with.

On leaving high school (2008) I was unsure of what I wanted to do but eventually decided to go to university. After attending university for 6 months (2009) and not agreeing with the methods of teaching (You sit there and listen for hours on end and then just teach yourself when you get home. I never put anything said in class in to practice as we were too busy talking....) so I started looking for a job.

I applied for a junior software testing role in which I was successful (2010). After a few months I started to help fix very basic bugs and problems. These were my first dealings with ColdFusion. After 6 months of being a software tester I applied for a software development role in the same company and I was again successful. I've now been in the role for a year and two months mainly doing ColdFusion development but as well as some Flex/Action Script.

Wednesday, July 13, 2011

SQL Stored Procedures Performance

I've been told there are performance gains when using 'Stored Procedures'. Lately I've been wondering what the real gains of performance are and does it relate to a simple select statement?

First we need to create a test set of tables:

Now some code to generate data for the tables:

Now lets make the store procedure to select results:

And now the code we used to test the execution time of cfquery and cfstoredproc:


Now the results I got are very mixed. Sometimes the procedure is faster; sometimes it is not. I've never done anything like this before so I'm wondering if EXECUTIONTIME is the best thing to be comparing? Will using a store procedure in cases like this be that much faster (on such a simple select) or is it more for all the other benefits you get with using it?

Wednesday, May 25, 2011

Gobal iTunes Hotkeys

As I've been using iTunes more lately (See last blog post) I've found an annoying problem with my Z-Board at home that I cannot seem to get the media keys to act globally.

My Microsoft keyboard at work seems to works perfectly with iTunes (Funnily enough?) but not my Z-Board.

I tried a few global iTunes hotkey programs but the one that ended up working the best/easiest and that I settled with was iTunesControl (http://itunescontrol.com/).

Setup was simple:
Download and install the free program.
Find the blue music note icon in your 'Notification area'.
I like to disable the shit that pops up with the song name so that can be done under the 'Display' tab by selecting the option 'Disable display always'.
Then all you have to do is setup the hotkeys to use the media keys on your keyboard. This is done under the 'Hotkeys' tab.

Now enjoy global song changing!

Monday, May 23, 2011

Play songs from iPhone through computer.

A major annoying problem I've had with my iPhone has been playing music at home, on the train and while at work. I've always felt hatred towards the device for it not letting me just drag and drop my music where I want to. For quite some time now I've had a music library at home, which was synced to my iPhone and then another library at work. This sucked as they where never in sync and I always wanted a song which was at home while I was at work or vice versa.

Today my life was changed.
I no longer have two music libraries, just the one and I now play the songs directly from my iPhone through my computer via iTunes.

Plug iPhone into any computer with iTunes.
Select your iPhone under Devices.
Select Music under your device.
Play songs as you normally would.




Up until today I never knew this was possible but it was a massive oversight on my behalf and is a great solution to a problem I was having. It also has a plus side as it syncs your ratings, play counts, etc.

But it really was quite simple -.-

Thursday, April 7, 2011

ColdFusion - Var Scoping.

A couple of days ago I was making a little program to recursively list files in sub-directories.
In doing so I ran into a good example of why var scoping is so important.

File structure:

Non var scoped code:


Non var scoped results:


However when I properly var scoped the variables. 

var scoped code:


var scoped results:


In simple terms, when the function is being run the second time, ColdFusion is being lazy. Instead of making and declaring a new variable it is using the old one. Adding var scoping will make sure that whenever the function is run the variables are scoped to that instance of the function.

Flash Builder - Debug launches wrong page.

Does your flash builder debug launch using the wrong page?
Do you get weird errors like 'Error #2152: Full screen mode is not allowed.'?

Well perhaps it is launching the wrong page! You can check and change this setting very simply.
1. Right click on your project folder and click 'Properties'.
2. Click 'Run/Debug Settings'.
3. Select the 'Launch configuration' for the application in question and click edit.

What we are looking for is 'URL or path to launch'.
This will most likely be set as 'Use default' but if you uncheck the box it you can change it to what you want.


At work we use ColdFusion and want to hit a .cfm file to start the application instead of the normal .html file.