Wednesday, November 29, 2017

Copying Files between Linux Computers



https://www.pks.mpg.de/~mueller/docs/suse10.2/html/opensuse-manual_en/manual/sec.filetrans.copy.html


Example using cygwin and scp :

//===The following command will copy  20171031_mule_3.4.1_1.tar file from stg-loginjpe1101z.stg.jp.local to local computer
 scp   ts-islammdsh01@stg-loginjpe1101z.stg.jp.local:/home/ts-islammdsh01/20171031_mule_3.4.1_1.tar /cygdrive/c/Projects


//==The following command will copy  2test_copy_sharif.txt file from local computer  to stg-loginjpe1101z.stg.jp.local
scp /cygdrive/c/Projects/test_copy_sharif.txt ts-islammdsh01@stg-loginjpe1101z.stg.jp.local:/home/ts-islammdsh01

Thursday, September 28, 2017

Java code coverage tool for eclipse

Overview : 

In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.

In this article we will see how we can generate code coverage report using tools in eclipse . There are number of tools for eclipse that we can use to generate code coverage report :


EclEmma : 
EclEmma is a free Java code coverage tool for Eclipse, available under the Eclipse Public License. It brings code coverage analysis directly into the Eclipse workbench:
  • Fast develop/test cycle: Launches from within the workbench like JUnit test runs can directly be analyzed for code coverage.
  • Rich coverage analysis: Coverage results are immediately summarized and highlighted in the Java source code editors.
  • Non-invasive: EclEmma does not require modifying your projects or performing any other setup.

How to install  EclEmma : 

There are number of ways we can install EclEmma to eclipse but in this article we will see how to install EclEmma using update site.  The steps are very easy :


use the following update site url in the ellipse install dialog
 http://update.eclemma.org/  and follow the instruction 

Help >> Install New Software 






After successfully installing the EclEmma eclipse plugin ; now it is time to see the coverage report:

Right client on project and click Coverage As > JUnit Test



Running the above command execute all the JUnit test cases and generate Code Coverage report in the coverage view: 



if you cannot see the find it from Window >> Show View >> Other..


Export the Report to local disk :

You can export the coverage report for later use: 


Click the index.html  from the exported files, your will see a coverage report like blow :


Now you can dig down you report!



Thursday, August 3, 2017

How to Read XML in Java – (DOM Parser)

In this Example I will demonstrate how to read and modify xml file using DOM parser:

Step 1. Read an xml file from disk or project directory
Step 2. Build an xml document form the xml file
Step 3. Retrive and update xml element and attribute

Course.xml file

       


<?xml version="1.0" encoding="UTF-8"?>  
<courses>     
   <course category="JAVA">  
      <title lang="en">Learn Java in 3 Months.</title>  
      <trainer>Sonoo Jaiswal</trainer>  
      <year>2008</year>  
      <fees>10000.00</fees>  
   </course> 
    <course category="XML">  
      <title lang="en">Learn XML in 2 Months.</title>  
      <trainer>Ajeet Kumar</trainer>  
      <year>2015</year>  
      <fees>4000.00</fees>  
   </course>    
</courses> 
       
 




           import java.io.File;  
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; 

/**
 * @author Md. Shariful Islam
 
*/
public class XMLDOMTester{

 /**
  * @param args
  */
 public static void main(String[] args) {
  
  //String filepath = "c:\\Course.xml"; 
  
  File xmlFile = new File("Course.xml");
  boolean exist = xmlFile.exists();
  System.out.println(exist);
  
  
  DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder;
  try {
   docBuilder = docFactory.newDocumentBuilder();
   Document xmlDocument = docBuilder.parse(xmlFile);
   
   //optional, but recommended
   //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
   xmlDocument.getDocumentElement().normalize();
   
   String rootElement =  xmlDocument.getDocumentElement().getNodeName();
   System.out.println("Root element :" +rootElement);
   
   NodeList nList = xmlDocument.getDocumentElement().getChildNodes();
   
   for (int i = 0; i < nList.getLength(); i++) {
    
    Node node = nList.item(i);
    
    if (node.getNodeType() == node.ELEMENT_NODE) {
     
     String nodeName = node.getNodeName();
     System.out.println(nodeName);
     
    }
   }
   
   
   
  } catch (ParserConfigurationException | SAXException | IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  

       
 

For modifying XML file Please read the follwing blog

how-to-modify-xml-file-in-java-dom-parser


Friday, April 21, 2017

Basic linux commands

I this blog post i am going to write some basic Linux command that every Linux user should know :

but before digging in to the commands it is important that we know about the basic directory structure of Linux OS . following article has the details linux-directory-structure-explained


1. pwd2. ls3. cd4.cp5. rm6. mkdir7. rmdir8.clear9. man command10. Check current OS version 11. Check memory usage12. Create an empty file (touch command)13. Which (shows the installation path of a program or command)14. Search text in a file (grep command)15. Zip a directory16.UnZip a directory




1. pwd
The first command i am going to talk about is "pwd" . pwd command stand for "print working directory". so if i write pwd in a terminal and press enter it will show which directory i am currently located at.


As you can see i am currently located at centos directory which is insdse root home directory.

2. ls
The second command I want to show you is the  "ls" command. ls stand for list. 
as you can see above the "pwd" shows where i am currently in and the ls command shows what i have inside my current directory.

 

so as you can see , inside my current working directory  i have the following item Desktop, Documents, Downloads, Music, Pictures, Public, Templates and Videos.

3. cd
The next command I want to show is "cd" command . cd stands for change directory. cd is a navigational command. so let's i want to go to the "Downloads" folder. how do i do that ? i have use cd command . 




4.cp
cp stand for copy. I can use the cp command to copy file or directory and past it to another directory


5. rm
rm stands for remove. i can use rm command to remove an file or directory.

6. mkdir
mkdir stands for make directory. i can use the mkdir command to create a new directory.

7. rmdir
rmdir stands for remove directory. i can use the rmdir command to remove a directory. one thing to remember here is if we can something inside the directory I can not remove the directory using the rmdir command. i that case i have to use rm command 

rm -r mydirectory

8.clear
clear command clear the terminal screen.


9. man command
man stand for manuals

10. Check current OS version 
using the following two commands we can check current OS info .
$ uname -a

$ cat /etc/*release*

11. Check memory usage

The free command is the most simple and easy to use command to check memory usage on linux . Here is a quick example:

$ free -m
             total       used       free     shared    buffers     cached
Mem:          7976       6459       1517          0        865       2248
-/+ buffers/cache:       3344       4631
Swap:         1951          0       1951

The m option displays all data in MBs. The total os 7976 MB is the total amount of RAM installed on the system, that is 8GB. The used column shows the amount of RAM that has been used by linux, in this case around 6.4 GB. The output is pretty self explanatory. The catch over here is the cached and buffers column. The second line tells that 4.6 GB is free. This is the free memory in first line added with the buffers and cached amount of memory.

Linux has the habit of caching lots of things for faster performance, so that memory can be freed and used if needed.
The last line is the swap memory, which in this case is lying entirely free.

12. Create an empty file (touch command)

One easy way to create an empty file is with touch.
touch my_file_name.txt 

The above command will create a file with the name my_file_name.txt 

13. Which (shows the installation path of a program or command)

[centos@localost ~]$ which git
/usr/bin/git

The above command shows the installation location of git.

14. Search text in a file (grep command)

15. $ zip -r myfiles.zip mydir

16. unzip myzip.zip

$  grep "text_to_search" filename




More usefull command can be found here





Tuesday, March 7, 2017

Standard Operating Procedures (SOP)

Standard Operating Procedures (SOP)



Agile Standard Operating Procedures

1. Create product backlog with User Stories

2. Designate the following roles:
        Product Owner
        Scrum Master
        Team Members

3. Conduct Sprint Planning Meeting

4. Daily Scrum with available team members

5. Weekly Code Review meeting including
        Storytime to groom Pivotal Tracker
        Retrospective “Inspect & Adapt” for team

6. Weekly Sprint Review with product owner

7. Developer Best Practices
  • Every new idea => document user story => vote number of points
  • Only choose work from voted upon features or chores
  • Be accountable for delivering story. Pair program on a problem you can't solve on your own
  • Person submitting pull request is different from person approving the request
  • If you are pairing, ping pong code
  • If you are working on a feature that does not need a pull request, when finished with tasks/chores:
               Check off each task finished in Pivotal Tracker as soon as completed.
                Mark feature finished when ALL TASKS it contains are finished.
               Team will check work at next scrum mtng.


http://www.agileventures.org/projects/codealia/documents/standard-operating-procedures-sop

5 Strategies for Getting More Work Done in Less Time

Summary.    You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...