Skip to content

Instantly share code, notes, and snippets.

(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.
@tmpvar
tmpvar / promise.js
Created February 21, 2010 21:42 — forked from ry/promise.js
promises!
var events = require('events');
exports.Promise = function () {
exports.EventEmitter.call(this);
this._blocking = false;
this.hasFired = false;
this._values = undefined;
};
process.inherits(exports.Promise, events.EventEmitter);
@tmpvar
tmpvar / client.js
Created March 17, 2010 19:17 — forked from felixge/client.js
no segfault, 64510 connections
var
PARALLEL_CONNECTS = 10,
http = require('http'),
sys = require('sys'),
connectionCount = 0,
messageCount = 0;
lastMessages = 0;
function addClient() {
var bar = function() {
this._baz = function() {
return this.value;
};
};
bar.prototype = (function() {
var i_am_private = 2;
function ScoreNetwork(score)
{
this.ws = null;
this.data = null;
this.score = score;
this.initialize = function()
{
this.ws = new WebSocket('ws://localhost:7000');
var sys = require("sys"),
dom = require('./lib/jsdom/lib/level1/core').dom.level1.core,
fs = require("fs"),
haml = require('./lib/haml-js/lib/haml')
windower = require("./lib/jsdom/lib/browser");
exports.toJUP = function(template) {
template = haml.render(template);
var window = windower.windowAugmentation(dom);
var document = window.document;
(function( window, undefined ) {
var JUP = {};
// Define a local copy of parseDOM JUP
JUP.parseDOM = function(items, ARR){
if(typeof ARR == 'undefined'){
var ARR = [];
}
window.jQuery(items).each(function(i,e){
var text = '<div><div class="container" >asd<div fuck="cakes" class="left column"><div id="date"></div><div id="address"></div></div><div class="right column"><div id="email"></div></div></div></div>';
var intag = false, tmpbuf = "", endtag = false, abspos = 0;
function parse(html, pos, lvl) {
var level = lvl || 0, current = level, ret = [], i=abspos, origpos = abspos;
for (i; i<html.length; i+=1) {
abspos = i;
var char = html[i];
if (char === '<') {
/*******************************
JSONloops is a javascript audio sequencer that runs on JSON arrays of sounds
JSONloops are nested arrays that contain: a nested array, a sound, or null
the arrays are nested in the following hierarchy
* SONG
* TRACKS
* MEASURES
var sys = require("sys"),
dom = require("jsdom/lib/level1/core").dom.level1.core,
fs = require("fs"),
sax = require("jsdom/example/sizzle/sax"),
document = require("jsdom/lib/browser").windowAugmentation(dom, {parser: sax.parser()}).document,
div = document.createElement('div');
document.body.appendChild(div);
div.innerHTML = "<span><img src='test' />foo<br /> bar<br /> </span><p><script>alert('test');\n\nconsole.log();</script>ting</p>";