prtconf -v | grep Memory
Wednesday, 28 December 2011
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
ps | grep java | cut -d' ' -f 2 | xarg kill -9
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
Sunday, 25 December 2011
Tuesday, 20 December 2011
bash comparison operators
Good page for bash comparison operators: http://tldp.org/LDP/abs/html/comparison-ops.html
Bash for loop
Three expression loop:
Simple loop:
For more details see http://www.cyberciti.biz/faq/bash-for-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/
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)
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
Sunday, 11 December 2011
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
Subversion Tag Fill Automatic Update
Inside JavaDoc section you write:
Inside file's properties you should set:
Read this page for more details.
/** * @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
http://www.mkssoftware.com/docs/man1/unalias.1.asp
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.93For 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:
If we need to change the locale formatting, then we have to add:
For more details consult Java API - DecimalFormat.
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:
The most interesting features are:
- try-with-resources statement;
- catching multiple exceptions;
- more precise re-throw of an exception;
- diamond syntax for more concise new expressions.
Monday, 21 November 2011
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.
The second script replaces all StringBuffer with StringBuilder, creating .bak file for every modified file.
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
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
Subscribe to:
Posts (Atom)