ReactiveNetwork – release of v. 0.2.0

2016-02-11 Android, Java, Open source, RxJava No comments

I’ve recently released new version of ReactiveNetwork library for Android.

Here are the fresh release notes for version 0.2.0:

  • added possibility to observe WiFi signal level with observeWifiSignalLevel(context, numLevels) and observeWifiSignalLevel(context) method
  • created WifiSignalLevel enum
  • added internet check to parameters of getConnectivityStatus(context, checkInternet) method
  • made getConnectivityStatus(context, checkInternet) method public
  • changed String variable status in ConnectivityStatus enum to description and made it public
  • changed output of the toString() method in ConnectivityStatus to keep consistency with another enum
  • made ReactiveNetwork class non-final
  • bumped Kotlin version in sample app to 1.0.0-rc-1036
  • increased immutability of code of the library
  • updated sample apps and documentation

Thanks to @llp and his Pull Request, we are able to observe WiFi signal level AKA RSSI now! It’s one of the most interesting features in the newest release.

We can do it as follows:

or we can observe an enum value instead of integer:

WifiSignalLevel enum can have the following values:

public enum WifiSignalLevel {
  NO_SIGNAL(0, "no signal"),
  POOR(1, "poor"),
  FAIR(2, "fair"),
  GOOD(3, "good"),
  EXCELLENT(4, "excellent");

Any feedback will be appreciated!

Happy coding!

Converting audio CD to *.mp3 files on Linux

2016-01-24 Linux, Ubuntu 2 comments

Not all songs are available on Spotify and sometimes we need to rip music from audio CDs in order to listen it on our computer or mobile device.

There are several approaches to do that. Here is mine:

Get RipperX:

sudo apt-get install ripperx

Put audio CD into your computer. Open RipperX, select All Tracks and check Rip to WAV option. Set quality of output files via “Config” option and names of the tracks if your want. Press “Go!”. After conversion, you should have directory with ripped *.wav files in your home directory.

Get SoundConverter:

sudo apt-get install soundconverter

Run it and convert *.wav files to *.mp3. You can choose another output format if you want.

Get EasyTag:

sudo add-apt-repository ppa:amigadave/ppa
sudo apt-get update
sudo apt-get install easytag

Open EasyTag and set appropriate tags for your *.mp3 files. You can also set CD cover as image for each file.

You are done!

Now, you can import files to your favorite music player. I’m using Spotify right now, where I can select local files, create a playlist and even sync it with my mobile device if my computer is in the same WiFi network. It’s very handy option.

I hope, this short tutorial will be helpful for you.

My summary of 2015

2016-01-16 Self development, Uncategorized No comments

Lot of people are making summaries of the last year on their blogs, so I’ve decided to create mine as well.
It’s also good way to collect your thoughts and do some analysis.

Everything started from open-source

In the last year I wanted to have my very own open-source project, which will be well written and popular. I wanted to start from something simple, so I created String formatting library called Kirai, which was written in TDD methodology. I wanted to make it as good as possible, with clean code, tests, continuous integration, examples, clear documentation and possibility to add it as Maven or Gradle dependency to simplify its integration with other projects. After that, I’ve posted it to website. Maintainer of this website added this library to the list as well as few of my other projects, which I haven’t posted. To my surprise, other projects were becoming popular. Unfortunately, they weren’t well written, so I started to improve them and making them better and better. This gave me a lot of energy boost. I also got Pull Requests and issues, which helped me to find some bugs, which I haven’t noticed. Moreover, thanks to other developers I was able to develop and release these projects faster. In the meantime, I got new, fresh ideas for new projects and implemented them. I still have more ideas waiting for realization. Besides that, I contributed to various projects of other users. One of my first contributions in 2015 was Pull Request to JavaPoet project. It wasn’t easy, but gave me enough confidence required to participate in more projects and shown me that keeping high quality of work can pay off. It’s an interesting fact that you can co-create open-source project with the best engineers overseas, they will respect your work and give you constructive feedback. It can be empowering experience from which you will learn a lot. Below, you can see my GitHub contributions to open-source projects in the last year.


According to coderstats all my repositories have 1274 stars and 157 forks right now. For your information, actually all of them were made in 2015.

My currently most popular project called ReactiveNetwork was featured on, which is well-known website in Android community. What is interesting, this library is small, very simple and its first version was developed in a few hours, but I knew exactly what I want to achieve in the end and how its API should look like. Moreover, this library solves 2 simple problems and it’s not all-in-one solution. Actually it’s improved successor of my previous project called NetworkEvents, which does the same thing, but in a different, less convenient way.

I think I somehow addicted myself to open-source contributions. I think it’s good and I always wanted to do that, but I didn’t know the right way.

Helping people to solve their problems

To give more from myself, I’ve decided to start contributing to StackOverflow community, because I’ve been always using this website, so I’d feel bad If I won’t contribute anything back. The same rule applies to open-source. It’s also a good way to train your abilities to understand problems and clearly explain correct solutions for them. From the chart below, you can see clear reputation progress.

Learning new things

I learnt much more about RxJava by creating some reactive libraries for Android. I also decided to learn Python by creating special repository on GitHub to track my progress and collect resources related to this language. I also created a few small Python projects. Moreover, I touched some of different technologies, but haven’t learnt them deeply. I definitely need to learn more about new things, languages and technologies I already use, what is probably more important. I also feel more comfortable around Linux and command line, but still there’s a lot of things to learn about. Software developers often underestimate such knowledge, but in my opinion it’s important and useful.

Fun fact: On Linux, it’s possible to prepare environment for almost any technology in a very short period of time. I’ve tested it with Haskell, Ocaml, Python, Go, Node and even pretty old-school technologies like COBOL and Fortran. Of course, I don’t know all of these languages yet and just wrote some “hello world” programs, but I could setup everything really fast without knowing anything in the beginning!

Learning fundamentals

I’ve decided to learn more about fundamentals, clean code, testing, algorithms and Java by reading more books and articles. I’ve already knew something about that, but my knowledge was too low and not sufficient. I still need to learn more, but I think I’ve found some way to do it right. I think, deep understanding of fundamentals of computer science, software development, software quality and our primary programming language is more important than knowing the newest, bleeding-edge, top-notch JavaScript framework, which will be outdated in 10 minutes and everyone will forget about it. Fundamental knowledge is universal and will never be outdated.


I haven’t pushed myself to create regular blog posts. In fact, I have been publishing at least one article per month, but sometimes I published more. I just wanted to collect some resources, knowledge and solution for some problems. Sometimes I use them again and I don’t have to re-invent the wheel if I already solved a specific problem in the past and documented it. Moreover, other people can have similar problems and I can share this knowledge. I also use the blog for publishing information about my projects and new releases. Below, you can see list of the most popular articles on the blog. As you probably noticed, most of them is related to solving problems connected with Android and Ubuntu Linux.

Interesting fact: People are usually viewing blog in the work-days.


Moreover, some of my articles were linked on StackOverflow and Reddit what is flattering.
I think, I’ll continue publishing articles and try to make them better as I’m not fully satisfied with form and content of all of them.

Being a conference speaker

Of course, on-line activity is not enough. Sometimes, it’s good to go out and talk with people. Due to my open-source contributions I was asked to be a conference speaker on 2 conferences. I actually was able to speak during one of them, which was GDG DevFest in Warsaw. It’s really interesting and challenging experience. I’d totally recommend anyone to try that out. You can read more about it in Reactive Live Coding during GDG DevFest 2015 in Poland article.

Starting new job

In December 2015 I’ve left my previous company called Future Processing and started new job at SAP Hybris. I wanted a new challenge, which triggered such change. Now, I’m working on development of enterprise framework used by other developers in their implementations of e‐commerce systems for big companies. It’s great responsibility, possibility to learn new things and gain new experiences in a new environment.

What’s next?

Definitely I want to keep up the pace with the things, which I think are good. Of course, I have some professional and personal goals in my head, but I won’t write them down. From my experience I think it’s better to start doing things instead of writing about them. Someone said that with this technique, you can increase probability of realizing your resolutions. 😉

3 questions about your Git repository

2015-12-28 Git, Linux, Open source, Python 3 comments


Can you answer the following questions about your Git repository?

  1. Does development branch has all changes from master branch?
  2. Is your gitlog a crap?
  3. How old are your branches?

If not, but you want to know answers, you’re lucky, because I prepared 3 simple scripts for you, which can help to find it out.

Does development branch has all changes from master branch?

git-branch-comparator is a python script, which checks if development branch has all changes from master branch in Git repository.

Another, easier way to accomplish the same task suggested in comments by Mike (thanks!) is to call simply:

$ git pull
$ git branch --contains master --no-merged development

When we are working in a Git Flow and critical bug occurs on production, sometimes there is a necessity to create so called hot-fix. We can create separate branch from master branch for this hot-fix and then merge it into master branch or we can commit a change on master branch. Second option is not recommended. After that, we have to remember to merge master branch into a development branch to have our hot-fix in a development version as well and avoid merge conflicts in the future.

This python script checks, if all changes made on master branch were also merged into development branch to keep those two branches consistent. We can add it as a job into Jenkins CI server and monitor branches consistency. In addition, release jobs can depend on that job and we can avoid merge conflicts or project unstability before release.

source code & documentation:

Is your gitlog a crap?

craplog is a python script, which checks if git git log of the given project is crappy or not. Right now, script is very simple. It just checks if more than half of the commit messages are good. Commit message is considered as good, when it contains more than two words. Of course, this is not the only condition determining the quality of the commit message, but this is early beta version of the script and can be improved later.

I’ve read a discussion in one of the pull requests to Linux kernel. It made me think about quality of Git commit messages. Of course, Linux kernel is a specific project and has its own standards. Maybe not all of these standards will be valid for a simpler or less complicated projects. Nevertheless, a lot of people don’t pay attention to git commit messages. They put crappy stuff inside them like random letters and numbers or stupid expressions, which has no specific meaning, aren’t related to the project or aren’t informative enough. In my opinion, good git log is one of the factors determining good quality of the project. Sometimes, we need to browse log to find some changes or analyze project history in order to fix a bug or find important information. It’s easier to do it, when git log is good. I’ve made some of the mentioned mistakes in the past, but I try to avoid them now.

source code & documentation:

How old are your branches?

git-aged-branches is a shell script showing git branches of defined repository with age of their last commit. It works on Mac OS X, Linux and can be helpful while investigating old Git branches to delete. This script does not delete anything! It’s just for informational purposes.

source code & documentation:


I hope, some of you will find these tools useful and maybe they’ll solve your current problems or help to improve quality of your projects.
If you would like to know more details about mentioned projects, check instructions how to use them and their source code, visit linked repositories on GitHub.

Note: Any feedback, new issues or pull requests are appreciated!

Reactive Live Coding during GDG DevFest 2015 in Poland

2015-11-29 Android, Conferences, Google, Java, RxJava 2 comments

I was asked to be a speaker during GDG DevFest 2015 conference in Warsaw, Poland. Of course, I accepted this invitation and prepared presentation titled “Reactive Live Coding”. Presentation covered basics of Reactive Programming, RxJava and RxAndroid. Besides my talk I’ve done live coding to show how to use mentioned libraries and basics principles of Reactive Programming in real life. I had only 20 minutes for all of that, so my time-box was very limited. Being a speaker at conference was really interesting and challenging experience, which I haven’t had before. Moreover, I could meet a lot of interesting people and hear very inspiring talks covering different topics. You can check activity from conference by browsing #devfest15pl hashtag on Twitter and Facebook event. You can also check official website of the conference at

Slides from my presentation are available below.

Source code of the exemplary Android app shown and partially coded during the presentation is available at

Picture documenting part of my short talk made by @depodefi can be found below.


GDG DevFest organizers have done really good job and I can definitely recommend this conference to anyone interested in new IT technologies.

New release of Kirai – elegant string formatting library for Java

2015-11-22 Android, Java, Open source No comments

I’ve recently released version 1.4.0 of Kirai library. Kirai means phrase in Swahili language. It’s string formatting library written in Java. It originally started as an Android library, but it evolved to pure Java library. It’s first possibilities were basic string formatting and text formatting for Android TextViews. Now, it allows to format strings for Java, Web, Android and even Unix Terminal! Have you ever wanted to have colorful and styled text in your mobile app, website or terminal app? Now you can with an elegant and fluent API! Moreover, I’ve added test coverage supported by It’s really nice service, which integrates with Travis CI and is free for open-source projects. It’s available for various programming languages and build systems.

Check library source code and samples at:

You can add it to your project via Maven:


or through Gradle:

dependencies {
  compile 'com.github.pwittchen.kirai:library:1.4.0'

Bunch of updates in my OSS for Android

2015-11-08 Android, Java, Kotlin, Open source No comments


In the last days I prepared a bunch of updates in my open-source software for Android. Most of them are bug fixes and are related to increasing robustness of the projects as well as their overall quality. I also decided to play a little with Kotlin language from JetBrains, which seems to be reasonable choice for mobile applications running on Android. Nevertheless, writing an app in Kotlin requires some additional configuration and we should remember, it’s still in beta version. If you are interested in Kotlin programming for Android, take a look at Getting started with Android and Kotlin guide from official Kotlin website. You can also take a look at one of my sample apps written in Kotlin and its configuration in Gradle.

Summary of updates

ReactiveNetwork v. 0.1.3

  • fixed bug with incorrect status after going back from background inside the sample app reported in issue #31
  • fixed RxJava usage in sample app
  • fixed RxJava usage in code snippets in
  • added static code analysis
  • updated code formatting
  • added sample sample app in Kotlin

Unfortunately, in Android we cannot use Java 8 yet and code should be written in Java 7. We can do some hacks like using RetroLambda or libraries implementing part of functionalities available in Java 8 like streams, but these solutions are still hacks – not the right way. In Kotlin we can use lambdas like in Java 8. In addition, we have a lot of other cool features, which allow us to write less lines of code and detect possible mistakes while writing apps. E.g. Kotlin helps us to avoid NPEs with its additional operators like !!, which tells us that NPE can occur, so we can think of eliminating this possibility. If we don’t use this operator when we should, IntelliJ IDEA or Android Studio will warn us. Below, we can see exemplary usage of ReactiveNetwork library with Kotlin. In this code snippet, we are using so called synthetic properties from Kotlin Extensions for Android. Value connectivity_status is an id of the view defined in XML layout. We can call it directly in Kotlin code and treat as object. It’s really useful and allows us to avoid calling findViewById(...) method for every view in Activity or injecting views with additional libraries like ButterKnife or KotterKnife. It means that we can get rid of a lot of boilerplate code.


  • fixed RxJava usage in sample app
  • fixed RxJava usage in code snippets in
  • added static code analysis
  • refactored sample app and removed repetitions in code

In this project I made only changes inside the documentation, improved Gradle configuration and added another sample app. There were no changes inside the library code, so there was no need to release new library version to Maven Central Repository. Moreover, I’m going to add sample app in Kotlin for this project in the nearest future.

ReactiveBeacons v. 0.3.0

  • replaced distinct() operator with distinctUntilChanged() operator in Observable observe() method in ReactiveBeacons class
  • added permissions ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION to satisfy requirements of Android 6
  • renamed void requestBluetoothAccessIfDisabled(activity) method to void requestBluetoothAccess(activity)
  • added boolean isBluetoothEnabled() method
  • added boolean isLocationEnabled(context) method
  • added void requestLocationAccess(activity) method
  • modified sample app in order to make it work on Android 6 Marshmallow
  • reduced target API from 23 to 22 in library due to problems with additional permissions and new permission model (it can be subject of improvements in the next releases)
  • added package private AccessRequester class
  • added sample app in Kotlin

WeatherIconView v. 1.1.0

  • added icons from 2.0 version of the original weather-icons project
  • updated compile sdk version
  • updated Gradle Build Tools version

Prefser v. 2.0.2

  • fixed bug reported in issue #70: get(...) method now returns a null value instead of “null” string when setting default value to null of String type
  • fixed RxJava usage in sample app
  • fixed RxJava usage in code snippets in
  • changed code formatting to SquareAndroid
  • added static code analysis
  • improved code according to static code analysis suggestions

Kirai v. 1.1.0

  • removed formatter(...) method from Kirai class
  • added format(...) method accepting implementation of Formatter interface to Kirai class
  • added Syntax interface and HtmlSyntax class implementing this interface
  • added put(String key, Object value, Syntax syntax) method to Piece class
  • set HtmlSyntax as default Syntax implementation in Piece class
  • removed dependencies to Android SDK
  • updated project dependencies
  • applied Square code style
  • updated tests, sample app and code snippets in
  • added gh-pages with JavaDoc

Any suggestions of further improvements are more than welcome as usual!

An Opinionated Guide to Modern Java by Parallel Universe

2015-11-05 Java No comments


I recently read series of three articles titled An Opinionated Guide to Modern Java by Parallel Universe. It presents really interesting point of view and can be read even by non-Java developers due to its form. Non-Java developers can learn that Java can be fast, elegant and lightweight as much as other hipster technologies like Ruby, Go or Node.js. The main difference is the fact that Java is quite old and widely used technology what means it’s well tested, stable, solid, has great development and monitoring tools. Besides widely known projects, author of the articles presents some information about tools built by Parallel Universe, which are not commonly used and are less popular, but are also worth considering for modern development. E.g. he writes about so called Capsule project, which is intended to be a Docker alternative for Java and Quasar, which is interesting high level API for multi-threading with concept of actors, which is also available in Akka and Erlang. I recommend any Java and non-Java developer to read this series to learn new things and consolidate the knowledge.

Series of articles

Introducing ReactiveBeacons

2015-09-30 Android, Context awareness, Java, Open source No comments

Recently, I’ve created yet another reactive library for Android. It’s called ReactiveBeacons and it’s responsible for observing BLE (Bluetooth Low Energy) beacons. Beacons are small devices, which became quite popular in the last years. They can be utilized in creating Contextual Awareness, Contextual Computing and Internet of Things. Beacons have lithium battery, are constantly turned on and emit signals via Bluetooth all the time. ReactiveBeacons library allows to transform these signals into Observable stream compatible with RxJava. Whenever new beacon is detected or RSSI (Received signal strength indication) changes, new immutable beacon data is emitted.

Usage of the library inside the Activity is simple:

We also have to remember to unregister subscription correctly in order to stop BLE scan, which can drain the battery.

If you want to use this library in your project, add the following dependency to your build.gradle file.

dependencies {
  compile 'com.github.pwittchen:reactivebeacons:0.0.1'

Don’t forget to add dependency to RxAndroid if you want to use Android-specific features of RxJava.

Source code of the library can be found at:

Any new issues or pull requests are welcome!
Happy coding!

Using tmux

2015-09-20 Linux No comments

What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more.



Tmux feature, which I find very useful is tiling terminal window. We can have several tiles with different terminals within a single terminal window.

How to use tiling?

First, we need to install tmux:

$ sudo apt-get install tmux

Then, we need to start it:

$ tmux

When we are inside tmux, we can execute its commands. It’s good to check full list of tmux key bindings.

Default initial key binding for different commands is Ctrl+B. When we hold Ctrl and then press B, we can press next key for specific command. It’s tricky and it isn’t intuitive at the first time.

For example, if we want to split terminal window vertically, we need to do the following thing:

Start tmux, Hold Ctrl, press B (while holding Ctrl), release buttons and press % key (equivalent to Shift+5).

If we want to split terminal window horizontally, we need to do the following thing:

Start tmux, Hold Ctrl, press B (while holding Ctrl), release buttons and press " key (equivalent to Shift+' – code for ' sign is 47 for xdotool).

We can create any tile configuration we want like in i3 windows manager.


If we want to switch between tiles, we need to use the following key combination:

Hold Ctrl, press B (while holding Ctrl), release buttons and press O key (“O” letter – not zero).

Creating 4 tiles automatically

Popular terminal windows configuration is 4 tiles (2 columns and 2 rows). We can split windows horizontally or vertically pretty fast with default shortcuts, but creating layout consisting of 4 tiles requires some clicking. I’ve written a simple script, which generates such layout for us automatically and saves the time.

First, we need to install xdotool:

$ sudo apt-get install xdotool

Next, we can create file named tmux-4tiles, set its chmod to 777 and save it in /usr/local/bin/ directory.

File should have the following content:

# generates 4 tiles in tmux (requires tmux and xdotool)
xdotool key ctrl+b shift+5 && xdotool key ctrl+b shift+48 && xdotool key ctrl+b o && xdotool key ctrl+b shift+48 ctrl+b o ctrl+b o ctrl+b o && clear

It’s also available in my dotfiles on Github.

When, we are done, we can enter tmux:

$ tmux

and run the script:

$ tmux-4tiles

After that, we’ll get the following layout:


We can automate generating different layouts for our purposes in the same way.


In my opinion, tmux is very useful tool for people working with terminal who want to have organized windows in an elegant way.