Brew Error: Failed to link all completions, docs and manpages: Permission denied

I’m trying to install brew on my mac book pro, it throw the message

Error: Failed to link all completions, docs and manpages: Permission denied

Then, copy-pasting the error to google search bring me to this solution:

sudo chown -R $USER:admin /usr/local/*

happy brewing!


Pug render variable twice

recently, I want to pass this variable to the view

passedVars.metaOgUrl = '<meta property="og:url" content="' + originalUrl + '">';

and use the usual way of rendering variable in pug


but it render the tag twice, a simple googling then found the answer, use != character as prefix


it’s rendered normal now




Yii : CGridView – Create Custom Column

I have a field which contains one character to represent project status (eg: F=Finished, S=Start, P=Pending, etc)

By default, CGridView will display one character value, but we want CGridView to display its description taken from other table, this is what I did:

First, create a component, let’s name it MyComponent. You can do it by create MyComponent.php and save it in component folder, I write something like this:

class MyComponent extends CApplicationComponent 
 public function getProjectStatus($statusCode)

 $rs = Yii::app()->db->createCommand($sql)->queryAll();

 $data = array();

 foreach($rs as $item){

 $statusCode = $item['STATUS_CODE'];
 $description = $item['DESCRIPTION'];

 $data[$statusCode] = $description;
 return $data[$statusCode]; 

This way, you can call the function like this

Then, replace the field name in your views (admin.php) with something like this

array('header' => 'Project Status', 'value' => 'Yii::app()->mycomponent->getProjectStatus($data->PROJECT_STATUS)'),

Some people suggest the function should be static

Yii version: 1.1.10

jQuery : Select All Checkbox

Yahoo! Mail and GMail both has a checkbox on top of their email list which will “checked” all chekboxes when clicked. Previously I use plain old javascript like those in this link, I just try to use jQuery to do this, its only 5 lines

        this.checked =;