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 CACHE_NAME = 'example-cache-v1'; | |
var urlsToCache = []; | |
self.addEventListener('install', function(event) { | |
// Perform install steps | |
event.waitUntil( | |
caches.open(CACHE_NAME) | |
.then(function(cache) { | |
console.log('Opened cache'); | |
return cache.addAll(urlsToCache); |
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
/** | |
* @param {string} name - Parameter name | |
* @param {string} url - URL to extract parameters from (Optional) | |
*/ | |
function getParameterByName(name, url) { | |
if (!url) url = window.location.href; | |
name = name.replace(/[\[\]]/g, "\\$&"); | |
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | |
results = regex.exec(url); | |
if (!results) return null; |
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
<VirtualHost *:443> | |
# ... | |
RequestHeader set X-Forwarded-Proto "https" | |
RequestHeader set X-Forwarded-Port "443" | |
# ... | |
</VirtualHost> |
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
SET @oldurl='http://www.oldurl.com'; | |
SET @newurl='http://www.newurl.com'; | |
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, @oldurl, @newurl); | |
UPDATE wp_posts SET post_content = replace(post_content, @oldurl, @newurl); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldurl, @newurl); |
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 slugify(text) | |
{ | |
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz"; | |
text = text.split(''); | |
var txtLen = text.length; | |
var i, x; | |
for (i = 0; i < txtLen; i++) { | |
if ((x = accents.indexOf(text[i])) != -1) { | |
text[i] = accentsOut[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
if (window.MutationObserver || window.WebKitMutationObserver) { | |
var observer = new MutationObserver(function (mutations, observer) { | |
// Do something after node has changed | |
console.log('#div has changed') | |
}); | |
// Configuration of the observer | |
var config = { | |
subtree: true, | |
attributes: 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
<?php | |
/** | |
* Disable Emojis | |
*/ | |
remove_action('admin_print_styles', 'print_emoji_styles'); | |
remove_action('wp_head', 'print_emoji_detection_script', 7); | |
remove_action('admin_print_scripts', 'print_emoji_detection_script'); | |
remove_action('wp_print_styles', 'print_emoji_styles'); | |
remove_filter('wp_mail', 'wp_staticize_emoji_for_email'); | |
remove_filter('the_content_feed', 'wp_staticize_emoji'); |
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
// Determine if an element is in the visible viewport | |
function isInViewport(element) { | |
var rect = element.getBoundingClientRect(); | |
var html = document.documentElement; | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= (window.innerHeight || html.clientHeight) && | |
rect.right <= (window.innerWidth || html.clientWidth) | |
); |
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
// If using with GTM, anonymize the function name | |
function isScrollable() { | |
function getDocumentHeight() { | |
return Math.max(document.body.scrollHeight, document.body.offsetHeight, | |
document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); | |
} | |
function getViewPortHeight() { | |
return Math.max(document.documentElement.clientHeight, window.innerHeight || 0) * 2; | |
} |
OlderNewer