Coldbox interceptor to redirect traffic from HTTP to HTTPS

Posted in Coldfusion
August 19, 2013

I needed a solution at work to redirect HTTP traffic to the HTTPS version of a website. The site is built on ColdBox and I did manage to find a plugin to do exactly this, the problem was that I couldn’t get it to work properly and it did not allow me (as far as I could tell) to turn SSL off in my development environment and on in the live environment. So I wrote a quick interceptor for ColdBox that works quite nicely and allows me to do everything I need to.

component extends="coldbox.system.Interceptor" {

	public function configure() {}

	public function preProcess(event, interceptData) {
		if (getSetting('useSSL')) {
			if (len(getSetting('AppMapping')) <= 1) {
				var path = "https://#cgi.HTTP_HOST#/index.cfm";
			} else {
				var path = "https://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm";

			if (len(cgi.path_info) > 0) {
				path &= cgi.path_info;

			if (isBoolean(cgi.server_port_secure) && !cgi.server_port_secure) {
				setNextEvent(uri=path, ssl=true, statusCode=302, queryString=cgi.query_string);

You’ll notice that I do a getSetting(‘useSSL’). This is a setting that I have defined in my Coldbox.cfc config file that I turn on in production and off in development.

Upgraded to Mountain Lion… finally!

Posted in Tech
August 10, 2013

It took me a while, but I finally took the leap of faith and installed OSX 10.8 – Mountain Lion. First impressions are really good. I am loving the notification centre with new touchpad gestures, the messages application, iCloud and social integration and the updates that Apple gave to the mail app.

With this upgrade I’ve decided to start embracing the full Apple product suite more, ¬†from iCloud (never really used it properly before) to remote syncing for iTunes and more of the OSX software like and Safari. I’m also really liking airplay between all the Apple devices in my house.

Bring on Mavericks in a few weeks time, I’m definitely upgrading as soon as it arrives! Maybe it’s actually time to get that Apple developer license I’ve always wanted.

Dual external monitors on a non retina display MacBook Pro

Posted in Tech
August 9, 2013

At work we’ve recently been given two really sleek LG LED 23″ monitors that we connect to a Dell docking station and run side by side. We all have high spec Dell laptops and it works great! In the past we used to just connect a single display to our laptops and use our laptop display as the main display and the external display as an extension.

Since switching to this setup my life has been changed forever. I can’t believe how much of a difference it makes having the same two monitors side by side with the same resolutions. Not only does it look great and fluid, it’s awesome to work on.

At home pretty much everything is Apple including my notebook, I have a 13″ MacBook Pro (late 2011 model), and I want need the same setup as I just described above. So I’ve been doing some research and unfortunately the options with MacBooks are really limited:

  1. Buy two thunderbolt displays which you can chain together. Problem is that they are hellishly expensive and not really an option right now. A single display maybe, but not two. So I’m ruling this option out.
  2. Buy a retina display MacBook Pro. They have two thunderbolt ports and you can easily connect two displays to them. I’ve wanted a retina display MacBook for a long time now, but we’ve just bought a house and this is probably not an option right now either :’(
  3. USB to DVI adapter. This is probably the most realistic solution for me right now, but from what I’ve been reading around forums, it can be extremely slow. Essentially it’s limited by the speed of the USB port and the adapter contains its own GPU.

There was one other solution I looked in to that turned out to be bogus.

  1. USB to HDMI adapter. If your MacBook has an intel graphics card it will only be able to support one external monitor (through the thunderbolt port). The reason why the USB to DVI adapter solution above will work is because it has its own GPU in the adapter.

What I’ve decided to do for now is wait it out until I get a retina MacBook. It sucks, but at present the only viable solution would be the USB to DVI adapter and that feels half-baked.

Thread safe variables in a Coldfusion Component

Posted in Coldfusion
August 8, 2013

When creating Coldfusion components, you need to be careful that you protect your variables from being overwritten and accessed by other requests or threads. If you don’t, you could see some really weird behavior in your application. Luckily, it is really simple to make your variables thread-safe by var’ing them.

The example below uses CFScript but can be easily translated to the tag based language.

component {
	function yourFunction() {
		var declaration = "value";

Notice the var keyword at the start of the variable declaration.

The main thing for me is to remember to var the variables in the first place! I often-times forget to do this (thank the Pope for code reviews).

Scout – live SASS (and Compass) build tool

Posted in HTML / CSS
August 7, 2013

In the past to build my SASS files I have always used the command line and/or an Ant script to do the dirty work for me. While this solution works well, I got tired of writing build scripts for small projects when they are not really necessary.

Today I stumbled upon Scout. It’s a free, cross platform tool which does live building of your SASS/Compass scripts as you save the source. So far it’s working well. I did have a few issues with slowness on my Windows machine at work (it runs fine on my MacBook). For some reason the application takes a long time to respond to click events, but other than that it builds my SASS files nicely and is really simple to use.

The other nicety of Scout is that it works well with Compass too. While I haven’t done much with Compass as of yet, I definitely plan on using it in the future. From reading some short tutorials and the docs, it looks really powerful.

I’m still looking for a decent Sublime Text plugin to build my SASS files, I’ve yet to find one that works well. For now, Scout and Live Reload are an unstoppable combination :)

Get Package Control to work with the Sublime Text 3 beta

Posted in Editors
August 6, 2013

I’ve recently upgraded to the Sublime Text 3 beta and as with any installation of Sublime Text, the first package that should be installed is “Package Control“. I only discovered its awesomeness recently and realized how much I’ve been missing out on. In short if you’re not aware of Package Control, it allows you to easily install, remove, enable, disable etc Sublime Text packages.

When installing Package Control on Sublime Text 3 beta, I’ve found that in 66% of my installations (I have 3 machines and tried installing it on all of them) it does not work by running the single command that is provided on the installation page – 2 out of my 3 installs failed. The reason why it doesn’t work is detailed here as well as how to get it working on Sublime Text 3 beta.

If you’re just wanting the quick command to get it working, go to your Sublime packages directory in a *nix terminal or git bash console on Windows and run the following commands.

git clone "Package Control"
cd "Package Control"
git checkout python3

Basically the command clones the repo to your packages directory, and lastly checks out the branch called python3 which is where the development for Sublime Text 3 beta is happening.

If you don’t learn Javascript, you’re going to get left behind!

Posted in Javascript
May 17, 2013

The official first day of the CF.Objective() conference has wrapped up and it was a pretty awesome day. There were lots of excellent talks by excellent developers in the ColdFusion and Javascript communities.

My big “take home” for the day was that it is becoming essential for every web developer to learn how to write Javascript properly, not just hack some jQuery together.

The day started off with the opening keynote address that was done by Dan Callahan from Mozilla and he talked about why you should learn to code with Javascript. He focused on Javascript performance, Firefox OS, mobile Javascript apps and the increasing popularity of the language. It really hit home for me and I couldn’t agree more with him on this. Needless to say, I spent most of my day on the JS Objective track.

As the web grows, browsers become more powerful and mobile web traffic increases so is Javascript becoming more useful and popular. Javascript has come a long way since the early days of the web and these days there are all sorts of applications built with it from 3D games to mobile apps.

So why should you (and I) learn to code Javascript properly?

  • Javascript is fast and getting faster
  • It is cross platform and works across browsers, mobile browsers, operating systems etc.
  • You can build mobile applications with it
  • Useful APIs – Javascript can now make a phone vibrate for example!
  • There is a great Javascript community
  • Tons of useful libraries from PDF renderers to physics engines and charting libraries
  • Many good frameworks for writing good clean code and MV* type applications

Those are just some of the many reasons why we should learn to code in it. I definitely get the feeling that in a few years time it’ll replace the current popular web programming and scripting languages when it comes to displaying and manipulating data (on the front end).

I’m looking forward learning more Javascript goodness at tomorrows talks!

CF.Objective() 2013 ColdFusion conference

Posted in Coldfusion
May 15, 2013

cfobjective 2013

If you follow me on Twitter or Facebook, you’d have noticed that I arrived in the USA last week Friday and have spent the past few days in northern Idaho visiting a good old friend of mine. I had a really good time in Idaho and would loved to have stayed longer, but the main reason I am visiting the States is to attend the 2013 CF.Objective() conference. I’m currently writing this blog post from the Denver International airport, waiting to board a flight to Minneapolis.

The conference starts tonight at the Radisson Blu hotel in Minneapolis and if you have not heard about it before, it’s the number 1 ColdFusion conference worldwide. This year there is a really strong speaking line up and some interesting talks. Check out the official conference website for the schedule and more info.

If you’re attending the conference, hope to see you there!

R140 million or R40 million, that’s not the point!

Posted in Thoughts
March 4, 2013

News of the apparent misspending by the Free State government here in South Africa spread like a wild fire out of control today – and rightly so! It was picked up by local media and even made it’s way on to the HackerNews front page.

From what’s been written, the whole deal reeks of corruption. From the amount spent on the website, to the deal being signed in 2011 which coincidentally seems to be when Cherry Online Design was formed (at least, that’s when the Facebook page as created). For those of us who live in SA and pay taxes, unfortunately corruption is pretty much an every day occurrence.

The Free State government tried to justify the cost by saying that the deal was R40 million and not R140 million. That’s not the point! The point is, they’ve wasted millions of tax payers hard earned money on something that should have cost a fraction of the price, even at R40 million. The point is, they should be ashamed that people are starving in their province and they’re unnecessarily wasting money. The point is they’re contributing to the overall growing negative image of South Africa globally.

The big issue here in my books is not that WordPress was used or even for that matter, that a premium theme was used! Some of the biggest websites on the internet are built on WordPress and I’m probably its biggest fan. We should actually be commending the Free State government for embracing open source technology.

The big issue is that as South Africans, we’ve pretty much have had to accept corruption because there is no consequence to corrupt behavior. Hey, just ask our President.

The road ahead, 2013.

Posted in Life
January 2, 2013

Yesterday I blogged about my 2012 year in review. There were lots of ups and downs last year and I learnt some valuable lessons at the end of the day. It has inspired me to do better this year and pursue my goals harder than ever before.

As far as new year resolutions/goals go, you’re either one of those that loves them or hates them. I’ve been on both sides of the fence. There’s been years where I have thought to myself, “Why bother?”. But nowadays, I really see the value of setting new year goals. I see them as my medium to long term goals that just coincidentally get set at the beginning of each year. The only difference between new years resolutions and monthly/weekly goals is the time frame.

Setting goals is the easy part though, executing and following up is the difficult part. I’m notoriously bad at the following up part. This year, I’m making a conscience effort to review the new year goals monthly and make sure that I am on track. It also gives me the opportunity to plan my monthly and weekly goals better knowing exactly what the bigger picture is!

So, without further ado, here are…

My goals for 2013

Write 1000 words a day

I’ve been really inspired to start writing lately. I’ve seen how writing can literally change a persons life in so many ways (especially in the tech/development world). Writing is an art form that takes time to perfect and I’m quite the amateur, but the only way to become a better writer is to write more.

The challenge I have set myself is to write a minimum of 1000 words a day. It’s hard! A lot harder than you’d think. I wrote my first 1000 word blog post yesterday and it took me a good hour or two. But the more words you write, the easier it gets and the more it starts to flow.

I’m going to split my 1000 words a day between blog posts, articles, and other cool things I have planned, see below.

Blog often

Ahhh, the good ol’ “blog more often” goal. How many times have you seen this one show up on new years resolution lists? Seriously though, blogging has so many benefits personally and professionally.

Last year I read the book (actually listened to it) called Platform by Michael Hyatt and a lot of what I had been thinking about blogging and building my own platform were reinforced by the book. It’s a really great read and has inspired me to really get my blog and platform together. For me, blogging is the key ingredient to building your platform and something I am going to focus intensely on.

Write 6 articles for some of the large web publications

One every two months. It doesn’t sound like much but it’s a lot of hard work. I’ve got lots of knowledge that I have picked up over the years in startups and development environments that I would like to share. This year I’ll be using some of my 1000 words a day to write really good articles for some of the big web development websites and publications. It’s also a big part of building my platform.

Start new open source projects

This year I’d like to release at the very least one new open source project. It will most likely come in the form of another WordPress plugin, but I need to start releasing some of the code I write. As a developer I write a lot of code, but 99% of it never gets released as open source. This needs to change, I need to write and release more open code.

Support and maintain open source projects better

Following on from the previous goal, I need to support my open source code better. This is much harder than writing and releasing but arguably way more important.

I’ve slacked quite a lot with the current code that I have released. Take for instance my WordPress Most Popular plugin. I’ve got 5 pull requests waiting for me! I’ve got to get better at managing the code that I have released.

Also, I want to contribute to more open source projects. Just today I fixed a bug in some software that we use at work and it felt really good. I’d love to contribute to the WordPress project this year as it has done so much for me throughout my development life.

Start and finish writing a book

Probably my most ambitious goal for this year is to write a book. I’ve always wanted to write one, but keep putting it off. I’ve even had a few paid offers to write books but ended up turning them down due to fear. This year I am biting the bullet and I am going to just start writing.

I have no idea what I am going to write a book on yet, but it will definitely be about something related to development and I’ll most likely self publish it.

Develop a product

I want to release a product this year. I’m going to build something, package it as a product and sell it on my website. Again, I’m not too sure exactly what I am going to build yet, but I have a couple ideas.

Pay off one of our cars

In 2011 I read a book called “The Total Money Makeover” by Dave Ramsey. It changed my outlook on money and finances. I decided that I am going to live my life debt free as soon as possible and only pay cash for things (excepting a house).

In 2012 myself and my wife made good strides to becoming debt free. We’ve paid off and cancelled our credit cards, clothing accounts and other small debts that we had. All the debt that we have left is two car loans. By the end of 2013, we’re hoping to have just one car loan left!

Completely finish the 2nd year of my computer science degree

As mentioned in my review post, I did terribly last year with my degree. This year I am setting a goal to simply and swiftly finish all the modules in the second year of my degree. I’m more than capable of doing this, it is just going to take some hard graft and determination!

Start trail running

I’ve wanted to start trail running for a long time now. There are tons of really cool runs each weekend around Pretoria and Johannesburg that I am going to get involved in this year. I’m quite unfit at the moment so it is going to take a good effort to get to a point where I can compete in the longer trails. I’m going to start off on the short 5km/7km trails.

Let’s go!

Those are the big goals that I have for 2013. I’m really excited about making them happen. The next review for me is on the 1st of February 2013. I’ll write a post then to recap how things went in the month of January. Let’s go!