Skip to content

Instantly share code, notes, and snippets.

@marcw
marcw / ls output on the file
Created February 15, 2012 07:25
phpunit fails
~/work/sensiolabs/websites/obfuscated (master) ls -lah /usr/local/Cellar/php/5.3.8/lib/php/share/pear/PHPUnit/Framework/TestFailure.php
-rw-r--r-- 1 root admin 7,2K 15 fév 08:12 /usr/local/Cellar/php/5.3.8/lib/php/share/pear/PHPUnit/Framework/TestFailure.php
@marcw
marcw / sopa.vcl
Created January 17, 2012 20:43
Varnish vcl file in order for varnish to participate to the sopa blackout
# use with:
#
# varnishadm -T host:port -S /etc/varnish/secret "vcl.load sopa /path/to/your/sopa.vcl"
# varnishadm -T host:port -S /etc/varnish/secret "vcl.use sopa"
backend default {
.host = "127.0.0.1";
.port = "8080";
}
@marcw
marcw / AppKernel.php
Created January 10, 2012 17:37
SF2 functional test good practices
<?php
class AppKernel extends Kernel
{
static protected $connection;
public function boot()
{
parent::boot();
@marcw
marcw / gist:957148
Created May 5, 2011 14:35
Steal the namespace + class in a file.
noremap <C-F9> gg/^namespace /e<CR>l"nyt;f\"Ny /^class /e<CR>l"Nye<ESC>
@marcw
marcw / gist:909430
Created April 8, 2011 07:20
Add twig search to ack-grep
alias ack='ack-grep --type-set twig=.twig'
@marcw
marcw / .vimrc
Created March 31, 2011 13:59
Insert the namespace in current php file
" Insert current namespace and opens php and create empty class, based on the file name
" last edited by https://www.github.com/ornicar
nmap <F9> ggO<?php<CR><CR><ESC>"%PdF/r;:s#/#\\#g<CR>Inamespace <ESC>d/[A-Z]<CR>Goclass <C-R>=expand("%:t:r")<CR><CR>{<CR>
@marcw
marcw / .bash_aliases
Created March 30, 2011 15:12
how to create tag file
alias tags='ctags -f tags -h ".php" -R --exclude=".svn" --exclude="*.yml.php" --totals=yes --tag-relative=yes --PHP-kinds=+cf --fields=+afkst --regex-PHP="/@method[ ][^ ]+[ ]+([^ (]*)/\1/f/"'
<?php
class mA
{
const TEST = 'mA';
public function getSelf()
{
return self::TEST;
}
@marcw
marcw / .gitconfig
Created February 22, 2011 18:05
git lint alias
[alias]
lint = "!sh -c 'git status | awk \"/modified/ {print \\$3} /new file/ {print \\$4}\" | xargs -L 1 php -l'"
@marcw
marcw / site-directory.sh
Created December 25, 2010 19:31
List vhost available on your machine and render it as an HTML5 document
#!/bin/bash
# Config
DIR="/opt/local/apache2/conf/sites-enabled"
# View
TITLE="local vhosts"
H1="vhosts on $HOSTNAME"
HEADER="<!DOCTYPE html>\n<html><head><title>$TITLE</title></head><body><h1>$H1</h1><ul>\n"