Wednesday, September 4, 2013

How to Enable Remote Desktop For Standard Users in Win 7

  1. Click Start -> Control Panel -> Systems
  2. Click Remote Setting on the left hand nav
  3. Select "Allo connections from computers running any version of remote desktop (less secure)
  4. Click Select users
  5. Add the "Standard" users that you want to enable the remote desktop

Monday, September 2, 2013

Git Pull Error - There is no tracking information for the current branch

Usually I can just do a git pull to get the latest update from master. However, I receive the following error/warning when I try to do git pull.

To solve this, I need to do "git pull origin master"

D:\xampp\htdocs\website>git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From 192.168.1.15:web/website
   25bc2eb..0b66cee  master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

Monday, July 8, 2013

Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.

The following error occur on my Yii web app
Alias "ext.dropdown.DropDownBox" is not valid.  Make sure it points to an existing PHP file and the file is readable.
I have checked that all of the permission is readable. This error only occurs in production and not in our test environment (mac and windows).
It turns out that our prod environment is using Centos and in my code I call
"$this->widget('ext.dropdown.DropDownBox', array(..." which should have been
"$this->widget('ext.dropDown.DropDownBox', array(..." 
Centos is very strict on case sensitivity. My extension folder name is with capital D "dropDown" and therefore I should have called the extension with capital D. 
D:\xampp\YII\framework\YiiBase.php(316)
304         if($isClass && (class_exists($className,false) || interface_exists($className,false)))
305             return self::$_imports[$alias]=$className;
306 
307         if(($path=self::getPathOfAlias($alias))!==false)
308         {
309             if($isClass)
310             {
311                 if($forceInclude)
312                 {
313                     if(is_file($path.'.php'))
314                         require($path.'.php');
315                     else
316                         throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias)));
317                     self::$_imports[$alias]=$className;
318                 }
319                 else
320                     self::$classMap[$className]=$path.'.php';
321                 return $className;
322             }
323             else  // a directory
324             {
325                 if(self::$_includePaths===null)
326                 {
327                     self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
328                     if(($pos=array_search('.',self::$_includePaths,true))!==false)

Friday, July 5, 2013

Jenkins fecthing upstream git changes take forever

Started by user anonymous
Building remotely on Windows Server 2003 in workspace c:\jenkins\workspace\your_app
Checkout:your_app / c:\jenkins\workspace\your_app - hudson.remoting.Channel@4296f09:Windows Server 2003
Using strategy: Default
Last Built Revision: Revision 9dc0a0401d62dd02f41a85ce00450d23ca85114f (origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
.
.
.
.

It just never ends

To solve this:

1. Go to your jenkins server
2. Go to jenkins workspace and do git pull
3. 
The authenticity of host '192.168.1.15 (192.168.1.15)' can't be established.
RSA key fingerprint is 6e:a3:e2:b5:b4:9f:02:4c:35:50:4f:8f:52:57:2b:d0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.15' (RSA) to the list of known hosts.
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 11 (delta 9), reused 0 (delta 0)
Unpacking objects: 100% (11/11), done.
From 192.168.1.15:k24/obat24

The reason jenkins does not work is because git is asking whether you want to add the rsa key fingerprint. You need to do this once manually and after that jenkins will be able to do the git pull for you.

Monday, July 1, 2013

Yii Require Once Error Cpanel

I tried to install Yii the first time on my cpanel hosting. However, when I try to launch my website I got the following errors:

Warning: require_once(/home/user_name/public_html/yii/demos/your_app/../../YII/framework/yii.php) [function.require-once]: failed to open stream: No such file or directory in /home/user_name/public_html/yii/demos/your_app/index.php on line 12

Fatal error: require_once() [function.require]: Failed opening required '/home/user_name/public_html/yii/demos/your_app/../../YII/framework/yii.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user_name/public_html/yii/demos/your_app/index.php on line 12

However, when I try the Yii demo apps like hangman, it works.

So I copied yii/demos/hangman/index.php to your_app/index.php file and it works. The reason I got the above error is because the yii path on my cpanel is different than on my local.

My cpanel index.php (I install yii on my public_html/yii)

<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'/../../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following line when in production mode
// defined('YII_DEBUG') or define('YII_DEBUG',true);

require_once($yii);
Yii::createWebApplication($config)->run();

Sunday, June 30, 2013

Yii Active Records

Yii Active Record

PostController.php

//Assuming we have a database table with ID, title, content, category_id and user_id as a field

public function actionActiveRecord()
{
  //example of what Yii Active record can return
  $model = Post::model()->find('id = 1');
  echo $model->title;
  $model = Post::model()->find('category_id = 2 AND user_id = 1');
  echo $model->title;

  //alternatively you can use Yii Active record find by attributes
  $model = Post::model()->findByAttributes(array(
      'category_id' => 2,
      'user_id'     => 1,
  ));
 
  echo $model->title;

  //or you can use findByPk
  $model = Post::model()->findByPk(1)

  //if you need to display more than 1 data findAll
  $model = Post::model()->findAll('category_id = 2');
  foreach($model as $m){
    echo $m->title."<br/>";
    echo $m->content."<br/>";
  }
}

How to enable Gii Tools In YII

Setting GII Tools in YII

1. Open your_app/protected/config/main.php
2. uncomment the following th enable the Gii tool
/*
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
*/

3. The UrlManager code needs to be uncommented as well
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),*/
4. Change the Gii password
5. Go to your localhost/your_app/gii