Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
<?php | |
use FooBar\Test\Mock; | |
// In the sample below, $mock expects the method "sayHelloTo" to be called one time | |
// with the parameter $name equals "Alexandre" and return "Hello Alexandre" | |
$mock = (new Mock)([ | |
'sayHelloTo' => function($name="Alexandre") { | |
return "Hello Alexandre"; |
<?php | |
use Respect\Transform\Transformer as t; | |
$users = array( | |
array("id" => 1, "first_name" => "Alexandre", "last_name" => "Silva", "location" => "São Paulo"), | |
array("id" => 2, "first_name" => "Satoshi", "last_name" => "Silva", "location" => "Curitiba"), | |
array("id" => 3, "first_name" => "Fulano", "last_name" => "Silva", "location" => "New York") | |
); |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
<?php | |
// http client making a request to github api | |
require __DIR__.'/../vendor/autoload.php'; | |
$loop = React\EventLoop\Factory::create(); | |
$client = new React\Http\Client($loop); | |
$request = $client->request('GET', 'https://api.github.com/repos/react-php/react/commits'); |
Since this is on Hacker News and reddit...
_t
in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".char *
s.type * name
, however, is entirely intentional.function dex-method-count() { | |
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' | |
} | |
function dex-method-count-by-package() { | |
dir=$(mktemp -d -t dex) | |
baksmali $1 -o $dir | |
for pkg in `find $dir/* -type d`; do | |
smali $pkg -o $pkg/classes.dex | |
count=$(dex-method-count $pkg/classes.dex) | |
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.') |
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */ | |
/* ========================================================================== | |
HTML5 display definitions | |
========================================================================== */ | |
/** | |
* Correct `block` display not defined in IE 8/9. | |
*/ |