This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
// A response to jashkenas's fine proposal for minimalist JavaScript classes. | |
// Harmony always stipulated classes as sugar, so indeed we are keeping current | |
// JavaScript prototype semantics, and classes would only add a syntactic form | |
// that can desugar to ES5. This is mostly the same assumption that Jeremy | |
// chose, but I've stipulated ES5. | |
// Where I part company is on reusing the object literal. It is not the syntax | |
// most classy programmers expect, coming from other languages. It has annoying | |
// and alien overhead, namely colons and commas. For JS community members who |
// create an array of terms from an array of objects | |
for item in trend.search_terms | |
search_terms.push(item.term) | |
// while a part of the array is left | |
while search_terms.length > 0 | |
// create a mini array of 7 items | |
for num in [0..7] |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
var a = {}; | |
a.foo = function() { | |
return "foo"; | |
} | |
a.bar = function() { | |
return "bar"; | |
} |
// put inside a .js file, referenced on the page by the resource's URI | |
// Create a local variable to hold `jQuery', so you type less. | |
// Using $ is stupíd, since that symbol is (by ES5 specs) reserved for | |
// machine-generated code. | |
void function(j) { | |
function get_data() { | |
// use functions to abstract code sections | |
function get_item(i) { return data[i].high + '<br>' + ~~(Math.random() * 111) } | |
function update(idx) { return j('#high').html(get_item(idx)) } | |
function process(data){ return j.each(data, update) } |
var http = require('http'); | |
var fs = require('fs'); | |
var url = require('url'); | |
var settingsPath='settings2.json'; | |
var Server = function(path){ | |
this.readSettings(path); | |
} |
var sDate = new Date() | |
, today = new Date() | |
, str = "" | |
, node; | |
sDate.setFullYear(2011, 0, 1); | |
if (sDate > today) { | |
str = sDate.getFullYear() } | |
else { |