What is my net salary after the taxes?

If you are working in Germany, you might ask yourself what is my net salary after the taxes and social contributions are deducted? The tax system in Germany is rather complex.

Your income tax is determined by your tax class. There are seven different tax classes in Germany. Don’t know which to pick? I will explain what they are and what they mean.

Every employee is assigned a tax class by the tax office. The tax bracket you are in is determined primarily by your marital status: single, single parent, or married an it can be one of the following

  • Class I: Single, widowed, civil partnership, divorced, spouse living abroad, or legally separated.
  • Class II: Single parents.
  • Class III: Married, one spouse has a significantly higher income than the other spouse and lives in Germany.
  • Class IV: Married, both spouses have similar wages, reside in Germany, and are not separated.
  • Class V: Married, but one of them, at the request of both spouses, is classified as tax Class III.
  • Class VI: Workers who receive multiple wages from multiple employers.

If you are married you can choose between the tax class combinations of IV/IV and III/V. Visual Smart provides a comprehensive calculator, breakdown of your tax and social contributions, as well as diagrams and plots which help you to understand the German income tax system. You can use the households income calculator (or Haushaltseinkommens-Rechner in German) to determine your and your partner’s combine monthly net income.

Diagram of the household income calculator generated by https://visualsm.art/haushaltseinkommens-rechner/
Combined household income in different tax class combinations.

If you are in another category, then you can use the Net Salary Calculator (or Brutto Netto Rechner in German) to evaluate how your monthly or yearly gross salary translates into net income in Germany.

Net income for different tax classes generated by https://visualsm.art/gross-net-salary-calculator/
Monthly net salary in different tax classes.

The tax class you choose is only relevant for withholding tax and, as a result, for income that is immediately available. After an income tax assessment is made a few months after the end of the tax year, the choice of tax class has no effect on tax refunds.

Where can I get family law legal advice (almost) for free in Germany?

This post describes how you can get family law legal advice (almost) for free in Germany. If you have any of the following questions:

  • Are you looking for advice on sexuality, pregnancy or partnership?
  • Do you have questions about family planning?
  • Do you need legal advice on separation or divorce?
  • Do you need legal advice on child custody?
  • Do you need legal advice on which financial and social are you eligible during pregnancy?

Pro Familia provides legal advice for almost free. You just need to become a member. The membership fee is between 30 and 55 € per year, depending on the location. You can register/become a member on the Pro Familia Membership page.

How to modify an XML attribute value using Matlab?

In the following example, I demonstrate how to modify an XML attribute value in a particular XML node using XPath in MATLAB. XPath stands for XML Path Language and is a query language for selecting nodes in an XML document. The XPath language is based on a tree representation of the XML document.

Let’s consider the following sample XML file

<?xml version="1.0" encoding="utf-8"?>
<xml>
    <busStop endPos="30" id="BusStop0" lane="1to2_0" startPos="20"/>
    <busStop endPos="80" id="BusStop1" lane="1to2_0" startPos="70"/>
    <chargingStation chrgPower="220" endPos="30" id="ChrgStn1" lane="1to2_0" startPos="45"/>
</xml>

I am going to select the chargingStation node which id has the value of ChrgStn1. The XPath in this case is xml/chargingStation[@id="ChrgStn1"]. The full code in MATLAB would be:

import javax.xml.xpath.*
fXML=xmlread('SampleXML.xml');

factory = XPathFactory.newInstance;
xpath = factory.newXPath;

expression = xpath.compile('xml/chargingStation[@id="ChrgStn1"]');
chargingStation = expression.evaluate(fXML, XPathConstants.NODE); 

if ~isempty(chargingStation)
     chargingStation.setAttribute('startPos', '45')        
end

xmlwrite('SampleXMLOut.xml', fXML);

If you need to select multiple nodes, you shall change the XPathConstants.NODE to XPathConstants.NODESET.

How to modify the last commit message?

Modify the last commit message in the local copy

There are cases when you must alter the last commit message. This can be done by typing the following command in the command line:

git commit --amend -m "My awesome new message" 

Modify the last commit message in the remote repository

First, you must modify the local commit message, as it is described in the previous section. Next, you can push the local state of the branch to the remote repository.

git push --force origin <branch_name>

Demonstration

The video below demonstrates the described commands above:

How to loop through multiple variables in Python?

In this post, I describe how you can iterate/loop through multipe (two or more) variables at the same time in Python.

Iterate/loop through multiple variable using the zip function

In this post, I describe how to use the zip function to iterate/loop through multiple variables at the same time in python. In the below example I defined three variables with the same length, however, the zip function can handle any number of input variables:

var1 = [1,2,3]
var2 = [4,5,6]
var3 = [7,8,9]
for v1,v2,v3 in zip(var1, var2, var3):
     print(v1, v2, v3)

Result:

1 4 7
2 5 8
3 6 9

The great thing about the zip function is that it can be used with arrays, lists, and dictionaries of different lengths. This is demonstrated in the below code snippet:

var1 = [1,2,3]
var2 = [4,5,6]
var3 = [7,8]
for v1,v2,v3 in zip(var1, var2, var3):
     print(v1, v2, v3)

Result:

1 4 7
2 5 8

Demonstration

The video below demonstrates the described code snippets above:

How to undo the last git commit in the repository?

In this post, I present a simple git command to revert/undo the last git commit in the local and remote repository.

Undo the last git commit in the local copy

There are cases when new commits are added to the git repository by mistake and you need to roll back the changes. This can be done by using the revert command:

git reset --hard HEAD~2
  • HEAD~2 reset the current branch back by two commits. If you change this to HEAD~1 then it will reset the last commit only. The number can be change in accordance to your need, number of commit to be reset,
  • --hard reset your files to the ones found in HEAD~2.

Undo the last git commit in the remote repository

To push the content to the remote repository type the following to the command line:

git push --force origin &lt;branch_name&gt;

Demonstration

The video below demonstrates the described commands above:

How to remove/undo/unstage files added through git add?

There might be cases when you added files (temporary, libraries, executes, etc.) by executing for example git add --all. Before or during the commit you notice that they shall not be included in the git repository. In this post I demonstrates how to remove/undo/unstage files added/staged accidentally.

Unstage a single file

Let’s say test.cpp~ was added by accident and you would like to undo the add. This can be done as follows:

git reset test.cpp~

Unstage multiple files

If you need to remove multiple files, wildcards can be used, for example:

git reset *.cpp~

Unstage all the added/staged files

If you need to undo all the added files you can use git reset without additional inputs.

git reset

Demonstration

The video below demonstrates the described git commands above:

How to split a string using multiple delimiters in Python?

In this post, I present two ways to split a string using multiple delimiters in Python.

Split a string using regular expression

Regular expressions are very powerful. It helps to get things done with a single function call. In the below example I use the split function from the re library to split a string along with multiple delimiters:

import re
str="this-is_an=example\string"
re.split(r"[-_=\\]", str)

Result:

['this', 'is', 'an', 'example', 'string']

In the above example, the string is split along the \, -, _, and = delimiters.

Replace other delimiters and split it

Another solution is to choose a single delimiter and replace all the other delimiters with the chosen one. After that, the split function can be used. I demonstrate this in the below example:

str="this-is_an=example\\string"
delimiters = ['-', '_', '=', '\\']
for i in range(1, len(delimiters)):
    str = str.replace(delimiters[i], delimiters[0])

str.split(delimiters[0])

Result:

['this', 'is', 'an', 'example', 'string']

In the above example, first I replaced all the delimiters with -, and then I used the same delimiter to split the string.

Demonstration video

How to split a string using multiple delimiters in PHP?

Split a string using preg_split

The preg_split function can split a string using regular expression. I demonstrate this in the below example:

<?php
$foo = "this/is\a-test_to-split=a-string-using?multiple_delimiters";
$res = preg_split("/(\/|\\\|-|_|\?|=)/", $foo);
print_r($res);
?>

Result:

Array
(
    [0] => this
    [1] => is
    [2] => a
    [3] => test
    [4] => to
    [5] => split
    [6] => a
    [7] => string
    [8] => using
    [9] => multiple
    [10] => delimiters
)

In the above example, the string is split along the /, \, -, _, and = delimiters.

Split a string using explode along with str_replace

Another solution is to choose a single delimiter and replace all the other delimiters with the chosen one. After that, the explode function can be used. I demonstrate this in the below example:

<?php

$foo = "this/is\a-test_to-split=a-string-using?multiple_delimiters";
$res=explode('\\',str_replace(array('/','-','_','?','='),'\\',$foo));
print_r($res);

?>

Result:

Array
(
    [0] => this
    [1] => is
    [2] => a
    [3] => test
    [4] => to
    [5] => split
    [6] => a
    [7] => string
    [8] => using
    [9] => multiple
    [10] => delimiters
)

In the above example, all the delimiters are replaced with \\, and then the same delimiter is used to split the string.

How to get the location name of a dragged marker?

In the following example, I show how to get the location name when the marker is dragged and dropped by the user on Google maps.

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY=initMap" async></script>

<script type="text/javascript">
    function initMap() {
        var myLatlng = new google.maps.LatLng(-25.363882, 131.044922);
        var mapOptions = {
            zoom: 4,
            center: myLatlng
        }
        var map = new google.maps.Map(document.getElementById("map"), mapOptions);

        //Create a marker
        marker = new google.maps.Marker(
            {
                map: map,
                draggable: true,
                animation: google.maps.Animation.DROP,
                position: myLatlng,
            });

        google.maps.event.addListener(marker, 'dragend', function () {
            geocodePosition(marker.getPosition());
        });

        //Callback function of the drag event.
        function geocodePosition(pos) {
            geocoder = new google.maps.Geocoder();
            geocoder.geocode
                ({
                    latLng: pos
                },
                    function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK)
                            console.log(results[0].formatted_address);
                        else
                            console.log('Cannot determine address at this location.' + status);
                    }
                );
        }
    }

</script>

First the geocodePosition callback function is added, which will be called whenever the marker was dragged. In this function the position of the marker is decoded into a location name using the Geocoder from Google Maps Geocoding service.