Skip to content

Instantly share code, notes, and snippets.

Avatar

Robin Harvey BraveSirRobin

View GitHub Profile
@BraveSirRobin
BraveSirRobin / libevent-segfault.php
Created Apr 6, 2012
Bug demonstration script for PHP/libevent 0.0.4 Segfault.
View libevent-segfault.php
<?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:
@BraveSirRobin
BraveSirRobin / tgad.php
Created Jun 4, 2011
Simple demo of token_get_all()
View tgad.php
<?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]);
}
}
View gist:973159
<?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));