Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9
@MrSwed
MrSwed / git-fetch-sub.sh
Last active February 7, 2020 22:19
Fetch all sub git
find . -name .git -printf "\n%h\n" -execdir git fetch --all -v --progress \;
@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 / calcSize.scss
Last active November 13, 2019 21:07
SASS function to calculate needed units
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
@function calcSize($size,$base:16px,$unit:1rem,$calc:true) {
// https://gist.github.com/MrSwed/958077f384bfeb62cc799b0946999590
@if ($calc) {
@return calc(#{$unit} * #{strip-unit($size)} / #{strip-unit($base)});
} @else {
@return $unit * $size / $base;
@echo off
rem https://gist.github.com/MrSwed/36abd8ed745e5717e9c0d926b2270137
rem 20191111_111148 11.11.2019 11:11:48.57
set datestr=%date:~-4%%date:~-7,2%%date:~-10,2%_%time:~-11,2%%time:~-8,2%%time:~-5,2%
echo %datestr% %date% %time%
@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' :'',
@MrSwed
MrSwed / _sprite.scss
Last active March 14, 2019 17:01
Adaptive sprite. Scss functions
// Adaptive sprite. Scss functions
// https://gist.github.com/MrSwed/9b74275a7c5fa82c78619f2b7b9bd4ba
// based on less mixins
// https://gist.github.com/MrSwed/162bc57a6225ff139d5299b6fb7944b3
// Defaults
$fzr: 16px; // html rem
$fz: $fzr; // body, current
$SpriteImgUrl: url(../images/sprite.png);
@MrSwed
MrSwed / jQuery-ajax-form.js
Last active December 27, 2018 12:56
jQuery extender submit form with ajax without reload page.
$(function(){
$.fn.extend({
/* A kit of jQuery extensions for an forms manipulation via Ajax
* https://gist.github.com/MrSwed/2d86f2f0fd96fdc1e81aa414f0d53881
*/
"class": function(){
/* jQuery-class-extender: Get className even is empty jQuery object https://gist.github.com/MrSwed/0a837b3acbfbf8cfb19e */
return $(this).attr("class") ||
$(this).selector.toString().replace(/^.*[\s]+([^\s])/, "$1").replace(/(^[^\.]+\.|[:][^\s]+)/, "").split(".")
.join(" ").trim();
@MrSwed
MrSwed / sprite.less
Last active December 6, 2018 11:05
Adaptive sprite. Less functions
// Adaptive sprite. Less functions
// https://gist.github.com/MrSwed/162bc57a6225ff139d5299b6fb7944b3
@fzr: 16px;
@fz: @fzr;
// functions
// Convert units
// https://gist.github.com/MrSwed/00c35fa57dd820eab7434149b72fa695
@MrSwed
MrSwed / README.md
Created September 18, 2018 05:21 — forked from jonathantneal/README.md
SASS @font-face mixin

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);