This file contains 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
/* | |
You need to mix EventEmitter into MyObject from the JS end before you can emit/listen for events | |
*/ | |
bool MyObject::Emit(const char *event, int argCount, Handle<Value> emitArgs[]) | |
{ | |
HandleScope scope; | |
//Format arguments to pass to v8::Function | |
int nArgCount = argCount + 1; | |
Handle<Value> *nEmitArgs = new Handle<Value>[nArgCount]; |
This file contains 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
prettySeconds = (secs) -> | |
days = Math.floor secs / 86400 | |
hours = Math.floor (secs % 86400) / 3600 | |
minutes = Math.floor ((secs % 86400) % 3600) / 60 | |
seconds = ((secs % 86400) % 3600) % 60 | |
out = "" | |
out += "#{days} days " if days > 0 | |
out += "#{hours} hours " if hours > 0 | |
out += "#{minutes} minutes" if minutes > 0 | |
out += " #{seconds} seconds" if seconds > 0 and days <= 0 |
This file contains 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
define | |
effect: "fade" | |
construct: -> # anything before render | |
render: require("templates/mock") | |
destruct: -> # clean up here |
This file contains 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 ids = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"]; | |
if (typeof XMLHttpRequest === "undefined") { | |
for (var i = 0; i < ids.length; i++) { | |
try { | |
new ActiveXObject(ids[i]); | |
window.XMLHttpRequest = function() { | |
return new ActiveXObject(ids[i]); | |
}; | |
break; | |
} catch (e) {} |
This file contains 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
class EventEmitter | |
constructor: -> | |
@events = {} | |
emit: (event, args...) -> | |
return false unless @events[event] | |
listener args... for listener in @events[event] | |
return true | |
addListener: (event, listener) -> |
This file contains 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
import processing.video.*; | |
MovieMaker movie; | |
boolean rec; | |
int n; | |
int varZero; | |
int prevN; | |
int prevZero; | |
int numPixels; | |
int prevPixels; |
This file contains 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
require 'should' | |
http = require 'http' | |
Vein = require 'vein' | |
port = Math.floor(Math.random() * 1000) + 8000 | |
server = new Vein http.createServer().listen port | |
describe 'first test', (done)-> | |
it 'should do stuff', (done)-> | |
server.drop() | |
server.stack = [] |
This file contains 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
isAnimatedGif = (src, cb) -> | |
request = new XMLHttpRequest() | |
request.open "GET", src, true | |
request.responseType = "arraybuffer" | |
request.addEventListener "load", -> | |
arr = new Uint8Array request.response | |
return cb false if arr[0..3] isnt [0x47,0x49,0x46,0x38] | |
request.send() |
This file contains 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
server = new Pulsar port: 4001 | |
schan = channel 'notify:operators' | |
schan.on 'newClient', -> | |
schan.emit 'updateUnanswered', 5 | |
client = new Pulsar.Client port: 4001 | |
cchan = client.channel 'notify:operators' | |
cchan.on 'updateUnanswered', (num) -> console.log 'unanswered:', num |
This file contains 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
### | |
Network workflow: | |
Client connects | |
Client creates transaction | |
Server sends 'sync' with root object | |
Client runs transaction | |
if .retry() called | |
Client listens for 'sync' message then runs transaction again | |
else |