Skip to content

Instantly share code, notes, and snippets.

View jaredwilli's full-sized avatar
🏄‍♂️

Jared Williams jaredwilli

🏄‍♂️
View GitHub Profile
@jaredwilli
jaredwilli / global-variables-are-bad.js
Created February 22, 2012 18:02 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@jaredwilli
jaredwilli / rAF.js
Created May 2, 2012 14:39 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@jaredwilli
jaredwilli / gist:2577051
Created May 2, 2012 14:40 — forked from paulirish/moved.md
Breakpoint on access to a property
function debugAccess(obj, prop, debugGet){
var origValue = obj[prop];
Object.defineProperty(obj, prop, {
get: function () {
if ( debugGet )
debugger;
return origValue;
},
@jaredwilli
jaredwilli / heart.js
Created May 2, 2012 14:40 — forked from paulirish/heart.js
sweetass heart canvas.
// 99% done by @rauri rochford
// http://js1k.com/2012-love/demo/1071
// i just rAF'd it.
// demo at http://bl.ocks.org/1823634
e = [];// trails
@jaredwilli
jaredwilli / gameengines.md
Created May 30, 2012 19:12 — forked from bebraw/gameengines.md
List of JS game engines. You can find a wikified version at https://github.com/bebraw/jswiki/wiki/Game-Engines. Feel free to modify that. I sync it here every once in a while.

IMPORTANT! Remember to check out the wiki page at https://github.com/bebraw/jswiki/wiki/Game-Engines for the most up to date version. There's also a "notes" column in the table but it simply does not fit there... Check out the raw version to see it.

This table contains primarily HTML5 based game engines and frameworks. You might also want to check out these pages: [[Feature Matrix|Game-Engine-Feature-Matrix]], [[Game Resources]].

Name Latest Release Size (KB) License Type Unit Tests Docs Repository Notes
ActionJS no github AS3 like in Javascript
Akihabara 1.3.1 (2011/05) 453 GPL2, MIT Classic Repro no API github Inten
@jaredwilli
jaredwilli / gist:3266726
Created August 5, 2012 19:10 — forked from zachleat/gist:980895
HTML5 Boilerplate Issue #378 (No Compatibility View button, tested in IE7/IE8/IE9)
<!--[if IE ]><![endif]-->
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@jaredwilli
jaredwilli / deferred-img.js
Created October 13, 2012 01:09 — forked from fcalderan/deferred-img.js
Image loader / preloader achieved by deferred objects in jQuery 1.6
/**
* For a current project I need to wait to execute a code until some images have been loaded.
* Beside, I also need to execute a callback (in my specific code I want to show the image
* with a fade-in effect) every time a single image has been loaded.
*
* So basically I used two deferred objects: the nested one which is resolved for a single
* image successfull load event (or when image has been discarded) and the outside one,
* which is resolved when all deferred objects on single images have been resolved or rejected.
*
* This snippet also takes care all frequent issues when trying to load an image (excessive
@jaredwilli
jaredwilli / domready.js
Created October 13, 2012 04:26 — forked from ded/domready.js
Smallest x-browser DOM Ready, ever
function r(f){/in/(document.readyState)?setTimeout(r,9,f):f()}
@jaredwilli
jaredwilli / sessionStorage.js
Created October 16, 2012 19:45 — forked from FiNGAHOLiC/sessionStorage.js
sessionStorage polyfill
/*
* Based on: http://www.quirksmode.org/js/cookies.html
* and https://github.com/wojodesign/local-storage-js/blob/master/storage.js
* and https://gist.github.com/350433
* License: http://www.opensource.org/licenses/MIT
*/
(function(window) {
'use strict';
window.sessionStorage = window.sessionStorage || {
@jaredwilli
jaredwilli / comma-first-var.js
Created October 16, 2012 19:46 — forked from FiNGAHOLiC/comma-first-var.js
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",