Skip to content

Instantly share code, notes, and snippets.

View BraveSirRobin's full-sized avatar

Robin Harvey BraveSirRobin

  • Codezilla Limited UK - Consulting
  • Leeds, U.K
View GitHub Profile
@BraveSirRobin
BraveSirRobin / gist:973159
Created May 15, 2011 13:24
Array speed tests
<?php
$a = array();
for ($i = 0; $i < 1000; $i++) {
$a[] = rand(0,1000000);
}
printf("Start, first mine:\n");
$t1 = microtime(true);
var_dump(mine($a));
@BraveSirRobin
BraveSirRobin / tgad.php
Created June 4, 2011 21:22
Simple demo of token_get_all()
<?php
$php = "<html><head><?php include '/foo/bar/php'; ?></head>....";
foreach (token_get_all($php) as $tok) {
if (is_array($tok)) {
printf("token type %s: %s\n", token_name($tok[0]), $tok[1]);
}
}
@BraveSirRobin
BraveSirRobin / libevent-segfault.php
Created April 6, 2012 15:24
Bug demonstration script for PHP/libevent 0.0.4 Segfault.
<?php
/**
* Run this script as-is and it will segfault. My setup is Ubuntu
* 11.10, library details:
*
* php5-cli : 5.3.6-13ubuntu3.6 (output from dpkg -l)
* libevent : 0.0.5 beta (output from pecl list)
* php-pear : 5.3.6-13ubuntu3.6 (output from dpkg -l)
*
* There are 2 things you can do to stop the segfault: