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 str = "Hello,\nMy name is, Bob!\n"; | |
str.replace(/(\r\n|\n|\r)/gm,""); |
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
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^([^.]+?)/?$ /$1.html [L,R=301] |
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
Header set Vary "Accept-Encoding" |
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
# Place this line of code anywhere in your .htaccess file | |
AddType application/x-httpd-php .html .htm | |
# This doesn't work for all servers and so if this doesn't | |
# work for yours, delete the code above and use the code | |
# below. If you use the code below, don't forget to remove | |
# the hash character '#' | |
# AddHandler application/x-httpd-php .html .htm |
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
$('pre code').on('mouseup', function() { | |
var sel, range; | |
var el = $(this)[0]; | |
if (window.getSelection && document.createRange) { //Browser compatibility | |
sel = window.getSelection(); | |
if(sel.toString() == ''){ //no text selection | |
window.setTimeout(function(){ | |
range = document.createRange(); //range object | |
range.selectNodeContents(el); //sets Range | |
sel.removeAllRanges(); //remove all ranges from selection |
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
$(".someSpinnerImage").show(); | |
$.getJSON('file.php', function(json) { | |
$.each(json, function() { | |
// Retrieving data from json... | |
}); | |
$(".someSpinnerImage").hide(); | |
}); |
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
$('ul').find('ul').each(function(idx){ | |
$(this).attr('data-index', idx); | |
}); |
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 increase_brightness(hex, percent){ | |
// strip the leading # if it's there | |
hex = hex.replace(/^\s*#|\s*$/g, ''); | |
// convert 3 char codes --> 6, e.g. `E0F` --> `EE00FF` | |
if(hex.length == 3){ | |
hex = hex.replace(/(.)/g, '$1$1'); | |
} | |
var r = parseInt(hex.substr(0, 2), 16), |
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
enum ParserError: ErrorType { | |
case EmptyDictionary | |
case InvalidKey | |
} | |
struct Parser { | |
var data: [String : String?]? | |
func parse() throws { | |
guard let _ = data else { |
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 hidden, visibilityState, visibilityChange; | |
if (typeof document.hidden !== "undefined") { | |
hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState"; | |
} | |
else if (typeof document.mozHidden !== "undefined") { | |
hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState"; | |
} | |
else if (typeof document.msHidden !== "undefined") { | |
hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState"; | |
} |