Skip to content

Instantly share code, notes, and snippets.

View jfsimon's full-sized avatar

Jean-François Simon jfsimon

View GitHub Profile
Starting benchmark, it takes several minutes...
1010 files
110 directories
10 iterations
9 cases
2 adapters
@jfsimon
jfsimon / gist:3229865
Created August 1, 2012 19:09
finder benchmark 2012-08-01
1010 files
110 directories
10 iterations
9 cases
2 adapters
case php gnu_find
0 1,407,415 958,688
1 1,653,591 858,276
2 4,286,048 1,183,027
1010 files
110 directories
10 iterations
6 cases
2 adapters
case php gnu_find
0 1,471,663 1,022,287
1 1,592,656 191,331
2 1,643,954 744,985
1010 files
110 directories
10 iterations
18 cases
2 adapters
case php gnu_find
0 873,349 125,462
1 950,045 152,989
2 1,035,071 128,547
@jfsimon
jfsimon / gist:3803729
Created September 29, 2012 11:23
CalendarUnit use cases
/**
* Je veux afficher les semaines et leur nombre d'évènements
* associés groupées par mois pour l'année 2011.
*/
$year = new CalendarUnit($calendar, new TimeUnitInterval(TimeUnitFactory::year(), 2011));
foreach ($year->getChildren(TimeUnitFactory::month()) as $month) {
echo 'Mois n°'.($month->getIndex() + 1)."\n";
@jfsimon
jfsimon / NegotiatorInterface.php
Created October 7, 2012 10:28
Content negotiation
/**
* Content negotiator.
*/
interface NegotiatorInterface
{
/**
* Adds a qualifier.
*
* @param VariantQualifierInterface $qualifier
*/
<?php
require_once 'vendor/autoload.php';
$routes = new \Symfony\Component\Routing\RouteCollection();
$routes->add('negotiation', new \Symfony\Component\Routing\Route(
'/negotiation.{_locale}.{_format}',
array(),
array('_locale' => 'fr|en|es', '_format' => 'html|xml'),
array('negotiate' => array('_locale', '_format'))
// fix previously broken serialized arrays content lengths
$content = preg_replace_callback(
'/s:(\d+):"(.*?)";/e',
function (array $matches) {
return sprintf('s:%s:"%s";', strlen($matches[1]), $matches[1]);
},
$content
);
### Keybase proof
I hereby claim:
* I am jfsimon on github.
* I am jfsimon (https://keybase.io/jfsimon) on keybase.
* I have a public key whose fingerprint is 6AEA 6B20 ECE1 0380 367E 0A0C F7BD 5638 1F9F 5811
To claim this, I am signing this object: