Skip to content

Instantly share code, notes, and snippets.

View nicolas-grekas's full-sized avatar
✔️
Green-keeping the Symfony CI

Nicolas Grekas nicolas-grekas

✔️
Green-keeping the Symfony CI
View GitHub Profile
@nicolas-grekas
nicolas-grekas / dumper-test.php
Last active August 29, 2015 13:56
dumper-test.php
<?php
// composer require patchwork/dumper '1.0.*'
require __DIR__ . '/vendor/autoload.php';
set_debug_handler(function ($var) {
$c = new Patchwork\Dumper\Collector\PhpCollector();
$data = $c->collect($var);
$data->dump(new Patchwork\Dumper\CliDumper());
});
@nicolas-grekas
nicolas-grekas / speed.php
Created November 26, 2014 14:59
Speed PHP benchmark
<?php
$len = 1000000;
$a = range(1, $len);
$f = SplFixedArray::fromArray($a);
$s = microtime(1);
$i = $len;
<?php
$foo = function (): foo {
return new foo();
};
$foo instanceof foo; // => true
$foo->toto = 123; // $foo() is evaluated and is swapped to its return value
@nicolas-grekas
nicolas-grekas / Advanced-HTTP-fr.md
Created June 15, 2011 14:07
Gestion avancée des requêtes HTTP en PHP
@nicolas-grekas
nicolas-grekas / gzipped-image.php
Created September 10, 2012 10:11
Test if browser supports compression
<?php
if (isset($_GET['i']))
{
// Send a blank gzipped GIF to test browser capability to decode it
// See http://www.stevesouders.com/blog/2010/07/12/velocity-forcing-gzip-compression/
header('Content-Type: image/gif');
header('Content-Encoding: deflate');
header('Pragma: no-cache');
@nicolas-grekas
nicolas-grekas / composer.json
Last active October 29, 2015 22:47
Global Debug Helpers for PHP
{
"name": "nicolas-grekas/debug-helpers",
"description": "Global Debug Helpers for PHP",
"require": {
"symfony/var-dumper": "2.8.*@dev"
},
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
<?php
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
function dump($var)
{
static $handler;
if (null === self::$handler) {
@nicolas-grekas
nicolas-grekas / t1.php
Last active January 4, 2016 03:09
Playing for PPP for native PHP function overloading
git clone https://github.com/nicolas-grekas/Patchwork-PHP-Parser.git ppp
cd ppp
./bin/ppp t1.php #see below for t1.php (and t2.php, required by t1.php)
@nicolas-grekas
nicolas-grekas / README.md
Last active January 4, 2016 05:49
Playing Patchwork CLI Color Dumper

Playing with Patchwork CLI color dumper

git clone https://gist.github.com/8578209.git try-patchwork-dumper
cd try-patchwork-dumper
composer install
php test-cli.php
@nicolas-grekas
nicolas-grekas / setup
Last active January 9, 2016 11:02
source ~/go/setup x.y.z
#!/bin/bash
go_version=$1
go_arch=linux-amd64
export GOPATH="$HOME/go"
if [ ! -e $GOPATH ]
then
mkdir $GOPATH