Skip to content

Instantly share code, notes, and snippets.

View criticalcss-bookmarklet-devtool-snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@govza
govza / regenerate_previews.php
Created Aug 19, 2015
modx recreate TicketFile previews
View regenerate_previews.php
<?php
define('MODX_API_MODE', true);
$modx->getService('error','error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->addPackage('Tickets', MODX_CORE_PATH . 'components/tickets/model/');
$files = $modx->getIterator('TicketFile');
foreach ($files as $file) {
View packages.php
<?php
// provider id => array of packages
$listPackagesToInstall = array(
1 => array( // standart modx provider
'sdStore'
, 'translit'
, 'TinyMCE'
, 'FormIt'
, 'Analytics'
View 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');
header("Content-type: text/plain");
View useTranslitService.php
<?php
$stringToApplyTransliterationTo = "Транслитерация кириллицы в modx";
$options = array();
$translitTableName = 'russian';
$translitClassPath = $modx->getOption(
'friendly_alias_translit_class_path',
$options,
$modx->getOption('core_path', $options, MODX_CORE_PATH) . 'components/'
).'modx/translit/';
@govza
govza / modx-file-upload-translit.php
Created Mar 11, 2013
Translit non-latin (cyrillic etc.) names of uploadig files to latin with timestamp by modx cleanAlias()
View modx-file-upload-translit.php
<?php
//Привязывать к событию OnFileManagerUpload.
$currentdoc = $modx->newObject('modResource');
foreach($files as $file)
{
if($file['error'] == 0)
{
$pathInfo = pathinfo($file['name']);
$oldPath = $directory.$file['name'];
$newPath = date("Y-m-d-h-s-").$currentdoc->cleanAlias($pathInfo['filename']).'.'. $pathInfo['extension'];
@govza
govza / authenticate.php
Created Feb 26, 2013
Без заполнения нужных полей юзера не выпускает из раздела с настройками.
View authenticate.php
case 'OnLoadWebDocument':
if ($modx->user->isAuthenticated() && $modx->resource->id != 15 && (
trim($modx->user->Profile->email) == '' || trim($modx->user->Profile->fullname) == ''
)) {
$modx->sendRedirect($modx->makeUrl(15));
}
}
View update.sh
#!/bin/bash
echo "Enter username"
read USERNAME
##############
echo "Updating MODx"
cd /var/www/$USERNAME/www/
View addsite.sh
#!/bin/bash
# MySQL root password
KEYLOCATION="/modx/.ssh/key.pem"
REMOTEUSERSERVER="user@8.8.8.8"
ROOTPASS="password"
TIMEZONE="Europe/Moscow"
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
View remove.sh
#!/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