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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="js/paper.js"></script> | |
<script type="text/javascript" src="js/paper-error.js"></script> | |
<script type="text/javascript" src="js/paper-timeline.js"></script> | |
<script type="text/paperscript" canvas="myCanvas"> | |
//scaling |
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
heapdump = require('heapdump') | |
memwatch = require('memwatch') | |
memwatch.on 'leak', (info) -> console.log('leak', info) | |
memwatch.on 'stats', (stats) -> console.log('stats', stats) | |
if frame % 25 == 1 | |
hd = new memwatch.HeapDiff() | |
if frame % 25 == 24 | |
diff = hd.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
;;make some complex hashmap with numbers, edges and complex structs | |
(def c {:from 0 :to 1 [0, 1] 3 #{0 {:x 2 :y 3} 1 {:x 0 :y 3}} 4}) | |
;;test getting edge value | |
(get c #{0 {:x 2 :y 3} 1 {:x 0 :y 3}}) | |
;;define points | |
(def p1 {:x 2 :y 3}) | |
(def p2 {:x 0 :y 3}) |
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
sha.js - test 700KB | |
https://github.com/dominictarr/sha.js/issues/5 | |
esprima - test 700KB | |
https://github.com/ariya/esprima | |
https://code.google.com/p/esprima/issues/detail?id=573&thanks=573&ts=1406550115 | |
browser-sync - cache 55MB | |
https://github.com/shakyShane/browser-sync/issues/212 |
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
How would you partition array into pairs in Ramda? [0, 1, 2, 3, 4, 5] -> [[0,1], [2, 3], [4, 5]] | |
//@vorg - my solution | |
var hasEvenIndex = function(n, i) { return i % 2 == 0; }; | |
var hasOddIndex = function(n, i) { return i % 2 == 1; }; | |
function pairs(list) { | |
var evens = R.filter.idx(hasEvenIndex)(list); | |
var odds = R.filter.idx(hasOddIndex)(list); | |
return R.zip(evens, odds); |
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 R = require('ramda'); | |
var list = ['a', 'b', 'c']; | |
var edges = [[0, 1], [1,2]]; | |
var values; | |
//1 | |
values = edges.map(function(edge) { | |
return [ list[edge[0]], list[edge[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
GeomUtils.center3 = function(points) { | |
var sum = new Vec3(0, 0, 0); | |
for(var i=0; i<points.length; i++) { | |
sum.add(points[i]); | |
} | |
sum.scale(1/points.length); | |
return sum; | |
} | |
GeomUtils.center3R = function(points) { |
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
FXStage.prototype.drawFullScreenQuadAt = function (x, y, width, height, image, program) { | |
var regl = this.regl | |
program = program || this.fullscreenQuad.program | |
if (!this.blitCmd) { | |
this.blitCmd = regl({ | |
// depth: { enable: false }, | |
// viewport: { x: x, y: y, width: width, height: height }, | |
attributes: this.fullscreenQuad.attributes, | |
elements: this.fullscreenQuad.elements, | |
vert: regl.prop('vert'), |
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> This example shows how to draw a mesh with regl </p> | |
*/ | |
const regl = require('regl')() | |
const mat4 = require('gl-mat4') | |
const bunny = require('bunny') | |
var vert = ` | |
precision mediump float; | |
attribute vec3 position; |
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 regl = require('regl')() | |
regl.clear({ | |
color: [0, 0, 0, 1], | |
depth: 1 | |
}) | |
// In regl, draw operations are specified declaratively using. Each JSON | |
// command is a complete description of all state. This removes the need to | |
// .bind() things like buffers or shaders. All the boilerplate of setting up |
OlderNewer