Skip to content

Instantly share code, notes, and snippets.

@MrSwed
MrSwed / git-smudge-clean-filter.sh
Created June 15, 2024 12:45 — forked from TomerFi/git-smudge-clean-filter.sh
Git smudge-clean script for using as filter for mutiple reducted values for various file types in various repositories.
#!/bin/bash
#####################################################################################################
# This script is meant to be used as a global smudge-clean filter for removing sensitive data #
# from your commits. #
# #
# 1. Place this script in an acceisble path, i.e. ~/scripts/git-smudge-clean-filter.sh. #
# #
# 2. Populate the 'mapArr' using what you need hidden as the key, and the replacment as the value. #
# DO NOT use same values for multiple keys (this will work only in one direction). #
@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 / 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 / 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({
@MrSwed
MrSwed / ninja-ya-metric-target.js
Created January 23, 2020 17:12
WordPress NinjaForm Yandex metric Targeting
(function($){
// Setup Ninja form - on Sumbit Yandex metric targeting.
$(document).on('nfFormSubmitResponse', function(e, r){
var Target = "form-"+r.id,
YMVar = $(document.scripts).filter(function(){ return /w.yaCounter\d+/.test($(this).text()) }).text().replace(/^.*w.(yaCounter\d+)\s+.*$/im, "$1");
if (YMVar && window[YMVar]) window[YMVar].reachGoal(Target);
});
})(jQuery);
@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 / get_hyp_comments-draft,js
Last active March 22, 2019 10:30
Отзывы с гиперкомента в Jot MODX
// use in debug console browser
//
var $d=[];
$(".comments__block").each(function(){
var t = this,
dt = $(".comments__table__items__date",t).text().match(/(\d+)[-;:.,]?(\d+)[-;:.,]?(\d+) (\d+):(\d+):(\d+)?/);
var r = {
'title' : $(".comments__table__items__name",t).clone().children().remove().end().text(),
'tagid' :'',