Skip to content

Instantly share code, notes, and snippets.

<?php
for( $i = 0; $i < 1000000; $i++ )
{
$el[] = md5('XX-'.$i);
}
$start = microtime(true);
foreach( $el as $hash )
### Keybase proof
I hereby claim:
* I am notian on github.
* I am notian (https://keybase.io/notian) on keybase.
* I have a public key ASD9AFHkME3cuw6Uw2OclN6eWuB1DTrN1oWyec1zAJIIgwo
To claim this, I am signing this object:
First,A Partridge in a Pear Tree.Secoond,Two Turtle Doves and.Third,Three French Hens.Fourth,Four Calling Birds.Fifth,Five Gold Rings.Sixth,Six Geese-a-Laying.Seventh,Seven Swans-a-Swimming.Eigth,Eight Maids-a-Milking.Ninth,Nine Ladies Dancing.Tenth,Ten Lords-a-Leaping.Eleventh,Eleven Pipers Piping.Twelth,Twelve Drummers Drumming
@notian
notian / exec.php
Last active March 29, 2018 14:05
PHP 5.6 -> 7 quirk
echo "A";
echo include(__DIR__.'/include.php');
echo "C";
@notian
notian / one_two_three.php
Created January 26, 2018 20:15
Code Golf # -> Words
define('b','');
$a = ['',one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve];$b = [3=>thir,5=>fif,8=>eigh];$c = [2=>twen,4=>'for'];
for(;strlen($n = $argv[++$i])>0;) echo trim((''||[$T,$h,$t,$o] = str_split(str_pad($n,4,0,STR_PAD_LEFT))).((!$n)?'zero':($T?$a[$T].' thousand ':b).($h?$a[$h].' hundred ':b).(($h&&($t||$o))?'and ':b).($t>0?($t>1?(($c[$t]?:($b[$t]?:$a[$t])).'ty-'):($a[$o+$t*10]?:(($b[$o]?:$a[$o]).'teen'))):b).($t==1?b:($o?$a[$o]:b))),' -1')."\n";
@notian
notian / string_to_bf.php
Created December 7, 2017 16:08
String to BF converter
<?php
namespace StrBF;
// Example Usage:
$input = implode(' ',array_slice($argv, 1));
echo wordwrap( Str2BF( $input ), 32, "\n", true );
echo "\n";
/**
@notian
notian / FileReader.php
Last active October 27, 2017 18:10
Directory / File reader using generators
<?php
class FileReader
{
private $filenames;
public function __construct($input)
{
if (is_file($input)) {
$this->filenames = [ $input ];
} elseif (is_dir($input)) {
@notian
notian / diamond.php
Created November 25, 2016 19:45
Diamond Table
<?php
function line($i){
$blank = '<td></td>';
$star = '<td>*</td>';
echo '<tr>'.
str_repeat($blank,5-$i).
str_repeat($star,($i*2)-1).
str_repeat($blank,5-$i).
'</tr>';
echo "\n";