Skip to content

Instantly share code, notes, and snippets.

View Marak's full-sized avatar

Marak

View GitHub Profile
(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.
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);
}
}
});
#!/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);
var d = $("#foo")[0].attributes;
for(var i = 0; i < d.length; i++) {
print(d.item(i).value);
}
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("/",""));
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("/",""));
@Marak
Marak / insanity
Created June 18, 2010 04:51 — forked from heapwolf/insanity
function doit() {
INSANITY:
for(var i=1; i < 20; i++) {
if(i == 10) {
continue INSANITY;
}
console.log(i);
// 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({
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;
set dirty(value) {
this.ascend(function(node) { node._dirty = value; });
},