Skip to content

Instantly share code, notes, and snippets.

View cebe's full-sized avatar
☁️
working on cebe.cloud

Carsten Brandt cebe

☁️
working on cebe.cloud
View GitHub Profile
@cebe
cebe / db.php
Last active December 13, 2015 20:18
How to separate config files in yii.
<?php
return array(
'connectionString' => 'mysql:host=localhost;dbname=mydatabase',
'emulatePrepare' => true,
'username' => 'myusername',
'password' => 'l3tm31n',
'charset' => 'utf8',
'enableProfiling' => false,
'enableParamLogging' => true,
@cebe
cebe / empty.php
Created August 9, 2012 21:27
PHP empty($x) vs. $x===''
<?php
$t = microtime(true);
for($n=0; $n<10000000; $n++) {
if (empty($class)) {
}
}
$e = microtime(true) - $t;
echo $e . "\n";
@cebe
cebe / EActiveRecordGraphBehavior.php
Created July 31, 2012 13:53
EActiveRecordGraphBehavior draft idea
<?php
/**
*
* @author CeBe <[email protected]>
*/
class EActiveRecordGraphBehavior extends CActiveRecordBehavior
{
/**
* @var string name of the relation/edge table
* schema must be:
@cebe
cebe / MyController.php
Created July 25, 2012 00:32
Yii: ajax links in ajax request, do not load jquery.js/core scripts
<?php
class MyController extends Controller
{
// ...
public function actionAjaxAction()
{
// do something
@cebe
cebe / EchoLogRoute.php
Created June 29, 2012 19:32
Yii Logging
<?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
*
@cebe
cebe / memory_usage.php
Created June 4, 2012 17:04
php memory usage
<?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');
@cebe
cebe / ActiveRecordFilterBehavior.php
Created May 7, 2012 16:41
ActiveRecordFilterBehavior - apply filters to attributes before validate
<?php
/**
* Allows to filter attributes before validation: trim,escape,re-format etc...
*
* List of implemented filters:
* - trim
*
* How to use:
*
@cebe
cebe / snippet.php
Created March 19, 2012 20:39
yii: run console command inside webapplication action
<?php
// ...
$runner=new CConsoleCommandRunner();
$runner->commands=array(
'commandName' => array(
'class' => 'application.commands.myCommand',
),
);
ob_start();
@cebe
cebe / Controller.php
Created March 15, 2012 14:09
yii debug ajax request with CWeblogRoute
<?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(
@cebe
cebe / about.md
Created March 15, 2012 10:40 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer