Set log4j2-Log Level via args4j parameters

Screenshot of a terminal executing the program

Implementing good logging in an application can be challenging. Using args4j we can easily set the root logging level of log4j via a command line parameter.

Introduction

When it comes to logging in Java, log4j2 is a wide-used framework. For small applications, using the configuration files to change the log level might be a bit of an overkill and a command line parameter is much more appropriate. If you don’t want to parse the command line parameters yourself, you can use a framework for that. args4j uses annotations to automatically populate the fields or properties of an object with the appropriate command line parameters.

In my recent project, I had the challenge of combining those two.

Continue reading Set log4j2-Log Level via args4j parameters

Linking Philips Hue and Ambilight from a Raspberry Pi

RaspberryPi + AmbiLight + Hue = Happiness

Using Hue bulbs to extend the Ambilight of my TV makes me happy. Using a Raspberry Pi instead of an app for that makes me even happier.

Introduction

For some time now, I have been wondering whether there is an easier ways to link my Philips Hue smart bulbs to the Ambilight of my Philips TV. Basically, my current setup is that I need to launch the Ambilight+hue app each time I want to watch TV to establish the link. Newer Philips TVs (I think later than 2014) seem to be able to provide this functionality without relying on this app. Unfortunately, my TV is from 2013, so no luck here.

If you only care for the result / download, then skip right to the end of the article.

Continue reading Linking Philips Hue and Ambilight from a Raspberry Pi

Will it block? Debunking async/await pitfalls

With classes and methods such as Task.Run, Task.Factory.StartNew, TaskScheduler, SynchronizationContext, ThreadPool and others it’s very easy to get confused by all the ways to distribute work between the UI thread and background threads in the .NET framework using C#. However, if you follow some easy rules and avoid some pitfalls, the TPL (Task Parallel Library) and the async/await keywords greatly simplify development of reactive user interfaces.

A screenshot of the "Tasks" window in front of source code
Debugging parallel code

Continue reading Will it block? Debunking async/await pitfalls

12 Java Snippets you won’t believe actually compile

“Does that really compile?” you might wonder not just once, but twelve times in a row – while reading this post about interesting, but valid Java syntax.

Our naming conventions have become quite complex recently
Our naming conventions have become quite complex recently

Continue reading 12 Java Snippets you won’t believe actually compile

Free and easy OCR for C# using OneNote

Although not suitable for production usage, this posting will introduce a free and easy way to equip your C# / .NET application with powerful OCR.

Surprise Pool
Surprise Pool, Yellowstone National Park – a fitting cover image in face of all the surprises you will encounter when using OCR

Continue reading Free and easy OCR for C# using OneNote