I hereby decree

by David LeMieux


There is a pattern in some JavaScript libraries in which methods called on an object return that same object so that more methods can be called. This is known as method chaining and it looks something like this:

$('#myDiv').show().addClass('foo').append("Hello"); //And so on 

This code gets the #myDiv jQuery object, shows it, adds the class 'foo' to it, then appends some HTML. We could continue doing this for many more methods.

Unfortunately, not every method follows this pattern consistently. Setting dimensions, for example:

works fine, but if we call either of those methods without the new dimension:
$('#myDiv').width() //Returns a number

what we are really asking for is the current width and so a number is returned. That means we have one method with different return types. The jQuery team have decided this is how they want their interface to work and that is fine but this is something to consider when designing your own library. You could easily imagine that the method should always return the current dimension, even if a new one is set. Perhaps a different method that always return self would then also provide the kind of usability that is desired for chaining (e.g. $().setDimension()).

Method chaining is useful, but so are well defined, consistent interfaces. Promises use this pattern to great effect which is a small part of what makes them so powerful. My own personal preference would be that if your interface method can consistently return self and it would be useful to do so, then make it happen. Otherwise, I fall slightly over the line of being more interested in a clean api.


Comments (View)



I made some minor updates to please lately and I figured I could talk about them here.

First, I fixed some bugs around the token replacement and input for aliases that use them. I also made it so that the template values could be provided inline with the initial command so that what was once:

> please do something

> input: _

can now be:

> please do something -input 'foo'

Next, I made it so that when using --list you can provide a filter argument. please --list bar, for example, will list all aliases that contain the word "bar".

Finally, I added environment variable support to aliases so that $ENV_VARIABLE will correctly parse to the right value.

Just download the project or clone it from github then run the rake install task and it should be ready to use on your OS X terminal!

I am sure that no one else actually uses please, but I find it very useful. Since the please.yml file can be stored in any directory (based on environment variable), I have it stored in my Dropbox folder so that between computers I have the same list of aliases, automatically synchronized. If it were to ever get more popular, I could even see putting together a github repository or some other way for people to share their alias files. But maybe I need to make the code more robust before then.


Comments (View)



To my knowledge, Kraft has not done a campaign like this, but they should.


Comments (View)



A quick update to say that I put the bulk of the E.ggTimer code on Github as is. Mostly because it isn't doing much good just sitting there. Also, it will better coax me to make improvements and clean it up.

Check it out on Github


Comments (View)



Responsive Design
All the different layouts. 1) Large. 2) Medium Large (iPad Horizontal). 3) Medium Small (iPad Vertical) 4) Small (iPhone)

Continuing last years example I made another digital family Christmas card.

Last year I experimented with different HTML5 features including audio and canvas. That card was JavaScript heavy. This year I decided to try my hand at CSS and everyone's favorite buzz-work: Responsive Design. The result is a page with a lot of rectangles and images. Clicking (or tapping) each image will flip it over with CSS 3d transitions and show new content. The JavaScript used is minimal.

I had originally set out to use a framework or library like Twitter's Bootstrap. I found, however, that there was a certain amount of feature overkill for what I was trying to accomplish.

I also attempted to use CSS media queries to support Retina devices, but I failed miserably. Maybe next year?

I've made the code for both cards available at github. As usual, it only works in modern browsers, and even then only really in the webkit ones. I didn't want to take the time to make it compatible. Sorry.


Comments (View)



Just a story I did on Twitter. Nothing important.

Back in my day we had books. You had to pick them up and open them and turn each page by hand. David LeMieux (@lemieuxster) January 29, 2013

And if you wanted to know where something was you'd have to hope it was in the index or that there was even an index at all. David LeMieux (@lemieuxster) January 29, 2013

And from time to time certain books would be enchanted. Opening them without first saying an incantation would release all of Hell's demons. David LeMieux (@lemieuxster) January 29, 2013

Then you'd have to run to the warlock's house and ask him to help, but there was always a price. Your Uncle Jim gave his life for ours. David LeMieux (@lemieuxster) January 29, 2013

Anyway, you kids don't know how good you have it, what with these AR Contacts and cranial implants. David LeMieux (@lemieuxster) January 29, 2013


Comments (View)



For nearly as long as I've worked at Flite I've done more or less the same thing. Not just "writing code" but "writing code to do the same thing." It has been a fun challenge and actually resulted in some work I am very proud of. Recently, however, I was assigned a new thing and it has been delightfully freeing.

I've worked on different projects in the past, but my main focus on all of those projects has been the ad runtime platform at Flite. Now I am working on something more front-end related and the change of pace has done two things: 1) It has given me a chance to stretch different coder muscles and 2) Taking a step back from platform work, I've actually begun to get lots of creative ideas about the platform again. Previously I was feeling somewhat stuck in a loop.

The stresses are different. In the platform code, I have to constantly make sure I'm not making the file size (for a file served thousands of times a minute) too large. I also have to make sure it is robust enough to work anywhere without breaking ad or webpage functionality. Not having that constant worry has been liberating. In its place are new worries - like am I writing code compatible with existing patterns and not breaking user experience - but they are new and fresh and welcome.

For the one or two people who will read this: Flite is Hiring


Comments (View)



I have been with Widgetbox/Flite for more than four years now and I've gained some valuable skills. I've added these skills to my LinkedIn profile.

Skillz Skillz Skillz Skillz Skillz Skillz

Please recommend me on LinkedIn.


Comments (View)



Dead Colors Preview
Updated list of DEAD colors

Spent a few minutes to update the DEAD Colors list. Check it out.


Comments (View)



Just a thought:

Valve recently announced a beta release of Big Picture. Big Picture lets you access and play your Steam library of games (or at least the compatible portions) on a large screen or TV using a console controller. Valve's main selling points for doing this are that a player doesn't have to give up all the collateral - friends, games, and achievements - when he or she decides to play video games "in the living room." A very interesting idea, but I have been wondering lately if maybe something else is going on.

Valve developers seem to be upset about the horizon of PC gaming. With some open concern about Windows 8 and what seems like a continuous march towards limitation and control from OS makers (app stores, sandboxes, etc.) it makes sense that Valve would start to explore alternate means of distribution. If you take the recent Big Picture announcement and combine it with even more recent news about Steam for Linux and add a sprinkling of desire to be free of OS overlords, it seems to me, at least, that Valve might be thinking of a future in set top devices. Or, if nothing else, linux powered machines that can run Steam powered games and allow players to play them on a large machine. Add in a controller and you've essentially created a console.

If anyone is going to disrupt the console market, I suppose Valve is in a unique position to do so. They already have the distribution and game mechanics architecture and have been learning how to scale both. They have a nice library of games, many of which already have console counter parts. Valve also has a tremendous fan and user base that would be willing to give things a go. If Valve stays consistent with their other marketing strategies, they are poised to take on the larger players.

That said, this could also be seen as a sustaining innovation. Either way, if Valve is considering a move toward set top hardware or alternate means of distribution to get around what they feel are too many OS restrictions this Big Picture beta test will give them at least a glimpse in to how users might react.

Then again, this is pure speculation. I could be 100% incorrect. I like to hope that there is at least a smidgen of truth in this thinking though, because it would be cool.


Comments (View)