Archive for January 2016

Yii2 custom logger

Step 1: app/config/console.php   ‘log’ => [ ‘traceLevel’ => YII_DEBUG ? 3 : 0, ‘targets’ => [ [ ‘class’ => ‘app\helpers\MyFileTarget’, ‘exportInterval’ => 1, ‘categories’ => [’my-category’], ‘except’ => [’application’], ‘levels’ => [’trace’], ‘logFile’ => ‘@app/runtime/logs/my-category.log’, ], ], ], Step 2: Create file app/helpers/MyFileTarget.php   <?php   namespace app\helpers;   use Yii; use yii\log\Logger; use […]

Change apache2 running user/group

vi /etc/apache2/envvars Edit export APACHE_RUN_USER=imran export APACHE_RUN_GROUP=www-data Save and restart apache

Ubuntu reset root password

If you forgot root’s password follow these steps to reset it: 1. Reboot, press ESC to get to GRUB boot loader menu 2. Choose from the list kernel with (recovery mode) 3. From the menu screen choose "Drop to root shell prompt" 4. By default it gives you read-only filesystem Run this for read/write: mount […]

Mysql bulk UPDATE

Run the following statement for bulk UPDATE UPDATE table1 SET column2 = CASE WHEN column1 = ‘A’ THEN ‘AB’ WHEN column1 = ‘B’ THEN ‘BC’ WHEN column1 = ‘C’ THEN ‘CD’ ELSE column2 END; Make sure you included ELSE statement, if you skip it then it will NULL rest of the column2 fields. So, if […]