Skip to content

Instantly share code, notes, and snippets.

View formikaio's full-sized avatar

WhileTrue formikaio

View GitHub Profile
@stephenhowells
stephenhowells / gist:5496740
Created May 1, 2013 17:25
CDNs fail, but your scripts don't have to - fallback from CDN to local jQuery
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min.js"></script>
<script>
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/js/jquery-2.0.0.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
@peterc
peterc / pi.js
Created February 23, 2013 13:44
Calculating pi using the Monte Carlo method in JavaScript
var r = 5;
var points_total = 0;
var points_inside = 0;
while (1) {
points_total++;
var x = Math.random() * r * 2 - r;
var y = Math.random() * r * 2 - r;