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’, ], ], ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => […]

Change apache2 running user/group

vi /etc/apache2/envvarsvi /etc/apache2/envvars Edit export APACHE_RUN_USER=imran export APACHE_RUN_GROUP=www-dataexport 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)(recovery mode) 3. From the menu screen choose "Drop to root shell prompt""Drop to root shell prompt" 4. By default it gives you read-only filesystem […]

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;UPDATE table1 SET column2 = CASE WHEN column1 = 'A' THEN 'AB' WHEN column1 = 'B' THEN 'BC' WHEN column1 = 'C' […]