Showing posts with label push. Show all posts
Showing posts with label push. Show all posts

Monday, December 16, 2013

Array in javascript - Basics

Declare an Array

var arr = new Array(); // Declaring an empty array.

var arr = [5,'sky blue','test']; // Simple array with custom values and default keys.
Structure: arr( [0] => 5,
                       [1] => sky blue,
                       [2] => test
                     );

var arr = [ {'id':23}, {'name':'green'}, {'category':'color'} ]; // Simple array with custom values and custom keys.
Structure: arr( [id]  => 23,
                       [name] => green,
                       [category] => color
                     );

var arr=[ {'id':23,'name':'green','category':'color'}, {'id':24,'name':'mango','category':'fruit'}, {'id':25,'name':'rose','category':'flower'} ]; // Multidimensional array with custom values and custom keys.


Access an Array

// Now consider arr is an array, which had we already created.

console.log(arr); // Display array in JavaScript console.

arr['new']='something'; // Add a new value with specific key.

arr.push('somemore'); // Add a new value with out specific key.

arr.pop(); // Remove last element from array.

arr.shift(); // Remove first element from array.


For Each in Array

<script type='text/javascript' src='js/jquery.js'></script> // JQuery need for use $.each function
var arr = [5,10,15];
$.each(arr,function(key,value){
console.log(key+' : '+value);
});
//Out put:
0 : 5
1 : 10
2 : 15


Tuesday, June 18, 2013

Get array input value in jquery

//js file

var tmp_array=new Array();
 $('input[name="search\\[\\]"]').each(function(){
tmp_array.push(this.value);
});

Friday, June 7, 2013

Make GIT on local

GIT basically used for listen our code changes in step by step. And we can revert back to any of these changes. This means  GIT does not totally backup our code for every changes, it just saving changes not all codes. From my point of view, this is the most short description for GIT.

For more clear details about GIT visit : http://git-scm.com/documentation

Now come to the point, We need to make GIT on local. GIT has one common stored are area where all our git data are saved. You may call this as GIT BARE REPOSITORY. And has one are more stored area which is used by programmer where they writing or changing coding. You may call this as GIT WORKING REPOSITORY.



Now you can understand our job easily, that is we need to make one GIT bare repository and more than one GIT working repository, and make a connection between them. That is changes on working repository need to saved or tracked in bare repository.

Reference: http://try.github.io/levels/1/challenges/1
(Most of the matter I noted follow are, learned from above link.)

Step 1: Make one directory for our whole work(called "git").

$ sudo mkdir git
$ sudo chmod 777 git (Changing file permissions. It may unnecessary)

Step 2: Make 'server' and 'client1' directory inside the folder "git".(Note: For only easy understanding I mentioned bare repository us 'server' and working repository us 'client1'. But there is no server and client in GIT.

$ cd git
$ sudo mkdir server
$ sudo chmod 777 server
$ sudo mkdir client1
$ sudo chmod 777 client1

Step 3: Setup 'server' folder as bare repository.

$ cd server
$ git init --bare

Output:
Initialized empty Git repository in /var/www/git/server/bare/.git/

Step 3: Setup 'client1' as working repository.

$ cd ..
$ cd client1
$ git init

Output:
Initialized empty Git repository in /var/www/git/client1/.git/

Step 4: Check status (Feel free to check status on any time, It not affect code.)

$ git status

Output:
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

Step 5: Make one index.html file in 'client1'.  Content of index file is follows

<html>
<head>
<title>Git Test</title>
</head>
</html>

Step 6: Again check status

$ git status

Output:
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# index.html
nothing added to commit but untracked files present (use "git add" to track)

Step 7: Now add this untracked file to stage. (Can check for "git status" after add to know file moved from untracked to stage)

$ git add index.html

Step 8: Now commit this add

$ git commit -m "first commit"

Output:
[master (root-commit) 3bdae52] first commit
 Committer: Ramasamy <ramasamy@dcmanilaptop-HP-430-Notebook-PC.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 9 insertions(+)
 create mode 100644 index.html

Step 9: This is important step so do carefully.

$ git remote add origin ../server/

//On above code 'origin' is a name of our repository. You can use anything. And last one is path to repository.

Step 10: Now push 'client1' datas to 'server'.

$ git push -u origin master

//Here origin is name of repository we made previously, and "master" is the name of  branch under repository. Default is pointing branch is "master". And "-u" used for remember current repository and branch name. So we need not give these when we push again.

Output:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 314 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To ../server/
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

You can make more clients like we made 'client1' and make connection and interaction with them.

Graphical and live Demo avail here: http://try.github.io/levels/1/challenges/1

Thats all... We successfully made GIT on local.






Thursday, May 30, 2013

Git Basic Commands

git status                                         -    display changes
git checkout .                                  -    clear all files from last edit
git checkout <file> <file>                -    clear specified files last edit only
git pull                                             -    pull all files from server
git diff > <file>                                 -    write whole diff on new file
git diff <file> > <file>                       -    write specific file diff on new file
git diff <file> <file> > <file>             -    write more than one files diff on new file
git add .                                           -    add all files to client from buffer 
git commit -m “msg”                       -    record local changes to local repository
git push                                           -    push the local repository recorded code(done by git commit) to server repository.
git add <file>                                   -    add untracked file to buffer
git diff --cached >> <file>               -    append new file changes to exist diff file.
git log                                              -    List commits
ctrl l or clear                                   -    clear screen
git diff --diff-filter=D >> <file>         -    Append all deleted file details to diff
git help <verb>                               -    Detail about specific verb
git reset HEAD <file>                     -    Move file from staged to unstage (Note: When new file added and send for push by       diff(used --cached), and if you try to pull from repository first you use ‘git reset HEAD <file>’ and then delete that file manually, then only you can pull.)
ctrl + ins (or) ctrl + shift + c           -    Copy
shift + ins (or) ctrl + shift + v         -    Paste
Q                                                    -    Go to new cmd
ctrl + c                                            -    Stop / Cancel current process
patch -p1 --dry-run < <diff_file>    -    List affecting file if we add or integrate specific diff file.
patch -p1 < <diff_file>                   -    Add or integrate specific diff file
git clone https://site.com/dir/project.git <localfolder> - Clone git from server using https
(Note: First open terminal and go to local folder where you want to pull and use above command to copy/ clone project to local.)
git checkout <branch_name>      -    Will switch to specified branch.
git branch <branch_name>          -    Will create a branch.
git checkout -b <branch_name>  - Will create and switch to branch at the same time.

Note: Be care full when using red marked comments above. Because it may affect your codes permanently, and most of the time will only used by admin of the project.

Learn JavaScript - String and its methods - 16

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>String and it's methods - JS...