Skip to content

Instantly share code, notes, and snippets.

View avoidwork's full-sized avatar

Jason Mulligan avoidwork

View GitHub Profile
@avoidwork
avoidwork / filesize.js
Created March 24, 2012 01:05
filesize.js
filesize(500); // "3.91Kb"
filesize(500, true); // "3.9k"
filesize(1500); // "1.46KB"
filesize("1500000000"); // "1.40GB"
filesize("1500000000", 0); // "1GB"
filesize(1212312421412412); // "1.08PB"
filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to *nix "ls -lh"
@avoidwork
avoidwork / gist:1423758
Created December 2, 2011 16:03
(Proof of concept) Facade for HTML5 dataset attributes with fallback to data- attributes
/**
* Data attributes facade
*
* @type {Object}
*/
var data = {
/**
* Getter
*
* @param {Object} obj Element to query