Skip to content

Instantly share code, notes, and snippets.

View eligrey's full-sized avatar
:octocat:

Eli Grey eligrey

:octocat:
View GitHub Profile

See .

/*
* textcontent.js
* 2010-07-21
* By Eli Grey, http://eligrey.com
*
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*
* Implements the element.textContent accessor in IE8.
*/
/*
* apng-detect.js
* 2010-06-13
* By Eli Grey, http://eligrey.com
*
* Detects if a browser supports the APNG format and sets a
* global `APNG` boolean indicating if the browser supports APNG.
*
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
@eligrey
eligrey / readme.md
Created September 13, 2009 19:51
High-resolution JavaScript timer
"use strict";var Timer=Timer||(function(){var c,b,a=Date.now||function(){return(new Date()).getTime()};if(typeof chromium!=="undefined"&&chromium.Interval){b=(c=chromium.Interval).prototype;b.milliseconds=function(){return this.microseconds()/1000}}else{b=(c=function(){var e=0,d=0;this.start=function(){d=0;e=a()};this.stop=function(){d=a();if(e===0){d=0}};this.milliseconds=function(){var f=d;if(f===0&&e!==0){f=a()}return f-e}}).prototype;b.microseconds=function(){return this.milliseconds()*1000}}b.profile=function(d,e){if(typeof d==="string"){d=new Function(d)}this.start();while(e--){d()}this.stop()};b.seconds=function(){return this.milliseconds()/1000};return c}());
/*
* importScripts.es5
* Requires ECMAScript 5 or JavaScript 1.9
* 2010-07-21
*
* By Eli Grey, http://eligrey.com
*
* Implements HTML5 web workers' importScripts() function using synchronous XMLHttpRequests.
* This is very useful for debugging worker scripts outside of a worker context.
*
/*
* importScripts.js simplified (no IE <8 or data: URI support)
*
* 2009-10-17
*
* By Elijah Grey, http://eligrey.com
*
* Implements HTML5 web workers' importScripts() function using synchronous XMLHttpRequests.
*/
@eligrey
eligrey / iter-own-props.js
Created September 19, 2009 20:49
Implicit filtering of properties that are not an object's own in `for (property in object)' and `for each (value in object)' loops.
/*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, strict: true, newcap: true, immed: true */
// usage example: http://gist.github.com/189580
"use strict";
(function () {
var objProto = Object.prototype,
hasOwnProp = objProto.hasOwnProperty,
iterMethod = "__iterator__",
Object.prototype.foo = "bar";
Object.prototype.bar = "foo";
var test = {a: 1, b: 2, c: 3},
props = [], vals = [];
for (let prop in test) {
props.push(prop);
}
"use strict";
importScripts("http://gist.github.com/212482.txt");
function matrix (width, height, fill)
[
[
arguments.length > 2 ?
(typeof fill === "function" ?
fill() : fill