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 / Advanced-HTTP-fr.md
Created June 15, 2011 14:07
Gestion avancée des requêtes HTTP en PHP
@nicolas-grekas
nicolas-grekas / Advanced-HTTP-en.md
Created June 15, 2011 22:03
Advanced handling of HTTP requests in PHP
@nicolas-grekas
nicolas-grekas / Dumper.php
Created July 7, 2011 16:58
Advanced error handling in PHP
<?php /****************** vi: set fenc=utf-8 ts=4 sw=4 et: *****************
*
* Copyright : (C) 2011 Nicolas Grekas. All rights reserved.
* Email : p@tchwork.org
* License : http://www.gnu.org/licenses/lgpl.txt GNU/LGPL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
@nicolas-grekas
nicolas-grekas / WinfsUtf8.php
Last active September 7, 2021 11:14
Unicode/UTF-8 filesystem access on MS-Windows
<?php /****************** vi: set fenc=utf-8 ts=4 sw=4 et: *****************
*
* Copyright : (C) 2012 Nicolas Grekas. All rights reserved.
* Email : p@tchwork.org
* License : http://apache.org/licenses/LICENSE-2.0
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Apache License version 2.
*
***************************************************************************/
@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 / 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 / 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;
@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