Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / ParametricGeometry2.js
Last active August 29, 2015 13:56
Exploring ParametricGeometry2
/**
* @author zz85 / https://github.com/zz85
* Parametric Surfaces Geometry
* based on the brilliant article by @prideout http://prideout.net/blog/?p=44
*
* new THREE.ParametricGeometry( parametricFunction, uSegments, ySegements );
*
*/
THREE.ParametricGeometry2 = function ( func, slices, stacks ) {
@zz85
zz85 / gist:10542662
Created April 12, 2014 15:54
Coefficients Generation for Optimized Gaussian Blurs using Linear Sampling
/*
* @author zz85 / https://github.com/zz85
*
* Related Readings
*
* http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
* http://www.sunsetlakesoftware.com/2013/10/21/optimizing-gaussian-blurs-mobile-gpu
* http://xissburg.com/faster-gaussian-blur-in-glsl/
* https://github.com/manuelbua/blur-ninja
*
@zz85
zz85 / cssRule.js
Created June 27, 2014 16:18
Easy way for creating and modifying CSS Rules in JS
if (!document.styleSheets.length) document.head.appendChild(document.createElement('style'));
var sheet = document.styleSheets[document.styleSheets.length - 1];
var rules = {};
function cssRule(selector, styles) {
var index;
if (selector in rules) {
index = rules[selector];
sheet.deleteRule(index);
} else {
index = rules[selector] = sheet.cssRules.length;
@zz85
zz85 / mem.js
Last active August 29, 2015 14:05
Print Memory
function format_numbers(n) {
return (n / 1024 / 1024).toFixed(3) + 'MB';
}
function mem() {
if (performance && performance.memory) {
console.log('used heap', format_numbers(performance.memory.usedJSHeapSize))
console.log('total heap', format_numbers(performance.memory.totalJSHeapSize))
console.log('heap limit', format_numbers(performance.memory.jsHeapSizeLimit))
}
@zz85
zz85 / histogram.js
Last active August 29, 2015 14:05
Simple Histogram Stats
function Histogram() {
this.reset();
}
Histogram.prototype.reset = function() {
this.counts = [];
this.types = {};
};
@zz85
zz85 / test.js
Created September 3, 2014 11:59
test bezier
var c = document.createElement('canvas');
c.width = innerWidth;
c.height = innerHeight;
var ctx = c.getContext('2d');
document.body.appendChild(c);
var last = performance.now();
var delay = 0;
@zz85
zz85 / pootify.js
Last active August 29, 2015 14:06 — forked from alisaifee/pootify.js
Pootify Bookmarklet
// TODO Use the DOM Mutation API!
(function switchText(node) {
var nodes = node.childNodes;
for (var n = 0; n < nodes.length; n++) {
if (nodes[n].nodeName.match(/(script|style)/i)); else
if (nodes[n].nodeType == 3) {
if (!/^\s+$/.test(nodes[n].value)) {
nodes[n].data = nodes[n].data.replace(/[a-zA-Z]+/g, function(w) {
return (w.match(/^(the|on|are|if|is|and|or|you|your|a|an)$/i))
? w
@zz85
zz85 / log.js
Created December 18, 2014 10:57
black background console log for code
function stretch(args) {
for (var i = 0, il = args.length; i<il; i++) {
var c = args[i];
args[i] += new Array(200).slice(c.length).join(' ');
}
return args;
}
@zz85
zz85 / gss_test.html
Created January 8, 2015 07:29
Testing GSS
<html>
<head>
<script>
GSS_CONFIG = {
worker: "bower_components/gss/dist/worker.js",
verticalScroll: !false
};
// also see https://raygun.io/blog/2014/06/next-gen-constraint-layouts-browser-grid-style-sheets/
@zz85
zz85 / main.css
Created April 22, 2015 17:12
boilerplate
body {
}