Skip to content

Instantly share code, notes, and snippets.

View asaokamei's full-sized avatar

Asao Kamei asaokamei

View GitHub Profile
$errMsg = getErrors( $errors );
function getErrors( $errors )
{
return function( $name ) use( $errors ) {
return $errors->first( $name, '<p class="text-danger">:message</p>' );
};
}
//...
{{ $errMsg('name') }}
@asaokamei
asaokamei / file0.php
Created April 21, 2014 02:02
Eloquentでリレーションを作成する方法 ref: http://qiita.com/asaokamei/items/ce87090c155d7b4d7f6d
class Post extends Eloquent {
public comments() {
return $this->hasMany('Comment');
}
}
class Comment extends Eloquent {
public posts() {
return $this->BelongsTo('Post');
}
}
@asaokamei
asaokamei / file0.php
Created April 19, 2014 07:11
Eloquentのモデル生成法比較:newとcreate ref: http://qiita.com/asaokamei/items/bdad9d0f931f0840a3a9
$entity1 = new Model();
$entity2 = Model::create( array() );
@asaokamei
asaokamei / gist:7396720
Last active December 27, 2015 22:09
ロボットの足問題とDI+名前空間

ロボットの足問題とDI+名前空間

DI(依存注入、Dependency Injection)でのロボットの足問題の解決方法としてDIに名前空間を導入してみました。 参考:「Diコンテナの名前空間に関するメモ」

ロボットの足問題については、こちらの英語ページあるいはkoriymさんのRay.DIのIssue#36に詳しくあります。

GuiceやRay.DIを理解できたとは言える段階にないので、他の技術での対応方法について比較できないのですが、DIに名前空間を導入することで、かなりエレガントに解決できると思っています。

@asaokamei
asaokamei / gist:6266426
Created August 19, 2013 07:15
モデル、ページオブジェクトのキャッシュ効果測定

モデル、ページオブジェクト

BEAR.Sundayで覚えたアプリオブジェクト全部をキャッシュ(APC)する荒業。 その効果についてxdebugのprofileで効果を測定。

結果

Response/Moduleのinstantiateメソード内で、生成するオブジェクトを変更して、プロファイルをチェック。

@asaokamei
asaokamei / gist:6260020
Last active December 21, 2015 05:49
WScore-dev performance measurement result as of 2013/08/18.

localhost/ws/contacts

###prod setup

  • Requests per second: 39.24 #/sec (mean)
  • Time per request: 25.484 ms (mean)

###normal setup

@asaokamei
asaokamei / gist:5692180
Last active December 17, 2015 23:49
Diコンテナの名前空間に関するメモ

Diコンテナの名前空間に関するメモ

自作Diコンテナに「名前空間」を実装してみた。 欲しいと思った理由をまとめてみました。

WScore/DiContainer : https://github.com/asaokamei/WScore.DiContainer

自動設定の問題点

@asaokamei
asaokamei / gist:5691992
Last active December 17, 2015 23:49
count lines of php code

Counting Lines of PHP Codes

###How to Count

use simple shell scripts. modify the following command as necessary.

wc -l `find . -name "*.php"`
@asaokamei
asaokamei / sample.md
Last active December 14, 2015 06:39
Markdown examples

Markdown examples

This is for Github flabored Markdown format.

Lists

  • list without numbers.
  • and the items follow.
@asaokamei
asaokamei / Interaction.php
Created December 1, 2012 21:51
an interaction demo.
<?php
namespace wsModule\Alt\Web;
/**
* Interaction for web input and output, such as forms.
* This is a DCI inspired module. things works as coded but still quite experimental.
*
* TODO: remove $this->view property. Interaction should not know about view...
*/
class Interaction