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
// hat-tip to [Kent Brewster](https://gist.github.com/kentbrew), mod to allow | |
// commandline usage: `node server.js {port} {rootdir}` | |
// hey, everybody! it's a tiny Web server! | |
// INSTALL: `npm install mime colors` | |
// instead of a bunch of foo = reqire("foo") | |
// list our required modules and loop through | |
var r = [ "fs", "http", "mime", "path", "url", "colors" ]; |
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
// turning the markdown feature into a one line include for kits. | |
// wicked closure pattern w/ hat tip to Paul Irish [source](https://gist.github.com/paulirish/315916) | |
(function(window, document, undefined){ | |
// check if Showdown is loaded already or not... if not, then load it | |
// once we have Showdown run the converter | |
if(!window.Showdown){ | |
var script = document.createElement('script'); | |
script.src = '//cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js'; | |
script.onload = extendAndConvert; |
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 request = require('request'); | |
var data = { | |
saturday: { | |
total_sessions: 0 | |
}, | |
sunday: { | |
total_sessions: 0 | |
}, | |
format: {}, |
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
// utility function to parse/use query strings | |
window.query = document.query = (function(window, document, undefined){ | |
var pairs = window.location.search.slice(1).split('&'), | |
result = {}; | |
pairs.forEach(function(pair){ | |
pair = pair.split('='); | |
result[pair[0]] = decodeURIComponent(pair[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
/* | |
* Javascript Diff Algorithm | |
* By John Resig (http://ejohn.org/) | |
* Modified by Chu Alan "sprite" | |
* | |
* Released under the MIT license. | |
* | |
* More Info: | |
* http://ejohn.org/projects/javascript-diff-algorithm/ | |
*/ |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Image 2 DataURL</title> | |
<style> | |
#images { | |
width: 420px; | |
margin: auto; |
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
// target.addEventListener shim, hat tip [mdn](http://mzl.la/18ELrGJ) | |
(function() { | |
if (!Event.prototype.preventDefault) { | |
Event.prototype.preventDefault=function() { | |
this.returnValue=false; | |
}; | |
} | |
if (!Event.prototype.stopPropagation) { | |
Event.prototype.stopPropagation=function() { | |
this.cancelBubble=true; |
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(window,document,undefined){var script=document.createElement('script');script.setAttribute('src','https://towtruck.mozillalabs.com/towtruck.js');document.body.appendChild(script);setTimeout(function(){try{window.TowTruck(window);}catch(e){alert('Failed to load TowTruck');}},400);})(this,this.document); |
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
// Does an inplace shuffle of an array in O(n) time. Uses the Fisher-Yates Shuffle. | |
Array.prototype.shuffle || Array.prototype.shuffle = function(){ | |
for(var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x); | |
}; |
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
// Remove first element, place it at the end. | |
// Returns the first element before move. | |
Array.prototype.cycle || Array.prototype.cycle = function(){ | |
var rtn = this.shift(); | |
this.push(rtn); | |
return rtn; | |
}; |