Monday, November 7, 2016

To find Nth maximum salary

To find nth max salary using correlated query

Saturday, October 22, 2016

DB details from properties file using Java


Reusuable class to get db details from properties file.
Now the helper function that reads from the property file and return the value from the property file.

Sunday, September 25, 2016

git commands

List of git commands that we might need when working with git.

In local machine after installing git:

git log #Log of our repo

git clone repo #To take a copy from repository in git hub to our local machine

git checkout <commitid> #To a detached headstate

For details on detached head state  please check this link

git diff <first commit id> < second commit id>

git init

git status

--Commands to add files to staging area

git add 'filename1'
git add 'filename2'

git status

git commit -m "Comment"

git diff <workingdir> <Staging dir>

git diff --staged #to diff between staging and repo

git reset --hard #to revert to previous commit ,to make master point to some previous commit

Branches:

git branch <branch-name>
git checkout <branch-name>

git log --graph --oneline branchname branchaname

[git checkout  -b <branchname>

equals to following two commands

git branch <newbranchname>
git checkout <newbranchname>]

Merge :

git merge <b1> <b2>

Diff between a commit and parent with out knowing it's parent id

git show <commitid>

Delete a branch:

git branch -d <branchname>

Remote branch:

git remote  add origin url
git remote
git remote -v

git push origin master

Pull branch:

git pull origin master

git log  #to update the remote to local and check if updates happens.

Fork a repo:

Merging remote changes:

If remote and local has changes on same file.During conflicts, use fetch.

git fetch origin
git merge master origin/master

origin/master points to the remote repository on git hub

Pull request commands:

git branch newbranchname
git checkout newbranchname

git checkout master

git add 'filename'
git commit
git push origin <newbranchname>


Clone Remote and cross -repo conflicts:

git remote add upstream 'original repo'
git checkout master
git pull upstream master

git checkout 'anotherbranch'

origin - forked repo
upstream - original repo

Merge newbranch with master

git merge master 'anotherbranch'

git add
git commit
git push origin 'anotherbranch'

Delete a remote branch:

git branch --remote
git push origin --delete <branch-name> 


List of Programming languages from A- Z

A - Ada
B - Bash
C - C
D - D
E - Erlang
F - Fortan
G - go
H - Haskell
I - Icon
J - Java
K - K
L - Lisp
M - MATLAB
N - NSIS
O - Octave
P - Python
Q - Q
R - R
S - Scala
T - Tcl
U - Unix
V - Verilog
W - Whitespace
X - xBase
Y - Yorick
Z - ZShell

Project Euler #8 - Largest Product in a series - Python

n = map(int, raw_input().split()) #To read the number of digits and 
                                  #k consecutive numbers
num = int(raw_input()) # To read the digit
#print n[1]
#print num
stri = str(num)
product = 0
for i in xrange(len(stri) - n[1] + 1):
        temp = 1
        k = i
        for j in range(n[1]):        
            temp = temp * int(stri[k])
            k = k + 1
           
        if(temp > product):
            product = temp
            #print product
print product