Skip to content

Instantly share code, notes, and snippets.

View tristanlins's full-sized avatar

Tristan Lins tristanlins

View GitHub Profile
#!/bin/bash
docker image ls | awk '$1 == "<none>" || $2 == "<none>" { print $3; }' | xargs docker image rm
@tristanlins
tristanlins / iconv.docker
Created October 10, 2015 15:41
Docker PHP extension recipes
FROM php:5.6-cli
RUN apt-get update \
&& apt-get install -y \
libfreetype6-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install iconv \
&& apt-get remove -y \
libfreetype6-dev \
&& apt-get install -y \
@tristanlins
tristanlins / docker-nginx.service
Last active October 6, 2015 08:51
Using docker nginx as local server
# @file /etc/systemd/system/docker-nginx.service
# @see https://docs.docker.com/articles/host_integration/
[Unit]
Description=nginx container
Requires=docker.service
After=docker.service
[Service]
Restart=always
@tristanlins
tristanlins / .my.cnf
Last active October 6, 2015 08:51
Using docker mariadb as local database
[client]
user=root
password=53CUr3-p422W0RD
host=127.0.0.1
port=3306
@tristanlins
tristanlins / contao.conf
Last active August 3, 2016 20:10
Contao 3 nginx setup
# Prevent logging favicon.ico and robots.txt
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
@tristanlins
tristanlins / accordion.js
Last active August 29, 2015 14:17
Annimate foundation accordion
$('.accordion').on('toggled', function (event, accordion) {
// show activated accordion
if (accordion.hasClass('active')) {
accordion.hide().slideDown();
}
// hide previous activated accordions
var group = $(event.target);
var accordions = group.find('.accordion-navigation > .content:not(.active):visible');
accordions.slideUp();
@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']);
<?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)
<?php
$iterations = 1000000;
echo <<<PHP
<?php
\$iterations = $iterations;
\$style = 'default';
PHP;
@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"