I’ve moved!

Go to blog.mattblair.co for new content.

Thanks for browsing!


Instrumenting Backbone for better error handling

At work, we’ve been having some issues tracking down some nasty client side bugs. We know they’re happening in our Backbone views, but we’ve been unable to locate them with any more accuracy due to the errors bubbling all the way to the window.onerror handler.

Enter Stackbone. A simple bit of code to instrument Backbone’s event loops to better locate client side errors.

To use:

  Backbone: Backbone
  jQuery: jQuery
  onError: function (err) {
    // ... log the error ...

You can use Stackbone = require(‘stackbone’) or simply include the .js file in a script tag. Enjoy!

Docco Fork – All JS, all the time

EDIT: My fork is no longer needed. The folks at docco saw the same thing, and recently ported over the library to use highlight.js.

I love documentation generators for code. You know what I’ve talking about to – something which gives you a split screen of the code and the comments, side by side, for easy reading and scrolling. Like jasmine uses for their documentation:

Since I’ve mostly been working in JavaScript lately, I’ve been looking for something to help document the packages I create easily.

In comes docco. A CoffeeScript + Python library to help generate good-looking documentation from comments in your code.

However, one thing bothered my about this project – the python part. Docco uses a python library to highlight the syntax. There are plenty of decent syntax highlighters out there – why not use one written in a JavaScript flavor?

So I decided to fork docco and plugin a decent highlighter.

Pretty happy with the results. You can check out the fork here.

Esvalidate Library – Standalone Validation Library Using Esprima

I spent a good bit of time working on the Esvalidate code that comes with Esprima, trying to get it to work smoothly with my sublime plugin. After submitting a massive pull request to the author of Esprima, and our reviewing my code, we came to a conclusion – the new code was better served in its own library.

It’s still in its early stages, but please check out the progress I’m making here:

Esvalidate Library

.Net Gotcha – Private Classes With Access To Containing Classes’s Protected Variables (Or Not)

A friend and I were working on some code together when we found an interesting edge case in .Net that neither of us knew about.

This is what we knew: if you have a class with a protected field in it, if you declare a private class inside of that class, the private class can access the protected variable. The example below shows what this looks like.

  public class ParentClassWithProtectedField
        protected readonly int protectedField;

        private class PrivateClassInParentClass
            public void Method(ParentClassWithProtectedField parent)
                Console.WriteLine(parent.protectedField); //Me Work Good!

And this is what we learned: If you create a child class that inherits from the parent class, and declare another Private class in the child class, you cannot access the parent’s protected field from the private class in the child class. I know that was a ton of Parent/Child/Private classes in a short sentence, so here’s an example, building on the previous one, of what won’t work in .NET.

    public class ChildClassOfParentClass : ParentClassWithProtectedField
        private class PrivateClassInChildClass
            public void Method(ParentClassWithProtectedField parent)
                Console.WriteLine(parent.protectedField); // NO WORK!

Portfolio Spotlight on Pathbrite = Cool?

I’ve recently created a portfolio on Pathbrite. If you haven’t heard of Pathbrite, they are a company aiming to:

Collect, organize and share a lifetime of learning and achievement.

I think this section of their mission statement sums up how they are relevant to working professionals.

… employers rely on our Pathbrite Portfolio Platform to get a holistic view of candidates, and to better evaluate their readiness for and organizational fit to the opportunity at hand.

How does it work? The sites allows you to import data (from LinkedIn and other sites) as well as other documents (such as images and PDFs) and lay them out in whatever manner you see fit. It can also import websites you’ve written as well. It’s a great tool for a web software developer to showcase what they’re about.

The link to the article:


Esprima Plugin for Sublime Text

In relation to my previous posts confessing my love for sublime, and my enjoyment of Esprima, here is some code that showcases both:

An Esprima plugin for Sublime Test!


This has been included in the official list of Sublime Plugins. So you can install this from Sublime using Packages Control.

Sublime Text – Esprima Plugin Screenshot