Skip to content

Instantly share code, notes, and snippets.

View hongymagic's full-sized avatar
🤪

David Hong hongymagic

🤪
View GitHub Profile
@hongymagic
hongymagic / curry.js
Last active August 29, 2015 14:05
JavaScript curry and curryRight functions
function apply(handler, args) {
return handler.apply(null, args);
}
function toArray(collection) {
return [].slice.call(collection);
}
function reverse(collection) {
return toArray(collection).reverse();
@hongymagic
hongymagic / gist:35c6093a7b0b48fb4c4b
Last active August 29, 2015 14:06
found this in ~/, saving it before removing. no idea what it does
//
// Compare two characters
//
// returns 0 if equal, -1 if x is before y, 1 otherwise.
function compareChars(x, y) {
if (x === y) {
return 0;
}
if (x === undefined) {
@hongymagic
hongymagic / THE_NORTH_FACE.logo.js
Created July 25, 2011 13:10
Draws half dome "THE NORTH FACE" logo on HTML5 Canvas
/**
* Draw "THE NORTH FACE" thrice half-dome logo
*
* usage:
* THE_NORTH_FACE.draw(
* context // canvas.getContext('2d')
* x, // x center of the dome
* y, // y center of the dome
* width, // width of the dome
@hongymagic
hongymagic / CanvasRenderingContext2D.renderText.js
Created July 27, 2011 04:25
CanvasRenderingContext2D fillText with letter-spacing support
/**
* CanvasRenderingContext2D.renderText extension
*/
if (CanvasRenderingContext2D && !CanvasRenderingContext2D.renderText) {
// @param letterSpacing {float} CSS letter-spacing property
CanvasRenderingContext2D.prototype.renderText = function (text, x, y, letterSpacing) {
if (!text || typeof text !== 'string' || text.length === 0) {
return;
}
@hongymagic
hongymagic / SF-Logo.raphael.js
Created December 19, 2011 03:50
SF Logo (svg and Raphael)
var
container = 'rsr',
scale = 1.00, /* TODO: doesn't work atm */
width = 170.48 * scale,
height = 203.22 * scale,
rsr = Raphael(container, width, height),
background,
lower,
@hongymagic
hongymagic / dabblet.css
Created December 19, 2011 06:21
BonBon+
/**
* BonBon+
*
* This is an improvement over BonBon CSS3 buttons
*
* @see: http://lab.simurai.com/css/buttons/
*/
/* Fonts being used */
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:bold+Lobster);
@hongymagic
hongymagic / dabblet.css
Created December 20, 2011 03:27
BonBon+
/**
* BonBon+
*
* This is an improvement over BonBon CSS3 buttons
*
* @see: http://lab.simurai.com/css/buttons/
*/
/* Fonts being used */
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:bold+Lobster);
@hongymagic
hongymagic / dabblet.css
Created January 10, 2012 00:01
css quiz 8
/**
* css quiz 8
* http://cssquiz.com/q8-theres-a-fire-starting-in-my-heart
*/
div {
width: 100px; height: 100px;
line-height: 100px;
text-align: center;
/**
* BonBon+
*
* This is an improvement over BonBon CSS3 buttons
*
* @see: http://lab.simurai.com/css/buttons/
*/
/* Fonts being used */
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:bold+Lobster);
@hongymagic
hongymagic / log.js
Created January 10, 2012 03:37
Simple log wrapper which prints line numbers...
window.log = (function (console) {
'use strict';
var COUNT = 0;
return function () {
var args = Array.prototype.slice.call(arguments),
line = [++COUNT + ':'];
if (typeof console === 'object') {