Monday, December 31, 2012

Jenkins enhancements without plugins

Jenkins is a popular open source continuous integration server. I use it heavily. Jenkins is super extensible CI server with huge plugins repository.
But I must admit that there are a lot of cases when all these Jenkins plugin's "zoo" doesn't help. What does it mean?:
  • we need a tons of plugin to solve some non-trivial problem,
  • too many plugins dependencies which must be properly managed
  • some available plugins partially provide required functionality
  • some plugins provide required functionality but contain bugs
  • or it might be impossible to find necessary plugin, and task have to be done ASAP
Based on these cases mentioned above we have at least two solutions:
  1. Implement own plugin which will provide all required functionality. It will take some time and slowdown the overall progress for this particular business task
  2. Use some Jenkins extra facilities which gives us a chance for Jenkins automation without plugin writing
I'm a real fun od 2d solution (at least as a prototyping phase or quick-and-dirty solution right-now-right-away).

So, what's the magic? Jenkins has two nice plugins (of cause there are much more similar plugin, but these two are the best for quick start) which give us a possibility to write Groovy scripts for build and post-build phases:
  • Groovy scripts have access to whole Jenkins infrastructure (Jenkins packages) and can invoke functionality of third-party plugins installed in this Jenkins instance
  • It's very easy to prototype your ideas and validate automation approaches
  • It gives us very quick business results
  • Groovy scripts can automate really amazing and non-trivial tasks
  • at the end these Groovy scripts are not easy for automated testing
  • version managements for these scripts involve additional work (implement simple import/export tool for job configuration)
  • these Groovy scripts can have dependency on some third-party plugins and these dependency must me somehow managed as well
  • testing and debugging are really painful activities, because it involve too many interactions with Jenkins UI, etc. (yes, it can be somehow improved via extending both Groovy plugins, but it's extra work)

Wednesday, December 12, 2012

Groovy or JRuby for Java developer

Today I've decided to share my own perception about the subject "Groovy vs JRuby" for Java developers.
When we are talking about any dynamic/scripting language like Ruby, Python, Groovy, etc. we are talking about quick development feedback (e.g. run - fix - run) no compilation, no packaging.
I must admit that mentioned above languages cover the same tasks' domain with own pros&cons. Now, we should differentiate pragmatic and ecstatic sides for each of them.

When we are talking about programming language we should clearly understand the difference between:
  1. language (as syntax and semantic soup) - ecstatic side
  2. language's ecosystem (community, tools, libraries, etc.) - pragmatic side
Let's discuss item (1). I think that learning a new programming language expand developer's mind. If we know many programming languages it helps us pick up any new language very quickly. I.e. to be pragmatic programmers we should learn many languages, dead simple.
In my opinion Ruby has much "nicer" syntax and language features in comparison to Groovy. Ruby meta model is very flexible that's why it has so many beatify frameworks and libraries (Rails, Cucumber, Rspec, etc.). But …

But Ruby ecosystem is totally different from Java/Groovy world. And it's really noticible when we are trying to mix Ruby and Java in the same project.
Mixing JRuby and Java isn't a difficult task. But using Java API in Ruby code doesn't looks natural. And developing in mixed Java/Ruby environment isn't very comfortable:
  • we have two package types: JARs and gems
  • library versioning and dependency management is different
  • Ruby/JRuby still has some cross-plafrom issues, especially on Windows (i.e. many Ruby gems do not support Windows and they must be fixed to support it, very annoying)
  • it might be difficult to convince teammates to use Ruby on Java project 
I thought that Groovy isn't a (J)Ruby competitor until I've tried to automate some simple tasks in Groovy. I've got seamless integration with Java. It's really transparent and comfortable coding tool for Java developer. I have no mess with gems (Groovy uses JARs). And the Java ecosystem stays the same. Groovy has the similar dynamic power as Ruby. Yes, in some cases this "sugar" isn't so sweet as in Ruby. But, Groovy is really pragmatic choice for Java developer.

Conclusion: Ruby language is beautiful and sexy language, no doubts. But, we need a time to master Ruby ecosystem, deployment issues and tools philosophy. Also, JRuby/Java integration doesn't looks to me so pragmatic as Groovy/Java. It means investment in Ruby might be expensive.
I will recommend to learn Ruby just to open another community for yourself (if you are Java developer), it should be as self-education task, no more.


Sunday, November 18, 2012

XP Days Ukraine 2012 - Conference Report

Kiev, 16-17 November, two days conference related to agile engeneering practices. I was there and it was cool. The organisers did really good job especially when selected those amazing speakers.   
Here is the core ideas extracted from this conference:
  • The role of software architecture in agile project ("The frustrated architect", by Simon Brown). How, when and why involve software design and why does it meter. Avoid dogmatism in agile projects.
  • Testing, TDD, continuos integration (CI), continuos deployment and quick builds are keys for success in agile projects:
    • "Testability for developers: Fighting a mess by making it testable", by Alexander Tarnowski
    • "Our way from 90 to 6500 tests", by Ivan Medvedev
    • "Crazy Talk: When 10 second builds start to make you nervous", by Daniel Worthington-Bodart
    • "Psychology of testing", by Miško Hevery (USA)
  • After these talk "Agile Testing by Example", by Mikalai Alimenkou and Andrii Dzynia I am a bit confused. Because speakers showed us how QA engineer should work with developers in agile team. It opened my eyes on monkey QAs I've seen so far. I have to motivate my colleagues to evolve their skills. No monkey job, only intellectual testing, proper tools for better work performance which simplify communication between developers and testers (QAs).
  • Several presenters showed their ways of using awersome tools: 
    • Acceptance testing of Web UI components via WebDeiver, Thucydides and Groovy , be Vladimir Tsukur
    • "Behavior-Driven Development on the JVM: A State of the Union", by John Smart. Here was highlighted the next tools: Selenium, JBehave, Spock, Cucumber and Thucydides. Which one use for each tests (unit, acceptance, UI, etc.)
    • "How Testacular makes AngularJS super-heroic at testing", by Miško Hevery. The creator of AngularJS showed demo how easy is to test AngularJS based app. It was really cool and inspired me to look closer into this framework.
    • "Introducing Thucydides: Better Automated Acceptance Testing on the JVM", by John Smart. The creator of Thucydides presented the concept behind this tool, how cool it is and when to use it. 
    • "Continuous Inspection with Sonar", by Olivier Gaudin. CEO of SonarSource presented the main idea of continuos code inspection. He highlighted that it's just a tool and we should use it as a part of overall development process to make it really valuable. It sounds reasonable, but so many people use Sonar metrics without deep understanding of what problems stand behind these numbers. 
  • "Agile Anti-Patterns. Yes your agile projects can and will fail too", by Sander Hoogendoorn. This speech was really inspiring, very honest and sarcastic. The speaker said about crazy dogmas in Agile. It's a funny to see how many people in our industry trying to copy some development process without simply adjustment to own project(s) and team(s). And Sander loudly told us about all this crap. I like his critics about Scrum "Masters" which are certified after 2-days training and accepted as Scrum experts without a single year experience in real Agile project. I've been waiting on video record of this talk. I can't wait to show it to some agile "experts".  
This conference gives additional motivation to push "right" practices in my surroundings. It's amazing how positively motivated conference can be. Unfortunately, many developers are very passive and don't  want to spend their time and money for education. They simply know "everything" they need.

XPInjection team (team behind this conference) is awesome. You did really great event with high quality. Big respect and keep moving. I'm waiting for the next similar events.

Friday, November 02, 2012

How to configure git diff and merge tools?

Git can use external tools to perform merge and diff:

Use default tool:
git difftool 
git mergetool

Use custom tool:
git difftool -t tool_name
git mergetool -t tool_name

There are tons on diff/merge tools, I'd like highlight git configuration for three of them:
Sample ~/.gitconfig (Windows):
[difftool "kdiff3"]
     path = D:/Tools/KDiff3/kdiff3.exe
     keepBackup = false
     trustExitCode = false
[mergetool "kdiff3"]
     path = D:/Tools/KDiff3/kdiff3.exe
     keepBackup = false
     trustExitCode = false
[difftool "diffmerge"]
     cmd = \"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe\"  \"$LOCAL\" \"$REMOTE\"
[mergetool "diffmerge"]
     cmd = \"D:/Tools/Git/cmd/\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
     trustExitCode = false

    tool = kdiff3
    tool = kdiff3

Content of
$cat D:/Tools/Git/cmd/
if [ ! -f $basePath ]
"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" --merge --result="$resultPath" "$localPath" "$basePath" "$remotePath" --title1="Mine" --title2="Merged: $4" --title3="Theirs"

Sample ~/.gitconfig (OS X):
    tool = opendiff
    tool = opendiff
opendiff is bundled with Xcode Tools.

Sample usage:
$ git difftool -t diffmerge HEAD..HEAD~1

Saturday, October 27, 2012

Mac OS X terminal supports colored output

Mac OS X Mountain Lion Terminal hasn't been configured to support coloured output.
You can check it via simple command run "ls -la":
Let's fix this.

1. Add the next string to  .bash_profile
export CLICOLOR=1

2. Create script:
$ cat ./

echo -e "\033[0mCOLOR_NC (No color)"
echo -e "\033[1;37mCOLOR_WHITE\t\033[0;30mCOLOR_BLACK"
echo -e "\033[0;34mCOLOR_BLUE\t\033[1;34mCOLOR_LIGHT_BLUE"
echo -e "\033[0;32mCOLOR_GREEN\t\033[1;32mCOLOR_LIGHT_GREEN"
echo -e "\033[0;36mCOLOR_CYAN\t\033[1;36mCOLOR_LIGHT_CYAN"
echo -e "\033[0;31mCOLOR_RED\t\033[1;31mCOLOR_LIGHT_RED"
echo -e "\033[0;35mCOLOR_PURPLE\t\033[1;35mCOLOR_LIGHT_PURPLE"
echo -e "\033[0;33mCOLOR_YELLOW\t\033[1;33mCOLOR_LIGHT_YELLOW"
echo -e "\033[1;30mCOLOR_GRAY\t\033[0;37mCOLOR_LIGHT_GRAY"

$ chmod +x

3. Run ./, you should get something like this:

Also, command "ls -la" should produce colored output. 


Wednesday, October 24, 2012

Github Gists in Eclipse

I'd like to describe simple steps regarding integrating GitHub Gists in Eclipse.
There are several sources which provoke me to do this:
I've been using Eclipse Java EE destibution, Mylyn plugin has been already installed there:
1. Install EGit plugin via Eclipse Marketplace:

2. Install GitHub Mylyn Connector via Eclipse Marketplace:
3. Open View "Task List" and click "Add Repository":
4. Add Mylyn Task repository - "GitHub Gists":
5 .Then you should create Mylyn Query to fetch all Gists:

6. You should get something like this:
That's it. Have fun.

PS. Please note I've excluded such common sense steps as providing credentials for your GitHub account.

Saturday, October 20, 2012

Git command extention

You probably know about "git config alias.*" command. See quote from documentation:
If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command. For example, defining " = !gitk --all --not ORIG_HEAD", the invocation "git new" is equivalent to running the shell command "gitk --all --not ORIG_HEAD". Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory.
Base on this we can define some "new" command via aliases. But, there is another way for extending git. Let's have a quick view into git.c source:
int main(int argc, const char **argv)
const char *cmd;

startup_info = &git_startup_info;

cmd = git_extract_argv0_path(argv[0]);
if (!cmd)
cmd = "git-help";


* "git-xxxx" is the same as "git xxxx", but we obviously:
* - cannot take flags in between the "git" and the "xxxx".
* - cannot execute it externally (since it would just do
* the same thing over again)
* So we just directly call the internal command handler, and
* die if that one cannot handle it.
if (!prefixcmp(cmd, "git-")) {
cmd += 4;
argv[0] = cmd;
handle_internal_command(argc, argv);
die("cannot handle %s internally", cmd);

It means we can define some executable peace of code (shell script, ruby script, etc.) which has prefix "git-". Put this script on system path (add to $PATH variable) and it will be treated as git command.

Let's clarify all this via sample code:
$ cd ~
$ mkdir bin

$ #create git-foobar file 
$ cat > git-foobar
echo "[foobar] commad"
$ chmod +x git-foobar

$ git-foobar
[foobar] commad
$ cd ~

$ #check if ~./bin folder is in $PATH variable
$ cat .bash_profile
export PATH="$HOME/bin:$PATH"

$ #now check git 
$ git foobar
[foobar] commad

Wednesday, October 17, 2012

How to configure Mac OS X terminal to support git completion and context based prompt?

Msysgit on Windows has several nice features:
  • git commands completion upon press <tab>
  • current git branch name in terminal command prompt
By default git on Mac OS X doesn't have these nice features. Let's configure OS X terminal to support them:
  1. Download two scripts (in $HOME/bin folder) from git contrib which support these features (
    cd ~
    mkdir bin
  3. Now we should update .bash_profile file:
  4. export PATH="$HOME/bin:$PATH"
    source ~/bin/git-completion.bash
    source ~/bin/
    export PS1='[\w$(__git_ps1 " (%s)")]\n\$ '
So, here we have:
  • git-completion.bash does all <tab> completion "magic"
  • is responsible for adding git current branch info, see __git_ps1 function call when defining PS1 variable

Monday, October 08, 2012

Review: Practices of an Agile Developer: Working in the Real World

I've read this book the third time. Authors (Venkat Subramaniam and Andy Hunt) shared their ideas and better practices regarding "how to become a real agile developer".
Each chapter has predefined structure:
  1. General idea
  2. Why something went wrong
  3. Applying the practice
  4. What might go wrong if we try to follow the practice without common sense
  5. Summary
I can suggest this book for any developer who has been diving in the world of "agile". Even more, any junior developer must read this book. After the reading and applying some of the recipes you've got real improvements in your daily work. Do not hesitate and start reading right away.

Monday, October 01, 2012

RubyShift 2012 Conference Report

Recently, a day ago :-) I visited RubyShift 2012 conference (September 29—30, 2012, Kiev, Ukraine). It's primary a Ruby conference with additional mixing from related technologies.

I'm a seasonal Ruby developer and Java is my primary programming language. So, what do I find so interesting in Ruby conference? Well, it's totally a different community with own culture, tools, frameworks and issues. It's better to break the borders and look out of the box. We might find there something interesting and amazing there.

Here is a list of speeches which are favored by me:
  1. DataMapper 2 — an object mapping toolkit, by Piotr Solnica
  2. Data Mapper is well-known pattern in Java community. It was breakthrough for me that Ruby/Rails community is not satisfied with ActiveRecord :-) Nice movement in "better" OO design direction.
  3. RVM 2: what we have learnt and where are we going, by Michał Papis
  4. I was really happy to see the guy behind this tool. The author is going to do a very important work to get rid off shell scripting and re-write RVM 2 in Ruby. I can predict that RVM 2 will be available on Windows as well.
  5. RabbitMQ Hands On, by Alvaro Videla
  6. Simple introduction in RabbitMQ. Nothing special (because it's quite popular in Java), but based on this talk it isn't popular in Ruby community (additional findings for myself).
  7. No nonsense asciicasting for serious hackers, by Marcin Kulik
  8. ASCII.IO is the simplest way to record your terminal and share the recordings with your fellow geeks.
    Very nice tool, well done and pragmatic. The presenter shared with the audience the ideas behind, technical issues and implementation details. It was really interesting.
  9. PostgreSQL in Highload Projects, by Alexey Vasiliev
  10. Alexey presented us "magical" sides of PostgreSQL. I haven't known about all those powerful extension and techniques which can be used with PostgreSQL. Well done :-)

Friday, September 28, 2012

Review: The Clean Coder: A Code of Conduct for Professional Programmers

This book has wow effect for me. The author is famous @unclebobmartin. I called books of such type as "craftsmanship" books (term borrowed from @unclebobmartin). This book is like a companion book for The Pragmatic Programmer, but it has a little bit another "inflection":
  1. Book has close relation to software engineering as a profession and style is narrative. It very easy to read and follow the general idea.
  2. Uncle Bob did very important thing (as for me), he told us about his own failures and their consequences. It is looks very honest which brings together author and reader.
  3. He isn't cardinal in his statements. Be pragmatic, borrow his experience and just don't do the same mistakes.
  4. You won't find any technological advices in this book. There is ONLY life concepts :)
  5. It's like a craftsmanship Zen for software engineers.
  6. Uncle Bob gives us bootstrap cookbook for non-technological skills.
 Read it. Re-think the ideas. And improve your skills.

Sunday, September 23, 2012

PACEMAKER LAMP Conference Report

I had a chance to be a speaker on PACEMAKER LAMP Conference. It was amazing experience.
The organizer did the job pretty well. The atmosphere was fun. I've got so many positive emotions.
I must admit that two topics were very interesting for me:
  1. Using and scaling Rack and Rack-based middle ware, by Alona Mekhovova
  2. The presenter has shared her experience in Rack and shown the most popular use cases where we can use this lib.
  3. Building rich web application with Flask and Chaplin.js, by Yehor Nazarkin
  4. This presenter has shown the another way of implementing web application without the Django framework. It's cool to see developers' efforts outside the "standard" web-stack.
And, here is the slides from my speech:

Thursday, September 13, 2012

Outlook: Two time zones in calendar

Today, during internal training I've noticed very neat feature in Outlook 2010 Calendar, see screenshot below:
It's very useful feature if you're working with geographically distributed teams and like to align "your" and "their" time on your Outlook Calendar. It's really helpful during the meeting's planing and similar issues.

How to switch on this feature? See below:
  1. Right click on "Time Zone", left line
  2. Select "Change Time Zone"
  3. Add second time zone
That's it. Have fun!

Wednesday, September 12, 2012

Install Rails on Ubuntu 12.04 with RVM support

Nowadays, RVM is very popular in Ruby/Rails community on Linux/OS X. Even more, it's best practice to use RVM for Ruby environment management. Ubuntu is my major Linux distribution. Here I've collected steps for installing Ruby, Rails via RVM on Ubuntu 12.04. I must admit that in many cases it's the re-post from different sources.

So, let's start.

Install Ruby, Rails (see the source):
sudo apt-get update
sudo apt-get install curl
curl -L | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvmsudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
rvm install 1.9.3
rvm use 1.9.3 --default
rvm rubygems current
gem install rails
Please check the original in case you have some issues during this process.

Fix Bundler issues:
If you create Rails project or any other Ruby project which supports Bundler and run install command, you will get the next error:
$ bundle install
ERRRO: Gem bundler is not installed, run `gem install bundler` first.

But gem list clearly shows us that bundler has been properly installed. To fix this problem We have to tweak .bashrc file a little (see the original idea):
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
source ~/.bashrc

Fix rails server throw could not find JavaScript runtime
Now you will get the next interesting error when you tried to run rails server:
username@ubuntu:~/_Projects/Rails/blog$ rails server
/home/username/.rvm/gems/ruby-1.9.3-p194/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See for a list of available runtimes. (ExecJS::RuntimeUnavailable)
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/execjs-1.4.0/lib/execjs.rb:5:in `'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/execjs-1.4.0/lib/execjs.rb:4:in `'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
 from /home/username/_Projects/Rails/blog/config/application.rb:7:in `'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in '
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
 from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `'
 from script/rails:6:in `require'
 from script/rails:6:in `
Install Node.js to fix this error:
$ sudo apt-get install nodejs
Check this wiki "Installing Node.js via package manager" If you have some troubles with installing node.js


Saturday, September 08, 2012

Install Rubymine 4.5.x on Ubuntu 12.04

As you probable know NetBeans has dropped Ruby support. And now, RubyMine is one of the best Ruby IDE. Here I'd like to describe the steps for installing RubyMine on Ubuntu 12.04.

Official requirement is "Sun JDK 1.6. (OpenJDK is not supported)". I've decided to install Oracle JDK v.1.7.

I've used the next advices from "Ubuntu 12.04 – install sun jdk 6-7" (see re-post below):

Install Sun JDK 7 on Ubuntu 12.04:
Download the sun jdk 7 tar file from here
Extract the tar file:
tar -xvzf jdk-7u4-linux-x64.tar.gz
Move extracted folder to this location:
sudo mv jdk1.7.0_04 /usr/lib/jvm/
Install Update Java package (see here)
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java
sudo update-java

Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_04/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_04/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_04/bin/javaws 1
Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
java version test:
java -version
javac -version
Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
JAVA_HOME configuration
You can set JAVA_HOME in Ubuntu so simple: Edit the file .bashrc under your home directory and add the following lines: (if .bashrc is hidden click in Nautilus Menu View > Show Hidden Files)
export JAVA_HOME=/path/your/jdk
export PATH=$JAVA_HOME/bin:$PATH
Install RubyMine (see official)
Unpack the rubymine-4.5.3.tar.gz file using the following command:
tar xfz rubymine-4.5.3.tar.gz

Run from the bin sub-directory


Tuesday, September 04, 2012

Monday, August 13, 2012

How to use SSH-Agent in msysgit?

UPDATE 08/14/12: changed .bashrc file

I assume that You've generated and added SSH key as was described here: Generating SSH Keys.
It means you've got something like this in Yours user folder:

$ dir /b
But, when You communicate with GitHub remote (via calling push/pull/fetch) You are getting the next message every time:
Enter passphrase for key '/c/Users/<user_name>/.ssh/id_rsa':
There is a simple solution:
  1. Add a file called .bashrc to my home folder (C:\Users\<user_name>\)
  2. Add the next content to this file:
  3. #! /bin/bash
    eval `ssh-agent -s`
  4. Approach used in case #2 it dangerous because it create ssh-agent instance every time you run msysgit shell. I've tested the next (similar) solution from GitHub again, very carefully and  it DOES work. So, you have to create .bashrc (or .profile) file with the next content:
  5. #! /bin/bash
    # start the ssh-agent
    function start_agent {
        echo "Initializing new SSH agent..."
        # spawn ssh-agent
        ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
        echo succeeded
        chmod 600 "$SSH_ENV"
        . "$SSH_ENV" > /dev/null
    # test for identities
    function test_identities {
        # test whether standard identities have been added to the agent already
        ssh-add -l | grep "The agent has no identities" > /dev/null
        if [ $? -eq 0 ]; then
            # $SSH_AUTH_SOCK broken so we start a new proper agent
            if [ $? -eq 2 ];then
    # check for running ssh-agent with proper $SSH_AGENT_PID
    if [ -n "$SSH_AGENT_PID" ]; then
        ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
        if [ $? -eq 0 ]; then
    # if $SSH_AGENT_PID is not properly set, we might be able to load one from
    # $SSH_ENV
        if [ -f "$SSH_ENV" ]; then
      . "$SSH_ENV" > /dev/null
        ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
        if [ $? -eq 0 ]; then

From now on You have to enter passphrase only once when you start msysgit shell:
Welcome to Git (version 1.7.11-preview20120710)

Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
Initializing new SSH agent...
Enter passphrase for /c/Users/<user_name>/.ssh/id_rsa:
Identity added: /c/Users/<user_name>/.ssh/id_rsa (/c/Users/<user_name>/.ssh/id_rsa)

Please note: I've tested the next (similar) solution from GitHub and it doesn't work. It works.

Wednesday, June 27, 2012

Maven Build Number Plugin - Sample Usage

Suppose we need to add a build number to some artifact (jar, war, etc.). Here I'd like to demonstrate the usage of buildnumber-maven-plugin.

This post is based on:

We have some project and need to include into jar manifest file sequential build number which isn't based on VCS (SVN, Git, Mercurial, etc.) revision number. Let's create appropriate pom.xml file and implement small demo to verify the result.

Generate maven project
$ mvn archetype:generate -DgroupId=org.halyph -DartifactId=buildNoTest\
-DarchetypeArtifactId=maven-archetype-quickstart \

Create the pom.xml




 If you have access to scm then you can place actual url's. 
 Otherwise with <revisionOnScmFailure /> you can give some fake URLs as follows. 

      doCheck and doUpdate actually talk to repository if it's true,
      Check would check that there are no local changes. 
      Update would update it 
      This ensures that even if we are not connected to scm than also
      take the version from local .svn file 
      Generate sequence build number based on:
      build number and timestamp      
     Build: #{0} ({1,date})
      <!-- will put the entries into META-INF/MANIFEST.MF file -->

Create demo application to verify the results
package org.halyph;

import java.util.ResourceBundle;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

public class App
    public static void main( String[] args ) throws IOException
        System.out.println("Verify Resource bundle" );
 // Check filtered resources based on generated build number
        ResourceBundle bundle = ResourceBundle.getBundle( "build" );
        String msg = bundle.getString( "build.message" );

        System.out.println("\nVerify Generated MANIFEST.MF Properties" );

 // Check Manifest file based on generated build number
        Manifest mf = new Manifest();"META-INF/MANIFEST.MF"));

        Attributes atts = mf.getMainAttributes();

        System.out.println("Implementation-Versio: " + atts.getValue("Implementation-Version"));
        System.out.println("Implementation-Build: " + atts.getValue("Implementation-Build"));

Build application several time and Run
$ mvn install 
$ mvn install 
$ mvn install  
$ java -cp target\buildNoTest-1.0-SNAPSHOT.jar org.halyph.App
Verify Resource bundle
Build: #3 (Jun 27, 2012)

Verify Generated MANIFEST.MF Properties
Implementation-Versio: 1.0-SNAPSHOT
Implementation-Build: Build: #3 (Jun 27, 2012)

  1. We should inform buildnumber-maven-plugin that we won't use version control revision as build number via adding fake <scm> section into pom.xml and <revisionOnScmFailure /> into buildnumber-maven-plugin <configuration>
  2. Implemented custom build number format, see buildnumber-maven-plugin <configuration>/<format> and <configuration>/<items>.
  3. Added build number into jar manifest, see maven-jar-plugin pom.xml section
  4. Tested if generated build number can be properly added in filtered resources
    • created src\main\filtered-resources\ file
    • build.message=${buildNumber}
    • added resource filtering, see section <resource> flag <filtering>true</filtering>
  5. Demo application verifying the filtered resources and build number in jar manifest file
 You can git clone this project github

Monday, June 25, 2012

How to Create Session Factory in Hibernate 4

You've probably noticed that org.hibernate.cfg.Configuration.buildSessionFactory is deprecated in Hibernate4, check out Javadocs:

 * Create a {@link SessionFactory} using the properties and mappings in this configuration. The
 * {@link SessionFactory} will be immutable, so changes made to {@code this} {@link Configuration} after
 * building the {@link SessionFactory} will not affect it.
 * @return The build {@link SessionFactory}
 * @throws HibernateException usually indicates an invalid configuration or invalid mapping information
 * @deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead
public SessionFactory buildSessionFactory() throws HibernateException 

E.g. We have the next old-fashion Hibernate3 code snippets:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

Session session = sessionFactory.openSession();
session.beginTransaction(); Event("Our very first event!", new Date())); Event("A follow up event", new Date()));

Based on Javadocs above we have to apply the next small changes to support new Hibernate 4 buildSessionFactory(ServiceRegistry):
Configuration configuration = new Configuration();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);

Session session = sessionFactory.openSession();
session.beginTransaction(); Event("Our very first event!", new Date())); Event("A follow up event", new Date()));
You can clone code sample from

Tuesday, June 12, 2012

How to improve cmd.exe prompt

I'm sure that you have some trouble with "too long command prompt in windows cmd.exe" and it is annoying:

Fortunately, it can be easily fixed with PROMPT command (see official help):

> prompt /?

PROMPT [text]

  text    Specifies a new command prompt.

Prompt can be made up of normal characters 
and the following special codes:

  $A   & (Ampersand)
  $B   | (pipe)
  $C   ( (Left parenthesis)
  $D   Current date
  $E   Escape code (ASCII code 27)
  $F   ) (Right parenthesis)
  $G   > (greater-than sign)
  $H   Backspace (erases previous character)
  $L   < (less-than sign)
  $N   Current drive
  $P   Current drive and path
  $Q   = (equal sign)
  $S     (space)
  $T   Current time
  $V   Windows version number
  $_   Carriage return and linefeed
  $$   $ (dollar sign)

I've configured PROMPT User variable to apply my custom PROMPT setting: [$P]$_$$$S
Now the previous console screen looks like this:
As you can see the full current path is shown one line before the input line. Now, we have a plenty of place for typing what ever we need ;-)

Monday, June 11, 2012

Maven Resource Filtering

This post is inspired by:
I assume that reader has a basic understanding of Maven resources.

Simple resource filtering

Let's generate the project:
$ mvn archetype:generate -DgroupId=org.halyph -DartifactId=proptest -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false


Now, we have an application property file with bunch of properties which must be filtered \proptest\src\main\resources\
We have to add build/resources and properties section into pom.xml:






Lets run maven resource filtering and check the resulted \proptest\target/classes/ file:

$ mvn process-resources
$ cat target/classes/

As you can see property values were successfully substituted.


Resource filtering with external properties file

We can extract Maven properties in external property file \proptest_extfile\src\main\filters\
also, we have to adjust pom.xml to work properly with external filters (added build/filters and removed properties):





Let's check the resulted \proptest\target\classes\ file:
$ mvn process-resources
$ cat target/classes/



Mixed resource filtering with external/internal properties 

What happen if we have overlapped properties in pom.xml with external property file.
Modified pom.xml:






Now, check the resulted \proptest\target\classes\ file:
$ mvn process-resources
$ cat target/classes/

In this case Maven uses application.databaseName property from pom.xml

Managing properties with properties-maven-plugin 

Please check the plugin home page for more details

This plugin read external property and they behave like were declared in pom.xml.
Modified pom.xml:





Also, we have to add new external property file just to verify the property overlapping issue:
Now, it's time to check the resulted file \proptest\target\classes\ file:
$ mvn process-resources
$ cat target/classes/


Have you noticed that we've got properties values from and Maven hasn't applied properties from file?

So, as you can see we have several ways for managing/filtering properties with Maven. And, it's very convenient.

You can checkout code snippets from github

First steps in Maven

Here I'm going to collect the most important resources which helps quickly use Maven in the "right" way.

Intro Tutorials

  1. Java Brains: Maven - 10 video tutorials cover very basic Maven use cases. 
  2. Maven By Example - free e-book which step-by-step how the Maven "world." I've notices that off-line PDF book is a little bit outdated (i.e. some POM samples)
  3. Maven Getting Started Guide - guide from Apache Maven Project
I must say that item 1 is optional, but item 2 is mandatory for newcomers.

Tutorial, How-tos and FAQs

  1. Maven Tutorial - short and descriptive Q&A tutorials.
  2. AVAJAVA - Maven Tutorials - very huge collection of how-to's and Q&A, there are about 80+ articles. 

Cheat Sheets

  1. Dzone Maven 2

Newcomers should clarify for yourself the next maven items which can potentially boost their productivity in future:
  1. Maven lifecycles
  2. Multi-module project
  3. Resource filtering
  4. Maven Profiles

Sunday, May 20, 2012

JEEConf - Kiev, 2012 - Report

This year we had the second JEEConf. The amount of stages was increased from three to four stages.
I was really impressed about conference program "notebooks" :-) it was well done. The amount of people was really huge more then 600. I think it's impressive number for the second conference.

As usual I've selected the most interest topics to watch/visit to:

1. Play with Play! by Anton Naumov
The presenter briefly has shown the Play Framework v.1.2.x features and discussed the pros&cons. The most notably was that he stated the "fails" caused by this framework and how we can avoid similar stuff. The most loud message was "use Spring/MVC, Hibernate and Maven" if you are experienced with them :-). And try to use Play for prototype projects.

2. Hibernate performance tuning by Sander Mak
It's very interesting and pragmatic topic. Even more I can say this presentation was a bunch of receipts for Hibernate performance improvement. There were depicted very interesting nuances which will be definitely valuable in real life codding.I'm looking forward for slides.

3.  Methodology of performance optimization by Alexey Shipilyov and Sergey Kuksenko
It was the most low-level topic on this conference. Guys shown the different ways to perform the subject. They review and in pair-speech way very complicated issues in performance optimization from conceptual point of view. I can't say that I will be able to reuse everything from this speech, but it's great start point for me. They are very proficient presenters.

4. Becoming a Professional Java Developer by Yakov Fain
I must say "Thank you" for this speech. It was cool. Yakov has highlighted the non-technical aspect of Professional (Java) Developer. Of course his advices and observation are based on own experience and might be biased for somebody. But it's honest and reasonable speech might open "some" boring minds. Also, Yakov recommended to read his free e-book "Enterprise Software without the BS". I've already downloaded it and I'm planning to read it in nearest weeks. 

5. Inject Injection by Yuriy Litvinenko
It was like a case study report about involving DI Framework (in this case Google Guice) in legacy project. It was very interesting, because I believe it's challenging task. The presenter has highlighted the issues which his team faced with. I can say this experience might be valuable when somebody needs to decide the benefits and evaluate the risks of involving DI Framework in something "really old". Well done.

6. Cloud Java platforms: what's inside and what's the difference by Ruslan Synytskyy
It was a pleasure to see ukrainian who is one of the founders of Jelastic. Ruslan has reviewed  different types of  "* as a Service": SaaS, PaaS and IaaS. The comparison criteria of PaaS's are very useful for further evaluation.

7. Why do I hate the Hibernate? by Mikalai Alimenkou
It was pragmatic, based on real experience presentation with tons of Hibernate issues. It's very useful for anyone who's developing application with Hibernate. We must know the weaknesses of our tools. Mikalai has used very interesting approach to blame something/someone: "nasty granny". You should review the slides to this presentation to understand what does it mean.

I'd like to say "Thank you" JEEConf organizers team. You are doing very important work for Ukrainian Java Community.

See: JEEConf - Kiev, 2011 - Report

Wednesday, May 02, 2012

Review: Java Brains Spring Framework - Core Spring, by Koushik Kothagal

I've recently watched the subject Java Brains - Spring Framework video tutorials and I must admit that these screencasts were well done. One of the best Java related video tutorials I've ever seen. Whether you are experienced or beginner developer it worth to watch them all. It's very good sample how to produce qualitative and pleasure to watch screencasts.

Let's review each tutorial one-by-one just to have some snapshot what was described there:

01 - Understanding Dependency Injection Dependency Injection (DI) introduction. Here was explained why do we need DI and some conceptual sample.

02 - Setting Up Project Setup. The author avoided using any build tools (Ant, Maven) and set up Eclipse-based project via using Eclipse User Library.

03 - Understanding Spring Bean Factory Explained the differences between Factory pattern and Spring Bean Factory without any technical details, plain conceptual overview.

04 - Writing Code Using the Bean Factory Actually it's the first video with some code inside. Author use classical approach to introduce Spring DI in practice - wrote simple code without Spring and re-wrote it with Spring. And it has nice effect - it became very descriptive.
The next Spring-related things were introduced:
  • spring.xml
  • BeanFactory
  • XmlBeanFactory and FileSystemResources
  • bean instantiation via factory
05 - ApplicationContext and Property Initialization Replaced BeanFactory with ApplicationContext. How to initialize bean property via spring.xml has been shown.

06 - Using Constructor Injection Depicted different ways of constructor injection:
  • plain
  • index based
  • type based
07 - Injecting Objects Created simple object and shown how to inject object dependency (i.e. was used  "property" tag and "ref" attribute, <property name="propname" ref="beanref" />

08 - Inner Beans, Aliases and idref The topic has pretty descriptive content, nothing more was here.

09 - Initializing Collections Here List was used as sample to initialize bean with collection. Stated that the same approach should be applied to Set and Map.

10 - Bean Autowiring Configured autowiring via spring.xml. Described pros&cons:
  • byName
  • byType
  • constructor
11 - Understanding Bean Scopes Explained bean scopes:
  • Singleton
  • Prototype
  • Request
  • Session
  • Global Session
12 - Using ApplicationContextAware Nicely shown how to use ApplicationAwareContext and BeanNameAware interfaces.

13 - Bean Definition Inheritance Nice Spring feature is bean definition inheritance and how it is different from OOP inheritance. Explained when to use it and what is the benefits. Introduced bean abstract and  parent attributes and when to use it.

14 - Lifecycle Callbacks Introduced init and destroy methods in different incarnations:
  • InitializingBean and DisposableBean interfaces
  • bean tag attributes: init-method and destroy-method
  • beans tag attributes: default-init-method and default-destroy-method
  • Added AbstractApplicationCantext to switch on redisterShutdownHook()
15 - Writing a BeanPostProcessor Shown how to implement custom BeanPostProcessor

16 - Writing a BeanFactoryPostProcessor Shown how to implement:
  • custom BeanFactoryPostProcessor
  • introduces properties for spring.xml via adding PropertyPlaceholderConfigurer (implementation of BeanFactoryPostProcessor)
Explained when and why to use BeanFactoryPostProcessors. Explained the differences between BeanFactoryPostProcessors and BeanPostProcessor.

17 - Coding To Interfaces Rewritten the initial demo project to support interface based design, the right way for developing Spring applications :-)

18 - Introduction to Annotations and the Required Annotation Added @Required annotation in demo project and activated it via adding bean post processor RequiredAnnotationBeanPostProcessor.

19 - The Autowired Annotation Shown how to use:
  • @Autowire and @Qualifier annotations
  • <context:annotation-config /> in spring.xml
20 - Some JSR-250 Annotations Shown how to use:
  • @Resource annotation
  • @Resource annotation with parameters
  • @PostConstruct annotation
  • @PreDestroy annotation
21 - Component and Stereotype Annotations Added the <context:component-scan base-packaeg="package" /> to spring.xml. Shown how to use @Component annotation and what rules applied to this annotation. Also, were mentioned other Spring stereotypes.

22 - Using MessageSource To Get Text From Property Files Shown how to use ResourceBundleMessageSource to get properties.

23 - Event Handling in Spring Very nice introduction tutorial into the subject: even definition, event listeners and even publishing on application level.

Ofcource, these tutorial are only intro and you should read Spring Documentation to gain the Spring "black" magic. But, it's good start point.

Tuesday, April 24, 2012

Review: Getting Good with Git by Andrew Burgess

There are several books about Git. I've decided to review them all and started with "Getting Good with Git" by Andrew Burgess
First of all it's beginner level book. I wouldn't recommend it to anyone experienced developer. Even more it's more like tutorial and not a book.
So, based on previous statements the next chapters can be easily cut off:
  • Introduction to Git
  • Commands
  • GitHub
 IMHO, I would left the next two chapters:
  • Configuration
  • Beyond the Basics
And more important is the price of this book: $19. Guys, come on $19 for this. It doesn't cost this money.

Summary: don't spend your time and money on this book.

Tuesday, March 27, 2012

Why you should join a user group?

Here I'd like to highlight the most important benefits for me:
  • Networking - ability to make social connections with developers from other companies
  • Learning - it's the right place to learn something for free and improve you skills.
  • Knowledge sharing - you shouldn't always take also you can give something to others. In our case it's your knowledge. Most people are very kind and really like to share own experience.
  • Public Visibility - here you can promote yourself as passionate and well skilled developer
  • Job Opportunities - you can find new contact which suggest a new job
  • Find Expert - it's the right place to find the right people which might help you to solve some technical problems
  • Become an Expert - it can happen
  • Meet Nice People - just fact :)
If you have other nice benefits please add in comments.

Sunday, February 26, 2012

State of numerical computation languages

When I was a student I spent a huge amount of time doing difference numerical computation with MATLAB and Maple. I must say I was falling in love with MATLAB. This environment, language and visualization possibilities were amazing and very powerful. I simply couldn't choose another stuff. It gave me a chance fully concentrate on engineering problems I had been trying to solve.

But now I must admit that MATLAB is very expensive software. And we should look around for other open-source mathematical computation environments. Today I'm biased because I prefer to invest time in general purpose language then in specialized computation languages (like MATLAB, R).

I've found very interested comparison (Mathesaurus):

Also, Hyperpolyglot provides nice comparison "Numerical Analysis Software: Fortran, MATLAB, R, NumPy".

Based on these two comparisons I've selected several factors for choosing the "right" numerical environments:
  1. Commercial or open-source
  2. Visualization possibilities
  3. Language itself (MATLAB, Maple, R, etc.): computational specific or general purpose (Python, Clojure/Incanter, etc. )
  4. Integration with Fortran/C/C++ etc.
  5. GUI features

Monday, February 13, 2012

UML Sketching Tools

UML drawing is painful in case your model should evolve very fast and you have to adjust it on the way. Such tool as Visio (and similar) is doing their job well till you don't need "aggressive" redrawing ;-) Have you ever tried to draw "huge" sequence, activity diagrams in Visio? I've "struggled" with grouping, layouting, styling, etc. So, I have decided to concentrate more on modelling and switched to "easy-going" UML tools also knowing as "Textual UML tools".
Here is the list of my favorite:
  • PlantUML - very powerful tool. It supports very intuitive diagram language. Seven diagram types, nice styling. And very good documentation.
  • UMLet - It's true sketching tool. Very very simple. And you shouldn't expect sexy UI ;-) BUT! It's so "right tool for the job". You just have to try it.
  • UMLGraph - It can be used to generate UML class and sequence diagrams. It has nice integration with javadocs tool.
I think that this Allen Holub's UML Quick Reference (example based and very pragmatic) might be helpful.

Saturday, January 21, 2012

Quick way to join array of String in Java without third party libraries

As you probably know Java SE doesn't include such useful method as String join. Even old good JavaScript has this nice method:
JavaScript join() Method
Definition and Usage
The join() method joins all elements of an array into a string, and returns the string. The elements will be separated by a specified separator. The default separator is comma (,).
How to implement the similar stuff in Java SE? The easiest what came to my head is:
  * Join String arguments into one String separated by comma (",")
  * @param args input Strings
  * @return joined String
 public static String join(String... args) {
  if(args.length <1) throw new IllegalArgumentException();
  String joined = Arrays.toString(args);
  String result = joined.substring(1, joined.length()-1);
  return result;
Usage is pretty trivial:
import static com.blogspot.HalypHUtils.join;


String joinedString = join("Banana", "Orange", "Apple", "Mango");
And as you've already noticed this join uses comma (",") separator only.