Skip to content

Instantly share code, notes, and snippets.

View Maciek416's full-sized avatar

Maciej Adwent Maciek416

View GitHub Profile
(
//
// 1 + 1 = 2
//
(function(x){return this+x}).apply(1,[1])==2
&&
//
$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 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");
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 = [];
var FFT = function(_bufferSize) {
var bufferSize = _bufferSize;
var self = {
// constructor
initialize: function(){
self.reverseTable = self.buildReverseTable();
return self;
},
p.FFT = function(_bufferSize) {
var bufferSize = _bufferSize;
var self = {
initialize: function() {
self.buildReverseTable();
self.buildTrigTables();
return self;
}
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 */
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
$('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 ) );
});
}
});
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();