Skip to content

Instantly share code, notes, and snippets.

@MrSwed
MrSwed / retry-load-img.js
Created March 20, 2024 13:10
retry load not loaded img on site page with too mane photos
jQuery(function(jQuery){
function catalogLoad() {
let l = $("img[src*=photo]").filter(function(i){return this.naturalWidth==0; }).each(function(i){this.src=this.src}).length
console.log("try load "+l+" img")
if (l>0) {
setTimeout(catalogLoad, 3000);
}
}
setTimeout(catalogLoad, 3000);
})
@MrSwed
MrSwed / wp_restore_active_plugins.sh
Created February 1, 2024 22:36
WordPress. Install missing plugins with wp-cli plugin command from just restored db
# thanks https://github.com/wp-cli/wp-cli/issues/2217#issuecomment-158125933
wp plugin install $(for p in `wp option get active_plugins --allow-root | grep '=>' | awk '{print $3}'` ; do echo $p | grep -oE "[^'/]+/"| grep -oE "[^/]+"; done) --allow-root
@MrSwed
MrSwed / git-hooks.sh
Last active July 12, 2023 14:06
Enable or Disable git hooks
#!/usr/bin/env bash
# Enable or disable git hooks
#find .git/hooks/ -type f ! -name "*.*"
gitHooks=.git/hooks/
echo "git Hooks $gitHooks"
option="${1}"
@MrSwed
MrSwed / AdBlock.txt
Last active July 18, 2022 03:10
AdBlock
[Adblock Plus 2.0]
! Title: MrSwed. AdBlock List
! Url: https://gist.githubusercontent.com/MrSwed/e5cf1146523a17bbf1749fad4284dbc8/raw/AdBlock.txt
mail.yandex.ru##.ns-view-react-left-column~div
mail.yandex.ru##.ns-view-advanced-search-box+div
mail.yandex.ru##.ns-view-mail-pro-left-column-button
mail.yandex.ru##.ns-view-mail-pro-left-column-button~div
@MrSwed
MrSwed / ext-caches.php
Last active April 8, 2022 06:52
Some Object caching of repeated sql queries for Woocommerce
<?php
/**
* Some Object caching of repeated sql queries for Woocommerce
* usage: `require_once( 'ext-caches.php' );`
*
* Author: MrSwed
* Author URI: https://gitlab.com/MrSwed
*
* */
@MrSwed
MrSwed / function-woo-get-shippings.php
Created April 7, 2022 14:01
Get a list of currently available shipping services in woocommerce
if ( ! function_exists( "get_shippings" ) ) {
/**
* Get a list of currently available shipping services.
* https://gist.github.com/MrSwed/dce4b3dd462eb18d3e7a198d8dfd4321
*
* @param mixed $filter instance_id if number, id if string, call it if it is function or array of fields for filter
*
* @return array
*/
@MrSwed
MrSwed / _fulW-pseudo.scss
Last active March 24, 2022 08:31
Полный фон по ширине окна, не контейнера по центру
// /* fulW-pseudo
// https://gist.github.com/MrSwed/0ad54e2db2ad5231cedb459761af4e56 */
// $mWidth:1142px;
@mixin fulW-pseudo($mW:$mWidth) {
content: '';
position: absolute;
background: inherit;
top: 0;
bottom: 0;
left: -1vw;
@MrSwed
MrSwed / jquery.unparam.js
Last active March 14, 2022 08:04
Short unparam string or object attr
/*
* Unparam url link parameters string 'key1=value1&key2=value2' to object {key1: 'value1', key2: 'value2'}
* https://gist.github.com/MrSwed/9164b1ffad0dfe33efdb3ca11b7377eb
* Usage:
* $("a").unparam() // return params from href {param1:"value1","param2":"value2"}
* $("div").unparam({"attr":"data-url"}) // return params from url at attr 'data-url' {param1:"value1","param2":"value2"}
* $("div").unparam("key1=value1&key2=value2"}) // return params from url at attr 'data-url' {param1:"value1","param2":"value2"}
* $.fn.unparam({"data":"key1=value1&key2=value2"}) // return {key1: 'value1', key2: 'value2'}
*/
$.extend({
<?php
if (!defined('MODX_BASE_PATH')) { die('HACK???'); }
/**
* HeaderModifiedSince
*
* Return header &quot;HTTP/1.0 304 Not Modified&quot; if HTTP_IF_MODIFIED_SINCE
*
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
* @author Sergey Davydov <dev@sdcollection.com>
@MrSwed
MrSwed / plugin.RedirectFriendly.php
Last active April 18, 2021 16:52
Modx evo Plugin. 301 Редирект с вложенных и наоборот ссылок (полезен при переключении настройки Использовать вложенные URL)
<?php
if (!defined('MODX_BASE_PATH')) die('HACK???');
/**
* RedirectFriendly
*
* 301 Редирект с вложенных и наоборот ссылок (полезен при переключении настройки <b>Использовать вложенные URL</b>)
*
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
* @author MrSwed <webmaster@sdcollection.com>