Wednesday, March 2, 2016

Useful Unix or Linux command on single post

Get process id of all the running program on Unix or Linux system.
ps ax | grep java

OUTPUT:
22491 pts/0    S+     0:00 grep --color=auto java
27209 ?        S      0:00 sudo nohup java
27210 ?        Sl     2:58 java

Kill process using process id (PDID) in unix or linux:
sudo kill -9 27210

Below command will fetch count of files in a particular director in Unix or Linux system?


ls -l | grep -v ^l | wc -l

Tuesday, January 26, 2016

Find text in table without table iteration

Normally we follow the approach of iterating table, find the required text and perform some operation on same row. This approach is fast for small table but when it comes to very large table iteration will be slow enough.

Instead without iterating the table find the text using xpath and perform operation on same row.

Let take an example:









From above table we want 'Travel' time (column = 7) of particular train from 'Train No' (column=1).

String travelTime = driver.findElement(
By.xpath("//table[@id='trainInfo']/tbody/tr/td[text()='19215']/../td[7]")).getText();

OUTPUT:
Travel time: 15.35

Tuesday, January 19, 2016

[ERROR]How to resolve "Multiple annotations found at this line" in pom.xml file?

Today while creating new project I came across below error message in POM.xml file after deleting Junit dependencies and including TestNG dependencies and worried how to solve. Luckily I found solution from my preview project.

Multiple annotations found at this line:
- ArtifactTransferException: Failure to transfer org.apache.httpcomponents:httpclient:jar:
4.5.1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution 
will not be reattempted until the update interval of central has elapsed or updates are forced. 
Original error: Could not transfer artifact org.apache.httpcomponents:httpclient:jar:4.5.1 from/to 
central (http://repo.maven.apache.org/maven2): connection timed out to http://
repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.5.1/httpclient-4.5.1.jar
- ArtifactTransferException: Failure to transfer org.apache.httpcomponents:httpcore:jar:
4.4.3 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution 
will not be reattempted until the update interval of central has elapsed or updates are forced. 
Original error: Could not transfer artifact org.apache.httpcomponents:httpcore:jar:4.4.3 from/to 
central (http://repo.maven.apache.org/maven2): connection timed out to http://
repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.4.3/httpcore-4.4.3.jar
- ArtifactTransferException: Failure to transfer commons-logging:commons-logging:jar:1.2 
from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not 
be reattempted until the update interval of central has elapsed or updates are forced. Original 
error: Could not transfer artifact commons-logging:commons-logging:jar:1.2 from/to central (http://
repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/
maven2/commons-logging/commons-logging/1.2/commons-logging-1.2.jar

SOLUTION:
Just include below "httpclient" dependencies solved my problem.
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.4</version>
</dependency>

Read CSV from S3

 import csv def count_records(csv_file):     record_count = 0     first_line = None     last_line = None     # Open the CSV file and read it...