JavaScript

Private Members In CoffeeScript

Apr 2, 2015

I’m a big fan of CoffeeScript. I find it to be more expressive and less clunky than regular JavaScript, plus it makes it easier to extend objects and emphasises lambdas. However, CoffeeScript partially obscures the native closures in JavaScript and as a result makes it very difficult to use private variables and methods.

Read More →

Classes, Inheritance And Mixins In JavaScript

Apr 1, 2015

JavaScript doesn’t have native support for classes. Functions can be used to simulate classes (somewhat), but in general JavaScript is a class-less language. Everything is an object. This makes inheritance particularly strange, since objects inherit from objects, not classes from classes as in languages like Ruby or Java.

Read More →

Internal Classes In CoffeeScript

Mar 23, 2015

CoffeeScript provides us with a very nice syntax for creating classes.

Read More →

Using Custom Directives in AngularJS

Sep 8, 2014

One of the areas I found the most confusing when starting out with Angular was directives. However, once I got comfortable with directives I found it to be true what most articles on directives were saying – they are really powerful and can really clean up your code.

Read More →

Prevent a User Navigating Away from a Page with Unsaved Changes

Dec 4, 2013

On my current project we have the problem where users will often navigate away from a page without saving their changes. The users of our application are often unfamiliar with websites and therefore simply navigate away without hitting update (as you would if you’re only familiar with desktop applications).

Read More →

Integrating EJS Templates into Rails

Nov 4, 2013

I’ve been on few projects where we need to have client-side view templates. This would mostly involve making an AJAX request to the server, getting back some JSON data at which point we need to convert this into HTML. EJS is one of a number of solutions to this problem.

Read More →

AngularJS Pain Points

Jul 11, 2013

I’ve been using AngularJS for almost 3 months. I had heard quite a lot about Angular before this time – many people were talking about it being the ‘next big thing’ and how it could become the defacto JavaScript framework for client-side development.

Read More →

Check if a variable is defined in CoffeeScript

Jun 4, 2013

In JavaScript it’s pretty common to check if a variable has been created. You would usually perform the check with the following code:

Read More →

Debugging CoffeeScript Line-by-Line

May 14, 2013

One of the main arguments against using CoffeeScript is that of debugging. CoffeeScript is compiled down to JavaScript before being sent to the browser which means we can only debug the compiled JavaScript version of our code, not the original CoffeeScript. Until now, that is.

Read More →

Custom Sorting in AngularJS

May 9, 2013

Today I had to implement custom sorting in AngularJS. As with most things in Angular it’s very simple once you figure out how.

Read More →

10 CoffeeScript Features You Might Not Know

May 6, 2013

This week I’ve spent some time researching different CoffeeScript resources to be used for training at a client. In the process I’ve discover a few CoffeeScript features that I didn’t know about or are not that well known.

Read More →

Resources for Learning CoffeeScript

May 3, 2013

CoffeeScript is a little language that compiles down to JavaScript. I’m a big fan of JavaScript, but it’s definitely a very quirkly language. CoffeeScript eliminates some of those quirks and brings JavaScript’s syntax more in line with languages like Ruby and Python.

Read More →

Using ngResource with AngularJS

Apr 30, 2013

In my first post on AngularJS I created a simple Todo application with a Rails/Mongo RESTful server. In this application I was doing all my ajax calls manually (which is really easy in Angular), which meant most of my controller methods looked like this:

Read More →

Getting Started with AngularJS

Apr 24, 2013

Read More →

Using Spine.js mobile

Oct 8, 2012

For the past 3 weeks I’ve been working on a mobile website for a hybrid iPhone app. We were already using Spine.js – as I mentioned in a previous post – and therefore Spine.js mobile was an attractive choice for building the mobile part of our website.

Read More →

Shared Examples with Jasmine

Sep 20, 2012

On my current project we’re doing quite a bit of JavaScript development using CoffeeScript and the Spine.js framework. Since we practice TDD we’re using Jasmine to drive all our CoffeeScript code and I’ve found it to be a great little framework.

Read More →

Six months with Spine.js

Aug 6, 2012

I have spent the last six months on a project where we are using Spine.js as one of the main technologies. Spine is a JavaScript library that allows you to build client-side-heavy applications with the MVC pattern using CoffeeScript.

Read More →

Method Resolution in Ruby

Jan 26, 2012

While reading the Ruby Pickaxe book I realized that while JavaScript and Ruby are both dynamic languages, they handle method resolution in very different ways. I often use JavaScript as a reference since it’s the dynamic language I’m most familiar with.

Read More →

JavaScript (or any other) as a First Language

Dec 27, 2011

A few weeks ago John Resig announced that Khan Academy will most likely be using JavaScript as the language of choice in Computer Science – prompting the discussion on the viability of using JavaScript as a first language.

Read More →

Better JavaScript–Iterating Arrays

Sep 16, 2011

If you do JavaScript on a regular basis you probably end up iterating over arrays fairly often.  And if you’re anything like me you’re going to end up missing the foreach looping construct in C#.

Read More →

Better JavaScript–What is this?

Jun 28, 2011

JavaScript has quite a few ways of using the this keyword, but it’s not really that difficult to know what this means in the different contexts.  Let’s take a look at the different meanings of this.

Read More →

Better JavaScript-User Defined Objects

Jun 22, 2011

In my last post I had a look at how we declare namespaces in JavaScript.  In that example I simply declared a function which was then accessible anywhere by simply referencing the correct namespace.  Today I’m going to take a look at creating custom JavaScript objects using the same kind of namespace syntax.

Read More →

Better JavaScript–Namespaces

Jun 21, 2011

I have recently had the opportunity to do some JavaScript-heavy programming which has allowed me take stock of my understanding of the different structures in this language.  Today I’m going to look at one of the most straightforward challenges in JavaScript – declaring namespaces.

Read More →

3D Tic-Tac-Toe with HTML5

Mar 25, 2011

I recently helped to organize a programming contest where you were required to write a Tic-tac-toe game using only HTML, CSS and JavaScript.  You then had to host your solution on jsFiddle.

Read More →

Ajax improvements in MVC 3

Jan 19, 2011

This post is part of the series I’m doing on the newly released ASP.NET MVC 3.

Read More →

Authentication with OpenId–Part 2

Jan 14, 2011

I my last post I created a very simple example of how to authenticate users with OpenId.  In that example the user needed to enter the full URL to their OpenId provider.  Today I’m going to modify that example to make the authentication process a little easier on the user.  To give you an idea of what I’m going on about, take a look at the login form for StackOverflow.

Read More →

Why FIFA.com crashed

Jun 5, 2010

If you’re soccer fan like me (the World Cup is only 2 weeks away!) you probably encountered considerable frustration in the past week.  This is due to FIFA ticketing system.  FIFA allow fans to buy tickets through the FIFA.com website (which generally works pretty well), but in the past few weeks there have been a number of outages leading to some seriously annoyed customers.  This culminated on Friday – FIFA had announced that 150 000 extra tickets would go on sale by 9 AM, but their website simply couldn’t handle the extra load and 24 hours later the problem still hadn’t been resolved.

Read More →

Debugging JavaScript errors

Jan 6, 2010

I have noticed that quite a few developers are unaware of one of the simplest methods of finding JavaScript errors in your page.  JavaScript exposes an event handler that fires whenever a JavaScript error occurs in a page.  Using it we can suppress all JavaScript errors on the page or display an error dialog.

Read More →