Becoming a better programmer

Over the past year I’ve been trying to discover what I really want from a career. Ever since high school I’ve known that I wanted a career in IT and set out towards achieving that dream. I took the non-traditional route and decided not to go to college initially but instead taught myself to code as a youngster, finished up high school and set off to America to do a couple of internships. Life continued as it does and I ended up working in many different programming roles in quite a few different environments. I worked for myself as a contractor, I led development for a start up and more recently I took a full time position at a payments company as a programmer.

Being self taught, I’ve always felt like I’ve missed out on something. I’m not too sure what it is (perhaps just a solid computer science grounding) but there are many concepts and ideas that I either don’t know about completely or have very limited knowledge about. Worst yet, these days I feel like I have so little time to actually go back and learn all those concepts.

This is not to say that because I don’t have that grounding in computer science that I’m a crappy developer, I’ve made an effort over the years writing code and through real life experience to learn about important topics when it comes to writing software like design patterns, testing, algorithms etc. But even still, in this industry if you’re not learning 24/7 you’re going to fall behind. This learning has to happen after work hours. Over the past few years I’ve been guilty of not putting as much extra time after work in to my programming career as I would like and as I did when I first started out, and this definitely has had an effect on my growth as a programmer.

Throughout my recent discoveries I started to question whether programming is actually the career path I really want to follow. I felt quite down about it and a little overwhelmed actually. There is so much to learn as a programer and I questioned whether I could keep up at all. I questioned if I was even smart enough to be a programmer. This was all a little depressing to be honest as programming is always something that I’ve really enjoyed and been quite good at.

The turning point came to me a little while ago when I decided that I am good enough and I will take control of my career. I made a decision to learn continually and to become a master of my craft. Yes, I won’t always know everything and at times I will get it wrong but that’s just part of the learning process. This attitude has given me renewed energy and at work I’ve started to try take on some more complex tasks (such as refactoring very old legacy systems) where as in the past I wouldn’t have done this, instead I would have sat back and either let someone else drive the change (which doesn’t happen often in most workspaces) or just tried be content in working on crappy old code.

Now as part of taking control, I’m committed to doing a few things daily, weekly, monthly that will help me become the programmer I want to be. In no particular order, they are:

Finishing my Bsc degree part time

I’ve committed to finishing my BSc degree in Informatics. This commitment forces me to find the time to sit down and do the study that is needed. I’m not going to lie, this is probably the hardest thing I’ve ever done especially in-between work and family commitments but I’m learning about those core computer science principles/concepts that I missed out on by not going to college straight after high school.

Focusing

There is no way that you can know it all when it comes to programming. It’s impossible! There is just too many languages, frameworks, concepts etc out there. So I’m picking my toolset carefully and becoming an expert at that. In the past I’ve been very much a generalist, good at a lot of things, but never excellent at a single thing. In focusing there is a concern that my toolset is too narrowly focused and I’ll become irrelevant when the next big thing comes out but that can be countered by again just picking what you focus on carefully and constantly taking a step back to make sure you’re on the right track.

Podcasts

I’ve subscribed and started listening to a whole bunch of podcasts. Most of them are in the programming space which helps keep me up to date with the latest information around my specific languages (Ruby/JS) and tools of choice. These podcasts are really good to listen to during my commute to and from work as this time is usually wasted listening to a mindless, but I’ll admit entertaining radio show. Surprisingly enough, I have also found these podcasts rather inspirational, they give me ideas to try new things and also make me want to work harder.

Blogging

When I first started out as a programmer, I used to blog very frequently and this unfortunately stopped as I became more comfortable and I suppose as my responsibilities got bigger. It’s something that I really, really miss though. I love writing and even though there is a lot of room for improvement, there is something therapeutic about putting your thoughts in to words on a blog post. I need to blog more and with my focused toolset of choice there is lots to be written about. I’d like to at some point also start doing videos, but that’s for another day.

Reading

I’m a bad reader. I usually never finish a book or go past the 5th or 6th chapter. I’m working on improving that. I found that audio books helped a lot with getting through books to the end but when it comes to technical books, you need to read those with your eyes and code while reading them. I’m starting to read technical books again and the end goal is to finish them. There is so much knowledge to be gained by reading books. I always welcome suggestions of good technical books too ;)

Writing software

It sounds simple and obvious, but just by writing more software we become better programmers. It’s been a long time since I’ve contributed to open source projects and I would like to get in to this again. The added benefit of this is that you learn a lot from seeing how other people write code in open source projects. I need to also do a bit of a clean up here. Get rid of old projects that are no longer worth keeping alive and update the ones that are.

Following

One last thing that I have started to do is follow industry leaders more closely through social networks and blogs. I love it when an expert in a field has a blog which I can follow to learn as much as I can from them. Luckily in the programming space, there is a lot of that.

All the things mentioned above are consistent actions that need to be taken on an almost daily basis. What I haven’t quite figured out yet is where I will find the time for all of this, but I am finding with the things I’ve already taken action on is that it’s easy to find time for something if you value it and it is important to you. The actions mentioned above are important to me and I’ve stated making time for them. Then secondly, the key is to just get started. Just start writing the code, just start reading a book when you have a free 10 minutes (the Kindle app is great) and the more you just start working on things, the more they¬†will just fall in to place.

 

Issues with the Ruby Bamboo Plugin and Windows

A quick tip if you’re having issues with the Ruby Bamboo Plugin where your Ruby installation is not showing up in the list of “Server capabilities” in Atlassian Bamboo. I struggled with this issue for a while and after digging through the Bamboo logs, I realized that the plugin was throwing an error when it tried to load JRuby as a server capability – I didn’t have JRuby installed.

The solution for now, is to just install JRuby alongside your normal Ruby installation – make sure that the bin folder is in your environment path as well! Once you install JRuby and add the path variable, restart Bamboo and hit “Detect server capabilities” again and your two Ruby installations should show up.

It appears as this is actually a bug with the plugin. I’ve logged a issue on the Github project page.

Errors with Atlassian services starting on a 64 bit windows server

This is a quick tip if you’re having issues with getting the Atlassian Bamboo (or any other Atlassian product for that matter – Jira, Crucible, Fisheye etc) Windows service to work on your Windows server after a new install or an upgrade. I recently upgraded our Bamboo at work and got the following error when I tried to start the service:

The Atlassian Stash service could not be started. A service specific error occured: 1.

And the Windows event viewer reported the following error:

The Atlassian Stash service terminated with service-specific error Incorrect function.

The funny thing was that if I started Bamboo with the start-bamboo bat file, it worked perfectly. After searching the internet furiously, I eventually stumbled upon an article that was for Atlassian Stash but seemed relevant to Atlassian Bamboo too (it was the same error I was getting).

The fix was simple, the installer for Atlassian Bamboo came with the 32 bit binaries of Tomcat and we were running on a 64 bit machine. I had to swap out the Tomcat binaries with the 64 bit versions and the service started perfectly! To do this, find your ../bin folder and replace the tomcat7.exe and tcnative-1.dll with the 64 bit version.

Here are the 2 articles that helped me for your reference:

* https://confluence.atlassian.com/display/STASHKB/Stash+service+(64-bit)+fails+to+start+-+not+a+valid+Win32+application
** https://confluence.atlassian.com/display/STASH/Running+Stash+as+a+Windows+service

Coldbox interceptor to redirect traffic from HTTP to HTTPS

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!

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 mail.app 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

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

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

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

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 https://github.com/wbond/sublime_package_control.git "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!

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!