Danger to Manifold

Okay, it's time for a rant. Today, I am going to uninstall Ubuntu. Although I admit that I am typically a Windows user, I am by no means an evangelist of the platform. I'm not a Linux newbie either - I've been using RHEL for years and recently gave a talk on Bash productivity. About a week ago, I started doing some development in C, so I thought I'd avoid the setup hurdles and just dual boot Ubuntu on my own machine. Surely, I thought, the most popular desktop distribution out there would make this a painless experience. After spending…

The modular nature of Node.js is great for maintainability, but have you ever been in a situation where you need to change or add functionality of a module that another module requires? For instance, you might want to implement sign-on with Google Plus and use the jsonwebtoken library to verify that the id_token was signed by Google. However, you might soon find that it uses the jws library, which expects a PEM-encoded public key, and not the JWK set that Google provides. Here is the relevant source code: var jws = require('jws'); try { valid = jws.verify(jwtString, secretOrPublicKey…

There are several ORMs available to use in JavaScript-based projects, the most popular among them being Sequelize and Bookshelf.js. Having used both, I prefer Bookshelf, as it borrows many conventions from Backbone.js and is built on the Knex query builder. While it is easy enough to get started with Bookshelf, the documentation is surprisingly sparse on examples of working with relational data. In this post, I'm going to show one approach to building models with associations and retrieving / updating their data. Here is the schema we are going to be working with: Let's start with a simple example…

I recently got a chance to work on a short project with a couple of pretty superb engineers at Hack Reactor. We came up with Cleaver, a cool way to choose a place to eat by eliminating unwanted restaurants or cuisines. One thing that may not be immediately obvious from using Cleaver is that you can send the generated short URL to multiple people. Any changes that are made on an individual client view are immediately propagated to everyone else. To simulate this on a single machine, open a new tab, incognito mode, or another browser. This functionality was key…

Having come from a Ruby / Rails background, I was initially offput by Backbone.js' paradigm of models, views, and collections. Now that I've had a chance to build a few small projects with the versatile framework, I have a much better understanding of how to structure complicated relationships in Backbone. As the list of models in any project grows, you will almost certainly encounter a temptation to make a collection of collections. Consider a simple HTML5 audio player that can play or queue individual songs. We might represent it like this: var SongModel = Backbone.Model.extend({ defaults: { playCount: 0, }, play…