This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This one is cebe's personal list.
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This one is cebe's personal list.
| <?php | |
| // ... | |
| public function actionXXX() | |
| // ... | |
| $this->beginClip('debug'); | |
| Yii::app()->log->processLogs(null); | |
| Yii::app()->detachEventHandler('onEndRequest',array(Yii::app()->log,'processLogs')); | |
| $this->endClip(); | |
| $this->sendJsonResponse(array( |
| <?php | |
| // ... | |
| $runner=new CConsoleCommandRunner(); | |
| $runner->commands=array( | |
| 'commandName' => array( | |
| 'class' => 'application.commands.myCommand', | |
| ), | |
| ); | |
| ob_start(); |
| <?php | |
| /** | |
| * Allows to filter attributes before validation: trim,escape,re-format etc... | |
| * | |
| * List of implemented filters: | |
| * - trim | |
| * | |
| * How to use: | |
| * |
| <?php | |
| $old = memory_get_usage(); | |
| // code that allocates memory (create objects etc...) | |
| $mem = memory_get_usage(); | |
| Yii::trace('memory usage: '.(abs($mem - $old)/1024).' kb'); |
| <?php | |
| // This is http://pear.php.net/package/Console_Color | |
| Yii::import('application.vendors.Console_Color.Console_Color'); | |
| /** | |
| * Logroute that simply echos what has been logged | |
| * | |
| * This files is available online at https://gist.github.com/3020140 | |
| * |
| <?php | |
| class MyController extends Controller | |
| { | |
| // ... | |
| public function actionAjaxAction() | |
| { | |
| // do something |
| <?php | |
| /** | |
| * | |
| * @author CeBe <[email protected]> | |
| */ | |
| class EActiveRecordGraphBehavior extends CActiveRecordBehavior | |
| { | |
| /** | |
| * @var string name of the relation/edge table | |
| * schema must be: |
| <?php | |
| $t = microtime(true); | |
| for($n=0; $n<10000000; $n++) { | |
| if (empty($class)) { | |
| } | |
| } | |
| $e = microtime(true) - $t; | |
| echo $e . "\n"; |
| <?php | |
| return array( | |
| 'connectionString' => 'mysql:host=localhost;dbname=mydatabase', | |
| 'emulatePrepare' => true, | |
| 'username' => 'myusername', | |
| 'password' => 'l3tm31n', | |
| 'charset' => 'utf8', | |
| 'enableProfiling' => false, | |
| 'enableParamLogging' => true, |