Skip to content

Instantly share code, notes, and snippets.

View hirak's full-sized avatar

Hiraku NAKANO hirak

View GitHub Profile
1. !0
2. str_rot13
3. !0
4. 0
5. aaaa
=> best: 1
6. $f=function()use(&$f){return $f;}
=> best: 22
7. (object)[!0]
8. new class extends Bar{}
@hirak
hirak / ___new benchmark
Last active March 18, 2017 00:01
new packagist.org in US?
$ curl -v https://packagist.org/packages.json --write-out "\n time_namelookup: %{time_namelookup}\n time_connect: %{time_connect}\n time_appconnect: %{time_appconnect}\n time_redirect: %{time_redirect}\n time_total: %{time_total}\n"
* Trying 87.98.253.214...
* Connected to packagist.org (87.98.253.214) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: packagist.org
* Server certificate: DigiCert SHA2 Secure Server CA
* Server certificate: DigiCert Global Root CA
> GET /packages.json HTTP/1.1
> Host: packagist.org
> User-Agent: curl/7.43.0
@hirak
hirak / 0-summary.md
Last active May 7, 2016 07:39
prestissimo-patch benchmark
@hirak
hirak / 01_default.sh
Created January 6, 2016 23:32
composer parallel install
$ composer create-project laravel/laravel laravel-test1 --no-progress --profile --prefer-dist
[53.1MB/1.03s] Installing laravel/laravel (v5.2.0)
[53.5MB/1.04s] - Installing laravel/laravel (v5.2.0)
[53.6MB/1.04s] Downloading
[53.7MB/3.26s]
[53.7MB/5.24s] Created project in laravel-test1
[54.7MB/5.26s] > php -r "copy('.env.example', '.env');"
[5.2MB/5.33s] Loading composer repositories with package information
[5.4MB/5.54s] Installing dependencies (including require-dev)
[170.3MB/9.16s] - Installing vlucas/phpdotenv (v2.2.0)
@hirak
hirak / 01_benchmark.md
Last active July 4, 2020 06:07
performance of "composer update" download meta.json phase

"composer update" benchmark

composer update is ...

  1. download https://packagist.org/p/*.json phase
  2. resolve dependencies phase
  3. download package.zip phase

In Asia(Japan, China, etc), far from packagist.org(French?), RTT is terrible. So it spends long time for "1. download meta.json phase". This is the benchmark for it. I think packagist.org should use CDN like CloudFlare.

@hirak
hirak / curlstream.php
Last active August 29, 2015 14:12
curlstream
<?php
class CurlStream
{
/** @type resource $context */
public $context;
/** @type resource<url>[] */
private static $cache = array();
@hirak
hirak / file0.txt
Created July 5, 2014 03:48
Zend\LogでFingersCrossedモード(問題発生時に過去ログを一気に出力) ref: http://qiita.com/Hiraku/items/ebc2c6ec051c7dd15bd4
$ mkdir some-project
$ cd some-project
$ composer require 'zendframework/zend-log:*'
@hirak
hirak / file0.php
Last active August 29, 2015 14:02
Iteratorをimplementsする奴は情弱。IteratorAggregateを使え ref: http://qiita.com/Hiraku/items/14722922441f9ed3fbbb
<?php
class A {
public $hoge = 1;
public $fuga = 2;
private $pri = 3;
protected $pro = 4;
}
$a = new A;
@hirak
hirak / FactoryDefault.php
Created February 26, 2014 23:47
Dependency Injectionを特定のDIコンテナに頼らず実現する ref: http://qiita.com/Hiraku/items/48fbdfca4b63c74494e9
<?php
class FactoryDefault
{
function createInfrastructureMailer()
{
return new SendmailMailer;
}
function createDomainTransferNewsletter()
{
@hirak
hirak / file0.php
Created February 26, 2014 15:23
explode()の挙動がキモい ref: http://qiita.com/Hiraku/items/a58b8aac3f9e55cd1bd5
var_dump(explode(' ', ''));
//array("")