Archive for the ‘Uncategorized’ Category

Hello All

Hope you all are fine. Today I will show how to work with Git in windows environment with TortoiseGIT client & ProjectLocker Git Hosting. ProjectLocker is a good Git hosting provider for startup a private project, you may check there pricing plan to let know more about the features of different plan.

Now first do signup from https://www.projectlocker.com/signup/startup ( I will show through a free plan) , After signing up verify your account and login through https://portal.projectlocker.com/ . You will find “Account Links > Add Project” from the left menu panel, select “Add Project”. Now give a project name, description and select Git as Repository type.I’m giving the name “DemoGit” for my project.Click “Create Project”.

In the next step you have to create user account from “Account Links > Add User”. Now you have to create a Public Key for your repository.

First download PuttyGen from the [ link ] or anywhere you found through googling and create a public and private key pair through the software as bellow by clicking Generate button and moving mouse pointer arbitrary.

Now give a passphrase and confirm it.After that save the private key by clicking “Save private key” , I have saved my with the name demokey.ppk . You have to copy the public key (the top red marked block in the following pictuer)

Its time to get back in ProjectLocker :) .  Click manage public key from “User Links > Manage Public Keys” and click “New Key”. Then pest  the public key in Key section ,User name (which you have created in user section, I’m putting my email here) and a name to identify the key in Name section and save it as bellow by clicking “Save Public Key”:

Open list projects from “Account Links > List Projects” and select your desired project from the Name column (I’m selecting DemoGit for the demonstration purpose.) as bellow:

Now assign the user to the project from the user list bellow by clicking “Add To Project” corresponding user.

It’s the time to play with Git client software. For this, first we have to install  msysgit from http://code.google.com/p/msysgit/downloads/list after that TortoisGIT from http://code.google.com/p/tortoisegit/downloads/list accordingly with next,next flow (I mean default settings, you don’t have to change any settings over there ) and reboot your machine.

Now open a folder where you want to put your files to sink with Git repository (I’m opening a folder named “DemoGit”). After that right click on the the folder and click “Gil Clone..” as bellow:

Now in the next panel you have to pest the Url (git repository location , you will get it from “User Links > User Home” like the image bellow ) and locate the private key which we have generated earlier (for me its demokey.ppk)

Now you have to enter passphrase which you have set during key generation.

That’s it , we have successfully configured our repository with TortoiseGIT client.

Now we will add a file named “demo_text_file.txt” and it to our repository.To that we have to right click the folder again and do as per image bellow.

Then confirm the add operation :

Now you have to do as per following image sequence to push the fine into server.

We are going to change some text in our file and give Git Commite as per image bellow:

We have to put a message before committing something into our brunch in Message section, We also can put signed off signature as bellow:

To finally push the file into server we have to click push :

And the we have to select in which brunch we should to push in server and click ok.

No to sink with others commit we have to update the code base as bellow.

Then select “Pull” as bellow:

There are lots more Git operation we can perform through TortoiseGIT but in this tutorial I just have shown how to do the basic operation. Hope in future I will post more advance feature & operation of GIT. 

Thanks

That’s all for today .

To know more visit to my blog [ http://blog.actcode.com/ ]

Bye

Hello All

Today I will focus on overloading method and property in PHP. Unlike other language Java/C# overloading is working in a little bit different way for PHP.

Normally we can overload a method by providing different/varying argument(s) ,but in PHP it should have to create through some magic methods.

These magic methods are as bellow:

(For overloading property)

void __set ( string $name , mixed $value )

mixed __get ( string $name )

bool __isset ( string $name )

void __unset ( string $name )

(For overloading method)

mixed __call ( string $name , array $arguments )

mixed __callStatic ( string $name , array $arguments )

It will be better to describe the operation inside code comment rather that bookish thing hear. Please go through the code comment to get know what is gonging over there to perform overloading .

<?php

class PhpOverloading {

  /* Property overloading -start- */
  private $_data = array ();

  public function __set($name, $value) {
    /*
     * set the key value in the $_data private
     * variable.
     * */
    $this->_data [$name] = $value;
  }

  public function __get($name) {
    /*
     * Retrieve the value of key which we have
     * set through __set method.
     * */
    return $this->_data [$name];
  }

  public function __isset($name) {
    /*
     * Check wheather the key exist or not.
     * */
    return isset ( $this->_data [$name] );
  }

  public function __unset($name) {
    /*
     * Unset the value of key.
     * */
    unset ( $this->_data [$name] );
  }

  /* Property overloading -end- */

  /* Method overloading -start- */
  public function __call($name, $argument) {
    /*
     * perform your operation as needed,
     * I just used a switch case to show how
     * we can set the dynamic method with parameters.
     * */

    switch ($name) {
      case ('First') :
        echo "This is the first dyanamic method and arguments are " . implode ( ',', $argument );
        break;
      case ('Second') :
        echo "2nd method and the arguments are {$argument[1]} and {$argument[2]}";
        break;
      default :
        echo "Method unhandled with the name {$name} and arguments are " . implode ( ',', $argument );
    }
  }

  public static function __callstatic($name, $argument) {

    /*
     * It's similar as __call but works as static method
     * call.
     * */
    switch ($name) {
      case ('FirstStatic') :
        echo "Static first dyanamic method and arguments are " . implode ( ',', $argument );
        break;
      case ('SecondStatic') :
        echo "Static 2nd method and the arguments are {$argument[1]} and {$argument[2]}";
        break;
      default :
        echo "Static method unhandled with the name {$name} and arguments are " . implode ( ',', $argument );
    }
  }

/* Method overloading -end- */
}

$phpOverloading = new PhpOverloading ();

echo 'Property overloading output -start-';
echo "<br /><br />";
var_dump ( isset ( $phpOverloading->dynamicProperty ) );
$phpOverloading->dynamicProperty = "new property injected";

echo "<br />";
echo $phpOverloading->dynamicProperty;
echo "<br />";

var_dump ( isset ( $phpOverloading->dynamicProperty ) );

unset ( $phpOverloading->dynamicProperty );

echo "<br />";
var_dump ( isset ( $phpOverloading->dynamicProperty ) );
echo "<br /><br />";

echo 'Property overloading output -end-';

echo "<br /><br />";

echo 'Method overloading output -start-';

echo '<br /><br />';
$phpOverloading->First ( 'one', 'two', 'three' );
echo "<br />";
$phpOverloading->Second ( '1', '2' );
echo "<br />";
$phpOverloading->UnHandledMethod ( '1', '2' );
echo "<br /><br />";

echo 'staic method overloading';
echo "<br /><br />";
PhpOverloading::FirstStatic ( 'one', 'two', 'three' );
echo "<br />";
PhpOverloading::SecondStatic ( '1', '2' );
echo "<br />";
PhpOverloading::UnHandledStaticMethod ( '1', '2' );
echo "<br /><br />";

echo 'Method overloading output -end-';

/*
 * final output is as bellow:

Property overloading output -start-

bool(false)
new property injected
bool(true)
bool(false)

Property overloading output -end-

Method overloading output -start-

This is the first dyanamic method and arguments are one,two,three
2nd method and the arguments are 2 and
Method unhandled with the name UnHandledMethod and arguments are 1,2

staic method overloading

Static first dyanamic method and arguments are one,two,three
Static 2nd method and the arguments are 2 and
Static method unhandled with the name UnHandledStaticMethod and arguments are 1,2

Method overloading output -end-

 *
 * */

You may check my other posts from my [ Blog ]

Please provide your feedback.

Thanks

That’s all for today.

BYE

Hello All

To day I will go through about coding standard which we must have to follow during development .

1.Pascal casing  should have to follow in Class & Method naming

example : public class TestClass{}; public void TestMethod(){};

2.Camel casing should have to follow in writing and local variable and parameter.

example : int localCounter;public void TestMethod(int counter){};

3. “_” should have to given while starting a private variable

example : private string _localAddress;

4. “I” character should have to place before the name of any interface.

example: interface IDataCollection{};

there are some vital information about coding standard here .

Bye