Saturday, December 28, 2013

Mount Nexus5 to Ubuntu 12.04

Instruction how to connect Nexus phone to Ubuntu 12.04:

1) Activate developer options on Nexus 5, instructions, that mode have to be switched ON always to be mounted.

2) just follow , at the end of article there is a script that do all that steps automatically (that require only 2 chapter to be done).

ATTENTION: unlock phone before connection to PC, if phone is locked auto connection/mount is not happen!!!!

it works for any device - Nexus 4, Nexus 5, Nexus 7, .... that use MTP protocol.

Only one minor nuance is noticed: Nautilus does not copy files/folders if you use Tabs in Nautilus, workaround just use separate nautilus windows.

Thursday, November 28, 2013

Sevntu Checkstyle release 1.10.0

official page:

New and noteworthy:

New project! sevntu-checkstyle-sonar-plugin -  Project was created as extension to Sonar Checkstyle Plugin for SonarQube, How to use it is described here in detail and pictures, Done by Ruslan Diachenko. More.

New project! sevntu-checkstyle-idea-extension -  Project was created as extension for Checkstyle IDEA plugin for IntelliJ IDEA, How to use it  is described here in details and pictures, Done by Vadim Panasiuk. More.

Bug fixing and improvements in existing Checks: 

CustomDeclarationOrderCheck -  Inner Classes in methods are ignored. Done by Baratali Izmailov. More.

VariableDeclarationUsageDistanceCheck -  Update to ignore raising violation against block constructions/builders and methods with long list arguments, Done by Baratali Izmailov. More.

ConfusingConditionCheck -  Update to skip raising violations on sequential IF, Done by Vadim Panasiuk. More.

NoNullForCollectionReturnCheck -  Fix for NulPointerException, Done by Ilja Dubinin. More.

ForbidCertainImportsCheck -  additional field as Regexp for specifying ignored imports from forbidden, Done by Daniil Yaroslavtsev. More.

Updates in messages -  Done by Baratali Izmailov, Ilja Dubinin, Vadim Panasiuk. More.

General information:

Monday, November 25, 2013

Saturday, November 23, 2013

How to merge github wiki changes from one repository to another

User forked a repository on GitHub and wiki pages are also forked, user do changes to wiki, but there is no way to send pull request for wiki changes, but Wiki is just another sub repository in GitHub repo, so admin of original repository have to do merge manually.

source wiki:
target/original wiki:

Source of wisdom for massive squash.

git clone
git fetch master:master-Vadim
git checkout master-Vadim

#checkout to last non-Vadim's commit  
git reset --hard 34a2f8e627dd6209f4928b6f66a37368789ab492

# do massive squash of all Vadim's changes
git merge --squash HEAD@{1}          
git commit -m "How to use SevNTU Checkstyle in Intellij IDEA (markdown)"
git checkout master

# cherry-pick newly squashed  commit
git cherry-pick cbe1915a65d80769d56f4fbd9a60dd0b88c8c049    

git push

If wiki was forked from latest state of original wiki, you can do it a bit simpler:
git clone
git pull master
# squashing all Vadim's changes in one 
git push origin master

Friday, November 15, 2013

Free API web services

Very concise list of free Web APIs:
It is good start for testing REST API calls in your application.

Execute JMX bean method by jolokia wrapper

official site:

Configuration in your jvisualvm or jconsole:

[user@server]$ curl localhost:8080/jolokia/exec/


Monday, November 11, 2013

Example of orastat usage to find problematic SQL on Oracle server

In Short:
orastat -ser | egrep -v INACT\|BG
# grab PID number of process , for example 9
orastat -sal 9

Here is logs of steps:

[oracle@server ~]$ orastat -ser | egrep -v INACT\|BG
2013/11/07-17:56:50 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-ser arg2=
2013/11/07-17:56:50 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/ - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:56:50 orastat | Version=3.53 Host=hana Company=some-company
2013/11/07-17:56:50 orastat | -ser: Session Details

Session      Ses    Ses      Wait    Wait       DB     OS                              Session             Last      Last                 +-UserCommits-+ Rollback Program
SID-Ser#     Type   Status   Class / Seq        Userid-Userid-PID-SPID-Term@Server     Start Time          Call ET   SQL    SQL_ID           Count   /Sec    Count Identifier
------------ ------ -------- ------------------ -------------------------------------- ------------------- --------- ------ ------------- -------- ------ -------- ------------------------
9,33801      USER   ACTIVE   User_I/O/51809     SCHEMA2-sb-1234-7525-unknown@other-server.rev 2013/11/07-17:10:05     8_Sec SELECT 1wrbrdf8qrrx8        0      ?        0 JDBC_Thin_Client      
482,56061    USER*  ACTIVE   Network/13         SYS-oracle-14955-14956-?@localhost          2013/11/07-17:56:50     0_Sec SELECT 9d688j2s309du        0      ?        0 sqlplus@localhost_(TNS_V1-V3)

2013/11/07-17:56:50 orastat | Count of USER session(s) in ACTIVE status: 2
2013/11/07-17:56:50 orastat | There are 50 total sessions (mysid=482 - denoted by *)

[oracle@server ~]$ orastat -sal 9
2013/11/07-17:57:23 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-sal arg2=9
2013/11/07-17:57:23 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/ - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:57:23 orastat | Version=3.53 Host=hana Company=some-company

Session SQL:

  cc.company_id  .....
  cc.start$ <= sysdate and sysdate < cc.end$


Session Current Wait State:

SID    DB-User          WaitType St WTSeq  Tmr WTTimSec Wait Event Details
------ ---------------- -------- -- ------ --- -------- -------------------------------------
9      SCHEMA2           RealWait  A  51976  -1        1 P1Raw=0000000000000021 P2Raw=00000000000233F5 P3Raw=0000000000000001 db file sequential read WAITED SHORT TIME file# 33 block# 144373 blocks 1

Session Stats:

SID-Ser#  OS:Userid-PID-Server     DB:User    Program       Hours  CPUTm Commit PFBlks TScans  MemSorts DiskSorts Con+BuGet PhysReads RHRat  LokWaitTm
--------- ------------------------ ---------- ------------ ------ ------ ------ ------ ------ --------- --------- --------- --------- ------ ---------
9,33801   sb-1234-other-server SCHEMA2     JDBCThinClie    0.8 277617      0      0  41609       175         0 118634411     12000  100.0         0

2013/11/07-17:57:25 orastat | orastat | -sal Done

[oracle@server ~]$ orastat -wr
2013/11/07-17:57:48 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-wr arg2=
2013/11/07-17:57:48 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/ - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:57:48 orastat | Version=3.53 Host=hana Company=some-company
2013/11/07-17:57:48 orastat | -wr: Wait Reasons - By User and Event Type (Idle Waits Excluded)

DB User    Wait Event Type                          Sessions Waiting
---------- ---------------------------------------- ----------------
SCHEMA2     db file sequential read                                 1

2013/11/07-17:57:48 orastat | Total Session(s) Waiting: 1

[oracle@server ~]$ orastat -wr
2013/11/07-17:57:56 orastat | oraver=11.2. oraver_short=11.2 oraver_num=11.2 sqlcmd=sp arg=-wr arg2=
2013/11/07-17:57:56 orastat | ORACLE_SID=MYSID ORACLE_HOME=/opt/oracle/product/ - SunOS hana 5.10 Generic_147441-12 i86pc i386 i86pc
2013/11/07-17:57:56 orastat | Version=3.53 Host=hana Company=some-company
2013/11/07-17:57:56 orastat | -wr: Wait Reasons - By User and Event Type (Idle Waits Excluded)

DB User    Wait Event Type                          Sessions Waiting
---------- ---------------------------------------- ----------------
SCHEMA2     db file sequential read                                 1

So problem is found, inadequate sequential read that was caused by problems with missed oracle statistics recalculation.

Wednesday, November 6, 2013

Checkstyle idea - require toString() method for Classes

toString() is required for classes that do logging as error to print context of them-self and around.

it might be reasonable to put in toString() only simple types fields that are provided by setXXXXX().

Johua Bloh idea about toString() for classes - Effective Java 2 book - "Item 10: Always override toString" -

Having useful toString() make logging of context during error a simple and pleasant task.

Questions: What criteria we could follow to make a Check that will not force all Classes to have toString() on domains and critical for logging?

Override toString() everywhere is not practical, so we need figure out distinctive characteristics of Classes that have to do it.
- Class that is POJO
- ....

if somebody have ideas please share them on!forum/sevntu-checkstyle or!forum/checkstyle-devel

Monday, October 28, 2013

Trailing Comment Check false positives

Original investigation of Daniil Yroslavtsev:

It has so much problem to report valid code so I do believe that it is switched off  in all companies configurations.

Other support for that Check: Trailing Comments .

But currently Trailing Comment check warns on the following valid cases:


  } catch (Exception e) { // SUPPRESS CHECKSTYLE IllegalCatchExtendedCheck now it part of logic

  } catch (Exception e) { // NOPMD

  } catch (Exception e) { // NOSONAR

double emerging = 100 - regions.sumEstimate(
  "54138", // Not Applicable/Disclosed
  "19668", // United States
  "200005", // Canada


ReportValidationResult r = validationResult.get(i);
    MessageFormat.format("  report_id={0} (co_id={1}), report_start$=''{2}'', report_end$=''{3}''"
     + ", period_start_date={4}, period_end_date={5}: "
     + "total percent on ''{6}'' is {7}% .... ",
     safeToPlainString(r.reportId), // 0
     safeToPlainString(r.companyId), // 1
     formatTimestamp(r.reportStartDate), // 2
     formatTimestamp(r.periodEndDate), // 7


  private static final Color[] COLORS = {             
            new Color(255, 128, 128), // pink
            new Color(255, 255, 128), // yellow             
            new Color(128, 255, 128), // green             
            new Color(128, 255, 255), // cian             
            new Color(255, 128, 192), // margent                      
            new Color(255, 128, 64), // brown
            new Color(0, 128, 128), // blue/gray
            new Color(128, 128, 255), // purple
            new Color(0, 128, 0), // dark green             
            new Color(128, 128, 0), // greenish/grayish     };

    record[++columnIndex] = geoAreaEntry.getKey(); // _NAME
    record[++columnIndex] = "unknown"; // _REGION
    record[++columnIndex] = "0"; // _WEIGHT
    record[++columnIndex] = "1"; // _CONF

To fix false-positives we can update Trailing Commentary Sonar check to ignore: //NOSONAR, //SUPPRESS CHECKSTYLE, //NOPMD, // formatter:off, // formatter:on commentaries (with all their possible variants) and other 'valid' comments by regexp in it`s configuration.

But I think, that Checkstyle Trailing Comment check should be disabled for all projects as too many comment formats can be considered as 'valid' and result 'ignore' regexp will be too complex and unreadable.

Monday, October 21, 2013

Checkstyle Check to detect System.out.println usage in java code

Examples of usage in code:
import static java.lang.System.out;


- Analyse import for short name usage "import static java.lang.System.out;"

Possiblle name for Check: ForbidQualifierUsage

forbiddenFullQualifierNames : String List-  qualifier that we will search for (Example:"System.err.println")
ignoredClasses : Regex -  ignores (Example:"com.mycompany.console.Main")

Bad sides:
1) we can not distinguish methods by parameters so any user method with same name and without package usage will be false-positive if not all methods are investigated to detects overlap of static import in local declaration .

import static java.lang.System.setIn;

public static void setIn(InputStream in) {
    // just a method with similar signature that is compiled
    // if you comment out that method System.setIn will be used (tested in Intelij Idea)

public static void main(String... args) {
    setIn(null); // it is local if local method is defined

2) Any overloaded methods(same name but different parameters) will be false-positives or known limitations :) :

   System.out.println("hi", "hi")

It is permissible for one single-static-import declaration to import several fields or types with the same name, or several methods with the same name and signature. 
So JDK is OK with multiple imports by single static import, so overloaded identifiers are ok.

So it is not complete solution, kind of same level of false positives as RegExp search on code approach.
Could we close eyes on that false-positives?
do you have other ideas and proposal?
Or discussion mail-list -!forum/checkstyle-devel

Friday, October 18, 2013

Thursday, October 17, 2013

Scala Books

List of books is here:

I highly recommend to read "Programming in Scala Second edition" book , first edition could be find easily for free download.
This book is much better then "Scala for the Impatient" and "Scala in Depth" as it describe in details functional patterns and basics and have very good history of Scala language and show from where Scala grab ideas and why syntax enhancements are not in Java and .... .

Logging exception message in log event message

When exception happen and you want to log it and the right way to do it is

log.error("Processing is failed during phase {}", phase , e);

In log you will get something like this:
[main] ERROR test.Test - My message Error.
java.lang.RuntimeException:  Long long Message
 at test.Test.main(

but this approach works fine for logging to output and file and have one problem with reporting to SysLog.
SysLog is not a java logger and it teat each line as separate event so printing stacktrace of exception will result into numerous event on SysLog level - so to resolve problem we use "throwableExcluded=true" , but we loose exception message in same time and it do contains useful information .
Exception message does not disclose reason of problem but it allow to quickly categorize problem and some time it is all that you need to fix a problem.

        <appender name="SYSLOG" class="">
                <suffixPattern>[%d${}] [%t] [%c{0}] [%p]: %m%n</suffixPattern>
                <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                      <!-- deny all events with a level below ERROR -->

Alternative way of logging - add Exception message to message of event.

logger.error("Handler execution resulted in exception: " + e.getMessage(), e);
log.error("Processing is failed during phase {} with exception message='{}' ", phase, e.getMessage(), e);

result in message duplicate(see bold text) in file and system output that complicate log reading. This example is not very representative but imagine long message like Spring give on exception.
[main] ERROR test.Test - My message Error: Long long Message
java.lang.RuntimeException:  Long long Message
 at test.Test.main(

but this will resolve problem of SyslogAppender and with "throwableExcluded"=true Syslog will have informative message.
Second approach is highly NOT recommended, as it brake nature of log events in java and do duplication of error details.

Throwable class in Java have getMessage() method:

So we need to update SyslogAppender to have "throwableMessageIncluded" or "throwableMessageAppended" parameter that will attach to Event message exception message.
Posted as -

Logback resources:
Discussion thread :,
or create issue:
sources only:

Monday, October 7, 2013

Meetup with Scala IDEA plugin team leader

It was sad to see that JetBrains team leader use Windows for development:

How to create Checkstyle analog for Scala in IDEA IDE:

video will be there:

Thursday, September 19, 2013

SevNTU Checkstyle version 1.9.0

SevNTU Checkstyle Release 1.9.0 (18/September/2013):

About project and previous releases:
To Discuss:!forum/sevntu-checkstyle

New in 1.9.0:

AvoidConstantAsFirstOperandInConditionCheck -  Avoid Constant As First Operand In Condition. If comparing values, C(C++) developers prefer to put the constant first in the equality check, to prevent situations of assignment rather than equality checking. But in Java, in IF condition it is impossible to use assignment, so that habit become unnecessary and do damage readability of code.
if (null == varialble)"
should be
if (varialble == null)"

Done by Sergey Burtsev.  More

EitherLogOrThrowException -  Either log the exception, or throw it, but never do both. Logging and throwing results in multiple log messages for a single problem in the code, and makes problems for the support engineer who is trying to dig through the logs. This is one of the most annoying error-handling antipatterns.
       catch (NoSuchMethodException e) {
          LOG.error("Blah", e);
          throw e;

Done by Baratali Izmailov.  More

ForbidWildcardAsReturnTypeCheck -  Do not use wildcard types as return types. Rather than providing additional flexibility for your users, it would force them to use wildcard types in client code. Properly used, wildcard types are nearly invisible to users of a class. They cause methods to accept the parameters they should accept and reject those they should reject. If the user of a class has to think about wildcard types, there is probably something wrong with the class’s API.
public <T> List<? extends T> getValues()

Done by Baratali Izmailov.  More

NoNullForCollectionReturnCheck -  Check detect when method, that must return array or collection, return null value instead of empty collection or empty array.
public List<String> metValues() { return null; }

Done by Ilja Dubinin.  More

ConfusingConditionCheck -  This check prevents negation within an "if" expression if "else" is present.
For example, rephrase:
if (x != y) smth1(); else smth2(); 
if (x == y) smth2(); else smth1(); 

Done by Vadim Panasiuk.  More

NoMainMethodInAbstractClassCheck -  Forbids main methods in abstract classes. Rationale: existance of 'main' method can mislead a developer to consider this class as a ready-to-use implementation.
         abstract class AbstractUiJob {
             public static void main(String args[]){ ... } 

Done by Baratali Izmailov.  More

SimpleAccessorNameNotationCheck -  Check only direct fields and setter and getter. Options: 1) member prefix "m_" 2) check only simple getter/setter XXXType getXXXName(); void setXXXName(XXXType).
private String value; 
void setValue(String val) { this.value = val;}

Reimplemented and fixed by Ilja Dubinin.  More

AbbreviationAsWordInNameCheck -  problem detection of 2 char abbreviation with length limit 1 was fixed.
int scaleX;

Done by Baratali Izmailov.  More

Thursday, September 12, 2013

Github need to have search of files feature in repo

I will be lovely if Github create search in repo at least by file name (with support of matching by Camel case), it will be very useful during sources investigation. Developers always search for files, and gihub is not just a web hosting - it is online editor, and allow contribution to project without clone to local PC.

This feature exists - just press "t" and search appear.

Scala Lift steps how to compile and run


git clone
cd simply_lift/samples/http_rest
> update
> jetty-run

But this project use old version of scala and lift and sbt

to do Project from scratch with all explanations:
just Rest example:

#udpate sbt-launch.jar from to latest version

# remove old file to activate changes
rm project/

#register eclipse plugin
echo "addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")" > simply_lift/samples/http_rest/project/plugins.sbt

Deploy (jetty, tomact ):
#create a war in target folder
sbt package

#deploy war to Java application server (jetty, tomcat, ...)!topic/liftweb/503eibvCvV4

#examples of prod configurations

Scala vs Nodejs:

Monday, September 9, 2013

Scala meetup at Netflix office 2013-09-09

How to run scala as script

1. Through interpreter
$ cat script.scala
println("Hello, World!")

scala script.scala

2. Thought a Scala script

$ cat script.scala
println("Hello, World!")

Run as:
$ ./script.scala

3. Compile and then run compiled class
, source.

$ cat script.scala
object Greeting {
    def main(args: Array[String]) = println("Hello world!")

Run as:
$ scalac script.scala
$ scala Greeting

Happy scripting!

Friday, September 6, 2013

Comparison web framework for rest api on scala

I did search for the best way to implement simple RESTfull Api service on JVM based technologies (not a node.js and "go" lang). Scala come up as good alternative, additional search shown a Lift framework that looks like popular between Scala community and a lot of posts recommend to do rest api on it, but ...

I met Alexy Khrabrov on one of Scala meetup, and he recommended me to take a look at project , that do show comparison of RESTful libraries and frameworks, and results are pretty interesting and shown that Lift is not ideal for performance demanding web services.

Just Java Servlet Api 3.0 show petty good performance - that make me think "Should I stay with Java? What can I benefit from Scala ?" :).

Useful stack-overflow discussions: discussion1, discussion2.

My final decision for deep investigation and try is spay:

Opposite results of performance:

Magic performance of Servlet Api 3.0 is due to "Java NIO (New I/O) API":

Sync local git repository with remotes github and bitbucket

It is common case when you need sync sources between few remote repositories of git, mostly one of them is backup mirror or you have two communities and do not want to bother them what is better github or bitbucket.

#recheck what remotes you have already
git remote

# add link to github and bitbucket remote repo
git remote add github
git remote add bitbucket
git push -u github master
git push -u bitbucket master

#Somebody sent you fixes to bitbucket rep - pull it from bitbucket and push github
git pull bitbucket
git push github

Saturday, August 31, 2013

Exception logging: 'log and rethrow' vs 'wrap and throw' vs 'log context and re-throw'

If Exception happen during any SQL call to DB server - Where it is good to catch and log it and how to do it?

There is no exact answer, but there are few ways to do it, and some of them have problems that you need to consider.

Case "log and re-throw":
} catch (SQLException e) {
               log.error("Exception occurred ,for sql [" + sql + ]", e);
               throw e;

Case "wrap and throw":
} catch (SQLException e) {
           throw new XXXXXDataAccessException("Exception occurred ,for sql [" + sql + ]", e) ;

Case "log context and rethrow":

} catch (SQLException e) {
               log.warn("Exception is appear, stack-trace see further in logs, failed sql is [" + sql + ]");
               throw e;

Case "log and re-throw":
In log and throw - log with Error or with Warning ?
If we do it with ERROR level - you will brake good pattern "one event - one ERROR message in logs", link to read.
If you will log with WARN - you will spoil logs with duplicated print of stacktrace. On moment of logs review it will not be clear (without review of sources) either exception happen twice or it was logged twice or ....   

General rules for logging and re-throwing:
 - if you develop Library - never log with ERROR level - library does not know how it is used so he have to return all to application and application decide how and when to log it, or even ignore it. Such problem existed in Hibernate, Hibernate, Hibernate, Hibernate, and looks like resolved in Hibernate 4.X only.
- if you are in Application - do logging on level that do know how to treat/translate/process that exception and make exception part of business logic(your algorithm).

Case "wrap and throw":
If you do not log sql and trow exception up, upper level does not have information what sql was in call. You can not log sql with ERROR level at place where you have SQL as is SQL is not an ERROR , exception is a ERROR event - log and rethrow is also bad practice (link to read). Wrapping to your exception make you have custom exception objects and ask yourself and Google why there is no such standard exception - it is so obvious (ones you end up in creation set of custom exceptions in each application).

if you so like to follow "big brothers" - non of these exceptions classes store SQL:
for 15 year off massive SQL usage in java non of them wanted to have it in class as member, because SQL is only one part of problem not a exact reason. 
Non of them have sql as member in class:

Case "log context and rethrow":
So logging with WARN is ok, but smb could yell "Error should encapsulate all details of it", and here is nuance - you will never put in Exception object all context, even previous events in logs is a context as you need to see what application did before ERROR. So I recommend to log context of SQL and parameters if any with WARN level and do rethrow exception without wrap.

Main idea is - as you got exception and that level can not log it or process it properly - just print context of exception with WARN level an re-throw it further. Context could be anything: all set of class members, any local variables, whatever will be useful to know state of class when exception happen.

Make a rule for yourself to search for exception in logs and then view events before ERROR event to see a context of problem not only be cause you did logging of exception context but due to the fact that previous events are also context , and they could be even more informational and helpful than smth that you did.

Attention: You can not fix a problem by just looking at exception stacktrace and its message - you need wide context of what happen in application before!

Friday, August 30, 2013

Moving Checkstyle sources from sourceforge to github


Follow installation steps from "How to convert mercurial to git" manual:

Command to do clone and convert in same time:
git-hg clone checkstyle-git

Review all participants to find duplicates:
git log --raw | grep "^Author: " | sort | uniq -c

2 Author: Bewied <>
4 Author: BurnOl <BurnOl@KAZ-027469>
1 Author: convert-repo <devnull@localhost>
1 Author: Lars Kühne <lkuehne>
683 Author: lkuehne <devnull@localhost>
43 Author: mstudman <devnull@localhost>
1054 Author: oburn <devnull@localhost>
9 Author: Oleg Sukhodolsky <o_sukhodolsky>
3 Author: Oliver Burn Cygwin <devnull@localhost>
135 Author: Oliver Burn <devnull@localhost>
288 Author: o_sukhodolsky <devnull@localhost>
410 Author: rickgiles <devnull@localhost>
14 Author: tschneeberger <devnull@localhost>

Create bash file that do squash of authors duplicates -
git filter-branch --tag-name-filter cat --commit-filter '
      if [ "$GIT_AUTHOR_NAME" = "BurnOl" ] && [ "$GIT_AUTHOR_EMAIL" = "BurnOl@KAZ-027469" ]; then
              GIT_AUTHOR_NAME="Oliver Burn";
              GIT_COMMITTER_NAME="Oliver Burn";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "convert-repo" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Oliver Burn";
              GIT_COMMITTER_NAME="Oliver Burn";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "lkuehne" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Lars Kühne";
              GIT_COMMITTER_NAME="Lars Kühne";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "Lars Kühne" ] && [ "$GIT_AUTHOR_EMAIL" = "lkuehne" ]; then
              GIT_AUTHOR_NAME="Lars Kühne";
              GIT_COMMITTER_NAME="Lars Kühne";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "mstudman" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Michael Studman";
              GIT_COMMITTER_NAME="Michael Studman";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "Oliver Burn" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Oliver Burn";
              GIT_COMMITTER_NAME="Oliver Burn";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "Oliver Burn Cygwin" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Oliver Burn";
              GIT_COMMITTER_NAME="Oliver Burn";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "oburn" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Oliver Burn";
              GIT_COMMITTER_NAME="Oliver Burn";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "Oleg Sukhodolsky" ] && [ "$GIT_AUTHOR_EMAIL" = "o_sukhodolsky" ]; then
              GIT_AUTHOR_NAME="Oleg Sukhodolsky";
              GIT_COMMITTER_NAME="Oleg Sukhodolsky";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "o_sukhodolsky" ] && [ "$GIT_AUTHOR_EMAIL" = "o_sukhodolsky" ]; then
              GIT_AUTHOR_NAME="Oleg Sukhodolsky";
              GIT_COMMITTER_NAME="Oleg Sukhodolsky";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "o_sukhodolsky" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Oleg Sukhodolsky";
              GIT_COMMITTER_NAME="Oleg Sukhodolsky";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "rickgiles" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Rick Giles";
              GIT_COMMITTER_NAME="Rick Giles";
              git commit-tree "$@";
      elif [ "$GIT_AUTHOR_NAME" = "tschneeberger" ] && [ "$GIT_AUTHOR_EMAIL" = "devnull@localhost" ]; then
              GIT_AUTHOR_NAME="Travis Schneeberger";
              GIT_COMMITTER_NAME="Travis Schneeberger";
              git commit-tree "$@";
              git commit-tree "$@";
      fi' HEAD

explanation to script:
" --tag-name-filter cat" - required to not loose tags after history rewrite.
"GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL" - to let github show commits correctly at page of commits history, in other case you have invalid-email-address in details for each commmit.

Do changes to authors and do push to remote:
git remote add origin
git push -u origin master --tags

Sources of wisdom:
In filter-branch shell syntax for IF-ELSE should be used -
usage of bash syntax for IF- ELSE cause errors - (chapter "Changing E-Mail Addresses Globally")

Monday, August 26, 2013

Rest api development best practices resources

Here is just list of resources that I found and do not want search one more time:

Разработка web API / Хабрахабр

Designing a Beautiful REST+JSON API (and other video around)

steps toward the glory of REST

API creation blog:

API creation mail list:!forum/api-craft

Tuesday, August 13, 2013

Krusader have problem with unpacking tag.gz

It is not a first time I noticed that after unzip/unarchive/unpacksome archive some files are missed. But when you do it from terminal or ubuntu befault archive manager - all works fine.

issue was reported:

Sunday, July 28, 2013

Extract certain tag with inner tags from huge XML

Task: You have huge XML file (300 Mb), you need to get out(filter out/extract/grab) it only one tag with specific value.

Under Ubuntu 12.04 install xslt processor:
sudo apt-get install xsltproc

Structure of huge XML (hugeFile.xml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<Feed ExtractDate="07/25/2013" ExtractTime="15:30:15">
  ..... a lot of companies information
<COMPANY ... LegalName="MyCompany" .....>
     ..... a lot of inner tags .....
 ..... a lot of companies information

Create extract.xsl file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
  <xsl:template match="/">

<xsl:element name="TagToExtract">
   <xsl:apply-templates select="//COMPANY[@LegalName='MyCompany']" />

  <xsl:template match="//COMPANY[@LegalName='MyCompany']">
      <xsl:apply-templates select="@*|node()" />
  <xsl:template match="@*|node()">
      <xsl:apply-templates select="@*|node()" />

Execute XSLT processor (12 seconds):
xsltproc extract.xsl hugeFile.xml > 1.xml

Saturday, July 27, 2013

Keep command launching after logout from terminal

It is very common case - you need to login to linux box, launch smth huge and that takes time, but you do not want to wait its finish and want to logout, or you afraid that internet connection could be broken in the middle of process that terminate your process.

thanks a lot for explanation to Dennis Williamson at here.

Two scenarios:
1) You launch process in background:

$ nohup myprogram &
$ logout

Explanation: nohup is allow process to ignore termination signal SIGHUP (“hang-up”)  on your logout (manual), "&" - just launch process in background and do not block current terminal session.

2) You launched process but forget to do it in background:

$ myprogram
<press Ctrl+Z>
[1]+  Stopped     myprogram
$ disown -h %1
$ bg 1
[1]+ myprogram &
$ logout

Explanation (copy-paste from stackoverflow):
You press ctrl-Z. The system suspends the running program, displays a job number and a "Stopped" message and returns you to a bash prompt. You type the "disown -h %1" command (here, I've used a "1", but you'd use the job number that was displayed in the "Stopped" message) which marks the job so it ignores the SIGHUP signal (it will not be stopped by logging out). Next, type the "bg" command using the same job number. This resumes the running of the program in the background and a message is displayed confirming that. You can now log out and it will continue running...
 ...You should be aware that when you use the "bg" command the result is the same as if you'd run your program in the background with an ampersand (&). It won't have any output to stdout so it should be made to write output to a file (nohup will redirect standard output to nohup.out or ~/nohup.out if you don't redirect it yourself).

FYI: to resume to stopped process to foreground you can use "fg" of "fg <number>" in our case "fg 1", where "<number>" - is number that shown after Ctrl+z.

Wednesday, July 10, 2013

How to resolve system variables in spring xml configuration

during Tomcat launch you can specify system variable as ".... -Dmy.value=Hello .... "

but do not forget to put in you Spring configuration following bean:
<bean id="system-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />

to make this variable resolvable in any other bean configuration like:

<entry key="myValue" value="${my.value}" />

Friday, July 5, 2013

Remove job from Oracle

There are few types of jobs:
till Orecle10 - packages DBMS_JOB is used.
from Oracle11 - package DBMS_SCHEDULER is used.

DBMS_JOB are used numbers for identifier.
DBMS_SCHEDULER use valid oracle object name (that can not be started from numbers) 
Links to spec: dbms_job is deprecatedschedulerdbms_joball_jobs.

when you try to remove old job by new package you got (2364 is job identifier):

Error starting at line 1 in command:
Error report:
ORA-20001: comma-separated list invalid near ,
ORA-06512: at "SYS.DBMS_UTILITY", line 236
ORA-06512: at "SYS.DBMS_UTILITY", line 272
ORA-06512: at "SYS.DBMS_SCHEDULER", line 623
ORA-06512: at line 2 

From SQLDeveloper I got different error when use old package DBMS_JOB:

[ERROR] ORA-23421: job number 2364 is not a job in the job queue
[ERROR] ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
[ERROR] ORA-06512: at "SYS.DBMS_IJOB", line 770
[ERROR] ORA-06512: at "SYS.DBMS_JOB", line 180
[ERROR] ORA-06512: at line 2

But it was ok from sqlplus under owner user :

BEGIN DBMS_JOB.remove(2364); END; commit;

How to change location of monitor according to laptop

When you use additional monitor to you laptop it is good to have ability to specify there is you monitor is located in relation to laptop to use mouse movement easily.

By default Ubuntu put your laptop to left side and monitor to the right side, so moving mouse to right edge will move it next monitor. That is cool, but what if you monitor is located on left side of your laptop,  and you can not switch monitor physical location - you need to switch its location  virtually :).

launch "Displays" or run "System Settings" and click on "Displays" in settings. You will see layout like this:

Just grab monitor rectangle by mouse and move it to left side of laptop's screen rectangle. That is all.

move window to other monitor at ubuntu

You need to install Compiz Config Settings Manager:
"sudo aptitude install compizconfig-settings-manage"

and launch it from Dash(main button) by filtering "compiz".

select in the "Window Management" section a "Put" item. With that enabled, you can set a shortcut key in the "bindings" tab for "Put to Next Output". By default, it's disabled, but is easy to set.
No restart is required (at least on Ubuntu 12.04 x64).

If you have two monitors - this combination will work like swap of window location on monitors.

My default is "Cntl+~".

Thursday, June 27, 2013

MOZILLA_FIVE_HOME exception while opening Checkstyle configuration

During opening Checkstyle configuration Ubuntu 12.04 x64 user can experience following error:

Unhandled event loop exception
No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]


sudo apt-get install libwebkitgtk-1.0-0

There is a bug reports for eclipse.

Sunday, June 9, 2013

Listen HitFM on Linux (Ubuntu and Fedora )

Listening HitFm from web page is not convenient as it force to open new browser window - that make inconvenience for window switching and .... .

1. Get URL for using it your Radio listen application

if you have problem with that url , it myght be that HitFm changed it, so go to press "Слушать радио", in newly appeared window look at links below "Слушайте Хiт FM у себя на компьютере:" copy URL from "Быстрый интернет (128 kb/s)"

2. I used default application in Ubuntu and Fedora - Rythmbox.
Add new radio by pressing "New Internet Radio Station ..." in context menu over "Radio" item in Library (left panel).

3. press "Play".

For Fedora be sure that you installed support for mp3 format, it is not installed by default - steps to install.
For Ubuntu you need to install Restricted codes(mp3,.....) " sudo apt-get install ubuntu-restricted-extras".

Wednesday, June 5, 2013

Data conversion and mining tool of any text, CSV, JSON fomats

Google tool :

Video explain all .... this is very cool tool for data mining, and data transforming. I usually use LibreOffice Calc for this data mining, that tools rocks as it could:
- conditions for columns creation from other column
- language for data minding from columns
- recording of data translation to repeat again and again
- usage of web services to generate new column base on existing column
- embedded language to parse JSON
- .... just look at video ...

Bulk files rename in linux

Task: in folder /www/logs/jobs/ rename all files started from "rp-repgen" to "repgen", in other words change prefix of files.

 for file in /www/logs/jobs/rp-repgen*; do dest="${file/rp-repgen/repgen}";mv $file $dest; done

Wednesday, May 1, 2013

How to split repository into two repositories

Source of wisdom.

We have infra repository that is have folder git_tool that is going to be new repository now.

State of repository "infra" before split:

Task: move "git_tools" to separate repository "infra_new".

1. Create new repo for "git_tools" only
$ git clone
$ cd infra/
$ git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch jenkins_checks/* sb-svn2git/* eclipse-compiler-warnings.epf ' HEAD
$ gitk --all
$ git remote add origin
$ git push -u origin --all

2. Remove all history remnants from old "infra" repo:

$ git clone
$ cd infra/
$ git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch git_tools/*' HEAD
$ gitk --all
$ git push -u origin --all --force

Thursday, April 25, 2013

Share folder between Windows and Ubuntu 12.04 by mean of Samba

The best way to share folder between different Windows and Linux is to share it on Linux and let Windows explore it in network. Sharing on Windows and exploring from computer and folder from Ubuntu is never stable (Linux guru could do this, but it is not for ordinary user).

Follow pretty good illustrated instructions, works fine for 12.04:

Restart samba service after each sharing( just in case :) ), in Ubuntu 12.04 as:

sudo restart smbd

If smth does not work, restart Linux PC, this will help windows to see your Linux :). 

Tuesday, April 23, 2013

Cleaning cache for Apache by htcacheclean

Detecting apache cache problem, cleaning cache for apache by htcacheclean.
good pages: page1, page2, page3.

My case:
in apache config /www/etc/apache/adm/virt.serv/10_my-service.cfg:

CacheRoot /www/cache/my-service
CacheDirLevels 2
CacheDirLength 1
CacheDefaultExpire 3600
CacheIgnoreCacheControl On
CacheEnable disk /my-service/

I get different content:

as HTTP Header have value:
Cache-Control: max-age=31556926, must-revalidate 
How to get this in Firebug addon of Firefox:

Or you can do this from terminal :
06:20 PM ~ $ curl -I
HTTP/1.1 200 OK
Date: Wed, 24 Apr 2013 01:20:08 GMT
Server: Apache/2.2.19 (FreeBSD)
Expires: Thu, 24 Apr 2014 07:08:54 GMT
Cache-Control: max-age=31556926, must-revalidate
Last-Modified: Mon, 22 Apr 2013 17:32:10 GMT
Content-Length: 36490
Connection: close
Content-Type: text/css
Set-Cookie: Coyote-2-4a7446e9=c0a89971:0; path=/

So caching could be adjusted on Tomcat side, after then on Apache side(CacheDefaultExpire and "CacheEnable disk /my-service/"), and then kept by user's Browser(Cache-Control: max-age). 

Cache could be adjusted in tomcat side in Spring config (28800 = 8 hour):
<mvc:resources mapping="/css/**" location="/css/" cache-period="28800" />

So after each Tomcat rollout we have to do:
htcacheclean -p/www/cache/my-service -l1K -v

if you have problem on apache clear cache like "An error occurred, cache cleaning aborted."
be sure you  /www/cache/my-service/ is created and "chown apache /www/cache/my-service/", "apache" username is taken from "ps -ef| grep http" as on Freebsd it is "www". Also be sure you launch htcacheclean under right user.

Saturday, April 20, 2013

SevNTU Checkstyle version 1.8.0

We finished new version of our extension for Checkstyle - release 1.8.0, new and noteworthy.

new NestedTernaryCheck.
Main idea of check to forbid to use nested ternary conditions, as it hard to read and debug them then
if(){}else{},  example:
int smth = (a == b) ? -1 : (c == d) ? 0 : 1;
this code is very compact, but it is disaster for other developer to understand and debug this code. In this case we could say logic is archived, and need spend extra time to extract logic over over again during debug, and that compact view does not contribute to performance.

Expected code is substitution by function:
int smth = calculateSmth(a, b, c, d);
int smth = -1;
if (a!=b) {
  if (c ==d) {
      smth = 0;
  } else {
      smth = 1;
The only benefits to use such statement is to declare "final" variable, so this is available as option in check, but it is not selected by default.

new ForbidReturnInFinalBlockCheck.
Return statement in final block is allowed by compilation. But it is highly non-recommended to use it, as it change return of main logic.
try { 
   return true; 
} finally { 
   return false; 
More info and discussion is here.

Bug fixing for existing checks:
 - Message improvement in ChildBlockLengthCheck,
 - bug fixing in AvoidHidingCauseExceptionCheck and OverridableMethodInConstructorCheck,
 - ignore methods now support RegExp at ReturnCountCheckExtended.

Available as EclipseCS extension and as extension for maven-checkstyle-plugin. Install instructions.