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 (exports) { | |
// because the anonymous function is being called without a scope being set, | |
// "this" will refer to the global scope. In a browser, that's the window, but | |
// will be "undefined" in strict mode. In other JS platforms, it may be some | |
// other thing. | |
// my code here. | |
// don't make accidental globals. | |
// hang a small number of things on the "exports" object. |
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
vows.describe('format.js library').addVows({ | |
"Number formatting": { | |
// run this once, and execute the following tests when it completes | |
topic: 42, | |
"is the number":function(n){ | |
assert.equal(n,42); | |
} | |
} | |
}); |
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 node | |
var sys = require("sys"), | |
fs = require("fs"), | |
chat = require('../lib/server'), | |
router = require("../lib/router"); | |
// create chat server | |
var chatServer = chat.createServer(); | |
chatServer.listen(8001); |
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); | |
} |
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
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
// 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 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
set dirty(value) { | |
this.ascend(function(node) { node._dirty = value; }); | |
}, |