This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flashFrameTime (counts, cb) { | |
if (!typeof counts === 'number' || !counts > 0) { throw "no!"; } | |
var accum = [] | |
, reqFrame = window.requestAnimationFrame | |
; | |
function calcFramerate () { | |
return accum | |
.slice(0, accum.length-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Required for using JSX in JsFiddle --> | |
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script> | |
<div id="view"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://www.gamedev.net/topic/579738-web-javascript-game-loop/ | |
//http://dev.opera.com/articles/view/framerate-control-system-for-javascript/ | |
//http://jsfiddle.net/digitalicarus/4kshN/3/ | |
var WEE = { | |
FPS: 60, | |
rate: 60, | |
dt: 1/60, | |
accrued: 0.0, | |
last: Date.now()/1000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var roundRect = function(ctx,o) { | |
if(!ctx || !o.x || !o.y || !o.w || !o.h || !o.r) { | |
return; | |
} | |
var x = o.x, | |
y = o.y, | |
w = o.w, | |
h = o.h, | |
r = o.r, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://www.gameprogrammer.com/fractal.html */ | |
// Also, as expected, shifting is waaay faster than division, even in JS :) http://jsperf.com/division-vs-shift unfortunately it also truncates to the mantissa of floating points | |
// http://jsfiddle.net/digitalicarus/YUDgH/24/ | |
// TODO: abs option, obj args, exception reason | |
var calcTerrain = function(conf) { | |
var height = conf.height, | |
swing = conf.swing, | |
h = conf.decay || conf.smooth || conf.smoothness, | |
i = conf.degree, | |
lb = (height-swing < 0) ? conf.lowerBound : null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$.fn.voila = function(content,cb) { | |
return this.each(function() { | |
var $this = $(this); | |
if($this.is(":visible")) { | |
//-- http://stackoverflow.com/questions/4085800/jquery-animate-changes-in-div-height-on-ajax-l | |
console.log("voila: origHeight="+$this.height()); | |
$this | |
.animate({height: $this.height(), opacity: 'hide'}, 'fast', function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calls an array of asynchronous functions and calls the continuation | |
* function when all are done. | |
* @param {Array} functions Array of asynchronous functions, each taking | |
* one argument that is the continuation function that handles the result | |
* That is, each function is something like the following: | |
* function(continuation) { | |
* // compute result asynchronously | |
* continuation(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-- JS number | |
[-+]?(?:(?:\d+)|(?:\d+\.\d+)|(?:\.\d+))(?:e[-+]?\d+)? | |
//-- vim non-greedy multiline http://www.fumbling-in-the-dark.com/2011/08/non-greedy-multi-line-search-and.html | |
%s/text1\_.\{-}text2/text3/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){var t=function(r){var n,a=[],w=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null,false);while(n=w.nextNode()) a.push(n);return a;},i,n=t(document.body); for(i=0;i<n.length;i++) n[i].nodeValue=n[i].nodeValue.replace(/baby|girl/ig,'Jesus').replace(/ her /ig, ' Him ').replace(/ she /ig, ' He ');})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function asyncLoader (s, cb) { | |
var d = document | |
, h = document.getElementsByTagName('head')[0] | |
, b = (Math.random()*1e8>>0) | |
, i = 'loader_'+b | |
, t = (/\.js$/.test(s)) ? "js" : "css" | |
, j = (t === 'js') ? d.createElement('script') : d.createElement('link'); | |
j.id = i; |