Skip to content

Instantly share code, notes, and snippets.

@chadrien
chadrien / pre-push
Created November 13, 2013 13:03
Git hooks for everyday PHP developer
#!/bin/sh
git stash >/dev/null
# if tests fail, do not push
exit_with_status() {
git pop >/dev/null
exit "$1"
#!/usr/bin/env sh
if [[ -z "$1" ]]; then
echo "You must chose an action [list, use]"
exit
fi
cd ~/repositories/cakephp/cakephp/
git fetch > /dev/null
@chadrien
chadrien / post-checkout
Last active December 25, 2015 12:19
Git hooks when using composer/bower/npm
#!/usr/bin/env php
<?php
exec("git diff --name-only {$argv[1]} {$argv[2]}", $changedFiles);
$filesAction = array(
'composer.lock' => 'composer install',
'package.json' => 'npm install',
'bower.json' => 'bower install',
);
suites:
main:
namespace: ""
src_path: "foo"
@chadrien
chadrien / security.yml
Created July 16, 2013 15:46
Symfony 2 : per host firewall
services:
my_host.firewall.request_matcher:
class: Symfony\Component\HttpFoundation\RequestMatcher
arguments: ["/", "www\.host\.eu"]
security:
firewalls:
my_firewall:
request_matcher: site.my_firewall.request_matcher
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
@chadrien
chadrien / gist:5394508
Created April 16, 2013 09:06
Symfony 2 Nginx configuration
server {
server_name domain.dev;
listen 80;
root /path/to/web;
index app_dev.php;
try_files $uri $uri/ /app_dev.php?$query_string;
location ~ \.php$ {
include fastcgi.conf;
@chadrien
chadrien / server.php
Created March 22, 2013 21:43
Server.php for laravel 3 and the PHP built in server
<?php
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = urldecode($uri);
$web = true;
$paths = require __DIR__.'/paths.php';
@chadrien
chadrien / gist:5208665
Last active December 15, 2015 05:20
Laravel nginx configuration
server {
listen 80;
server_name domain;
root /paht/to/public/;
index index.php;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
@chadrien
chadrien / README.md
Last active November 6, 2015 11:00
X application from docker on OS X
  • brew install socat
  • brew cask install xquartz
  • Restart
  • socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" &
  • docker run -e DISPLAY=XXX:0 jess/geary where XXX is the IP from ifconfig vboxnet0