Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
Ben Nadel at CFUNITED 2009 (Lansdowne, VA) with: Todd Sharp
Ben Nadel at CFUNITED 2009 (Lansdowne, VA) with: Todd Sharp

Recent Blog Posts by Ben Nadel

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 . 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 »

Exposing An Optional Directive Template Using ng-Template And The $templateCachce() In AngularJS

Most directives can be easily defined by a single template. But, some directives are not so clear-cut. This is especially true for 3rd-party directives. Case in point, the "tooltip." The tooltip is a rendered element; but, it doesn't replace its contextual content. It's kind of an odd mixture of bo... read more »

Directive Architecture, Template URLs, And Linking Order In AngularJS

When it comes to directive compiling, linking, and general timing in AngularJS, it probably feels like I'm beating a dead horse. But, the reason that I keep revisiting the topic is because the directive workflow is a complex multi-faceted process that keeps revealing new quirks and edge-cases. Toda... read more »

Mutating Isolate Scope References In AngularJS

When dealing with isolate-scope variable references, in AngularJS, reading data is a non-issue. And, technically speaking, mutating data is also possible. But, just because an isolate-scope component directive can mutate a given value, it doesn't mean that it should. The more I work with AngularJS,... read more »

Asking The User To Confirm Location Or Route Changes In AngularJS

The other day, Ward Bell and I were discussing both the future and existing routing features in AngularJS . In that conversation, we talked about what was and wasn't an appropriate responsibility for a routing module. In my opinion, the router itself shouldn't know when it's safe to navigate awa... read more »

Using $rootScope.$emit() As A Performance Optimization In AngularJS

Yesterday, I looked at how to create a simple modal window system in AngularJS . In that exploration, I used the $rootScope to bridge the gap between the modal Service and the modal directive. In the past, I've used the same approach to bridge the gap between a global uploader service and its Plu... read more »