How to fix slow file read/write in Node.js

This morning, I had trouble with one of my grunt tasks taking several minutes to finish instead of 3-4 seconds. After a bit of troubleshooting, I isolated the bottleneck to a bunch of seemingly harmless file reads. Guess who was the culprit? The company-supplied McAfee. Turning off on-access scan immediately fixed the issue and dropped […]

What is “ReferenceError: Can’t find variable: __gCrWeb”?

I have seen this error in our Sentry logs, and after some research, it appears to be an error that can safely be ignored. It only happens in Chrome on iOS, most likely at random, and it is seemingly unrelated to the page being viewed. It has been tweeted about, but there doesn’t seem to […]

.find() vs. .children(): which one should you use?

jQuery offers two functions to find children in an element: .find() and .children(). .find() will look through all children of an element while .children() will only look at immediate children. <ul> <li> <p></p> </li> <li> <p></p> </li> <li> <p></p> </li> </ul> In the snippet above, $(‘ul’).children(‘p’) wouldn’t return anything, while $(‘ul’).find(‘p’) would return all three […]

Javascript, jQuery and parent windows

When you open a window with, you can access the popup’s parent window using window.opener from the child window. //In the parent window‘’); //Opens a new window/tab with this URL //In the opened window window.opener.document; You can perform the same requests on window.opener.document as you would on the document object: window.opener.document.getElementById(‘#tableInParent’); //Gets #tableInParent […]

How to get the textarea’s maxlength attribute to work in Internet Explorer

If you are developing for an older version of Internet Explorer (IE8 and older), you might have noticed that your chronogically-challenged browser does not support the maxlength attribute. Fortunately, you can solve it with a few lines of jQuery: //textarea maxlength support for chronogically-challenged browsers $(‘textarea[maxlength]‘).keyup(function(){ //Get the value var text = $(this).val(); //Get the […]

Select the element in JavaScript

If you are like me and take jQuery for granted in your projects, you might sometimes forget the most basic stuff. Here is a small reminder of how to select the <body> element in JavaScript: document.getElementsByTagName(“body”)[0] So to answer your question, no, there is no shortcut. Select it just like any other element. If you […]

How to get a reference to a CodeMirror instance

If you want to access a CodeMirror instance, perhaps because it was created programmatically, or by a module you don’t control, you can access it like this: //Get a reference to the CodeMirror editor var editor = $(‘.CodeMirror’)[0].CodeMirror; //You can then use it as you wish editor.setValue(‘lorem ipsum yada yada’); editor.replaceSelection(‘this is a test’); In […]

Drag and drop image upload directive for Angular.js

While converting an application of mine to Angular.js, I could not come up with a reasonable way to support drag and drop uploads, so I have created my own. Browser support As with everything that is enjoyable on the web, this will only work in IE10+, Chrome and Firefox. This is because you will need […]

How to use the HTML5 full screen API (with examples)

The new HTML5 fullscreen API allows you to build full screen web applications very easily. Before we get started, there are a few things you need to know: Only user events (click, keyup etc.) can trigger full screen mode. This prevents pop up ads from going full screen. The API is supported by IE9+, Chrome […]

Using angular.js with Tastypie for Django

The following angular.js service will allow you to consume a standard TastyPie REST API. As you may know, TastyPie returns its JSON objects a bit differently from what angular expects, so this service fixes it. This example assumes that you have always_return_data=True in your resource. This is the resource I used with this example: class […]