This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# script/whitespace | |
# | |
# Strips whitespace from any files modified in git | |
# Also: | |
# - converts tabs to spaces | |
# - ensures a single newline at the end | |
class WhitespaceProcessor | |
def self.process(code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var noc = require('noc'); | |
var job = noc.createJob('install node.js on ubuntu'); | |
job.addTask(function (server) { | |
// Some javascript code .. maybe: | |
// server.mkdir(....) | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var item = { "hdbarcode": hdbarcode, "description": description }; | |
// 2nd argument is callback | |
getDescription(item.hdbarcode, function(upcDescrip){ | |
db.save(null, item, function (err, meta) { | |
// This does not change item on line 1. Why? | |
item.key = meta.key; | |
sys.puts('saved ' + JSON.stringify(item) + ' as '+ meta.key); | |
// tell client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set dirty(value) { | |
this.ascend(function(node) { node._dirty = value; }); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function benchmark(method, times, name){ | |
//See http://gist.github.com/227048 | |
var startTime = (new Date()).getTime(), endTime; | |
while(times--){ | |
method(); | |
} | |
endTime = (new Date()).getTime(); | |
console.log(name, endTime - startTime); | |
} | |
var x = 1, y = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HttpClient only calls 'success' once. | |
var respondsWith = function (code, body) { | |
var context = { | |
topic: function () { | |
var req = this.context.name.split(/ +/), // ["POST", "/"] | |
method = req[0].toLowerCase(), // "post" | |
path = req[1], // "/" | |
self = this; | |
new HttpClient({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doit() { | |
INSANITY: | |
for(var i=1; i < 20; i++) { | |
if(i == 10) { | |
continue INSANITY; | |
} | |
console.log(i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var intag = false, ret = [], tmpbuf = "", endtag = false; | |
for (var i=0; i<html.length; i++) | |
{ | |
var char = html[i]; | |
if (char === '<') { | |
intag = true; | |
if (tmpbuf.length > 0) { | |
ret.push(tmpbuf.replace("/","")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var intag = false, ret = [], tmpbuf = "", endtag = false; | |
for (var i=0; i<html.length; i++) | |
{ | |
var char = html[i]; | |
if (char === '<') { | |
intag = true; | |
if (tmpbuf.length > 0) { | |
ret.push(tmpbuf.replace("/","")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var d = $("#foo")[0].attributes; | |
for(var i = 0; i < d.length; i++) { | |
print(d.item(i).value); | |
} |