Spring Boot Admin inside Docker

Spring Boot Admin is great tool to manage and monitor your Spring Boot Applications. As the famous idiom says, a picture is worth a thousand words.

It offers really cool features and it is very easy to install, but… it gets bit more complicated when you have all your applications in Docker and want to run Spring Boot Admin in Docker as well.
If you use Spring Cloud supported service discovery solution like Netflix Eureka, Zookeeper or Consul you can probably run Spring Boot Admin within this service discovery and you are good to go. Find more about it in documentation.

In this post I will describe what you need to do if you are not using any of these service discovery tools and want to run Spring Boot Admin as Docker container along with you other Spring Boot applications.

Czytaj dalej

Why to use Spock

From Spock documentation:
Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language.

Spock in an amazing testing framework, which I believe is a better replacement for JUnit library. Using Spock will make your tests not only easier to write, but what is more important, it will make them easier to read and understand their results.

What could be the biggest challenges to switch from JUnit to Spock:

  1. Spock is using Groovy (not Java) so you need to learn new language.
  2. Spock is not JUnit so it is not compatible with other software (i.e. IDE, build tools, continuous integration tools).

Fortunatelly, the above statements are false!

Czytaj dalej

Definition of Done

It is not always clear what are the requirements for the task to be considered „done”. Each team member might have slightly different understanding of „done” which is build gradually with gaining experience in the team. This can sometimes cause miscommunication and misleading perception of functionality as being production ready. From the team member perspective (especially someone new in the team) it is hard to tell if all the work required for the task, has been completed.
There is a solution for this issue called „Definition of Done” which is well known Agile methodology tool.

Czytaj dalej

Date and time in Java – java.util.Date and java.time.Instant

I have lately discovered, I wasn’t fully aware how date and time works in Java. In my current project we are using date and time quite heavily, but until recently we were on Java 7 and we have used java.util.Date and Joda-Time library.
Recently things have changed when we’ve started a new project using Java 8 with brand new and shining Date and Time API (JSR 310). Because we are integrating our application with external system which API library was using old java.util.Date, we had to convert data between old java.util.Date and new date and time Java API.

Czytaj dalej

Editable HTML element with AngularJS and HTML5 contentEditable attribute

There is a new attribute in HTML5 „contentEditable”. It allows user to edit content of the website elements like „span” or „div”. It might be very useful when you need to make some element editable only in the specific circumstances.
I my TaskRoo project I am using „contentEditable” with AngularJS to make tasks names editable in-place with the double-click.

ContentEdit

In this post I will describe how to implement and use AngularJS directive to make HTML element editable in-place. In case you are just looking for solution, you can find complete implementation on plunker:

http://plnkr.co/edit/Yt4bFd9mF9iwZirtWvYg?p=preview

Czytaj dalej

Null sucks

I know there are already many articles in this topic, but sometimes looking into the codebase, I feel it is still not emphasised enough. This post purpose is to explain why null reference is undesired in clean code. I would like this post to clearly answer why „null” should be avoided if you care about quality of your code.
Czytaj dalej

Game of Life on Global Day of Coderetreat 2014

Last Saturday I took part in the Global Day of Coderetreat 2014 (GDCR2014) in Aspect Capital, London. GDCR is an amazing event organised every year since last 6 years. This year it was organised in 44 countries, 141 cities with about 2500 developers participating.

Long story short – on GDCR there is a simple programming problem to solve: Conway’s Game of Life. The aim is to learn as much as possible and not necessarily solve the problem. To achieve this aim there is 6 pair programming (and TDD) sessions. To make things even more interesting, each session had a different additional constrains and you should pair program with someone else. After each session you remove all you have done so far and start the next one from scratch.

I have never solved the whole problem during the sessions, but I feel, I have learn a lot anyway. The day after the GDCR I have decided I want to finish the task and implement the complete solution for Conway’s Game of Life and so I did.

My solution is available on Github. It is implemented in Scala. There is also small bonus as I have integrated the solution with the GUI implemented in Swing by other GDCR2014 attendee.

Groovy coding conventions

At work we are using Groovy language to write the Cucumber acceptance tests. Groovy turns out to be very nice language with flat learning curve for Java developer. There are many interesting features in the language, but I believe some of them have to be used with caution.
As we work more with Groovy and learn more of its features we found there are many ways of doing the same thing. It is useful, because it makes code more expressive, but it can also be an issue when there are multiple developers working on the same code base. This problem most probably exists in every programming language and it can be partially solved by agreeing on the coding conventions. Unfortunately there is no established code convention for Groovy yet as there are for other languages like Java.
In this post I list some features of the Groovy language and try to choose a convention to use. Of course this is not the only correct approach. This is more a try to orginise the conventions and keep it for future reference.

Czytaj dalej

Owncloud – instalacja i aktualizacja

Owncloud to aplikacja, która umożliwia utrzymywanie swoich plików, kontaktów i kalendarzy w prywatnej chmurze. Owncloud do działania potrzebuje tylko PHP i MySQL (lub SQLite). Większość osób najprawdopodobniej kojarzy Dropbox, który ma bardzo podobny sposób działania. Owncloud wyróżnia się tym, że możemy go zainstalować na własnym serwerze dzięki czemu nie musimy polegać na firmie, która będzie zarządzać naszymi danymi.

Instalacja z konsoli, na serwerze, na którym jest zainstalowany Apache wraz PHP i MySQL jest banalnie prosta i opiera się na pobraniu odpowiednich plików z repozytorium GIT.

Jeśli na serwerze nie są zainstalowane potrzebne paczki to należy doinstalować:
apache2 php5 php5-sqlite php5-json php5-gd

Można też doinstalować paczki:
mp3info curl libcurl3 libcurl3-dev php5-curl zip

Te drugie nie są niezbędne, ale mogą zwiększyć możliwości aplikacji.

  1. Najlepiej przejść od razu do miejsca, w którym chcemy docelowo zainstalować OwnCloud
  2. Teraz pobranie pliku z repozytorium git:
    git clone git://gitorious.org/owncloud/owncloud.git
  3. Kolejny krok to zmiana odpowiednich uprawnień dla Apache’a:
    sudo chown -R www-data:www-data owncloud
  4. lub jeśli sudo jest niedostępne:
    setfacl -Rm d:u:YOUR-USERNAME:rwx,u:www-data:rwx owncloud

To w zasadzie wszystko. Pozostaje wejście przez przeglądarkę na stronę wskazującą na katalog z zainstalowaną aplikacją i skonfigurowanie tam kilku opcji.

Zainstalowanie OwnCloud w ten sposób daje też łatwą możliwość aktualizacji.Jeśli w repozytoium GIT pojawi się nowsza wersja, wystarczy wejść do katalogu owncloud na serwerze i wpisać komendę:
git pull --rebase

Kod OwnCloud powinien zostać automatycznie zaktualizowany do najnowszej wersji.

I'm Linux!

Linux Foundation startuje z kampanią reklamową, a właściwie konkursem, mającym promować systemy Linux. Kampania „I’m Linux” ma być odpowiedzią linuksowego świata na wcześniejsze akcje promocyjne „I’m Mac” oraz „I’m PC”.

Linux Fundation zachęca wszystkich do nadsyłania filmików związanych z zaletami systemów Linux. W zamian, na twórcę najlepszego filmu czeka wylot i konferencja Linux Foundation Japan Symposium w grudniu 2009.

Tutaj można umieszczać filmy, a także zdobyć więcej informacji na temat konkursu.