Jesse Cravens

Building Modern Web Applications and Teams that Deliver

Researching the Latest in HTPC (Home Theater PC)

Fed up with paying for lame content, we recently turned off our cable and turned in our DVR.
Since then, I have been doing my research and preparing to build or purchase a system that leverages our broadband connection and Local HD Channels for content.

Here is my growing list of resources:

General Information


Articles

Videos

Channels

On Demand Content

Players

Hardware – All In One


Hardware – Parts

Software and OS

Network Storage

Recorders

Antennas

Remotes

Cables/Converters













Big Dummy Longtail From Surly

I stumbled upon the Big Dummy Longtail from Surly today while purchasing a 09’ Trek 4500 24” frame at the Bicycle Sport Shop in Austin.. Btw, for riders 6’6” and above, afters years of research, this is the only non custom frame I could find for entry/intermediate tall riders. I’ll be doing some customizing as needed, but at least I have an inexpensive starting point. So…I love the size and fit of the Trek, but I can’t get over the sweetness of the Big Dummy Longtail. Someday, I’ll use the Xtracycle Free Radical conversion kit to convert my cruiser.

Understanding JavaScript Closures

So it took me awhile to truly understand JavaScript closures. There is limited documentation of the subject on the web, but here is a list of the resources I used to finally grasp not only what specifically creates a closure, but also why we would want to use them.

First, let’s define closures:

  • A “closure” is an expression (typically a function) that can have free variables together with an environment that binds those variables (that “closes” the expression). - Jim Ley
  • …JavaScript has closures. What this means is that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned. This is an extremely powerful property of the language. - Douglas Crockford
  • Things are different if you save a reference to the nested function in the global scope. You do so by using the nested function as the return value of the outer function or by storing the nested function as a property of some other object. - JavaScript: the Definitive Guide
  • Simply put, a closure is a variable, created inside a function, which continues to exist after the function has finished executing. - Patrick Hunlock

I should preface the more detailed explanation below with a few prerequisite concepts. If you don’t truly grasp these concepts, then you may get hung up when trying to understand JavaScript closures. Fortunately, your quest to understand closures should force you to understand these concepts on a deeper level first.

  • global object and global scope
  • reference types and primitive types
  • lexical scope and the scope chain
  • the call object or the ECMA activation object
  • idea of persistent data
  • private variables
  • using return

To begin, we want to create a reusable function containing data that persists across invocations.

We don’t want to hard code variables into the reusable function, and a local variable will not persist.

From what we have learned by our ‘Responsible JavaScript for the Enterprise’ guidelines and through our understanding of the call object, lexical scope, and namespacing: we also know that we want to greatly limit global variables in our global scope.

So instead, we want the developer to make two calls: One, to set up or ‘configure’ the function, and two, to invoke this ‘pre-configured’ function.

The power is in the first call. I like to refer to it as the configuration call.

During the configuration call, we ‘freeze’ the inner function by setting a reference to it in the global scope.

So this data persists. Why?

We have an external reference to this inner function.

The inner nested function retains its reference to the call object of the outer function.

The outer function’s local scope resolves and the reference to its inner function remains.

This is an example from a friend that helped me finally wrap my head around the power of the technique.

Initialize closure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function configEquation(A,B,C){
  //The equation: Ax^ex1 + Bx^ex2 + Cx^ex3
  //The exponents are ex1, ex2, and ex3
  //The coefficients are A, B, and C and are set

  var ex1 = 2;
  var ex2 = 1;
  var ex3 = 0;

//The exponents constitute a quadratic equation.
function theEquation(x){
  var result = A * Math.pow(x,ex1) + B * Math.pow(x,ex2) + C * Math.pow(x,ex3);
  return result;
  }

  return theEquation; //notice we return the reference not the invocation of the function(no params)
  }

var myEquation = configEquation(2,3,0); //the configuration call
  console.log('myEquation, x = 2: ' + myEquation(2));
  console.log('myEquation, x = 5: ' + myEquation(5));

var myEquation2 = configEquation(1,1,1); //a 2nd configuration call
  console.log('myEquation2, x = 2: ' + myEquation2(2));
  console.log('myEquation2, x = 5: ' + myEquation2(5));

Rails 2.0 on Windows: Making Sense of Old Tutorials

I know it is fairly well documented around the web that some of the old ‘ROR up and running’ tutorials are a bit difficult to digest with the new features in in Rails 2.0. So, I wanted to document my findings. And provide links to the resources that have helped me.

Here’s a couple of resources to get started:

akitaonrails.com weblog.infoworld.com

Stay posted for more of my findings.

American Modern Vintage: Peacefield.info Gets Redesigned

So I am calling it Generic American with a splash of Modern Vintage…I guess. I’m having one of those moments as a designer when the ‘correct’ images are present in my mind’s eye, but for various reasons they haven’t formulated on the canvas. Yet…but what the heck - I’m in no real hurry. I want to savor the taste of this one.

I absolutely love working on peacefield.info. It is a designer’s dream, absolute creative freedom. An opportunity to shine, explore, create and innovate.

So what do I have to work with? Not much yet, and that is ok in some respects, because I don’t want to ever steer away from my built in ‘open source’ aesthetic: championing the best of free fonts and hacked, and neo-Dadaist imagery. This new concoction hopes to blend cinematic urban cityscapes, with an adaptation of the ever trendy rustic earth tone color palette.(see my post on the the Neo-Green Aesthetic)

Actually, keyboardist R. Bruce Phillips says it best:

Peacefield isn’t so “Pleasantville.” It’s grittier, even darker maybe – or at least it has that side. Kind of like in the face of the ubiquitous B&W photo of the old man who lives on the street. He is generic, he is vintage. His face tells who knows what variety of stories? Some lovely, and some horrific, to be sure.

But there is peace still. His old weather face still attracts us.

Some may not see readily the quality of peace about this town. They might think it a contradiction, or irony, that the gritty, mysterious town has such a “nice” name as “Peacefield.” Of course, America is full of contradiction and ironies, and people who don’t get it when others do.

Technorati Profile