Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / SimpleEventExample.js
Created June 22, 2012 21:01
Example for SimpleEvent component from http://jsdo.it/zz85/75cq
// generates a "event channel"
var onFire = new SimpleEvent();
// adds an listener
onFire.add(function aListener(hello, world){
alert(hello + ' ' + world);
})
// notifies listeners
onFire.notify('Bye', 'Universe');
@zz85
zz85 / in_words.js
Last active December 14, 2015 08:29 — forked from bcamarda/in_words.js
Now support up to 999 trillion. (fixed a flooring error with ~~ and removed unneeded console.log)
// Converts a number to english words
// Based on https://gist.github.com/bcamarda/3001102
// Refactored and made some changes to support numbers to a hundred (US) trillion
// github.com/zz85
var inWords = (function() {
var numberHash = {
0:"", 1:"one", 2:"two", 3:"three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine", 10: "ten",
@zz85
zz85 / gist:5522800
Last active December 17, 2015 00:39
JS1K 2013 "Spring" Finalists
@zz85
zz85 / messages.js
Created September 7, 2013 23:48
Offline Rendering of @kig's Message presentation app using SlimerJS
/*
PDF Generator for @ilmarihei's Awesome "Messsage" Presentation App!
Usage:
./slimerjs messages.js
You may also need to
- get http://slimerjs.org/
- edit the config variables
- run `convert slides/*.jpg presentation.pdf`
@zz85
zz85 / README.md
Last active February 6, 2016 14:40
Drawing / Painting as Many Rects as Possible (Still WIP, feel free to comments or contribute!)

Moved here

Fastest Rectangles

Some thoughts:

  • How many ways can you draw rectangles in a browser (eg. dom, css, 2d canvas, svg, webgl)
  • How is the fastest (most number of) rectangles can you draw with each approach?

Task:

  • Paint random rectangles for 5 seconds, find out how fast each approach takes.
@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 / README.md
Last active May 9, 2016 00:59
Easing Experiments
@zz85
zz85 / test.html
Last active June 21, 2016 01:51
Game API
<html>
<body>
<style>
body {
font-family: 'monospace';
font-size: 12px;
}
</style>
Hello Copter World!
<div id="debug"></div>
@zz85
zz85 / array_joining.js
Created June 23, 2016 05:34
Fastest Array Joins on Strings
var array = ['livechat', 'visitors', 'apple', 'display_name'];
function testConcat(y) {
return array.concat([y]);
}
function testDeconstruct(y) {
return [...array, y];
}
@zz85
zz85 / hello.js
Last active July 5, 2016 07:14
Adele Hello Chat Bot
// Inspired by http://www.dailymail.co.uk/femail/article-3672152/Man-infuriates-Facebook-scammer-Adele-lyrics.html && simon toh
// ADELE Hello lyrics
HelloMsgs = `
Hello, it's me, I was wondering
If after all these years you'd like to meet to go over everything
They say that time's supposed to heal, yeah
But I ain't done much healing
Hello, can you hear me?