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

Saturday, June 29, 2013

How To Install YII Framework on Windows

Step By Step Guide to Install YII Framework on Windows

Installing YII Framework on Windows

1. Download YII framework on www.yiiframework.com
2. Install XAMPP
3. Put YII framework (rename to YII) on the XAMPP folder. e.g c:/xampp/yii
4. Open System Properties -> Advanced -> Environment Variables -> Edit System Variables (PATH) -> Put YII path into the
system variables. e.g c:/xampp/YII;c:/xampp/php
5. Open CMD
6. Go to c:/xampp/htdocs/
7. Execute "yiic webapp your_app"
8. Automatically your_app will be generated
9. Open localhost/your_app

Yiic will automatically generate your web application.

PS C:\xampp\htdocs> yiic webapp your_app
Create a Web application under 'C:\xampp\htdocs\your_app'? (yes|no) [no]:yes
      mkdir C:/xampp/htdocs/your_app
      mkdir C:/xampp/htdocs/your_app/assets
      mkdir C:/xampp/htdocs/your_app/css
   generate css/bg.gif
   generate css/form.css
   generate css/ie.css
   generate css/main.css
   generate css/print.css
   generate css/screen.css
      mkdir C:/xampp/htdocs/your_app/images
   generate index-test.php
   generate index.php
      mkdir C:/xampp/htdocs/your_app/protected
   generate protected/.htaccess
      mkdir C:/xampp/htdocs/your_app/protected/commands
      mkdir C:/xampp/htdocs/your_app/protected/commands/shell
      mkdir C:/xampp/htdocs/your_app/protected/components
   generate protected/components/Controller.php
   generate protected/components/UserIdentity.php
      mkdir C:/xampp/htdocs/your_app/protected/config
   generate protected/config/console.php
   generate protected/config/main.php
   generate protected/config/test.php
      mkdir C:/xampp/htdocs/your_app/protected/controllers
   generate protected/controllers/SiteController.php
      mkdir C:/xampp/htdocs/your_app/protected/data
   generate protected/data/schema.mysql.sql
   generate protected/data/schema.sqlite.sql
   generate protected/data/testdrive.db
      mkdir C:/xampp/htdocs/your_app/protected/extensions
      mkdir C:/xampp/htdocs/your_app/protected/messages
      mkdir C:/xampp/htdocs/your_app/protected/migrations
      mkdir C:/xampp/htdocs/your_app/protected/models
   generate protected/models/ContactForm.php
   generate protected/models/LoginForm.php
      mkdir C:/xampp/htdocs/your_app/protected/runtime
      mkdir C:/xampp/htdocs/your_app/protected/tests
   generate protected/tests/bootstrap.php
      mkdir C:/xampp/htdocs/your_app/protected/tests/fixtures
      mkdir C:/xampp/htdocs/your_app/protected/tests/functional
   generate protected/tests/functional/SiteTest.php
   generate protected/tests/phpunit.xml
      mkdir C:/xampp/htdocs/your_app/protected/tests/report
      mkdir C:/xampp/htdocs/your_app/protected/tests/unit
   generate protected/tests/WebTestCase.php
      mkdir C:/xampp/htdocs/your_app/protected/views
      mkdir C:/xampp/htdocs/your_app/protected/views/layouts
   generate protected/views/layouts/column1.php
   generate protected/views/layouts/column2.php
   generate protected/views/layouts/main.php
      mkdir C:/xampp/htdocs/your_app/protected/views/site
   generate protected/views/site/contact.php
   generate protected/views/site/error.php
   generate protected/views/site/index.php
   generate protected/views/site/login.php
      mkdir C:/xampp/htdocs/your_app/protected/views/site/pages
   generate protected/views/site/pages/about.php
   generate protected/yiic
   generate protected/yiic.bat
   generate protected/yiic.php
      mkdir C:/xampp/htdocs/your_app/themes
      mkdir C:/xampp/htdocs/your_app/themes/classic
      mkdir C:/xampp/htdocs/your_app/themes/classic/views
   generate themes/classic/views/.htaccess
      mkdir C:/xampp/htdocs/your_app/themes/classic/views/layouts
      mkdir C:/xampp/htdocs/your_app/themes/classic/views/site
      mkdir C:/xampp/htdocs/your_app/themes/classic/views/system

Your application has been created successfully under C:\xampp\htdocs\your_app.

Wednesday, June 26, 2013

How to Startup Tomcat server in MAC

How to Startup/Shutdown Tomcat server in MAC

/Library/tomcat/bin/startup.sh
/Library/tomcat/bin/shutdown.sh

Saturday, June 22, 2013

How to display .gitignore file in netbeans

To display .gitignore file in netbeans simply modify the miscellaneous options in:

Tools->Options->miscellaneous ->Files

And change the Files ignore by the IDE:
From:
^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|~$|^\.(?!(htaccess)$).*$

To:
^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|~$|^\.(?!(htaccess|gitignore)$).*$

Friday, June 21, 2013

CSS style submit button height

To adjust the text on the submit input button use the following CSS style:

line-height: 2;

Monday, June 3, 2013

Unable to create Git index.lock File Exists

fatal: Unable to create '/Users/username/Sites/testsite/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

Just delete the index.lock file

rm /Users/username/Sites/testsite/.git/index.lock
git pull

Sunday, June 2, 2013

Apache Access Log, Error Log in Mac

is located in

tail - f /var/log/apache2/access_log
tail - f /var/log/apache2/error_log

Friday, May 31, 2013

PHP error - It is not safe to rely on the system's timezone settings

To fix the bellow error:

1. Find you php.ini files
2.  to see your php.ini files- you need to pass in the INFO_GENERAL parameters as without the parameters you will get the same error as phpinfo() will trigger the timezone issue settings
3. Edit your php.ini files and go to

; Defines the default timezone used by the date functions

; http://php.net/date.timezone

;date.timezone =


Change to what ever your time zone is. For a list of php timezone please visit http://id1.php.net/manual/en/timezones.asia.php

; Defines the default timezone used by the date functions

; http://php.net/date.timezone

date.timezone = "Asia/Dubai"


Ps: don't forget to delete the ";"

4. Restart your apache server. if you are using mac use "sudo apachectl restart"


date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Dubai' for 'WIT/7.0/no DST' instead

CException CAssetManager is invalid

To fix the below error:
 1. Set the group permission to WWW using
 sudo chown user:www assets (mac)
 sudo chown user.www assets (linux)

------------------
Websever Error

CException

CAssetManager.basePath "/Users/user/Sites/website-code/assets" is invalid. Please make sure the directory exists and is writable by the Web server process.

/Users/user/YII/framework/web/CAssetManager.php(138)

126     }
127 
128     /**
129      * Sets the root directory storing published asset files.
130      * @param string $value the root directory storing published asset files
131      * @throws CException if the base path is invalid
132      */
133     public function setBasePath($value)
134     {
135         if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath))
136             $this->_basePath=$basePath;
137         else
138             throw new CException(Yii::t('yii','CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.',
139                 array('{path}'=>$value)));
140     }
141 
142     /**
143      * @return string the base url that the published asset files can be accessed.
144      * Note, the ending slashes are stripped off. Defaults to '/AppBaseUrl/assets'.
145      */
146     public function getBaseUrl()
147     {
148         if($this->_baseUrl===null)
149         {
150             $request=Yii::app()->getRequest();

Monday, May 27, 2013

Windows Batch File Not Executing

I use jenkins to automate my cucumber test automation. I use windows to execute the batch command in Jenkins

bundle install --path vendor
set test_env=test_server 
bundle exec cucumber features\regression\dashboard.feature

However, only the first line is executed by jenkins. It turns out that jenkins creates a .bat file for those above commands and jenkins calls the commands as

cmd \c call hudson.bat

And apparently the cmd "Call" command only works on the first command.

To fix the issue simply append the keyword "call" on every command.

The solution:
call bundle install --path vendor
set test_env=test_server
call bundle exec cucumber features\regression\dashboard.feature

Jenkins does not execute All Windows Batch Command

I use jenkins to automate my cucumber test automation. I use windows to execute the batch command in Jenkins

bundle install --path vendor
set test_env=test_server 
bundle exec cucumber features\regression\dashboard.feature

However, only the first line is executed by jenkins. It turns out that jenkins creates a .bat file for those above commands and jenkins calls the commands as

cmd \c call hudson.bat

And apparently the cmd "Call" command only works on the first command.

To fix the issue simply append the keyword "call" on every command.

The solution:
call bundle install --path vendor
set test_env=test_server
call bundle exec cucumber features\regression\dashboard.feature

Friday, May 24, 2013

Cannot run program sh in jenkins

Error from Jenkins console:

[cuke-test] $ sh -xe C:\Users\username\AppData\Local\Temp\4\hudson4066016990068916818.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "c:\jenkins\workspace\cuke-test"): CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(Unknown Source)
 at hudson.Proc$LocalProc.<init>(Proc.java:244)
 at hudson.Proc$LocalProc.<init>(Proc.java:216)
 at hudson.Launcher$LocalLauncher.launch(Launcher.java:763)
 at hudson.Launcher$ProcStarter.start(Launcher.java:353)
 at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:988)
 at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:955)
 at hudson.remoting.UserRequest.perform(UserRequest.java:118)
 at hudson.remoting.UserRequest.perform(UserRequest.java:48)
 at hudson.remoting.Request$2.run(Request.java:326)
 at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
 at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at hudson.remoting.Engine$1$1.run(Engine.java:58)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create(Native Method)
 at java.lang.ProcessImpl.<init>(Unknown Source)
 at java.lang.ProcessImpl.start(Unknown Source)
 ... 17 more
Build step 'Execute shell' marked build as failure

Solution:
- It turns out that I copied a job from a linux slave and therefore the default build step that was used was "Execute shell". To fix the issue just change the "Execute shell" to "Execute Windows batch command"

Tuesday, May 7, 2013

Git Setup Remote Tracking Branch


Git global setup

git config --global user.name "Test User"
git config --global user.email "testuser@gmail.com"

Create Repository

mkdir testproject
cd testproject
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@gitlab.testserver-123.testuser/testprojects.git
git push -u origin master

Existing Git Repo?

cd existing_git_repo
git remote add origin git@gitlab.testserver-123.testuser/testprojects.git
git push -u origin master

Friday, May 3, 2013

Capybara Check Select Options

To check Select options using Capybara

To choose the select option:

select('Morning', :from => 'Shift')

To check the value of the select options:

page.has_select?('Shift', :selected => 'Morning')




Thursday, March 28, 2013

Creating GIT branch and merge


--- to create:
git checkout master
$ git checkout -b new-branch
--- to merge
git commit -am "commit file in branch"
git checkout master
git merge new-branch

Tuesday, March 19, 2013

Resizing image to create thumbnail in MAC

to resize an image or images in a directory use the following command:

//to resize all of the images in a directory to 245x245 size
sips --resampleHeightWidth 245 245 *

Tuesday, January 22, 2013

How to remove custom Alexa toolbar from Chrome extension completely

I created a custom free Alexa toolbar and installed it as an extension on my Chrome.

So whenever I open my chrome, the custom alexa extension appears as another menu on chrome. However, the extension apparently makes my browser test automation to fail.
I remove the extension manually from the chrome setting. I thought the extension is removed completely.

However, it turns out that Alexa still saves the extension on your hardisk. Whenever, my test automation runs, it loads up the extension to chrome again. I tried to remove it again, but it always appears. This is very annoying.

To find the location of the Alexa chrome extension just open regedit and search for "Alexa" and remove any of alexa information.

For me the culprit is stored in "C:\Users\<username>\AppData\Local\Alexa\atbpg-MSXGM-1.2.crx". And this file will be loaded by chrome automatically.

I deleted the file and the Alexa chrome extension never comes up again.