Skip to content

Instantly share code, notes, and snippets.

View alroniks's full-sized avatar

Ivan Klimchuk alroniks

View GitHub Profile
@mrryanjohnston
mrryanjohnston / Dockerfile
Created February 23, 2014 18:50
nginx with php5-fpm on Ubuntu 13.10 Dockerfile
FROM ubuntu:13.10
RUN apt-get update
# nginx
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install nginx
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# php5-fpm
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install php5-fpm
@Mark-H
Mark-H / compare.lexicon.php
Created June 19, 2014 12:50
compare.lexicon.php - A super useful script for people that want to update translations for MODX (or MODX Extras) and need to get a good at a glance view of the changes. Got it from the forums somewhere in the past, but can't find the original source now. It probably changed a bit over the years too.
<?php
$default = realpath(dirname(__FILE__).'/core/lexicon/en').'/';
$local = realpath(dirname(__FILE__).'/core/lexicon/nl').'/';
$showSame = false;
// find default files
$theFiles = array();
if($handle = opendir($default)) {
while(false !== ($file = readdir($handle))) {
@rtripault
rtripault / checkLexicon.php
Created October 31, 2010 21:55
Check MODx Revolution lexicon files (by Hansek, source : http://modxcms.com/forums/index.php/topic,50565.0.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Updated for MODx Revo by: Hansek http://www.modxcms.cz/ hansek@coex.cz
Created for MODx Evo by : Coroico (http://modx.wangba.fr)
Short Description: Language files checking tool for MODx Revolution
Version: 1.2
Created by: Coroico (http://modx.wangba.fr)
@jgebhardt
jgebhardt / gist:1676679
Created January 25, 2012 15:06
hotfix to manually generate MODx resource URIs from the tree after updating
BEGIN TRANSACTION;
WITH builder AS(
SELECT id , alias , parent, CAST('' AS VARCHAR(765)) [path], 0 [iter], parent [top], CAST('root' AS VARCHAR(300)) [hierarchy]
FROM dbo.modx_site_content parent
UNION ALL
SELECT child.id, child.alias, parent.parent, CAST(path AS VARCHAR(255)) + CAST('/' AS VARCHAR(255)) + CAST(child.alias AS VARCHAR(255)) [path], iter + 1 [iter], child.parent [top], CAST(hierarchy AS VARCHAR(100)) + CAST('/' AS VARCHAR(100)) + CAST(child.id AS VARCHAR(100)) [hierarchy]
@Mark-H
Mark-H / snippet.php
Created May 7, 2012 14:47
MODX Snippet to take a database backup and to email that.
<?php
$mailto = (isset($mailto)) ? $mailto : '@@ DEFAULT EMAIL HERE @@';
$warningMail = '@@ EMAIL TO SEND WARNING TO IN CASE OF A SMALL BACKUP FILE @@';
include MODX_CORE_PATH.'/config/'.MODX_CONFIG_KEY.'.inc.php';
$host = $database_server; // database host
$dbuser = $database_user; // database user name
$dbpswd = $database_password; // database password
$mysqldb = $dbase; // name of database
@valpackett
valpackett / README.md
Created August 18, 2012 14:16
MODX + Monolog

MODX Revolution + Monolog

Replace MODX logging with Monolog to log to Graylog2, syslog, AMQP, etc.

Installation

  • put all the contents of this gist into the document root (where folders core, manager, etc. are located)
  • run composer install to get Monolog
  • run sh patchmodx.sh
  • edit modx-monolog.php - at line 22 there's the default handler - replace it with whatever you want to log to - see monolog readme for more info
@balupton
balupton / README.md
Last active December 11, 2015 05:58
DocPad: Querying custom categories (via single categories object)
this.exp = new Ext.grid.RowExpander({
expandOnDblClick: false,
tpl: new Ext.Template(
'<table class="paymentsystem-expander"><tbody>',
'<tr>',
'<td><b>' + _('paymentsystem_num') + ': </b>{num}</td>',
'<td><b>' + _('paymentsystem_cost') + ': </b>{cost:this.renderMoney}</td>',
'<td><b>' + _('paymentsystem_tax') + ': </b>{tax:this.renderMoney}</td>',
'<td><b>' + _('paymentsystem_sum') + ': </b>{sum:this.renderMoney}</td>',
<?php
$Tickets = $modx->getService('tickets', 'Tickets', $modx->getOption('tickets.core_path', null, $modx->getOption('core_path') . 'components/tickets/') . 'model/tickets/', $scriptProperties);
$Tickets->initialize($modx->context->key, $scriptProperties);
/** @var pdoFetch $pdoFetch */
$fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
if ($pdoClass = $modx->loadClass($fqn, '', false, true)) {
$pdoFetch = new $pdoClass($modx, $scriptProperties);
} elseif ($pdoClass = $modx->loadClass($fqn, MODX_CORE_PATH . 'components/pdotools/model/', false, true)) {
$pdoFetch = new $pdoClass($modx, $scriptProperties);
<?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
*/