Friday, March 18, 2011

GIT repository

Setting up GIT in Linux

Step 1 : Add user account in github.com

Step 2 : Install GIT and GIT GUI in your machine.

Step 3 : Then open the terminal and type git gui, a popup window will come.
             From that select Help -> Show SSH Key, copy the key and add it to your GITHUB account.

Step 4 : There are 2 types of repositories in GITHUB
             1. Public
             2. Private
             In your dashboard Repositories will be listed.

Step 5 : Select a repository
             There will be SSH url copy that and go to your machines web folder in your machine through
             Terminal where you want to create a copy of the project.

Step 6 : Then type  :  git clone {sshurl} here ssh url is the url copied from the GITHUB Repository.

Step 7 : When this command is executed the clone from the repository is generated in your local machine.
            Then browse to the project folder.

Step 8 : If you want to create a branch (i.e. view)  in your machine which will not affect the MASTER (i.e. copy of the project from server)
            use git branch branch_name will create a new branch. Then use git checkout branch_name will checkout into the branch.
            Now you can work on your own branch.

Step 9 : After working on your branch, if you need to add some of your changes to the git repository use git gui command inside your project folder.
            A popup comes with 3 frames. Left most one will be the files that has been changed based on the master copy.
            On selecting the file it shows the changes that you have made on the file based on the Master copy on the right side frame(biggest).
            On the right side there are 2 sections : one is the files that are been changed. On double clicking on the files it will move to the staged section
            i.e. files to be merged with the master copy. Then on the right side bottom there is section for specifying your comment on the updation.
            After adding the comment press the commit button. Before merging the files into the master copy you have to stack (buffer) the changes that
            you have made for other files which are not to be merged to the master copy.

Step 10 : use git stash to stack your local changes then checkout to your master copy using git checkout master. Then take all the updates from server
            using git pull. Then merge the updates that you have committed to the master copy using git merge branch_name.
            Now you have made the changes to the master and can be pushed to the github repository by using git push

Step 11 : Then is you need your local changes to be applied back, checkout to your branch using git checkout branch_name,
            now you have to apply the updates obtained from the github repository by git rebase master (which resets your branch to the master copy).
            Now you need to apply your local changes which has been stacked before merging, by git stash pop, again you can work separately on your local copy.

Zend assigning clean values

Assigning clean values

 

$entityFilter = new Zend_Filter_HtmlEntities();
$urlFilter = new My_Filter_Url();
$this->view->title = $this->escape("Seite 1");
$this->view->headline = $entitiyFilter->filter($this->getRequest()->getPost('link'));
$this->view->link = $urlFilter->filter($this->getRequest()->getPost('link'));

Monday, March 7, 2011

Jquery Validation Check for username with letters, numbers and dashes

$(function () {  $.validator.addMethod("nameRegex", function(value, element) { return this.optional(element) || /^[a-z0-9\ \'-]+$/i.test(value); // letters, digits,',- and space. }, "No special characters please.");  $("#signupForm").validate({ rules: { "login": { required: true, loginRegex: true, } } }); });

 

Using Zend Auth Adapter for login

Add this in your action controller

$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter()); $authAdapter->setTableName('users'); $authAdapter->setIdentityColumn('Email'); $authAdapter->setCredentialColumn('Password'); $authAdapter->setIdentity($email); $authAdapter->setCredential($password);  $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if (!$result->isValid()) { $auth->clearIdentity(); return 'Oops check your password or maybe you havent confirmed your email or forgotten your password. Click here to resend~1'; }