Wednesday 28 December 2011

How much memory on SunOS 5.1

prtconf -v | grep Memory

Kill all Java processes on Unix

ps | grep java | awk '{ print $1 }' | xarg kill -9

ps | grep java | cut -d' ' -f 2 | xarg kill -9

How to ask Unix ls to show only directories

ls -d */

Pentaho

Pantaho - a complete business intelligence platform that includes reporting, analysis (OLAP), dashboards, data mining and data integration (ETL). Use it as a full suite or as individual components that are accessible via web services. Ranked #1 in open source BI.

CUDA Parallel Programming

A good place to start learning something about CUDA.

Tuesday 27 December 2011

Oracle Java Certification Updates

Here is an article about the news in the Oracle Java Certification requirements.

Using a ThreadPoolExecutor to Parallelize Independent Single-Threaded Tasks

Here is a good article about the task execution framework, introduced in Java SE 5.0

SunOS 5.1 - how to get current time in seconds in bash

perl -e "print time()"

Sunday 25 December 2011

Don't aim for success if you want it; just do what you love and believe in, and it will come naturally.
Dale Carnegie

Tuesday 20 December 2011

SunOS 5.1 - ps and ptree

/usr/ucb/ps auxwww | grep java
ptree

bash comparison operators

Good page for bash comparison operators: http://tldp.org/LDP/abs/html/comparison-ops.html

Bash for loop

Three expression loop:
for (( c=1; c<=5; c++ ))
do
 echo "Welcome $c times..."
done

Simple loop:
for i in {1..5}
do
     echo $i
done

For more details see http://www.cyberciti.biz/faq/bash-for-loop/

page down inside less on SunOS 5.1

d lets to scroll down a page inside less on SunOS 5.1

get command from history on SunOS 5.1

Ctrl + R, then type a keyword

vi on SunOS 5.1

a - append
i - insert
x - delete the current symbol
hjkl - move cursor on the screen (h - left, j - down, k - up, l - right)

Monday 19 December 2011

It is better to be prepared for an opportunity and not have one, than to have an opportunity and not be prepared.
Whitney Young, Jr.

Sunday 11 December 2011

People with goals succeed because they know where they’re going.
Earl Nightingale

Tuesday 6 December 2011

java.util.concurrent ReentrantLock vs synchronized() - which should you use?

An article about new ReentrantLock class and differences between it and the classical synchronized java code session.

Monday 5 December 2011

Sample of log4j.proprties

# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE
#log4j.rootCategory=INFO, CONSOLE, LOGFILE

# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=application.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=INFO
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Getting the Current Working Directory in Java

String curDir = System.getProperty("user.dir");

DokuWiki Manual

Subversion Tag Fill Automatic Update

Inside JavaDoc section you write:

/**
 * @version $Date$ $Author$
 */

Inside file's properties you should set:
svn:keywords = LastChangedDate Author Id Revision HeadURL

Read this page for more details.

unalias

Unalias removes alias from the Unix command:
http://www.mkssoftware.com/docs/man1/unalias.1.asp

Sunday 4 December 2011

Goals are dreams with deadlines.
Diana Scharf Hunt

Friday 25 November 2011

Get geographical location (geolocation) by IP address using jQuery

To get geographical location (geolocation) by IP address it is enough to use the following query:
http://iplocationtools.com/ip_query.php?output=json&ip=80.80.214.93
For more details see this page.

Currency Custom Formatting in Java

To format numbers like currency without currency symbol and without grouping it is enough to declare:
NumberFormat format = new DecimalFormat( "#####0.00" );

If we need to change the locale formatting, then we have to add:
DecimalFormatSymbols dfs = new DecimalFormatSymbols( Local.UK );
NumberFormat format = new DecimalFormat( "#####0.00", dfs );

For more details consult Java API - DecimalFormat.

Wednesday 23 November 2011

Java 7 Adoptation Guide

Java 7 Adoptation Guide is a good place to learn the new features of Java 7.

The most interesting features are:
  1. try-with-resources statement;
  2. catching multiple exceptions;
  3. more precise re-throw of an exception;
  4. diamond syntax for more concise new expressions.

Monday 21 November 2011

Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
Dr. Seuss

Thursday 17 November 2011

Improve performance by switching from StringBuffer to StringBuilder

If you have a lot of old code and you are pritty sure that you do not use StringBuffer objects shared with different threads, you can upgrade all your project's code, changing StringBuffer with StringBuilder. The advantages could be like 35% of effeciency increment based on this article.

Here you are a couple of Unix scripts for this.

The first script just produces the list of files to be modified.

grep -l -R 'StringBuffer' ./project/src/* > files-to-change.txt

The second script replaces all StringBuffer with StringBuilder, creating .bak file for every modified file.

while read CUR_FILE
do
    echo "$CUR_FILE"
    mv $CUR_FILE $CUR_FILE.bak
    sed 's/StringBuffer/StringBuilder/g' $CUR_FILE.bak > $CUR_FILE
done < files-to-change.txt

If you like chess by correspondence, a good site to be registered on is gameknot.

Wednesday 16 November 2011

Pattern & Matcher in Java

// All values equals to "0,00" but not those 
// which have "0,00" as a part, like "20,00"
final Pattern pattern = Pattern.compile( "\\D*?0,00" );
final Matcher matcher = pattern.matcher( values );
if ( matcher.matches() ) {
      // ... 
}
For more details see this page.

Leading zeros during numbers' formatting in Java

final int number = 1;
// my formatter with leading zeros
final DecimalFormat myFormatter = new DecimalFormat( "00" );
String out = myFormatter.format( number );

For more details see this page.

How to remove the last character in StringBuilder


StringBuilder text;
// ...
final int length = text.length(); 
if ( length > 0 ) {
     // We remove the last character.
     text.deleteCharAt( length - 1 );
}

Thursday 10 November 2011

Wednesday 9 November 2011

Good guide for cron/crontab usage. Some useful commands:

crontab -l      - to list all tasks
crontab -e      - to edit the list using vi
Character consists of what you do on the third and fourth tries. 
James A. Michener