Skip to content

Instantly share code, notes, and snippets.

View alroniks's full-sized avatar

Ivan Klimchuk alroniks

View GitHub Profile
var fs = require('fs');
var Connection = require('ssh2');
var chokidar = require('chokidar');
var c = new Connection();
var local_path;
var deploy_path;
process.argv.forEach(function (val, index, array) {
var item_arr = val.split('=');
#!/bin/bash
DEPLOY_PATH="/var/www/site"
DEPLOYER_PATH="deploy.js"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
TARGET="$(readlink "$SOURCE")"
if [[ $SOURCE == /* ]]; then
@alroniks
alroniks / lang.php
Created January 16, 2014 10:32
Script for add all files of modx lexicons to trasifex
<?php
$cmdSource = 'tx set --source -r modx-revolution.core-{:slug} -l {:lang} core/lexicon/{:lang}/{:file} -t PHP_ALT_ARRAY';
$cmdTransl = 'tx set -r modx-revolution.core-{:slug} -l {:lang} core/lexicon/{:lang}/{:file} -t PHP_ALT_ARRAY';
$search = ['{:slug}', '{:file}', '{:lang}'];
$langs = [
'ru',
'de',
'cs',
@alroniks
alroniks / template.html
Last active January 12, 2016 03:39
Yandex.Weather Snippet for MODX
[[!weather?
&cityId=`26850`
&tpl=`weather.tpl`
&cacheTime=`7200`
]]
<?php
$str = 'fD3_';
$chars = array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9'), ['_']);
$total = 0;
$brut = '';
$len = strlen($str);
/**
* @see: https://www.programmingalgorithms.com/algorithm/brute-force?lang=PHP
*/
@alroniks
alroniks / db
Created December 6, 2016 20:50
Server maintenance scripts
#!/bin/bash
flag=5
if [ ! $1 ]; then
echo "Set user name for connect to mysql"
let flag=flag-1
fi
if [ ! $2 ]; then
@alroniks
alroniks / code.mdx
Created November 28, 2015 16:48
Get resources by resource group

[[!pdoResources? &tpl=@INLINE {{+id}} {{+pagetitle}} &select={"modResource":"id,pagetitle"} &parents=0 &leftJoin={ "modResourceGroupResource": {"on":"modResourceGroupResource.document = modResource.id"}, "modResourceGroup": {"on":"modResourceGroup.id = modResourceGroupResource.document_group"} } &where={"modResourceGroup.name":"test"} ]]

$get = $modx->sanitize($_GET);
if (!$get['day']) {
$now = time();
$day = date('Y-m-d', $now);
}
$day = $get['day'];
$step = 15; // minutes
@alroniks
alroniks / Gulpfile.js
Last active April 1, 2018 14:08
Gulpfile for run watch commands for Gitify (MODX)
'use strict';
console.time('Loading plugins');
var gulp = require('gulp'),
watch = require('gulp-watch'),
shell = require('gulp-shell'),
tap = require('gulp-tap');
console.timeEnd('Loading plugins');
<?php
// обрабатываем только события OnPageNotFound, на случай, если отметили галкой и другие в настройках плагина
if ($modx->event->name != 'OnPageNotFound') {
return false;
}
// на случай, если у нас настройки кто-то менял, получаем значение переменной, через которую передаются ссылки в modx от веб-сервера
$alias = $modx->context->getOption('request_param_alias', 'q');