Skip to content

Instantly share code, notes, and snippets.

View udovichenko's full-sized avatar
👾

Dmitry Udovichenko udovichenko

👾
View GitHub Profile
@udovichenko
udovichenko / defaultTemplateSource.php
Last active September 5, 2018 11:42
MODX defaultTemplateSource plugin
<?php
if ($modx->event->name == 'OnDocFormSave') {
// ms2Gallery
$templateSources = array(
4 => 3, // templateId => sourceId
);
// minishop Gallery
@udovichenko
udovichenko / htmlMinify.pl.php
Created August 31, 2018 10:41
MODX Plugin htmlMinify
<?php
$e =& $modx->event;
switch ($e->name) {
case "OnWebPagePrerender": {
$output = &$modx->resource->_output;
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
@udovichenko
udovichenko / font-size-calc-px-vw.js
Last active August 1, 2018 19:35
Calculation of mixed font-size: calc(px + vw) by two breakpoint values
var w1 = 360; // first breakpoint window width
var w2 = 1920; // second breakpoint window width
var fz1 = 20; // first breakpoint required font-size
var fz2 = 55; // second breakpoint required font-size
var px, vw;
vw = (fz1 - fz2) / (w1 - w2);
px = parseInt(fz2 - w2 * vw);
vw *= 100;
vw = vw.toFixed(1);
@udovichenko
udovichenko / gulpfile.js
Created February 4, 2018 18:44 — forked from antonioOrtiz/gulpfile.js
My first gulp file!
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
gulpif = require('gulp-if'),
usemin = require('gulp-usemin'),
uglify = require('gulp-uglify'),
gutil = require('gulp-util'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
browserify = require('gulp-browserify'),
minifyHTML = require('gulp-minify-html'),
@udovichenko
udovichenko / Bg Image Ratio
Created September 18, 2017 11:03
Get Image Ratio of background-image vanilla js
i=document.querySelector('.mfp-content .image');
bg=getComputedStyle(i)['background-image'];
u=bg.split('"')[1];
i=new Image();
i.src=u;
i.naturalWidth/i.naturalHeight;
@udovichenko
udovichenko / gist:f0a5d9c84b69c85b8129d6298d7e0f89
Created December 29, 2016 21:38 — forked from sgergely/gist:3793166
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@udovichenko
udovichenko / secure_install.sh
Created November 12, 2016 11:26 — forked from Realetive/secure_install.sh
Advanced installation MODx from GitHub with rename and move core outward the webroot, rename manager and connectors
#!/bin/bash
##############
echo "
//////////////////////////////////////
// //
// Welcome to MODx autoinstaller. //
// //
//////////////////////////////////////
@udovichenko
udovichenko / vk_top_posts.js
Created November 6, 2016 07:35
Get text of VK post with raiting over N
var n = 700;
var a = document.querySelectorAll('.post_content');
var t = '';
[].forEach.call(a, function(i) {
if (i.querySelector('.post_like_count').textContent > n) {
t += "\n\n" + i.querySelector('.wall_post_text').innerText;
}
});
document.getElementById('public_actions_wrap').innerText = t;
console.log(t);
@udovichenko
udovichenko / README.md
Created October 2, 2016 10:02 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@udovichenko
udovichenko / wgetNodeList.js
Last active February 5, 2019 20:44
Allows to generate wget query for a custom selector on a page
var parentElement = '.gamma-decori'; // Родительский элемент
var elements = ['img']; // из каких элементов брать путь к картинкам?
var fileTypes = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'bmp']; // какие разрешения нужны?
var selector = [];
elements.forEach(function(elem){
var href = (elem == 'a')
? 'href'
: 'src';
fileTypes.forEach(function(ext) {