Thursday, 28 April 2016

Example : How to use ng-model to maintain and update state on the page ?


<html ng-app>
  <head>
   <script src="https://ajax.googleapis.com/ajax/libs
                /angularjs/1.3.3/angular.min.js"></script>
  </head>

  <body>
   <div>
      <label>Name:</label>
      <input type="text" ng-model="yourName" 
             placeholder="Enter a name here">

      <label>Age:</label>
      <input type="text" ng-model="yourAge" 
             placeholder="Enter age here">
      <hr />
      <h1>Hello {{yourName}} !!!</h1>
      <h4>Your age is {{yourAge}}</h4>
      <br><br>
      <h3>
                  <u>Arithmetic Operation</u>
      </h3>
      <hr />
      <label>Number1:</label>&nbsp;
      <input type="number" ng-model="num1" 
             placeholder="Enter first number">

      <label>Number2:</label>&nbsp;
      <input type="number" ng-model="num2" 
             placeholder="Enter second number">           <hr />
      <h4>Sum is: {{ num1 + num2 }}</h4>
      <h4>Sub is: {{ num1 - num2 }}</h4>
      <h4>Multiply is: {{ num1 * num2 }}</h4>
      <h4>Div is: {{ num1 / num2 }}</h4>
   </div>
  </body>
</html>

What are basic git commands ?


Configuration

Configure user name and email
git config -global user.name “SHAAN”
git config -global user.email shaan@gmail.com

Create new Local git repo
git init

Connect your local repository to a remote server (First time)
git remote add origin <server>

List all configured remote repo
git remote -v


Operations

Checkout a repo
git clone /path/to/repository
git clone username@host:/path/to/repository

List changed files at your side

git status

Add one or more files to staging 
git add <filename>git add *

Commit changes to head of the local repo
git commit -m “Commit message”

Commit all changes (to local repo)
git commit -a

Push changes to master branch of Remote repo
git push origin master


Branches

List all branches
git branch

Create new branch and switch to it
git checkout -b <branchname>

Switch to other branch
git checkout <branchname>

Delete branch
git branch -d <branchname>

Push branch to remote repo
git push —all origin

Delete a branch from remote repo
git push origin :<branchname>

Fetch the changes from remote repo
git pull

Merge a different branch in your branch
git merge <branchname>


Tagging

Create a tag
git tag 1.0.0 <commitID>

Push all tags to remote repo
git push —tags origin

Revert back the local changes
git checkout — <filename>

Wednesday, 27 April 2016

Apache Axis2 vs. Apache CXF vs. Spring Web services


Apache Axis2 vs. Apache CXF vs. Spring Web services

  • CXF and SpringWS supports Java
  • Axis2 supports Java, C, C++
  • Axis2 and CXF supports Contract-First and Contract-Last approaches
  • SpringWS supports only Contract-First approach
  • Apache CXF supports data bindings : JAXB, XMLBeans, JiBX, Castor, Aegis
  • SpringWS supports data bindings : JAXB, XMLBeans, JiBX, Castor, Xstream
  • Axis2 supports more data bindings : JAXB, XML Beans, JaxME, JaxBRI , ADB (Axis Data Binding)
  • Integration with Spring : Axis 2 (compatible) , CXF (better integration) , SpringWS (Much better)
  • OSGi support : Axis 2 (Not better) , CXF (better support) , SpringWS (better support)


  • Axis2 and CXF supports WS-RM but SpringWS doesn't support WS-RM


Apache CXF advantages over Axis2 and Spring WS

  • Support for the Tuscany implementation
  • High extensibility
  • More configurable features via API
  • Ease of development
  • Better performance

How to integrate github with Jenkins ?


Github plugin can be used to receive push notifications that can trigger a Jenkins job.

Install Github plugin

  • Open Jenkins home page and Login as Admin (if security is enabled)
  • Click manage Jenkins
  • Click Configure Jenkins
  • Go to Manage Plugins link on left side
  • Select Github plugin from available plugins
  • Click Download and Install
  • Restart Jenkins


Configuration of Github project in a Jenkins job




  • Open Jenkins home page
  • Select the job
  • Click Configure link on left side
  • Inside Source code management section, Enter URL of Github projecthttp://github.com/username/project
  • For authentication, provide username / password in advanced... options.


Receiving the push notifications from GitHub
  • Open Jenkins home page and Login as Admin (if security is enabled)
  • Click manage Jenkins
  • Click Configure System
  • In Github Web hook sectionselect auto-manage hook URLs

    OR
  • In Github Web hook section, select Manually manage hook URLs
  • Go to Github project page
    • In Service Hooks tab, select Post-Receive URLs hook
    • Add URL <root_URL_of_Jenkins>/github-webhook
  • Open Jenkins home page
  • Select the job
  • Click Configure link on left side
  • Select Build when a change is pushed to GitHub and Save.
  •  

How to integrate git with Jenkins ?


Plugin site : https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

Git can be used to checkout the code in Jenkins jobs using Git plugin of Jenkins.

Install Git plugin

  • Open Jenkins home page and Login as Admin (if security is enabled)
  • Click manage Jenkins
  • Click Configure Jenkins
  • Go to Manage Plugins link on left side
  • Select Git from available plugins
  • Click Download and Install


Configuration of Git repo in a Jenkins job

  • Open Jenkins home page
  • Select the job
  • Click Configure link on left side
  • Inside Source code management section, Enter URL of Git projecthttps://www.myrepo/git/projects/myproject.gitBy default, it will checkout all branches of the repository
  • To build a particular branch, provide branch name
  • For authentication, provide username / password in advanced... options.


Tuesday, 26 April 2016

Ant vs. Maven vs. Gradle


Ant

+ Simple to learn
+ Popular

- No convention ; Need to define the project layout (structure)
- XML becomes complicated and unmanageable for long term project

Use Ant when :

  • No need of dependency management
  • Quick development of project
  • Legacy project unfit for Maven convention


Maven

+ Dependency management

  • Just declare dependencies, Maven will download them over the network (Like, Ant+Ivy)
  • Also manage Dependencies of the dependencies (Transitive dependencies)

+ Has convention to write configuration ; No need to provide project structure
+ has a Life cycle

- Dependencies cannot handle well conflicts between different versions of same library
- Difficult to write complex scripts and customized tasks

Use Maven when : 
  • Product development, to manage multiple versions and branches 
  • Several teams working on dependent modules


Gradle

+ combines good parts of both tools
+ Life cycle like Maven
   Compile, Static analysis, Testing, Packaging and deployment
+ Doesn't use XML
+ Short and clear script

Git vs. SVN


DISTRIBUTED vs. CENTRALIZED
  • Git is distributed
  • SVN is centralized versioning system.

AVAILABILITY
  • If you cannot reach SVN server, you cannot commit the code.
  • In Git, local copy on your system is the repository and you can commit to it - Local Source Control

COMPLEXITY
  • Git is complex to use : 
    • "git clone" provides checkout of repository code
    • "git checkout" switches the branch
    • "git commit" commits teh code locally
  • SVN is much simpler to learn

FAST
  • Git is faster than SVN

USAGE
Git is preferred :  
  • When developers do not commit to master repository too often.
  • need better support for merging and branching.
  • for Open source projects
    • Fork the project for yourself
    • Commit the changes to your Fork
    • Ask the project owner to pull your changes