Skip to content

Instantly share code, notes, and snippets.

@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;
@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);
@MrSwed
MrSwed / imageAutoSized.tpl
Last active September 3, 2018 13:36
Ссылка на изображение соответственно одному из заданых разрешений устройств (Modx EVO 1.2+ )
<?php
/**
* imageAutoSized
*
* ссылка на изображение соответственно одному из заданых разрешений устройств
*
* @category snippet
* @version 0.2
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
* @internal @properties
@MrSwed
MrSwed / sum-of-column.js
Last active March 5, 2018 12:41
Суммы колонки в таблице. (table column sum)
// Восстановление прототипа reduce на случай, если
// криворукие разработчики написали (или не убрали) свой прототайп
Array.prototype.myReduce = function(callback, initialVal) {
var accumulator = (initialVal === undefined) ? undefined : initialVal;
for (var i = 0; i < this.length; i++) {
if (accumulator !== undefined)
accumulator = callback.call(undefined, accumulator, this[i], i, this);
else
accumulator = this[i];
@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%
<?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 / No-Ads-Youtube-for-AdBlock-Plus
Created January 15, 2018 14:56
Отключить рекламу в конце роликов youtube
# Add Filters:
# thanks https://www.youtube.com/watch?v=kfqxnZ4yo3E
youtube.com##.ytp-ce-covering-overlay
youtube.com##.ytp-ce-element-shadow
youtube.com##.ytp-ce-covering-image
youtube.com##.ytp-ce-expanding-image
youtube.com##.ytp-ce-element.ytp-ce-video.ytp-ce-element-show
youtube.com##.ytp-ce-element.ytp-ce-channel.ytp-ce-channel-this
youtube.com##.ytp-ce-element.ytp-ce-website
@MrSwed
MrSwed / aibolit-start.sh
Last active October 22, 2017 10:19
Aibolit home/$USER check. Log and Email
u=$USER
if [ $1 ]
then
u=$1
shift
fi
log=/root/temp/$u.ai-$(date +"%Y%m%d%H%M%S").log.html
php ai-bolit/ai-bolit/ai-bolit.php -p /home/$u/ -r $log $@
@MrSwed
MrSwed / jQuery.FitIn.js
Last active May 29, 2017 11:24
Fit element to parent width by decrease font-size (js must be after css load)
$.fn.FitIn = function(o){
// Fit element to parent width by decrease font-size (js must be after css load)
// https://gist.github.com/MrSwed/cd80923f28e91fe79386996668da1ecd
o = $.extend({},{minFontSize:3});
return $(this).each(function(){
var fz = parseInt($(this).css("font-size"));
do {
$(this).css('font-size', fz--);
} while (($(this).width() > $(this).parent().width()) && fz > o.minFontSize);
});
@MrSwed
MrSwed / byMonthFolders.bat
Created April 13, 2017 07:39
Simple sort files to folders by its month (windows cmd)
@echo off
rem simple sort files to folders by its month
SETLOCAL ENABLEDELAYEDEXPANSION
for %%a in (*.*) do (
set df=%%~ta
set mf=!df:~3,2!
if not exist !mf! mkdir !mf!
echo move %%a to !mf!
move %%a !mf!