Skip to content

Instantly share code, notes, and snippets.

View vbatushev's full-sized avatar

Vitaly Batushev vbatushev

  • Издательство "Просвещение"
  • Krasnodar, Russia
View GitHub Profile
@vbatushev
vbatushev / packages.php
Last active August 29, 2015 14:17 — forked from govza/packages.php
<?php
$installPackages = array(
'sdStore'
, 'translit'
, 'SanitizeUpload'
, 'TinyMCE'
, 'FormIt'
, 'Analytics'
, 'Big Brother'
@vbatushev
vbatushev / settings.php
Last active August 29, 2015 14:17 — forked from govza/settings.php
<?php
require_once dirname(__FILE__).'/config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
@vbatushev
vbatushev / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@vbatushev
vbatushev / hostingphptest.php
Created June 18, 2014 16:12
Script para testear de velocidad de hosting
<?php
$time = microtime(true);
for ($i = 1; $i <= 1000000; $i++) {
$x = rand();
}
echo microtime(true) - $time;
@vbatushev
vbatushev / getActualCurrency.php
Created June 17, 2014 11:15
Snippet for get actual currency
<?php
// Получаем текущие курсы валют в rss-формате с сайта www.cbr.ru
// Формируем сегодняшнюю дату
$date = date("d/m/Y");
// Формируем ссылку
$link = "http://www.cbr.ru/scripts/XML_daily.asp?date_req=".$date;
// Загружаем HTML-страницу
$content = file_get_contents($link);
// Разбираем содержимое, при помощи регулярных выражений
<?php
$siteName = $modx->getOption('siteName', $scriptProperties, $modx->getOption('site_name')); // Имя сайта
$companyName = $modx->getOption('companyName', $scriptProperties, $modx->getOption('site_name')); // Компания
$bid = $modx->getOption('bid', $scriptProperties, 10); // Цена за клик
$categoriesTpl = $modx->getOption('minishop.categories_tpl'); // Шаблоны категорий
$goodsTpl = $modx->getOption('minishop.goods_tpl'); // Шаблоны товаров
$siteUrl = $modx->makeUrl($modx->getOption('site_start'), '', '', 'full'); // Ссылка на главную страницу сайта
$descTpl = strip_tags($modx->getOption('descTpl', $scriptProperties, '[[+description]]')); // Шаблон для описания товара, без html
// Параметры товаров
#!/bin/bash
##############
echo "Welcome to MODx autoinstaller.
------------------------------------
Enter MySQL root password"
read ROOTPASS
echo "Enter username for site and database"
#!/bin/bash
echo "Enter username"
read USERNAME
##############
echo "Updating MODx"
cd /var/www/$USERNAME/www/
#!/bin/bash
# MySQL root password
ROOTPASS='password'
TIMEZONE='Europe/Moscow'
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############
#!/bin/bash
ROOTPASS='password'
echo "Enter username to delete:"
read USERNAME
mysql -uroot --password=$ROOTPASS -e "DROP USER $USERNAME@localhost"
mysql -uroot --password=$ROOTPASS -e "DROP DATABASE $USERNAME"
rm -f /etc/nginx/sites-enabled/$USERNAME.conf