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
( | |
// | |
// 1 + 1 = 2 | |
// | |
(function(x){return this+x}).apply(1,[1])==2 | |
&& | |
// |
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
$R = function(a,b){ | |
var r=[] | |
for(var i=a;i<=b;i++) r.push(i) | |
return r | |
} | |
$L = function(){ | |
var alphabet = "abcdefghijklmnopqrstuvwxyz" | |
var typeHint = (typeof arguments[0][0]) | |
var f = arguments[arguments.length - 1] |
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
/* | |
* This code searches for all the <script type="application/processing" target="canvasid"> | |
* in your page and loads each script in the target canvas with the proper id. | |
* It is useful to smooth the process of adding Processing code in your page and starting | |
* the Processing.js engine. | |
*/ | |
if ( window.addEventListener ) { | |
window.addEventListener("load", function() { | |
var scripts = document.getElementsByTagName("script"); |
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 calculateFFT = function(real, imag) { | |
var bufferSize = real.length; | |
if ( bufferSize == 1 ) { | |
return [[real[0], imag[0]]]; | |
} | |
if(bufferSize % 2 != 0) throw "Invalid buffer size, length must be an even number"; | |
var even_real = []; |
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 FFT = function(_bufferSize) { | |
var bufferSize = _bufferSize; | |
var self = { | |
// constructor | |
initialize: function(){ | |
self.reverseTable = self.buildReverseTable(); | |
return self; | |
}, |
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
p.FFT = function(_bufferSize) { | |
var bufferSize = _bufferSize; | |
var self = { | |
initialize: function() { | |
self.buildReverseTable(); | |
self.buildTrigTables(); | |
return self; | |
} | |
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 tick = function(){ | |
/* ... compute stuff, do the work that needs to be done ... */ | |
var data = ...; | |
sendMessage(data); | |
// schedule the next tick according to our course correction | |
/* observe what time it is and how long it's been | |
since a heartbeat and compute how much less than | |
500ms to delay for */ |
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
irb(main):001:0> # Builds a function which returns true | |
irb(main):002:0* # whenever _every_ function in 'predicates' | |
irb(main):003:0* # returns true. | |
irb(main):004:0* def conjoin *predicates | |
irb(main):005:1> base = lambda {|*args| true } | |
irb(main):006:1> predicates.inject(base) do |built, pred| | |
irb(main):007:2* lambda do |*args| | |
irb(main):008:3* built.call(*args) && pred.call(*args) | |
irb(main):009:3> end | |
irb(main):010:2> end |
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
$('div').click(function() { | |
var div = this; | |
if($(div).hasClass("width_restrictor")) { | |
$('ul.uses_width_restriction li').each(function(item) { | |
var li = item; | |
$(li).width( Math.round( $(div).width() / 2 ) ); | |
}); | |
} | |
}); |
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
for(var k in p){ | |
if(typeof(p[k])=='function'){ | |
(function(k){ | |
var cachedCommand = commands[k]; | |
commands[k] = function(){ | |
if(ctx == null){ | |
if(strict==true){ | |
throw "No context!"; | |
} | |
ctx = makeDefaultContext(); |
OlderNewer