Skip to content

Instantly share code, notes, and snippets.

@krismas
krismas / Ubuntu_1604_flectra_installation.sh
Last active October 22, 2017 09:10
Install Flectra On Ubuntu 16.04 LTS
#!/bin/bash
sudo adduser --system --quiet --shell=/bin/bash --home=/opt/flectra --gecos 'flectra' --group flectra
sudo mkdir -p /etc/flectra && sudo mkdir /var/log/flectra/
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install postgresql postgresql-server-dev-9.5 build-essential python3-pillow python3-lxml python-ldap3 python3-dev python3-pip python3-setuptools npm nodejs git gdebi libldap2-dev libsasl2-dev libxml2-dev libxslt1-dev libjpeg-dev zlib1g-dev -y
sudo git clone --depth=1 --branch=master https://github.com/flectrahq/flectra.git /opt/flectra/flectra
sudo chown flectra:flectra /opt/flectra/ -R && sudo chown flectra:flectra /var/log/flectra/ -R && cd /opt/flectra/flectra && sudo pip3 install -r requirements.txt
sudo npm install -g less less-plugin-clean-css -y && sudo ln -s /usr/bin/nodejs /usr/bin/node
cd /tmp && wget https://downloads.wkhtmltopdf.org/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb && sudo gdebi -n wkhtmltox-0.12.2.1_linux-trusty-amd64.deb && rm wkhtmltox-0.1
@krismas
krismas / plint.sh
Last active February 25, 2016 10:37
A quick bash script to recursively lint PHP files
#!/bin/bash
# Requires: PHP
#
# See: https://github.com/njoannidi/phpLintBash/blob/master/phpLint
#
# Usage:
#
# ./phpLint
#
# Lint all files recursively in defaultDir
@krismas
krismas / YouTube.php
Created April 15, 2015 12:15
A dummy YouTube Snippet for MODX
<?php
// Dummy YouTube Snippet for MODX by ackwa.fr : [[Youtube?id=`ugzbGxRuHtI`&auto=`true`]]
return (isset($id) ? '<iframe width="560" height="315" src="https://www.youtube.com/embed/'.$id.((isset($auto) && $auto) ? '?autoplay=1' : '').'" frameborder="0" allowfullscreen></iframe>' : '');
@krismas
krismas / log.php
Last active August 29, 2015 14:05
A small MODX Snippet / Output Filter to log message to the MODX error log
<?php
/**
* log : A small MODX Snippet / Output Filter to log message to the MODX error log
*
* @version : 1.0.0
* @see : https://gist.github.com/krismas/c321a4b3e29675424526
* @name : log.php
* @author : g.noel@ackwa.fr
* @usage : [[*aTV:log]]
* [[+aPH:log]]
@krismas
krismas / PHPBinary.php
Last active August 29, 2015 14:03
Try to find the best location for PHP binary
<?php
// Try to find the best location for PHP binary
$sPHP = ((isset($_SERVER['_']) && $_SERVER['_']) ? $_SERVER['_'] : (defined(PHP_BINARY) ? PHP_BINARY : (defined(PHP_BINDIR) ? PHP_BINDIR.'/php' : preg_replace(':/lib$:', '/bin/php', PHP_CONFIG_FILE_PATH))));
$sPHP = (is_executable($sPHP) ? $sPHP : 'php');
echo "$sPHP\n";
@krismas
krismas / resource.grid.js
Created November 2, 2012 13:19
"Refresh Cache" an extension for MODX Batcher
// 02/06/12 - Gildas - g.noel@ackwa.fr
// - assets/components/batcher/js/widgets/resource.grid.js patch to Add "Refresh Cache" Option
// 05/11/12 - Gildas - g.noel@ackwa.fr
// - Add custom log
// - Force timeout to 30s for each request
Batcher.grid.Resources = function(config) {
config = config || {};
this.sm = new Ext.grid.CheckboxSelectionModel();
Ext.applyIf(config,{
@krismas
krismas / syncpage.php
Last active October 14, 2021 14:03
A small MODX plugin to avoid refreshing - by default - the entire site cache when editing a resource
<?php
/*
* A small MODX plugin to avoid refreshing - by default - the entire site cache when editing a cached resource - (c) 2012 ackwa.fr
*
* @version : 1.0.0
* @see : https://gist.github.com/gists/3639503
* @name : syncpage.php
* @author : g.noel@ackwa.fr
*
* @event : OnDocFormSave, OnDocFormPrerender
@krismas
krismas / checkCode.php
Created August 27, 2012 09:45
A simple MODX output filter to convert TV code to value
<?php
/*
* checkCode : A simple MODX output filter to convert TV code to value - (c) 2012 ackwa.fr
*
* @version : 1.0.0
* @see : https://gist.github.com/gists/3487008
* @name : checkCode.php
* @author : g.noel@ackwa.fr
* @usage : myTV : First==1||Second==2||Third==3
*
@krismas
krismas / now.php
Created July 24, 2012 12:51
A small MODX snippet to time other snippets
<?php
/*
* A small MODX snippet to time other snippets - (c) 2012 ackwa.fr
*
* @see : https://gist.github.com/gists/3169775
* @name : now.php
* @author : g.noel@ackwa.fr
* @usage : [[!now]] -> First call
* [[!now?seed=`1`]] -> subsequent calls
*
@krismas
krismas / argv.php
Last active August 3, 2019 16:37
A small MODX snippet to extract POST, GET, SESSION & COOKIE values
<?php
/*
* A small MODX snippet to extract POST, GET, SESSION & COOKIE values - (c) 2012-2016 ackwa.fr
*
* @version : 1.0.4
* @see : https://gist.github.com/gists/2853625
* @name : argv.php
* @author : g.noel@ackwa.fr
* @usage : [[!argv?key=`myparam`&default=`1`]] -> return the value
* [[!argv?key=`myparam`&default=`1`&toph=`1`]] -> set [[+argv.myparam]]