Skip to content

Instantly share code, notes, and snippets.

View jfsiii's full-sized avatar

John Schulz jfsiii

View GitHub Profile
@jfsiii
jfsiii / dual.js
Created May 13, 2011 03:01 — forked from unscriptable/another-way.js
AMD-compatible CommonJS Module/1.1 that can also be loaded in a script tag
(function (define) {
define(function (exports) {
function Color(){}
return Color;
});
}(
// provide define if it's not available
this.define || (function (global, moduleId) {
@jfsiii
jfsiii / gist:814784
Created February 7, 2011 17:33 — forked from paulirish/gist:601751
get and set objects in localStorage and sessionStorage
// Forked from paul irish's https://gist.github.com/601751
// desire: localStorage and sessionStorage should accept objects
// in fact they do according to spec.
// http://code.google.com/p/chromium/issues/detail?id=43666
// but so far that part isnt implemented anywhere.
// so we duckpunch set/getItem() to stringify/parse on the way in/out
// this seems to work in chrome
// converts milliseconds to '3:45' or if hours > 0, '2:01:23'
var getTimeFromMillis = function( ms )
{
var seconds = ':' + twoDigit( ~~( ( ms / 1000 ) % 60 ) ),
minutes = ~~( ( ms / ( 1000 * 60 ) ) % 60 ),
hours = ~~( ( ms / ( 1000 * 60 * 60 ) ) );
function twoDigit( n ) { return n < 10 ? '0' + n : n; }
return hours > 0 ? hours + ':' + twoDigit( minutes ) + seconds : minutes + seconds;
/*! Cross-browser-compatible async
*
* I took Mathias' setZeroTimeout and changed it to async, based on http://fitzgeraldnick.com/weblog/35/. Some style changes (varible names, show logic first).
*
* I took the original setZeroTimeout and made it cross-browser-compatible, using setTimeout(fn, 0) as a fallback in case postMessage is not supported.
* Mathias Bynens <http://mathiasbynens.be/>
* See <http://mathiasbynens.be/notes/settimeout-onload>
*
* Copyright statement below:
*
/*! Cross-browser-compatible setZeroTimeout
*
* I took the original setZeroTimeout and made it cross-browser-compatible, using setTimeout(fn, 0) as a fallback in case postMessage is not supported.
* Mathias Bynens <http://mathiasbynens.be/>
* See <http://mathiasbynens.be/notes/settimeout-onload>
*
* Copyright statement below:
*
* See <http://dbaron.org/log/20100309-faster-timeouts>
* By L. David Baron <dbaron@dbaron.org>, 2010-03-07, 2010-03-09
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
// jquery invert plugin
// by paul irish
// some (bad) code from this css color inverter
// http://plugins.jquery.com/project/invert-color
// some better code via Opera to inverse images via canvas
// http://dev.opera.com/articles/view/html-5-canvas-the-basics/#insertingimages
// and some imagesLoaded stuff from me
// http://gist.github.com/268257