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
_.mixin({ | |
cacheFor: function(wait, fn) { | |
return _.throttle(fn, wait, { trailing: false }); | |
} | |
}); |
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 isUsingImperialSystem(countryCode) { | |
return /US|PR|JM|BS|GU|BZ|VI|KY|PW/.test(countryCode); | |
} |
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
/* | |
Kilo.js | |
#toSize: 2048 => "2 KB" | |
#toBytes: "2 KB" => 2048 | |
*/ | |
var Kilo = (function() { | |
"use strict"; | |
var kilo = 1024; | |
var sizes = { "B": 0, "KB": 1, "MB": 2, "GB": 3, "TB": 4 }; | |
var sizesNames = Object.keys(sizes); |
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 generateOfficeWebAppURL(url) { | |
return "http://view.officeapps.live.com/op/view.aspx?src=" + encodeURIComponent(url); | |
} |
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
// https://github.com/jquery/jquery/blob/master/src/core/init.js#L14 | |
var isHTMLString = (function() { | |
var rHTML = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/; | |
return function(str) { | |
return rHTML.test(str); | |
}; | |
}()); |
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
[ | |
{ | |
"uid": "keywordSELECT", | |
"subtext": "[FQL keyword]", | |
"text": "SELECT" | |
}, | |
{ | |
"uid": "keywordFROM", | |
"subtext": "[FQL keyword]", | |
"text": "FROM" |
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
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<label for="uploadFile">UPLOAD</label> | |
<input type="file" id="uploadFile"/> | |
<script> | |
$("input[type='file']").on("keyup", function(e) { | |
if (e.keyCode === 27) this.blur(), e.stopPropagation(); | |
}); | |
$(document).on("keyup", function(e) { |
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 geolocate = function(callback) { | |
callback = typeof callback === "function" ? callback : function(){}; | |
if ('Geo' in window) { | |
callback(window.Geo); | |
} else { | |
var script = document.createElement('script'); | |
script.src = "https://geoiplookup.wikimedia.org/"; | |
script.onload = function() { callback(window.Geo) }; | |
document.head.appendChild(script); | |
} |
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
_.mixin({ | |
whenOnline: function(fn, context) { | |
return function() { | |
var args = arguments; | |
context = context || this; | |
if (navigator.onLine) { | |
fn.apply(context, args); | |
} else { | |
window.addEventListener('online', function online() { | |
fn.apply(context, args); |
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
// https://github.com/felixge/node-mysql/blob/master/lib/protocol/SqlString.js | |
function escapeSqlString(text) { | |
return text.replace(/[\0\n\r\b\t\\\'\"\x1a]/g, function(s) { | |
switch(s) { | |
case "\0" : return "\\0"; | |
case "\n" : return "\\n"; | |
case "\r" : return "\\r"; | |
case "\b" : return "\\b"; | |
case "\t" : return "\\t"; | |
case "\x1a": return "\\Z"; |