wiki https://github.com/koriym/BEAR.Sunday/wiki に移動しました
<?php | |
class MyClass { | |
public function __toString() { | |
try { | |
return $this->render(); | |
} catch(Exception $e) { | |
// the __toString method isn't allowed to throw exceptions | |
// so we turn them into an error instead | |
trigger_error($e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_ERROR); |
原文:Scaling Isomorphic Javascript Code (This is just for study, please contact me at tily05 atmark gmail.com if any problem.)
考えてみれば Model-View-Controller とか MVC ってよく聞くよね。実際どんなものか知ってる? 抽象的に言うなら「オブジェクト情報の保持されるグラフィック・システム (つまり、ラスターではないグラフィック。ゲームとか) 上に構築された、表示系を中心としたアプリケーションにおいて、主要な機能どうしの関わりをうまく分離すること」とでも言おうか。もう少し深く考えを押し進めてみれば、これは当然、他のさまざまなアプリケーションにもあてはまる言葉 (bucket term ?) だ。
過去に多くの開発コミュニティが MVC による解決案を提供し、それによってよくあるユースケースにうまく対処し、地位を築くことができた。例をあげるなら、Ruby や Python コミュニティは Rails や Django を作り、MVC アーキテクチャを実現した。
Array functions: | |
array_search $needle, $haystack | |
in_array $needle, $haystack | |
String functions: | |
strchr $haystack, $needle | |
stripos $haystack, $needle | |
stristr $haystack, $needle | |
strpos $haystack, $needle | |
strrchr $haystack, $needle |
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.
General principles for good URI design: | |
Don't use query parameters to alter state | |
Don't use mixed-case paths if you can help it; lowercase is best | |
Don't use implementation-specific extensions in your URIs (.php, .py, .pl, etc.) | |
Don't fall into RPC with your URIs | |
Do limit your URI space as much as possible | |
Do keep path segments short | |
Do prefer either /resource or /resource/; create 301 redirects from the one you don't use | |
Do use query parameters for sub-selection of a resource; i.e. pagination, search queries |
<?php | |
class App_Aspect_Lock implements BEAR_Aspect_Around_Interface{ | |
public function around(array $values, BEAR_Aspect_JoinPoint $joinPoint){ | |
$lock = sprintf('%s/tmp/locks/%s', _BEAR_APP_HOME, sha1(serialize($joinPoint->getMethodReflection()))); | |
if(!file_exists($lock)){ | |
touch($lock); | |
} | |
if(file_get_contents($lock)){ | |
return false; | |
} |
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } | |
body > *:first-child { |
##Given Apache 2 and MySQL are already installed.
#Update MacPorts sudo port selfupdate;sudo port -u upgrade outdated
#Install PHP 5.4.* sudo port install php54 php54-apache2handler ##Activate Apache Module cd /opt/local/apache2/modules
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |