Plotly dash beginners guide

This is a guide how to get your own simple dashboard running locally. You will need a computer and an internet connection, but given that you are readig this you already have both.

Since dash is a python framework we need to install python first. If you are using Linux it will most likley be already installed (check by typing python in your terminal). Otherwise you can download python here. For Linux you might also have to install pip, you can find instructions here.

Now we have to install dash. For Linux open a terminal and run the command ‘python -m pip install dash pandas’. For Windows open CMD or Powershell and run ‘py -m pip install dash pandas’. Now we can use dash and pandas. Pandas in a library to handle datasources.

Open up the editor or IDE of your choice and a terminal session in your source folder.

First of all we need to import all needed packages:

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objects as go

from dash.dependencies import Input, Output

import math
import random

import pandas as pd

Now lets get the data from a csv file:

df = pd.read_csv('')

And create the layout of our dashboard:

app = dash.Dash(__name__)

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='Hello there'),

    dcc.Interval('interval', interval=1000),


                x = df['AAPL_x'],
                y = df['AAPL_y'],
                name='Share Prices (in USD)',

Now to make the dashboard a little bit more interesting, lets add a callback:

    Output(component_id='scatter', component_property='figure'),
    [Input(component_id='interval', component_property='n_intervals'),]
def update_scatter(input):
    if(input is None):
        return dash.no_update

    data = go.Scatter(
        x=[random.randint(0, 100) for i in range(0, 100)],
        y=[random.randint(0, 100) for i in range(0, 100)],
    layout = dict(

    return go.Figure(data=data, layout=layout)

And finally run it!

if __name__ == '__main__':

Now switch to your open terminal and run the server:
Linux -> ‘python3’
WIndows -> ‘py’

You will see some output with information about the server, like the adress where you can reach it.

If you enable the debug optiption, you will see debug information on the dashboard and the code will be ‘interactive’ so when you change something and save the file it will auto restart the server which is super useful. Just make sure there are no errors : )

You can find the example with a bit more happening here.
Head over here to see all the graphs or inputs available.

Now you are ready to tinker around on your own and create beautiful dashboards.

GameMaker Studio 2 – Making games is for everyone!

The following tutorial shows how to clone the demo project used in the presentation. In the presentation we will program the demo project step by step.

What is GameMaker Studio 2?

GameMaker Studio 2 is an IDE that combines the game engine GameMaker and other useful tools for game development, such as a graphics editor or a sound mixer… GameMaker specializes in 2D game development and offers a series of tutorials and demos for different skill levels. The demo includes a short introduction of the most important editors and a project where the basic functions of GameMaker are explained.

Installing the Demo project

Step 1: Install the free version of GameMaker Studio 2 by selecting, downloading and installing the Free Trail version. Note: unfortunately a registration at YoYo Games is necessary!

Step 2: Open GameMaker Studio and log in On the main screen, select the Source Control tab and then click “Clone Repository”.

Step 3: Enter the path to the demo project:
in the first field and select a new folder where the project should be cloned. Afterwards confirm with OK.

Step 4: After successful cloning a window opens where you have to select the demo project. Select the file “Demo.yyp” and confirm with OK.

Step 5: The project is now opened and can be started. To do this, you have to press the “Run” button at the top of the control bar. The game starts in an extra window.

Step 6: Now you can try everything as you like. The graphics are cc and can be processed further.

Thank you for reading this little tutorial about GameMaker Studio 2. I hope it could help you to get a first impression on how to work with GameMaker. Every feedback is appreciated.

Best regards,

Clemens Hübner

Mockito – an introduction into mocking frameworks

The following tutorial should give an overview about the functionality of mocking frameworks and why you should use them to write better tests. The popular mocking framework for Java, Mockito, will be used as a practical example.

What is Mocking?

Mocking in general describes the copying of something else behaviour. In the context of object-oriented programming languages do you want to fake the behaviour of an object without having to create a real instance of the object. But why should you want to do something like this?

Good code should also be well tested. Many of those tests will be unit tests, which should verify the behaviour of a single component, without relying on dependencies to other objects. The following picture illustrates this well.

Source: https://[email protected]/what-is-mocking-in-testing-d4b0f2dbe20a

By mocking the needed objects are you able to isolate the component that you want to test. Now it is easier to locate a possible error, because only the test of the broken component will fail if something goes wrong.

There are two different methods of mocking, proxy-based mocking and class loader remapping. Mockito uses proxy-based mocking.

Why Mockito?

I chose to work with Mockito for this tutorial because it is the most used mocking framework for Java and one of the most used Java libraries in general. It has many advanced features, but it is also easy to write good tests with just the basic tools. When you encounter a problem, then the possibility that someone already solved it or something similar, is extremely high. Also, the general concept of working with proxy-based mocking should be transferable to any other mocking framework of your choice.

Mockito logo

How to use Mockito

To use Mockito do you have to include the Mockito library and a testing framework into your project. I will use Junit 5 as my testing framework. For an easy setup did I use Maven. You can find the necessary Maven packages with the following addresses:

  • org.mockito:mockito-core:2.2.2
  • org.junit.jupiter:junit-jupiter:5.5.2

Then all you need is to make the following imports at the beginning of your test class, and you are ready to write unit tests with mocks.

Necessary imports

Basic functionalities

In the following part I will explain some of the basic functionalities of Mockito. For better visualization did I write a little test project where I showcase the explained functionalities. You can find the source code in the following git repository:

It contains a simple library and book class. The different tests should cover the functions of the library class and I will always mock the book class to give an example how you can work with Mockito. When writing about a certain feature, I will be referring to the test class where it is implemented.

Create a mock an set its behaviour

Let us begin with the most important part. How do I create a mock of the needed class? This part is very simple. You just call the static method mock(MyClass.class) to create a new mock object. Now you must define the behaviour of your mock object when certain functions are called on the object.

This can be realized with when(mock.doSomething()).thenReturn(xyz) and is called stubbing. With this you can create the necessary environment that is needed for your test to work. You can find this in every test class, but in its most basic form can you see it in the class
Now you are already able to get your test working without dependencies to other classes than the on that should be tested. But we are still not verifying if the behaviour of our class is as intended. First you can use the utilities of JUnit in form of the different Assert-functions to verify the output of the tested methods. But Mockito also provides you with some extra tools, so you can write even better tests.

Verification with Mockito

You can verify if the functions of a mock object have even been called within your test. This can be helpful to see if the code is executed as intended and does not only somehow gives the correct results back. For this you can use the verify() function. You can also specify how often a function should have been called, either with an exact number or a minimum or maximum. In the class can you find a simple example for the use of the verify() function.

In this class can you also find an example for the InOrder feature. You have to create a new InOrder() object with the mock objects that have to be verified as arguments to make use of this. Then you can call the verify() function on the InOrder() object to check if the functions have been called in the same order as you verify them. This can be helpful in multithreading scenarios when certain functions must be called before the rest. The given example is not very practical but shows how to use the functions.

Alter the behaviour of the mock while testing

Sometimes you also want to test your code under different scenarios. Then you must change the behaviour of your mock multiple times. In theory you can do this by stubbing the needed function again with a different return value after the first use. In big tests this can become very tedious and blows the code up. That’s why there are different options to control the behaviour of your mock for different calls.

The most simple variant is the reset() function. When you call this on a mock, all stubbing will be reset to the default value. You can find a simple example for this in the test class in the function testAvgChapterPerBook().

A little bit more advanced is the usage of consecutive stubbing. With this feature do you define the return value for every call at once. You can either do this by chaining doReturn() statements or by giving several arguments. They will then be executed in the defined order. An example can be found in the class Consecutive stubbing can be helpful when you want to test different scenarios in one test. You then have a clear separation of the test code and the definition of you mock object.

Partial mocking

At the end I want to give a brief introduction into the topic of partial mocking of real objects. The basic idea is that you use a real instance of the needed object for testing and only stub selected functionalities, where necessary. In the past this was considered a bad practice and a code smell because the reason you are using mocks is just to avoid using the real object. But there are several use cases where this can be necessary, like when working with legacy code or third-party interfaces.

When you want to utilize this feature you can use the spy() method to create your mock object. You need a real instance of the object to mock as an argument. Then you can use your mock instance as usual. The difference is now that when you are not stubbing a function then the function of the real object will be called instead of a default null value. An example for this can be found in the class and the function testWithSpy().

Thank you for reading this little tutorial about Mockito. I hope it could help you to get a first impression on how to work with mocks. Every feedback is appreciated.

Best regards,

Tim Leistner