Home Navigation

Thursday 29 September 2016

DB2 Some useful tips

Check view Definition/Contents:

select name, cast(statement as  varchar(8000)) from SYSIBM.SYSVIEWS where name={VIEW_NAME} for read only;

DB2 Dummy table: sysibm.sysdummy1

DB2 optimize query to control result set:

- with ur for read only
- fetch first n rows only
- optimize for 1 row

log4j tips

Pattern tokens to avoid:


C For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass".
WARNING Generating the caller class information is slow. Thus, use should be avoided unless execution speed is not an issue.
F Used to output the file name where the logging request was issued.
WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue.
L Used to output the line number from where the logging request was issued.
WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue.
M Used to output the method name where the logging request was issued.
WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue.

Sample pattern:

[%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%t] - %m%n


Levels:

Levels used for identifying the severity of an event. Levels are organized from most specific to least:

  • OFF (most specific, no logging)
  • FATAL (most specific, little data)
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE (least specific, a lot of data)
  • ALL (least specific, all data)

Typically, configuring a level in a filter or on a logger will cause logging events of that level and those that are more specific to pass through the filter. A special level, ALL, is guaranteed to capture all levels when used in logging configurations.

Two logger appender Example:

# First you set the level of logger and then followed by appender name
log4j.rootLogger=WARN, file
log4j.logger.progress=DEBUG, progressAppender

#disconnects the arrow from a logger up to its parent
log4j.additivity.progress=false

#disconnects the arrow from a logger up to its parent
log4j.additivity.progress=false

#Progress file appender
log4j.appender.progressAppender=org.apache.log4j.RollingFileAppender
log4j.appender.progressAppender.File=${logname}.txt
log4j.appender.progressAppender.MaxFileSize=6MB
log4j.appender.progressAppender.MaxBackupIndex=5
log4j.appender.progressAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.progressAppender.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%t] - %m%n

#Error file appender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${logname}.log
log4j.appender.file.MaxFileSize=6MB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%t] - %m%n


Tuesday 27 September 2016

Dynamic programming intro

Dynamic programming is a method for solving a complex problem by breaking it down into a collection of simpler subproblems, solving each of those subproblems just once, and storing their solutions and reuse them. It is a powerful technique that allows one to solve many different types of problems in time O(n^2) or O(n^3) for which a naive approach would take exponential time.

Application of dynamic problem:

  • Tower of Hanoi
  • 0/1 Knapsack problem
  • Matrix chain multiplication
  • Longest common subsequence
  • Traveling salesmen problem

Thursday 22 September 2016

Common errors in maven projects

 1. -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
  • To get rid of this issue go to window->preference->Installed JRE’s and click the default one and then click on edit
  • Type the below text in Default VM    
    -Dmaven.multiModuleProjectDirectory=%M2_HOME%

Scrum framework

Definition:
Iterative, incremental, cross-functional, selft managing, lean thinking and empirical process control. Not a methodology

Appropriate:
High risk
complex
large project

Avoid:
if waterfall suits current needs

Impediments:
Habits of waterfall
Predictive thinking of last 20/30 years
Cut quality to meet dates

Tool:
Finds all deficiency and impediment
It puts the stress on product development to improve its engineering skills
The Gap between current practice and target practice is a measure of incompetence and competitive risk.

Iterative and incremental process has to be done in every iteration

Notes:
Modifies/partially implements scrum restricts competence of scrum
Not a methodology, Efforts center on the changes in the enterprise that is needed
People are not resource and managers aren't bosses

Change:
Should led from the top and requires change by everyone in the organization


Working agreements rules

  •  Public and visible
  • Collaborative ( created by all, don't impose)
  • Shorter
  • Updated frequently
  • Violations

    • Core hours
    • Headphone time
    • Product owner availability
    • Daily standup  time
    • Equal voice and respect
    • Definition of done
    • Prepare for demo


Team size size: 7+/-2


Roles

Scrum Master
-Catalyst of team and organization effectiveness. Servant leader. Keeper of the agile flame. Master of no one. - Serve and protect the team - Remove obstacle and impediment - Observant, coach, communicator, cheerleader, motivator - Jiggle - Nurture ( cherish) - Owns the scrum process, help team to grow, deliver more value
Product Owner
- Collaborative with customer and the team to understand WHAT? - Vision and roadmap. Ensure right product is building - Provide well formed backlog and make priority - Maximize return on investment - Decision maker - Maximize return on investment - Owner of product backlog Development Team
- plan the work - Estimate the work - Co-located - Continuous improvement - Building high quality product


Events/Activities

Sprint planning - Commit to stories for the next sprint
Sprint Review
Sprint Retrospective
Daily Scrum
Product Backlog Refinement/Story time/Backlog grooming

- Writing acceptance, adding, changing, removing, splitting and estimating
- 10% of the time of sprint, its an ongoing activity
 - Should have 3-4 sprints worth of story
- Product owner and few team members
- Last about 1 or 2 hours, frequency every few sprints

User story


  • A user story is a small vertical slice of functionality.
  • Small a few days of effort
  • Not a description of the component or technical need.
  • Starting point of ongoing collaboration
  • Three components of user stories:
    • Card [Title/Description],
    • Conversations [Story details, one or more test confirmation]
    • Product owner is the main participant, may include stakeholders, tester, developer
  • Scrum team often allocate 10% of their time
  • Confirmations [Acceptance Criteria]
  • Format -1: As <a User> I want to <do something> so that <value statement>
  • Format -2: As a <Role> I want <business value> by <Method/requirement>
  • Format -3: In order to <Achieve some value>, as a <Type of user>, I want <Some functionality>


   INVEST

  • Independent
  • Negotiable
  • Valuable
  • Estimable
  • Sized
  • Testable
Sprint Artifact:

Product backlog:

what controls what gets build. must be visible all the time. Product owner is the owner. Ready for deployment:
  • Split so 5-10 can be completed per sprint
  • Include basic acceptance criteria
  • Estimate enough work for 3 sprints
Waiting for refinement:
  • Large split so 1/2 can be completed for sprint
  • Estimates are large
  • 5-6 Additional sprints worth
The future:
  • Multiple sprint in size
  • If estimated very large
  • Out as far as 6 months
Facts:
  • One scrum team is better to maintain a single product backlog for multiple product.
  • Multiple scrum team is better to maintain a single product backlog for single product. So they can see the common goal.
  • Many effective team use story map.
Controversy:
  • Technical items like ( CI, tyding up classes, patch update). Team should maintain a list and set aside some time every sprint
Sprint Backlog:
The list of product backlog that are committed for the next sprint.
Product Increment:
       The product that build in the sprint. meet the definition of done and shippable.

Not Required as part of scrum (Optional):

  • Task : PBI breaks down into task of < 1
  • Release Burndown : Amount of work remaining agains Vs number of sprints
  • Sprint Burndown : Progress within a sprint. Often mis-used


GIT Commands

Create empty repository:
$ssh user@host git init --bare /path/to/repo.git
  
Clone:
$git clone ssh://user@host/path/to/repo.git
  
Reset:
Remove the file from staging
$git reset [file_name] 

To reset the staging are just use the below command
$git reset


Status:
shows the files Changes to be committed, Changes not staged for commit, Untracked files
$git status

This allows previewing a commit to be made.
$git status -v  


Add:
$git add -A                          //stage all ( new, modified, deleted) files
$git add .                             //stage all ( new, modified, deleted) files
$git add --ignore-removal . //stage new and modified files only
$git add -u                           //stage modified and deleted files only

Diff:
Shows the changes between the working directory and the index. This shows what has been changed, but is not staged for a commit.
$git diff

Shows the changes between the index and the HEAD (which is the last commit on this branch). This shows what has been added to the index and staged for a commit.
$git diff --cached

Shows all the changes between the working directory and HEAD (which includes changes in the index). This shows all the changes since the last commit, whether or not they have been staged for commit or not.
$git diff HEAD

This shows the list of files what have been added to the index and staged for a commit.
$git diff --cached --name-only

Note: use --name-only options with diff if you just want to see files name.

Modify commit message:
amend staged commit statement
$git commit --amend -m "i missed mentioning these changes ...."

Branch:
Create new branch
$git checkout -b [branch-name] master // -b option tells to create a new branch.
push to remote
git push -u origin [branch-name]

Using git branch -r lists all remote branches and git branch -a lists all branches on local and remote. These lists get outdated though. To keep these lists up-to-date, run
$git remote update --prune

which will update your local branch list with all new ones from the remote and remove any that are no longer there. Running this update command without the --prune will retrieve new branches but not delete ones no longer on the remote.
You can speed up this update by specifying a remote, otherwise it will pull updates from all remotes you have added, like so
$git remote update --prune origin

List all remote branch
$git branch -r
remote show shows all the branches on the remote, including those that are not tracked locally and even those that have not yet been fetched.
$git remote show origin

Rename Branches:

Rename your local branch.

If you are on the branch you want to rename:
$git branch -m new-name

If you are on a different branch:
$git branch -m old-name new-name

Delete the old-name remote branch and push the new-name local branch.
$git push origin :old-name new-name

Reset the upstream branch for the new-name local branch.
Switch to the branch and then:
$git push origin -u new-name

Rebase:
$git pull --rebase origin master
  
Git log:
$git log --graph --all --oneline
$git log master..branch-X      # That will show you commits that branch-X has but master doesn't
$git log --oneline --decorate
  
Revert by commit number:
$git revert -m 1 [commit-hash]
  
Merge:
$git checkout feature
$git merge master

Remove from staging:
$git restore --staged .
$git restore --staged <individual_file>

Useful maven commands

Create maven project command prompt:

In a terminal /command prompt, navigate to the directory you want to create the project. Type the below command :


mvn archetype:generate -DgroupId={project-packaging}
   -DartifactId={project-name}
   -DarchetypeArtifactId=maven-archetype-quickstart
   -DinteractiveMode=false

Change the version from command prompt:

mvn versions:set
mvn versions:set -DnewVersion=0.8.1

Create git initial repository

Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license or gitignore fields.

 git init
git add .
git commit -m "initial commit"

git remote add origin <remote repository URL>
# Sets the new remote
git remote -v
# Verifies the new remote URL

git pull origin master
git push -u origin master

Linux/Ubuntu environment variable setup location

/etc/profile is global configuration for all user if you set environment variable

.bash_profile applicable for specific user  ~/.profile

use .profile for ksh and .bash_profile for bash. Since most configuration directives recognized by ksh are also recognized by bash, some people who use both shells find it easier to just create a symlink between the two.

There is also the matter of .kshrc, which is actually not a file that the korn shell specifically looks for. It's just a practical convention, and many people use it, and then source the file from inside their .profile. Otherwise, ksh will not automatically read it.