Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@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 / test_canvas_strokes.js
Created September 7, 2014 11:10
benchmark 2d canas strokes
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 / undo.js
Last active July 26, 2022 20:18
Simple Undo / Redo System
// Simple Undo / Redo System
/*
* @author joshua koo / http://joshuakoo.com
*
* There are usually 2 different ways to handle undo / redo
* 1. you snapshot and store the states, so you can load them anytime
* 2. you store the deltas, actions, events or commands between save points.
*
* Method 1 is simplistic. But it works. It's a lot like git.
@zz85
zz85 / drag.js
Last active July 26, 2022 19:00
Generic onDrag handler
/*
@author twitter.com/blurspline
*/
function handleDrag(element, ondown, onmove, onup, down_criteria) {
var pointer = null;
var bounds = element.getBoundingClientRect();
element.addEventListener('mousedown', onMouseDown);
@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 / README.md
Last active May 9, 2016 00:59
Easing Experiments
@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 {
}