Thursday, May 29, 2014

Install and run PHP CodeIgniter under XAMPP in Windows 7

CodeIgniter is a powerful PHP framework 
based on the Model-View-Controller development pattern
Download page:
Documentation page:

1) Download and unzip to
note I installed XAMPP under C:\xampp
2) Run
welcome page should appear.
3) Create test.php under
4) configure database\application\config\database.php
In mycase, conect to localhost test database with root and no password
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'test';

Example code:
5) controller test.php

class Test extends CI_Controller {
    public function index() {
        $data = array();
        $user = new Users();
        $data['message']= $user->login();
        echo '<tt><pre>' . $data['message'] . '</pre></tt>';
        echo '<h2>This is a test</h2>';

6) model users.php
Class Users extends CI_Model

    private $_username;
    private $_password;

    function __construct()
    public function setUsername($value)
        $this->_username = $value;
    public function setPassword($value)
        $this->_password = $value;
   public function login()
        $username = $this->_username;
        $password = $this->_password;
        $this -> db -> select('id, username, password');
        $this -> db -> from('users');
        $this -> db -> where('username', $username);
        $this -> db -> where('password', $password);
        $query = $this -> db -> get();
         if($query -> num_rows() == 1)
           return "user name and pasword matched";
         return "user name and pasword not matched";

7) view test.php
echo "from view ".$message;

Video: Install and run PHP  CodeIgniter under XAMPP in Windows 7

Saturday, May 17, 2014

Set up Git server in Ubuntu 14.04

To setup Git server in Ubuntu 14.04, log in  admin account  in Ubuntu:
1) Install git-core
  sudo apt-get install git-core
2) create   git master firectory, using --bare for not directly editable
sudo mkdir -p /opt/git/directory.git
sudo git init --bare /opt/git/directory.git

3)  create group gitgroup make directory.git and its sub-directories  write permission by  gitgroup
sudo groupadd gitgroup
sudo chmod -R g+ws *
sudo chgrp -R gitgroup *

4) Set sharedRepository true
cd directory.git
sudo git config core.sharedRepository true

5) For test purpose, create new user Andy and assign him to group gitgroup:
sudo adduser andy
sudo groupadd gitgroup

Now in andy account (normal user account):
1) set name and email for git
 git config --global ""
  git config --global "andy"

2) Clone from master, change to your git server IP, a newdirectory /home/andy/directory will be created
 git clone andy@
3)Create a new file README under directory and commit it
cd  directory
git add README
 git commit -am 'fix for the README file by Andy'

4) push to server
git push origin master

Video: Set up Git server in Ubuntu 14.04

Sunday, May 4, 2014

Install statistics R and R studio in Windows 7

Statistics R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS. Statistics R can be downloaded from HERE.

After installing R, you can download R studio, which has a better interface than original R. Statistics R studio can be downloaded from HERE.

Both of them are free open source and work for Linux, Windows and Mac.

code example to plot in R and statistics data summary:

Video: Install statistics R and R studio in Windows 7