Wednesday, June 29, 2016

Git Cheatsheet


To create a branch and switch to it at the same time, run the git checkout command with the -b switch:
git checkout -b <branch_name>
Same as:
git branch <branch_name>

git checkout <branch_name>

To check the current status of the branch.
git status
To add the changes - from the root directory - will make all red into green, if you are using git-shell

git add .
To commit your changes - use "-m" - to add message
git add -m "committing for the first time"
To do a git push into your branch

git push origin HEAD:branch_name 
To rename a branch
If you want to rename a branch while pointed to any branch, then use:
git branch -m <oldbranch> <newbranch>
If you want to rename the current branch, you can do:
git branch -m <newbranch>

To delete  a branch 

deletes the branch locally, use -D to force delete.

git branch -d <brnach_name>
 To delete it form remote:

 git push origin --delete <branchName>


Saturday, April 30, 2016

Larry Wall: 5 Programming Languages Everyone Should Know



You should see this video if you are starting your career in programming or you are interested in programming. :)


Tuesday, December 29, 2015

Resolving Unsupported major.minor version 51.0 error

Have came across this error on number of occasions.

Unsupported major.minor version 51.0 error

The reported major numbers are:
J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45
(Source: http://en.wikipedia.org/wiki/Java_class_file)



This java error comes, if you are compiling your code in java 1.7 and running it in JRE of lower version. To fix this, either you run the java class in a higher version (1.7 in this case) or instruct the compiler to create a 1.6 complaint byte code.

So, major number's represent the compiler version of the compiled bytecode here. And, may be, minor means, the JRE version you are trying to execute it in. (That's my analogy, I may not precise here, but it works for me, to recall.)
 
Fixing it in Ecplise project:
This can be done in eclipse , by right click the on the Project folder => Properties. Then choose compiler option => choose 1.6.

Fixing it in ItelliJIdea project:
File => Settings->Compiler => Java Compiler => Choose 1.6 under the Project byte code version drop down

There is a interesting story behind the convention of these numbers. If you are interested to read about it, you can find it here : James Gosling private communication to Bill Bumgarner (Source Wikipedia)





Thursday, December 24, 2015

Considering migration to cloud? Here are some tips and lesson learnt.

Recently, I was involved in migration to Openshift based cloud environment (enterprise version). We were migrating some of the apps based on the tech stack Java/JEE and back-end as oracle.

Though my organization has facilitated a dedicate infra support team, such migrations are still never easy to deal with.

Here are some of the lessons learned and point to consider if you are planning to place your apps into the cloud or, for that matter a new infra.

Do not show off and become the first one ever to do it in your company. You can be applauded, but might as well have to spend quite a few sleepless night depending upon number of switches you are turning on in the production environment.

Get a free ride or just walk in park. Get your feet wet by writing a simple app or a few servlets in a trial or evaluation server. Or, just watch someone help video/help manuals.

Talk to people who are doing the same thing in your company and as and when situation arise help them to get thru some technical issue or problem. The reward comes when you get stuck. :)

Housekeeping time. Remember, this is best time to get rid of your technical debts or any refactoring or code cleanup plans you had been keeping in the back burner  due to schedule crunch.


Analyze the impacts properly while committing yourself for the migration. You might not be knowing all the small little dependency. Following are some of the important stuff to lookout for:
  • DB Connection pooling code
  • Legacy code
  • Utilities like sending mails
  • Codes that reads a file like image or properties, from the codebase or the file system
  • Logging mechanism
  • LDAP Connections
  • Any 3rd party https calls that needs to be white-listed or needs to be added into 
  • Any other code that are based on the environment (for example, server provided API/tool etc.)
  • And last but not the least, static URLs which refers to your application 

Keep moving. When you are stuck on one particular issue, don't keep working on the same for long. Move ahead, solve the other small hanging ones. At the same time, keep following up with the support or any kind of help you can seek from a larger community. Usually, these are some small screws, which we some times just don't realize ourselves until may be, the very next morning. So, don't worry. Stay calm.

I think, these are some basic yet very relevant points I can tell from my experience. In case, you have some story or comment related with this, please do leave a comment.

Good luck in case you are into a migration phase and stumbled on this blog post. :)

Wednesday, September 2, 2015

Facade Design Pattern - A brief note

What is Facade Design Pattern?


Facade, pronounced as fuh-sahd, originated from french façade and italian facciata, meaning the face of a building, esp the main front or a front or outer appearance.

Lets see what it means in the world of design patterns.There are two important part of the problem it addresses:
a) The subsystems within a system 
b) Interaction between subsystems of two different systems. 

Sometimes the interaction becomes so complex, that we need to create a layer abstraction which can help in achieving simplicity by introducing simple interface to communicate.


Definition

Now lets see the official GoF definition, Facade Pattern: a single class that provides a unified interface to an entire subsystem.

Use case or example of Facade


There are many use case if we look through the interactions between various systems and their components. One such example is the interaction that happens between various components in Supply Chain Domain. The below image explain one such interaction. Although this is not exact interaction but this pretty much explains the crux of Facade.

Wednesday, June 18, 2014

Deprectaed and Abandonened...

Well, this is a slightly off technical discussion. However, it is nice and interesting to take a note of what software industry uses the word for something which is not going to be there anymore. These words differs in the context they are used.

Below are some common used words, in no particular order.

Deprecated: This is something which we often see while using  a programming language or a framework, where some methods/members are deprecated, meaning they are either no longer used, or they are replaced by some other methods/members.

Obsolete: Obsolete is word which people use to refer to something very old, such as a process or methodology which was relevant few years back, but not recommended any more or replaced by some better relevant process or methodologies or technique.

Withdrawn: For example, some product developers may withdraw BSD License, and provide their product with LGPL license, which is little more strict license in open source world.

Decommission: Lets say an enterprise has started to switch over to a new version control system or to a new version of RDBMS. Then, once the transition happens the old system are usually decommissioned.

And, there are some more:
  • uninstalled
  • discontinued
  • deactivated
  • unsupported
  • EOL (end of life)
  • Sunset
  • Dead (We witnessed an interesting discussion by some industry stalwarts likes of David, Kent and Martin on is TDD dead just a few weeks back )

Any other words comes in your mind? Please leave your comments :-).

Wednesday, June 4, 2014

Unix Tip: Working with CSV file in Unix


One of the unix problem I worked recently, thought its worth sharing.
The problem required to query over csv files in unix, like we query database using sql.
So, these commands work quite like SQL. :)

Requirement:

To get the first record for where 2nd column is null, that is, emp_name has been left blank for the below input file content.

Input File Name:

test_data.csv [1]

Input File Content:

employee_id,emp_name,emp_age
234,Ram,27
235,Shyam,21
236,Mohan,40
237,,25

Command:

sed 's/,,/,NULL,/g;' test_data.csv | awk -F, '$2 ~/NULL/'  | sed 's/,NULL,/,,/g;' | head -n 1

Description:


- sed 's/,,/,NULL,/g;' test_data.csv : replaces all empty values with the string "NULL"
- awk -F, '$2 ~/NULL/' : finds all the values where 2nd column is NULL, -F option is used for defining field separator
- sed 's/,NULL,/,,/g;' : reverts back all the NULL to empty values
- head -n 1 : prints only the first record, if you remove this you will get all the records. [2]



Other examples:

1) Get all employees age greater then 20

sed 's/,,/,NULL,/g;' test_data.csv | awk -F, '$3 > 20' | sed 's/,NULL,/,,/g;'

2) Get all employees whose employee_id is equal of 234

sed 's/,,/,NULL,/g;' test_data.csv | awk -F, '$1 == 234' | sed 's/,NULL,/,,/g;'

3) Get all employees whose employee_id is less than or equal to 235

sed 's/,,/,NULL,/g;' test_data.csv | awk -F, '$1 <= 235' | sed 's/,NULL,/,,/g;'


--------------------------------------------------------------------------------------------
[1] CSV: A CSV file contains comma separated values and can be easily created/edited with Microsoft Excel, almost like normal excel files.
[2] In case we don’t need entire row, we can also use cut command here to get only one field or a few fields

Prototype

Prototype is another creation pattern. Intent:  - Intent is to create objects by cloning existing instance  - Specify the kinds of obj...