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
import processing.video.*; | |
MovieMaker movie; | |
boolean rec; | |
int n; | |
int varZero; | |
int prevN; | |
int prevZero; | |
int numPixels; | |
int prevPixels; |
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
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 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 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 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
define | |
effect: "fade" | |
construct: -> # anything before render | |
render: require("templates/mock") | |
destruct: -> # clean up here |
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
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 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
/* | |
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 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
parseLocation = -> | |
out = {} | |
for key in window.location.search.substring(1).split "&" | |
pair = key.split "=" | |
out[pair[0]] = pair[1] | |
return out |
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
# Most throttles are actually just delays | |
# This will only call the function if it hasn't been triggered in (delay)ms | |
throttle = (fn, delay) -> | |
return fn if delay is 0 | |
timer = false | |
return -> | |
return if timer | |
timer = true | |
setTimeout (-> timer = false), delay unless delay is -1 | |
fn arguments... |
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
cookie = (name, value) -> | |
if name and value | |
document.cookie = "#{name}=#{value};" | |
return value | |
else | |
out = {} | |
for cookie in document.cookie.split ";" | |
pair = cookie.split "=" | |
out[pair[0]] = pair[1] | |
return (if name? then out[name] else out) |
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
# DOM ready | |
window.ready ?= (fn) -> | |
fire = -> | |
unless window.ready.fired | |
window.ready.fired = true | |
fn() | |
return fire() if document.readyState is "complete" | |
# Mozilla, Opera, WebKit |