You may be doing FP already

Functional programming (FP) has been a somewhat hot topic in recent years in my surroundings. Although in my close surroundings people are usually not zealous or overly excited, I do notice sometimes talks, discussions and vocally expressed opinions where tremendous benefits of FP over other paradigms are claimed, through presenting FP as a fundamentally new approach to writing code, opposite to, say, OOP. Some go as far as saying, that one must fully ditch OOP and all related experience because it’s all just a mistake.

Such extreme claims are rarely challenged. When a person with an OOP background gets involved in any FP-related discussion, it quickly gets overwhelmed with new unfamiliar vocabulary: algebras, monads, semigroups, functors, type classes…​ And I start questioning intents of those claims — are they made to make people shift to FP, or to prove, that some definition of FP is better than some definition of OOP?

With this post, I hope to show that FP can be seen as an evolutionary step, a generalization over practices we already consider the best in OOP paradigm. And if viewed like this, it can be useful even when adopted gradually. I hope this point of view will persuade programmers to look into FP and to borrow new techniques from it to improve non-FP code.

Filtering ScalaTest tests by tags in sbt

ScalaTest lets you tagging your tests with arbitrary tags and then filtering by tags when executing tests.

It’s not immediately obvious though, how to make use of this in sbt, at least I couldn’t find an answer on the very first page in Google or StackOverflow, and I remember myself looking for a complete solution for quite a while, so here it is.

Turning Synology NAS into a geeky media server: PulseAudio

This post was written in pre-docker era. Back in the time it was necessary to perform many things that are no longer required on modern devices (like installing Debian Chroot package which, expectedly, is no longer offered).

Modern devices with Docker support or equivalent features (FWIW, my choice is Linux Station from QNAP) are much more friendly towards linux enthusiasts

Required files can be downloaded from https://github.com/edio/synology-mediaserver

Previously we’ve covered ALSA setup and Debian chroot.

In this post I’ll describe how to set up PulseAudio in Debian chroot, so that it’s possible to stream any sound from linux-powered pc to a sound card connected to Synology NAS.

Overloading that is not permitted or Java bridge methods

Most of my technical interviews for Java developer position include a puzzle, where candidate should implement 2 very similar interfaces in a single class:

// Implement both interfaces in a single class if possible
// Explain why possible or not possible

interface WithPrimitiveInt {
  void m(int i);
}

interface WithInteger {
  void m(Integer i);
}

Sometimes candidates, not being sure about the right answer, are willing to solve the following puzzle instead (I give it to candidates later anyway):

interface S {
  String m(int i);
}

interface V {
  void m(int i);
}

Turning Synology NAS into a geeky media server

This post was written in pre-docker era. Back in the time it was necessary to perform many things that are no longer required on modern devices (like installing Debian Chroot package which, expectedly, is no longer offered).

Modern devices with Docker support or equivalent features (FWIW, my choice is Linux Station from QNAP) are much more friendly towards linux enthusiasts

Required files can be downloaded from https://github.com/edio/synology-mediaserver

I’m not a huge fan of Synology. I bought my DS214 by friend’s recommendation and became frustrated with it right after the purchase. Bundled software was limited and buggy. Many people find Synology products great. But for me it just didn’t work well because it forced its use cases on me instead of being a helpful tool for my own very specific use cases.

Anyway, I wasn’t willing to lose money on reselling my NAS, so I decided to get as much as possible from it and currently with my DS214Play I can:

  1. Play virtually any sound via connected USB sound card.

  2. Particularly, I can play my huge collection of high-resolution music in various formats (with replaygain tags respected). All that thanks to mpd, which I can control from any decent phone, web-browser or even smart-watch and scrobble all statistics to Last.fm.

  3. Stream sound from my laptop via PulseAudio, while watching videos on YouTube or movies.

randrctl — profile-based screen manager for X

While having some free time, decided to automate one of my daily routines — setting up external display.

Idea appeared long before I was told about famous (or not?) autorandr project. So if you are familiar with autorandr, you are already familiar with randrctl idea.

How Java logging frameworks determine caller class and method name

This post describes how java logging frameworks (log4j, for example) know a point (concrete class and method name), where logging statement has been invoked.

I decided to write this post, because quite often I communicate with developers, who do not understant what is the cost of writing caller information to logs, and why such high cost is imposed.