Skip to content

Instantly share code, notes, and snippets.

View tristanlins's full-sized avatar

Tristan Lins tristanlins

View GitHub Profile
@tristanlins
tristanlins / PHP Setter Method
Last active August 29, 2015 14:04
PHP Storm - File and Code Templates
#if (${TYPE_HINT} == "string" || ${TYPE_HINT} == "int" || ${TYPE_HINT} == "float" || ${TYPE_HINT} == "double" || ${TYPE_HINT} == "bool")
#set ($CAST = "(${TYPE_HINT}) ")
#set ($PARAM_HINT = "")
#else
#set ($CAST = "")
#set ($PARAM_HINT = "${TYPE_HINT} ")
#end
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*
@tristanlins
tristanlins / dcaconfig.php
Created August 3, 2014 14:33
Overwrite the Avisota 2 header and footer with static content in all templates.
<?php
/**
* Hint: this will overwrite the template for ALL mailings!!!
* There is no solution yet to manipulate this in a simple way for each theme/layout.
*/
foreach ($GLOBALS['AVISOTA_MAILCHIMP_TEMPLATE']['templates'] as &$template) {
$template['cells']['header']['content'] = '<h1>My superious newsletter: ##message.subject##</h2>';
$template['cells']['footer']['content'] = '<p>Acme Company, Master street 123, 45677 Example town, USA</p>';
@tristanlins
tristanlins / system config initconfig.php
Last active August 29, 2015 14:05
Find class declaring file
<?php
$class = new \ReflectionClass('Composer\\Autoload\\ClassLoader');
var_dump($class->getFileName());
exit;
@tristanlins
tristanlins / backup-db.sh
Created August 15, 2014 10:26
Create daily fail-resistence (slow) DB dumps.
#!/bin/bash
if [ -t 1 ]; then
CGREEN="\033[0;32m"
CYELLOW="\033[1;33m"
CNONE="\033[0m"
fi
MYSQL_USER="root"
MYSQL_PASS=""
@tristanlins
tristanlins / sieve
Created September 11, 2014 05:39
sieve filter for github notifications
require ["variables", "fileinto", "mailbox"];
if header :matches "list-id" "*/* <*.github.com>" {
set "owner" "${1}";
set "repo" "${2}";
fileinto :create "abo_github.${owner}.${repo}";
stop;
}
@tristanlins
tristanlins / cjs.js
Last active August 29, 2015 14:07
regfish improve dnspad interface
var select = document.getElementById('addtype');
if (select) {
function fixSubmit() {
setTimeout(function() {
input = document.getElementById('add_name');
input.onkeyup = function(event) {
if (13 == event.keyCode) {
rr.add_commit();
}
@tristanlins
tristanlins / gist:2e28acfb8b25b701a760
Created October 27, 2014 09:25
Replace contao Environment class with symfony request class.

Replacement possible

Environment::scriptName()
  => string(33) "/environment-vs-request/index.php"
Request::getBaseUrl()    
  => string(33) "/environment-vs-request/index.php"
<?php
$iterations = 1000000;
echo <<<PHP
<?php
\$iterations = $iterations;
\$style = 'default';
PHP;
<?php
class Shipping
{
public function isAvailable()
{
// HOOK: allow to add custom logic
if (isset($GLOBALS['ISO_HOOKS']['shippingIsAvailable']) && is_array($GLOBALS['ISO_HOOKS']['shippingIsAvailable']))
{
foreach ($GLOBALS['ISO_HOOKS']['shippingIsAvailable'] as $callback)
@tristanlins
tristanlins / initialize.php
Last active August 29, 2015 14:13
Use symfony memcached session handler in Contao
<?php
...
/**
* Symfony session storage
*/
$memcached = new \Memcached();
$memcached->addServer($GLOBALS['TL_CONFIG']['sessionMemcachedHost'], $GLOBALS['TL_CONFIG']['sessionMemcachedPort']);