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
## get file from production if doesn't exist on dev environment | |
RewriteCond %{HTTP_HOST} =site1.xyz | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} .(gif|jpe?g|png|bmp|tiff|xcf|psd|ico|svg|pdf|mp4)$ [NC] | |
RewriteRule ^(.*)$ https://www.productionsite.com/$1?from=dev [R=301,L] |
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 | |
function interceptQuery( $query ) { | |
if ( $GLOBALS['pagenow'] === 'users.php' && strpos( $query, 'SELECT post_author, COUNT(*) FROM' ) === 0 ) { | |
echo '<h3>count_many_users_posts disabled for performance reasons</h3>'; | |
return false; | |
} | |
return $query; | |
} |
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 | |
/* | |
WPML checks for gutenberg like this: | |
\WPML_Page_Builders_Defined->has() | |
``` | |
if ( 'gutenberg' === $page_builder ) { | |
if ( version_compare( $wp_version, '5.0-beta1', '>=' ) ) { | |
return true; | |
} | |
} |
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
<noscript id="deferred-styles"> | |
<link rel="stylesheet" href="/assets/styles/slick/slick-all.min.css" type="text/css" media="all" /> | |
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&display=swap&subset=cyrillic,cyrillic-ext,latin-ext" rel="stylesheet"> | |
</noscript> | |
<script> | |
var loadDeferredStyles = function() { | |
var addStylesNode = document.getElementById("deferred-styles"); | |
var replacement = document.createElement("div"); | |
replacement.innerHTML = addStylesNode.textContent; | |
document.body.appendChild(replacement) |
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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
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
(function() { | |
var throttle = function(type, name, obj) { | |
obj = obj || window; | |
var running = false; | |
var func = function() { | |
if (running) { return; } | |
running = true; | |
requestAnimationFrame(function() { | |
obj.dispatchEvent(new CustomEvent(name)); | |
running = false; |
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
; -------------------------------------------------------------- | |
; Switches the left Control and Alt keys. | |
; -------------------------------------------------------------- | |
;LCtrl::LAlt | |
;LAlt::LCtrl | |
;Apple keyboard | |
;LAlt::LWin | |
;LWin::LAlt |
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 | |
$start = microtime(true); | |
$cycles = 0; | |
$elapsed = 0; | |
do { | |
$loops = 1000; | |
$begin = microtime(true); | |
do { | |
// Тестируемая операция |
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
/* | |
No jQuery necessary. | |
Thanks to Dan's StackOverflow answer for this: | |
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport | |
*/ | |
function isOneHundredPercentOfElementInViewport(el) { | |
var rect = el.getBoundingClientRect(); | |
return ( | |
rect.top >= 0 && |
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
//scroll arrow hides on scroll | |
function hideOnScroll() { | |
var scroll_el = document.getElementById('scroll'); | |
if ( document.getElementById('app').scrollTop > 20 ) { | |
scroll_el.style.display = "none"; | |
} else { | |
scroll_el.style.display = "block"; | |
} | |
} |
NewerOlder