Log4j2 PatternLayout Cheatsheet

In Log4j2 for Kotlin I’ve showed you how to configure a basic logger with log4j2. If you use a PatternLayout like this appender.console.layout.type = PatternLayout appender.console.layout.pattern = %m%n you can customize the appearance of the output. eg. appender.console.layout.pattern = %d{yyyy-mm-dd-HH:mm:ss.SSS} %-4p %C{1}.%M [%t] – %m%n%ex Parameter Parameter Meaning %m The log message %n line break…

Log4j2 for Kotlin

Motivation Logging is a common good practice in software engineering. It enables you to monitor applications in production to gather information about crashes and other malfunctions for further analysis. It is the “little brother” of debugging and often a precursor for setting up test cases which can lead to reproducing the bugs on the developers…

Kotlin Scripts with Gradle

If you are using Gradle and you want to run a Kotlin script you have to add the following to your build.gradle file dependencies { implementation “org.jetbrains.kotlin:kotlin-stdlib” implementation ‘org.jetbrains.kotlin:kotlin-script-runtime:1.4.32’ }

Python Argparse

Primer: Arguments vs Parameters I’m sometimes confused. Is it an argument or a parameter? So here it goes: A parameter is a variable in a function definition. When a function is called, the arguments are the data you pass into the function’s parameters. The same goes for a program: A program has parameters, you call…

Android Asynchronous Http Client

Motivation In Android it is highly inadvisable to do heavy lifting in the UI thread. When you even try to do some networking stuff like fetching images from a web server you might get an android.os.NetworkOnMainThreadException I’ve also written about it here To work around this issue you can use a third party library like…

New Blog Post

k-fold crossvalidation with sklearn

from sklearn.model_selection import KFold kf = KFold(n_splits=2) kf.split(df_train) step = 0 # set counter to 0 for train_index, val_index in kf.split(df_train): # for each fold step = step + 1 # update counter print(‘Step ‘, step) features_fold_train = df_train.iloc[train_index, [4, 5]] # features matrix of training data (of this step) features_fold_val = df_train.iloc[val_index, [4, 5]]…

pytest Tutorial – Part 3

Having your tests in place after reading pytest Tutorial – Part 1 and pytest Tutorial – Part 2 you certainly want to know how much of your code is actually tested by your tests. This is called coverage. Installation pip install pytest-cov Checking the coverage

pytest Tutorial – Part 2

In my last article pytest Tutorial Part 1  I showed some basic concepts of testing with pytest. Here are two additional concepts Parameterize Test parameterization follows the concept of DRY – Don’t repeat yourself Instead of writing a new testcase for every different value you annotate your test function and handover the different values. The…

Pandas Cheat Sheet

If you are new to Pandas feel free to read Introduction to Pandas I’ve assembled some pandas code snippets Reading Data Reading CSV import pandas as pd # read from csv df = pd.read_csv(“path_to_file”) Can also be textfiles. file suffix is ignored

Data Science Pipeline

Motivation Learning Data Science can be grueling and overwhelming sometimes. When I feel too overwhelmed it’s time to draw a picture. This my current overview of what a data scientist has to do: General tools Linear Algebra with numpy – Part 1 numpy random choice Numpy linspace function Data acquisiton Data Science Datasets: Iris flower…