Skip to content

Instantly share code, notes, and snippets.

@simonkcleung
simonkcleung / index.js
Created September 25, 2012 14:21
node.js websocket example
var server=require('websocket.js').createServer();
var chatroom=server.addApp('/chatroom');
chatroom.ondata=function(data,userName){
this.broadcast(data,userName);
}
chatroom.onclose=function(userName){
this.broadcast(userName+" disconnected.");
@simonkcleung
simonkcleung / drawingproxy.js
Created June 30, 2012 06:23
Canvas Drawing Proxy
function DrawingProxy(ctx){
"use strict";
setContext(ctx);
var lastMethod, History, slice=Array.prototype.slice;
Object.defineProperty(Main,"context",{get : function(){return ctx}, set : setContext});
Object.defineProperty(Main,"$",{get : $});