Skip to content

Instantly share code, notes, and snippets.

View gliese1337's full-sized avatar

Logan Kearsley gliese1337

View GitHub Profile
@gliese1337
gliese1337 / submsNow.js
Created August 26, 2012 16:07 — forked from jeromeetienne/submsNow.js
a submillisecond version of Date.now() based on based on window.performance.now()
/**
* precise version of Date.now() -
* It provide submillisecond precision based on window.performance.now() when
* available, fall back on Date.now()
* see http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
*/
var nowSubms = (function(){
var p = window.performance || {};
if( p.now ) return function(){ return p.timing.navigationStart + p.now(); };
else if( p.mozNow ) return function(){ return p.timing.navigationStart + p.mozNow(); };
@gliese1337
gliese1337 / mozilla-readasarraybuffer.js
Created June 21, 2011 04:07 — forked from also/mozilla-readasarraybuffer.js
readAsArrayBuffer polyfill for Firefox 4 with caching
if (!FileReader.prototype.readAsArrayBuffer) {
FileReader.prototype.readAsArrayBuffer = function readAsArrayBuffer () {
this.readAsBinaryString.apply(this, arguments);
this.__defineGetter__('resultString', this.__lookupGetter__('result'));
Object.defineProperty(this, 'result', {
get : function () {
var string = this.resultString,
result = new Uint8Array(string.length);
for (var i = 0; i < string.length; i++) {
result[i] = string.charCodeAt(i);