Friday, July 19, 2013

Ruby 'and' 'or' vs && , || precedence

Just like in maths :  Order of Operations - BODMAS   or

In general programming languages, && has higher precedence than || operator.

But in Ruby it is not like that as and or  have same order of precedence.

Lets see one example :

"a" || "b" && "c"  will be assumed as  => "a" || ("b" && "c")

output: "a"  ("b", "c" are never called) why as "a" is always true.

here && has higher precedence than ||

Lets see with and or operations

"a" or "b" and "c"  will be assumed as  => ("a"  or "b") and "c"

output: "c" 


Thursday, July 18, 2013

helpful GIT command aliases

[alias]
   st = status -sb
   ci = commit
   br = branch
   df = diff
   lg = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
   lg = log -p
   co = checkout
   cp = cherry-pick
   tree = log --graph --decorate --pretty=oneline --abbrev-commit --all
   pom = push origin master
   amend = commit --amend -C HEAD
   wdiff = diff --color-words
   standup = log --since yesterday --author jreddy@reddyonrails.com
   rst = reset --hard
   pr = pull --rebase

You can also add aliases like so, and they will get added to your .gitconfig file automatically.
$ git config –-global --edit