Milk – monitoring of the volume of infant’s feeding

The parents need to monitor the daily volume of the milk which the infant has eaten. Furthermore one need to also pay attention to the number of poops that the child makes during the day. I have decided to create an application that makes these things possible in very easy and comfortable way. Additionally storing the data only locally on the phone’s database was not an option because both parents should have an access to it. Because of that I have decided to keep the records on Google Firebase only.
The main screen of the application presents daily volumes of milk and on press results within a day are displayed. The best day is marked with a crown icon as well as a day with the highest volume of one-time feeding:
The application is being developed in React Native and the code can be found on this repo.

Kotlin Android application – Glucose

People with diabetes need to take frequent blood glucose measurements on empty stomach and an hour after each major meal. This data needs to be stored and then presented to the doctor during the appointment.
I was asked to create an Android application with which the user would save his measurements in google spreadsheets. This time I have decided to use Kotlin to create a native application because of the easier integration with google.
The application has not yet reached its final shape but currently has basic functionalities and can be used. Please find below the screens:

The spreadsheet is organized in the way one can find below (random test data are used):
Application is being developed with Fragments and uses Model-View-ViewModel pattern and the source code can be found on this github repo.

React-Native application – Raspberry Pi Radio

Recently I have got my Raspberry Pi Radio up and running again. In the past I created simple internet radio player by installing Music Player Daemon on my Raspberry Pi device. The radio looks like this:
In order to play/stop playing the hardcoded radio stream on need to press the yellow button on the top of the cover. This solution has a serious drawback: to change the radio one need to connect by ssh to the device and modify by hand the perl script which controls the button. This solution is far from being handy.
So I have decided to play around with Android application and I have created the mobile application – the remote controller. The prototype was created in pure Kotlin however I have decided to build the final version in React-Native. The application has the following screens:
It allows to play different streams which the user can add and remove. The application lets user to control the volume of the sound and restart or even shutdown the device as well.
The communication between the Music Player Daemon and mobile application is handled by the REST service I have created on Raspberry Pi with Express web application framework and mpc-js client library.
The entire code can be found on this repo.

Advent of Code 2019 in Kotlin

I have decided to solve this year’s puzzles in Kotlin and I have succeeded. Kotlin turns out to be very pragmatic programming language where you can very efficiently solve the problems. It reduces the boiler plate code to absolute minimum and this allows you to reduce the number of lines of your source code. However it needs a bit of training and patience, I had to switch from Java to Kotlin thinking.

My solutions can be found on this github repo

Solved Advent of Code 2019:
Screenshot from 2020-02-21 10-39-59

Kotlin scope functions: let, run, with, apply, and also

  • Let
  • inline fun  T.let(block: (T) -> R): R {
      return block(this)

    Let returns the result of lambda. Lambda takes as an input parameter the object upon let is invoked. Thus the object can be referred in the function scope as it. The function returns the last statement.

    val test = "my test string"
    val res = test
      .let { it.substring(0, 3) }
      .let { it.length}
    println(res) //3

    Let can be used for the null check:

    val test: String? = null
    test?.let {
      println("$it is not null") //prints nothing
  • Also
  • inline fun T.also(block: (T) -> Unit): T {
      return this

    Also returns the original object and the function invokes the lambda which takes as an input parameter the object which invoked also.

    data class Draft(var id: Long, var name: String)
    val draft = Draft(1L, "test")
    val res = draft.also { = 2L = "test2"
    println(draft) //Draft(id=2, name=test2)
    println(res == draft) //true
  • Run
  • inline fun T.() -> R): R {
      return block()

    Run is an extension function of the object which is invoking run. So in the scope of the function the object can be referred by this (however this can be omitted). The function returns the last statement.

    data class Draft(var id: Long, var name: String)
    val draft = Draft(1L, "test")
    val res = {
      id = 2L
      name = "test2"
    println(draft) //Draft(id=2, name=test2)
    println(res) //test2

    Run can be used for the null check:

    val draft: Draft? = null
    draft?.run {
      println(draft) //prints nothing
  • Apply
  • inline fun T.apply(block: T.() -> Unit): T {
      return this

    Apply is an extension function of the object which is invoking apply. In the scope of the function the object can be referred by this. Apply returns the original object.

    data class Draft(var id: Long, var name: String)
    val draft = Draft(1L, "test")
    val res = draft.apply {
      id = 2L
      name = "test2"
    println(draft) //Draft(id=2, name=test2)
    println(res == draft) //true
  • With
  • inline fun  with(receiver: T, block: T.() -> R): R {
      return receiver.block()

    With is invoked with the object passed as an argument then an extension function is called on it. In the scope of the function the object can be referred by this. The last expression of with function returns a result.

    data class Draft(var id: Long, var name: String)
    val draft = Draft(1L, "test")
    val res = with(draft) {
      id = 2L
      name = "test2"
    println(draft) //Draft(id=2, name=test2)
    println(res) //2

Please find the link to the Kotlin documentation regarding the conventions of using the scope functions.

Advent of code 2017 in TypeScript

Mission completed! I have just solved the advent of code 2017, however in June/July 2019 and not in December 2017 🙂
Programming puzzles can be found here: adventofcode2017 and my solutions: github/rzubala.
This time I used TypeScript which I was only using before for Angular applications development. I was just curious about the possibilities of this language in solving sometimes advent of code’s complex numeric problems. And indeed TypeScript is very handy, easy and fast to develop the code language. I would even say that sometimes it was easier to solve the puzzle in TypeScript than in Python I was using before.

Ubuntu – old releases

When you are using non-LTS Ubuntu your system may become impossible to update very soon. When the system upgrading is not the option you could try to update the content of
as follows:

Mutt as an command line ImapFilter

I have a free email account on server and I use it as a secondary account only for shopping or registration purposes. Everything works just fine and the only issue is the SPAM which sends me everyday and this SPAM can not be filtered by the filters defined in the account settings. I am fine with this since I am not paying for anything and it looks like it’s just the price you need to pay for this account.

I have started to look for some command line tool in order to filter and remove these unwanted and annoying messages automatically. I found a tool named ImapFilter. You can define some rules how to deal with the messages and ImapFilter will do everything by itself. The configuration is pretty simple:
Screenshot from 2018-09-10 16-20-29

… however in my case I was not able to make it running, I was playing around with the settings but every time I was receiving an error like that:

$ imapfilter
imapfilter: reading data through SSL; EOF in violation of the protocol

So I decided to look for an alternative solution and eventually I found a command line email client Mutt. It’s really powerful and handy utility and without any issues I was able to make it running and apply SPAM filtering.

The configuration is stored in ~/.muttrc file:

set imap_user = ""
set imap_pass = "somepassword"
set smtp_url = "smtps://"
set smtp_pass = "somepassword"
set from = ""
set realname = "AA"
set folder = "imaps://"
set spoolfile = "+INBOX"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.cache/mutt/messages
set certificate_file=~/.mutt/certificates
set move = no

To show the messages in Mutt sent by one need to define the limit ~f Then to delete the messages one need to press D and confirm the operation with the key $. And that’s it.

To make it even faster I defined an alias in ~/.bashrc file:

alias wppl='mutt -e "push '"'"'<limit>~f<enter>D<enter>'"'"'"'

which opens the mutt with already filtered and tagged to delete messages.