Skip to content

Instantly share code, notes, and snippets.

View jfsiii's full-sized avatar

John Schulz jfsiii

View GitHub Profile
// 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
/*
* 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',
/*! 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
/*! 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:
*
// 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;
@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
@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 / dual.js
Created May 13, 2011 03:22 — forked from unscriptable/another-way.js
AMD-compatible CommonJS Module/1.1 that can also be loaded in a script tag
(function () {
/*!
* expose.js
*
* @author Oleg Slobodskoi
* @website https://github.com/kof/expose.js
* @licence Dual licensed under the MIT or GPL Version 2 licenses.
*/
function expose(namespace, api) {
var env = {};
@jfsiii
jfsiii / index.html
Created January 10, 2012 17:51 — forked from joubertnel/gist:870190
HTML5 Canvas - Rendering of Text on high-DPI screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>
@jfsiii
jfsiii / _.md
Created January 14, 2013 20:21 — forked from enjalot/_.md
An inlet to Tributary