Skip to content

Instantly share code, notes, and snippets.

View MugeSo's full-sized avatar

TANAKA Koichi MugeSo

View GitHub Profile
<?php
$obj = new stdClass();
$obj->a = new stdClass();
$obj->a->child = new stdClass();
$obj->b = new stdClass();
$obj->b->child = $obj->a->child;
$serialized = serialize($obj);
@MugeSo
MugeSo / leak-test.php
Last active August 29, 2015 13:55
Memory leak test of BEAR.Package
<?php
$context = 'prod';
$app = require dirname(__DIR__) . '/bootstrap/instance.php';
$count = $argv[1];
echo "Request page://self/ {$count} times.", PHP_EOL;
for ($i = 0; $i < $count; $i++) {
@MugeSo
MugeSo / AuraRouterMapProvider.php
Last active August 29, 2015 13:56
This class generates routing map for BEAR(http://bearsunday.github.io/) application.
<?php
namespace Webnium\BEAR\Extension\Router;
use Aura\Router\Map;
use Aura\Router\DefinitionFactory;
use Aura\Router\RouteFactory;
use Ray\Di\ProviderInterface;
use Ray\Di\Exception\NotInstantiable;
use BEAR\Sunday\Inject\ResourceInject;
module LRUMemoryCache {
export class Cache {
private leastRecentlyUsed: Node;
private mostRecentlyUsed: Node;
private map: Map<string, Node>;
private usage: number = 0;
constructor(public size: number) {
if (size <= 0) {
throw new Error('Cache size should be larger than 0');
@MugeSo
MugeSo / file0.txt
Last active August 29, 2015 14:15
Chrome拡張のEventPageでchrome.contextMenusを正しく動かす ref: http://qiita.com/MugeSo/items/e5307bda346c0bb8e22e
{
...
"background": {
"scripts": ["background.js"],
"persistent": false
}
...
}
@MugeSo
MugeSo / gist:1626063
Created January 17, 2012 10:06
$hoge.foo(); on php without any errors.
error_reporting(E_ALL);
function foo(){}
class Hoge{ public function __toString(){return "a";}}
$hoge = new Hoge();
$hoge.foo();// Success!
# language: ja
フィーチャ: 検索機能
欲しい商品を見つけるために
会員または非会員として
商品を検索できる
シナリオ: カメラを検索する
前提 "ショッピングトップ" を表示している
もし "検索窓" に "カメラ" と入力する
かつ "検索" ボタンをクリックする
$ behat
フィーチャ: 検索機能
欲しい商品を見つけるために
会員または非会員として
商品を検索できる
シナリオ: カメラを検索する # features/search.feature:7
前提 "ショッピングトップ" を表示している
もし "検索窓" に "カメラ" と入力する
かつ "検索" ボタンをクリックする
@MugeSo
MugeSo / gist:3148548
Created July 20, 2012 03:58
Render a view without asking.
<?php
interface HearerInterface
{
public function retain($key, $value);
}
interface SelfExpressableInteface
{
public function expressSelf(HearerInteface $hearer);
}
@MugeSo
MugeSo / FeatureContext.php
Created October 29, 2012 02:41
How to use "Diggin - Guzzle AutoCharsetEncoding plugin" with Behat MinkExtension
use Behat\MinkExtension\Context\MinkContext;
use Diggin\Bridge\Guzzle\AutoCharsetEncodingPlugin\AutoCharsetEncodingPlugin;
class FeatureContext extends MinkContext
{
/* ommitted */
/**
* @BeforeScenario