Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
Ben Nadel at CFUNITED 2008 (Washington, D.C.) with: Sean Corfield
Ben Nadel at CFUNITED 2008 (Washington, D.C.) with: Sean Corfield@seancorfield )

Recent Blog Posts by Ben Nadel

The 8th Annual Regular Expression Day - June 1st, 2015

It's been eight years since we started international Regular Expression Day and my love for regular expressions hasn't lost momentum. When you're married to such an awesome piece of technology, there is no "seven-year itch;" the romance just keeps getting more and more intense. Hardly a day goes by... read more »


Trying To Understand Unicode Normalization In ColdFusion And Java

Just when you think character encoding can't get any worse - it gets worse. Apparently, in Unicode, some characters can be represented by more than one sequence of bytes. This means that two sequences of code may be structurally different but, functionally equivalent in so much as they render the e... read more »


AngularJS Will Parse JSON Payloads In Non-2xx HTTP Responses

This is probably an AngularJS feature that you're already using; but, you may not be cognizant of the fact that it's happening. When you make an HTTP request with AngularJS, the request and response goes through a promise chain that applies a series of pre and post transformations . The default tr... read more »


Reading Environment Variables In ColdFusion

The other day, when I was experimenting with the default credential provider chain in the Amazon Web Services SDK (Software Developer's Kit), I had to do something that I've never done before - read environment variables from ColdFusion. Since ColdFusion is built on top of Java, however, reading en... read more »


Parsing Various Units-Of-Measurement As Bytes In Node.js

After the long holiday weekend, I wanted to do a fun little exercise to help get the machinery firing again - you know, a little something to brush away the cobwebs. I thought it would be nice to parse strings as bytes. Now, I'm not talking about buffers; I mean taking a string like, "10Mb" (ie, te... read more »


Anonymous Functions, Assigned To References, Show Up Well In JavaScript Stack Traces

The other week, as I was reading Programming JavaScript Applications by Eric Elliott , I came across a passage that didn't feel right. Or, at least felt outdated - the book was written 3 years ago. On pages 31-32, Eric talks about "anonymous functions" and how they show up in error stack traces wi... read more »


Normalizing Untrusted Deferred / Promise Values For The $digest Lifecycle In AngularJS

The other day, in my blog post about the $q.when() method in AngularJS , Jordan brought up the question at to what the AngularJS documentation meant when it referred to, "the promise comes from a source that can't be trusted." My guesstimation of this statement was that we couldn't trust that the ... read more »


Angular Air Episode 15: Architecting Huge Angular Apps With Ben Nadel And Aaron Frost

Yesterday, I had the pleasure of being on the 15th episode of the videocast / podcast, Angular Air , with Aaron Frost , talking about architecting huge AngularJS applications . InVision App is a collection of large AngularJS applications that we've been building and maintaining since AngularJS... read more »


Programming JavaScript Applications By Eric Elliott - Revisited

A few years ago, I read the "early release" edition of Programming JavaScript Applications by Eric Elliott . At the time, the book was only a fraction complete, so there was very little to review (shame on O'Reilly's early release program - what a diservice it does). Now, three years later, I've... read more »


Exposing Promise / Deferred Functionality On Streams In Node.js

As I've been diving into Node.js, I'm starting to see that Streams will often live side-by-side with Promises (I use the Q library for promises). Some of those streams make sense as streams; but, some of those streams might make more sense as promises. Or, at least, they might be easier to consume ... read more »


Rethrowing Errors In JavaScript And Node.js

When dealing with errors, handling them at the perimeter of your application isn't always sufficient. By the time the error bubbles up, you've often lost a lot of the context in which the error was thrown. As such, people will sometimes catch an error, record it locally in some way, and then rethro... read more »


Learning Node.js: Building A Simple API Powered By MongoDB

For the next step in my Node.js learning journey, I wanted to try and build a simple API powered by MongoDB. As per my usual approach to learning, I am purposefully avoiding established libraries like Express (for routing and rendering) and Mongoose (for MongoDB connection management and object map... read more »


String Interpolation Using util.format() And util.inspect() In Node.js

In my blog post yesterday on creating custom error objects in Node.js , you may have seen me use the util.format() method to prepare some of the error data. The util.format() and util.inspect() methods are my two new favorite methods in Node.js. Together, they make string interpolation painless an... read more »


Creating Custom Error Objects In Node.js With Error.captureStackTrace()

Coming from the world of ColdFusion, I'm used to using the CFThrow tag (and throw() function) , which allows me to throw error objects with a good deal of contextual information that can later be used for debugging purposes. As such, I wanted to see if I could create a custom Error class in my Nod... read more »


EdgeCast CDN Won't Cache Your First Request And Can't Cache Subsequent 304 Not Modified Responses

EdgeCast is a pretty amazing CDN (Content Delivery Network). But, it took me a little while to understand the quirks in its caching strategy. When I first started using EdgeCast, it seemed like I could never get anything to cache (as defined by the "X-Cache" header in the response). After some ba... read more »


ColdFusion Image Resize Stuck At sun.java2d.cmm.kcms.CMM.cmmColorConvert With Massive CPU Usage

At InVision, we recently performed a large infrastructure upgrade. And, after we did this, we noticed that image thumbnailing times and CPU-load shot through the roof. Suddenly, we were seeing massive CPU usage (80%-100%) and thumbnail times that took up to 45 minutes on average! It didn't seem to ... read more »


Fixing Grayscale PNG Thumbnail Images That Come Out Too Dark In ImageMagick 6.7.7

For the last couple of days, I've been battling with ImageMagick and the generation of image thumbnails. For the most part, it's been super awesome - fast conversions and high-quality images. But, I noticed that grayscale images tend to come out extremely dark. Most of the forums and threads that I... read more »


getHttpRequestData() May Break Your Request In ColdFusion But getHttpRequestData(False) May Not

Out of the box, ColdFusion will parse multipart/form-data requests for you (putting the data in the Form scope). But, if you want to accept any other kind of data, such as JavaScript Object Notation (JSON) or XML payloads , you will likely have to reach into the HTTP request data to access the r... read more »


Does The HTTP Response Stream Need Error Event Handlers In Node.js?

When you start programming in Node.js, one of the first things you discover is that a Node.js application is "amusingly" brittle; one uncaught error and your entire applications comes to a grinding halt. This is especially true when dealing with Streams (which inherit error-handling behavior from ... read more »


The User Experience (UX) Of Tipping As Personal Expression

Last summer, I was in the Empire Cake Bakery in Chelsea (across from the Google building), when I noticed something that gave me pause - their Tip jar wasn't just your ordinary tip jar; rather, it was a chance to say something about myself. Unlike a typical tip jar, this jar was divided in two wi... read more »


Adventures In Angular, Episode 38: Performance With Ben Nadel

Last week, I was honored to be back on the Adventures in Angular podcast over on DevChat.tv . I got to ramble on about how much I love JavaScript, AngularJS, performance tuning, and how that all gets applied at InVision App , which is, of course, written in AngularJS. ... read more »


Function Hoisting, Prototype Chains, Exports, And process.nextTick() In Node.js

In my demo yesterday, on consuming a Crypto Hash object as a Stream in Node.js , I ran my demo inside of a process.nextTick() callback. I did this in order allow my demo code to be fully defined before I consumed it. Sometimes you need this; sometimes you don't. It depends on what values are being... read more »


Consuming The Crypto Hash Algorithms As A Stream In Node.js

The other day, when I was building a static file server in Node.js , I noticed that the Crypto module treats the Hash object as a Transform stream that is both writable and readable. And, that it explicitly has "legacy" support for the old .update() and .digest() methods. In the world of programmi... read more »


Learning Node.js: Building A Static File Server

As I've been learning about Node.js, I've come to the realization that learning Node.js is only possible in sufficiently complex contexts. If things are too simple, then the fact that it is "JavaScript" makes it seem deceptively simple. As such, I'd like to embark on some non-trivial experiments th... read more »


The Affect Of Back-Pressure When Piping Data Into Multiple Writable Streams In Node.js

As a learning exercise, I wanted to try and create a small static file server in Node.js. I figured this was small enough but, complex enough to help me learn about the Node.js fundamentals. During one of my refactoring efforts, I noticed that some larger files were only being "partially served" to... read more »


Managing User Input Key-Events Across Views In AngularJS

Managing click events, in an AngularJS application, is somewhat straight-forward because the structure of the DOM (Document Object Model) very closely mirrors the order in which click handlers will be invoked. Key-events, on the other hand, are not so simple. Not only are the events not necessarily... read more »


Directive Controllers Cannot Use The Revealing Module Pattern In AngularJS

This is just a quick blog post (more of a note-to-self) to demonstrate the fact that you cannot use the revealing module pattern with Directive Controllers in AngularJS. And, just to be clear, all controllers, in AngularJS, are "directive controllers." Meaning, the ngController directive is nothing... read more »


$animate:before, $animate:after, $animate:close And The ngAnimate Enter Workflow In AngularJS

After my blog post yesterday, on animating an element in from a mouse-click location in AngularJS , I was a little irked that I couldn't get consistent results from the "$animate:before" and "$animate:after" events triggered by the $animate service. I couldn't figure out how they fit into the over... read more »


Animating Elements In From A Mouse-Event Location Using ngAnimate And AngularJS

The ngAnimate module, in AngularJS, is pretty awesome. This is especially true when your transitions can be defined entirely within your CSS files. In that case, your code doesn't need to know anything about your animations at all. But, if your transitions need to be partially defined by context-se... read more »


CAUTION: Overloading The ng-Controller Directive In AngularJS

I'm putting " CAUTION " right in the title here because I'm not actually recommending that anyone do this. This is just a fun experiment whose only purpose is to demonstrate some of the flexibility and the power that the AngularJS directive architecture provides. We've already seen how powerful it ... read more »