Tuesday, July 15, 2014

Basic git commands

  • git init
To create a new Git repository
git init
git init <directory>
  • git clone
Clone the repository in local machine
git clone <repo>
git clone <repo> <directory>
  • git config
Define author name, email for commits
git config user.name <name>
git config --global user.name <name>
git config --global user.email <email>

Example: 
git config user.name kien.nguyen
git config --global user.name kien.nguyen
git config --global user.email nguyenanhkien2a@gmail.com
  • git diff
View a change in details (line by line)
git diff <file>
git diff --cache
git diff --base <file>
git diff <source_branch> <target_branch>
  • git status
List files in staged, unstaged, untracked.
git status
  • git reset
Clear all local changes
git reset
git reset <file>
git reset --hard
git reset <commit>
git reset --hard <commit>
  • git add
Add a change to staging area, staging area will be used into commit
git add <file>
git add <directory>
git add .
git add *
  • git commit
Commit your changes in staging area to HEAD in local working repository
git commit -m "your message"

Commit all your changes in staging/unstaging to HEAD in local working reposiroty
git commit -a -m "your message"

Edit the last commit
git commit --amend
  • git log
View committed snapshots
git log
git log -n <number>
git log --oneline
git log --stat
git log <file>
git log -p
git log --author="<pattern>"
git log --grep="<pattern>"
  • git fetch
Fetch latest changes from remote repository
git fetch
git fetch origin
  • git pull
Fetch and update commits from remote repository into local working repository
git pull
  • git push
Push local working branch to remote repository
git push
git push origin <remote_branch>

Example:
git push origin master
  • git branch
List all branches in your local repository
git branch
  • git checkout
    Checkout a branch to working tree
    git checkout <branch>

    Tuesday, December 20, 2011

    Javascript objects

    http://www.comptechdoc.org/independent/web/cgi/javamanual/javawindow.html

    Wednesday, November 9, 2011

    Regular expression

    http://www.vogella.de/articles/JavaRegularExpressions/article.html

    Wednesday, October 26, 2011

    Simple Maven command

    Create a webapp:
    mvn archetype:generate -DgroupId=com.exoplatform.app -DartifactId=hello-strut -DarchetypeArtifactId=maven-archetype-webapp

    Create a portlet app:
    mvn archetype:create -DgroupId=com.exoplatform.app -DartifactId=hello-portlet -DarchetypeArtifactId=maven-archetype-portlet

    .
    |-- src
    | `-- main
    | `-- java
    | |-- [your project's package]
    | | `-- MyPortal.java
    | |-- jetspeed
    | | `-- web.xml
    | |-- resources
    | |-- webapp
    | | |-- WEB-INF
    | | | |-- tld
    | | | | `-- portlet.tld
    | | | |-- portlet.xml
    | | | `-- web.xml
    | | |-- help.jsp
    | | |-- maximized.jsp
    | | `-- normal.jsp
    | `-- index.jsp
    `-- pom.xml

    Monday, October 17, 2011

    Servlet Specification Notes

    1. requestURI = contextPath + servletPath + pathInfo
    Ex1:/catalog/garden/implements/
    - ContextPath(webapp): /catalog
    - ServletPath(servlet mapping): /garden
    - PathInfo(extra path): /implements/

    Ex2: /catalog/help/feedback.jsp and
    servlet mapping: Pattern: *.jsp

    - ContextPath: /catalog
    - ServletPath: /help/feedback.jsp
    - PathInfo: null

    Sunday, October 16, 2011

    Installing Jira server standalone in Ubuntu

    1. Download .bin file (ex: atlassian-jira-4.4.1-x32.bin) http://www.atlassian.com/software/jira/JIRADownloadCenter.jspa
    2. Run this .bin file and get some screens to setup port, address,... ex: 9090
    3. Run Jira server from installed folder: kiennguyen/atlassian/jira/bin/start-jira.sh

    Thursday, October 13, 2011

    Openssl commands

    - Create X509 certificate:
    openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem -out testkey.pem -subj '/CN=mytestkey'

    - Create a private key from Cert:
    openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM

    - Create public key from Cert:
    openssl rsa -in exokey.pem -pubout

    - To just output the public part of a private key:
    openssl rsa -in key.pem -pubout -out pubkey.pem