This file contains hidden or 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
// parseURL function from James padolsey | |
// http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ | |
function parseURL(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return { | |
source: url, | |
protocol: a.protocol.replace(':',''), | |
host: a.hostname, |
This file contains hidden or 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
// parseUri 1.2.2 | |
// (c) Steven Levithan <stevenlevithan.com> | |
// MIT License | |
function parseUri (str) { | |
var o = parseUri.options, | |
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), | |
uri = {}, | |
i = 14; |
This file contains hidden or 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
// Taken from: http://stackoverflow.com/a/9349999 | |
// <img data-other-src="big-zebra.jpg" src="small-zebra.jpg"> | |
// <img data-other-src="big-elephant.jpg" src="small-elephant.jpg"> | |
// <img data-other-src="big-bear.jpg" src="small-bear.jpg"> | |
$(function () { | |
$('img').on('mouseenter mouseleave', function () { | |
$(this).attr({ | |
src: $(this).attr('data-other-src'), |
This file contains hidden or 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
// Taken from: http://stackoverflow.com/a/476681 | |
(function() { | |
var arrayOfImages = ["one.jpg", "two.jpg", "three.jpg"]; | |
function preload(arrayOfImages) { | |
$(arrayOfImages).each(function () { | |
$('<img/>')[0].src = this; | |
}); | |
} |
This file contains hidden or 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 Distance = { | |
rad: function (x) { | |
return x * Math.PI / 180; | |
}, | |
haversine: function (p1, p2) { | |
var R = 637100000, | |
dLat = this.rad(p2.latitude - p1.latitude), | |
dLong = this.rad(p2.longitude - p1.longitude), |
This file contains hidden or 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
<?php | |
// Takes two dates formatted as YYYY-MM-DD and creates an | |
// inclusive array of the dates between the from and to dates. | |
// Taken from: http://stackoverflow.com/a/4312491 | |
function createDateRangeArray($sDate, $eDate) | |
{ | |
$range = array(); |
This file contains hidden or 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 elements of second array from the first array | |
// Ex. 1 JavaScript Filter (no IE 8 support) | |
var arr1 = ['A', 'B', 'C', 'D', 'E', 'F'], | |
arr2 = ['C', 'E', 'F'], | |
filteredArray; | |
filteredArray = arr1.filter(function(e, i) { | |
return !(arr2.indexOf(e) > -1); | |
}); |
This file contains hidden or 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
Handlebars.registerHelper('quotify', function (string) { | |
var string = string.replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"'); | |
return string; | |
}); |