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
// just a slimmed-down implementation of browser testing for IE in JavaScript | |
// based on code I found online | |
/** | |
* detect IE | |
* returns version of IE or false, if browser is not Internet Explorer | |
*/ | |
function detectIE() { | |
var ua = window.navigator.userAgent; | |
var msie = ua.indexOf('MSIE '); | |
if (msie > 0) { |
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
/** | |
* Nicely format large numbers to make them readable: | |
* Billions to one decimal like "$1.3 billion" | |
* Millions to nearest million like "$346 million" | |
* Thousands to nearest thousand like "$144,000" | |
* @param {number} The number to format | |
* @returns {string} Readable string with dollar sign and amount | |
*/ | |
function niceBigNumber(num) { | |
// format billions to one decimal like "$1.3 billion" |
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
$ wget \ | |
--recursive \ | |
--no-clobber \ | |
--page-requisites \ | |
--html-extension \ | |
--convert-links \ | |
--domains example.us \ | |
--no-parent \ | |
example.us |
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 hash = window.location.hash; | |
if (hash == "#hashish" || pathArray[0] == "#hashish") { | |
// do stuff | |
} |
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
// returns false unless valid | |
function validateEmail(email) | |
{ | |
var re = /\S+@\S+\.\S+/; | |
return re.test(email); | |
} |
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
// takes a parent el (like a li) and goes to work on its children | |
// assumes the parent has one label and one input | |
function labelsToPlaceholders(parent) { | |
$(parent).each( function(index){ | |
$(this).children('label').css('display', 'none'); | |
labelText = $(this).children('label').text(); | |
labelText = labelText.slice(0,-1); | |
// console.log(labelText); | |
$(this).children('input').attr('placeholder', labelText); |
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
$("#back_to_top").click(function(e){ | |
e.preventDefault(); | |
$('html, body').animate({scrollTop:0}, 'slow'); | |
}); |
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
// reading time | |
$('#reading-time').html(function(){ | |
var wordcount = $('#wordcount').text(); | |
timetoread = Math.round(wordcount / 200); | |
readmessage = timetoread + " min read"; | |
return readmessage; | |
}); |
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
<!-- drop this into your post.html or other page template --> | |
<div id="reading-time"></div> | |
<span id="wordcount" style="display:none">{{ content | number_of_words }}</span> |