Skip to content

Instantly share code, notes, and snippets.

View tristanlins's full-sized avatar

Tristan Lins tristanlins

View GitHub Profile
@tristanlins
tristanlins / Contao2ClassLoaderHack.php
Last active December 27, 2015 17:39
Hacking the Contao 2 classes cache and overwrite with a class_exists check, so Controller::classFileExists() will return true, even if the class file does not exist in any system/modules/* directory.
<?php
/**
* Hack the Contao2 Controller::classFileExists()
*
* (c) Tristan Lins <[email protected]>
* Christian Schiffler <[email protected]>
*
* @author Tristan Lins <[email protected]>
* @license MIT
@tristanlins
tristanlins / FilesData.php
Last active August 29, 2015 13:55
FilesType for Symfony 2, allows HTML5 multiple file upload.
<?php
namespace Acme\DemoBundle\Form\Type;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* Class FilesmData
*/
class FilesmData
@tristanlins
tristanlins / git-mass-status.sh
Last active August 29, 2015 13:57
Script to find GIT repositories that have modified files and unpublished commits.
#!/bin/bash
BASEDIR=$(pwd)
find -type d -name .git | while read GITDIR; do
DIR=$(dirname $GITDIR)
cd "$BASEDIR/$DIR"
STATUS=$(git status -s)
if [[ -n "$STATUS" ]]; then
echo '--- modifications --------------------------------------------------------------'
pwd
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="bit3">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="8" />
<option name="TAB_SIZE" value="4" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<?php
class Hooks
{
public function outputFrontendTemplate($buffer)
{
$buffer = preg_replace_callback(
'~class="([^"]+)"~',
function ($matches) {
$classes = explode(' ', $matches[1]);
#####
#
# Avisota nightly build example configuration based on contao-community-alliance/build-system-repositories
#
#####
config:
storage: .../repositories
providers:
<?php
$GLOBALS['TL_DCA']['tl_content']['fields']['my_headline']['save_callback'][] = array('Hooks', 'saveMyHeadline');
class Hooks
{
public function saveMyHeadline($value, $dc)
{
$headline = array('value' => $value, 'unit' => 'h2');
@tristanlins
tristanlins / quick-flow.sh
Last active July 10, 2017 21:13
Quick creation of new releases with git flow, without using the release branch.
#!/bin/bash
TAG=$1
if [[ -z "$TAG" ]]; then
echo "No tag specified!"
exit 1
fi
if [[ -n "$(git status --porcelain)" ]]; then
echo "Uncommited changes detected!"
@tristanlins
tristanlins / gist:5dc5c248189b8c23e7b8
Last active August 29, 2015 14:02
Recursive evaluation of the root ID in MySQL
SELECT
@r AS _id,
(
SELECT
@r := pid
FROM
tl_page
WHERE
id = _id
) AS parent,
<?php
use NotificationCenter\Model\Notification;
class Hooks
{
public function processFormData($post, $form, $files)
{
$notificationIds = (array) unserialize($form['notifications']);