Dienstag, 26. Januar 2021

Tagesschau - Coronavirus Live-Feed - RSS-Feed

Es war zugegebenermaßen lästig, jeden Morgen auf tagesschau.de den Corona Live-Feed zu suchen, ihn aufzurufen, ganz nach unten zu rollen und den RSS-Link aus dem entsprechenden Icon zu kopieren, um ihn dann in meinen RSS-Reader einzufügen.

Bei der allgemeinen Umgestaltung der Tagesschau-Seiten scheint dieses RSS-Icon jedoch untergegangen zu sein.

Der Feed als solcher ist jedoch noch da und seine URL folgt dem nachstehenden Muster:

URL der Seite:

https://www.tagesschau.de/newsticker/liveblog-coronavirus-dienstag-175.html

URL des RSS-Feeds:

https://www.tagesschau.de/newsticker/liveblog-coronavirus-dienstag-175~rss2feed.xml

Wochentag und Zahl ändern sich täglich.


Update: 30. Januar 2021

Das Format der URL hat sich leicht geändert. Aus "coronavirus" wurde nur "corona".

https://www.tagesschau.de/newsticker/liveblog-corona-samstag-109.html

Grund dürfte sein, dass die gleiche URL mit "coronavirus" bereits im Mai verwendet wurde.Am Prinzip hat sich aber nichts geändert.

Donnerstag, 13. August 2020

Retro Music Player app and playlists

Until now I've used the Google Play Music app. One reason was that I could store songs I regularly hear locally on my device and didn't need to stream them over and over again via the mobile data connection.


As Google Play Music is being discontinued and I have transferred my collection to its successor - the Youtube Music App - only to find that I have to pay 9,99 € a month for the privilege to have the music I already bought played back locally without streaming.

I've managed - with some difficulty - to download my collection and my playlists from Google Music and I'm now trying to find an app which can play my music (most do) and can import my playlists (here lies the problem).

The Retro Music Player app is an open-source music player for Android which claims to be able to import and export playlists. But this is only partially true.

The export works perfectly as it is implemented in the app. The import is (currently) performed by the operating system and its implementation ranges from "works perfectly" to "doesn't work at all" as many bug reports on GitHub can attest to.

Until RMP decides to implement the playlist import in the app itself the functionality of this feature is left to chance.

Mittwoch, 29. April 2020

Wake Me Up After You Go-Go

I took me days but I got Wake-on-LAN working on my new B450 Tomahawk Max. I need this functionality to power-on the machine from another always-on-computer on the network so that I can access it while I am on the road.

The reason that WoL was not working was presumably not the BIOS (which I did update to the current version (E7C02AMS.360)), it was neither the router nor the network cable – as mentioned elsewhere – and my BIOS settings were correct as well. 

It turns out that contrary to my other computers it is not enough to simply turn on the settings in the BIOS as shown below.  The operating system must inform the motherboard Ethernet subsystem “which kind of WoL” it should use – otherwise that setting, which is not accessible from the BIOS, stays disabled, nothing will happen and it looks as if WoL were not working at all.

The most common WoL option is the so called Magic Packet which can be sent by utilities like etherwake (on Linux) or Wake-on-LAN (on Android), but apparently there are other options as well.

Windows user can specify the option to use in the Control Center, but I’m not running Window, I’m using Ubuntu Linux 20.04 LTS… What to do?  The answer is ethtool.

Let’s start with the BIOS settings:

Settings\Advanced\Integrated Peripherals
   Onboard LAN Controller: Enabled  ... (which is the default)

Settings\Advanced\Power Management Setup
   ErP Ready: Disabled   ... (which is the default)

Settings\Advanced\Wake Up Event Setup
  Resume By PCI-E Device: Enabled


With Linux running, determine the device identifier of your onboard Ethernet “card” using the ifconfig command:

    ifconfig

If ifconfig is not installed run:

    sudo apt install net-tools

Furthermore you need ethtool:

    sudo apt install ethtool

The name of my ethernet device is: enp34s0
Change the following commands accordingly.

Enter:

    sudo ethtool enp34s0

Look for the line “Wake-on:”. If the value in this line is “d” then the WoL function is (d)isabled. To make it react to the WoL Magic Packet is has to be set to “g”.

    sudo ethtool -s enp34s0 wol g

Check the setting again with:

    sudo ethtool enp34s0


Shut-down the computer and try to wake it with a WoL tool as mentioned above.

This command needs to be executed after each boot. The simplest way to achieve this is to append or create the file /etc/rc.local:

#!/bin/bash
ethtool -s enp34s0 wol g
exit 0


Don’t forget to make it executable:

    sudo chmod 744 /etc/rc.local


A more elaborate way can be found here. Note: Check the path of ethtool with “which ethtool” and correct the script accordingly.

Wake-up happy….

Links


  • https://www.thomas-krenn.com/en/wiki/Wake_On_LAN_under_Linux

P.S.: Here is the German version of the BIOS options:

Settings\Erweitert\Integrierte Peripheriegeräte
   Onboard LAN Controller: Aktiviert     (default)

Settings\Erweitert\Energieverwaltungs Konfiguration
  ErP Ready: Deaktiviert    (default)

Settings\Erweitert\Einrichtung der Reaktiverungsereignisse
  Fortsetzung durch PCI-E-Gerät: Aktiviert


Donnerstag, 6. Februar 2020

How to set the active camera ... when Blender renders in the background



Background rendering, i.e. rendering without the UI and based on command line parameters alone, is usually the domain of render farms.

But there are situations where this functionality is useful for normal users as well: scripts.

In my case the blend file contains a complex architectural model and various cameras (which you can conveniently set-up and switch between with the “Stored Views” add-on).

Some of those cameras are (virtual) panoramic cameras.  Their output will be fed into a generator script to calculate multi-res images for use with the web panorama viewer pannellum (https://pannellum.org) to create a virtual tour.

Wouldn’t it be nice to have a script producing the rendered pictures for all those cameras; it might even call the pannellum generator script afterwards to calculate the multi-res images needed for the virtual tour...

When Blender is started in background mode, various parameters can be set from the command line - among others the frame and scene to be rendered, the render engine and the output path.

Missing however are some settings I would like for my workflow: the active camera and the dimension percentage (Output Properties > Dimensions > Resolution > %). Those values are stored in the blend file and used in the render process.

If you want rendered images from multiple cameras you usually open the blend file, switch the camera, save the blend file and re-render…

As for the other setting: I sometimes forget to switch the resolution from my usual 50% to 100% before starting to render. While rendering without the UI you don’t notice this right away.  Something that sets this value to 100% would be nice.

The solution

Blender’s command line option --python-expr lets you enter a short Python snippet which gives you access to all settings in your scene.

To switch the active camera in the current screen use

import bpy
bpy.context.scene.camera = bpy.context.scene.objects.get('XXXXXX')


where XXXXXX is the name of the camera.

The command for setting the resolution percentage value is

bpy.context.scene.render.resolution_percentage = 100

You can test these commands in Blender’s Python console.

Note: It does matter where you put the --python-expr command on the command line. If used at the end of the command it will be ineffective because it changes the parameter after the render process.

My typical Blender background render command looks like this:

blender -b myblend.blend --python-expr "import bpy; bpy.context.scene.camera = bpy.context.scene.objects.get('Camera XXXX'); bpy.context.scene.render.resolution_percentage = 100" -o /tmp/pic_#### -F PNG -x 1 -f 1 -E CYCLES

  • -b: background render of myblend.blend.
  • --python-expr: use camera ‘Camera XXXX’ and render at 100%
  • -o: store under /tmp/pic_####
  • -F: store as PNG
  • -x: add the PNG extension
  • -f: render frame 1
  • -E: use cycles render engine

You might use this technique to change other values on the fly without them being saved back to disk.

Montag, 18. November 2019

Berechnung der Vorabpauschale bei Fonds und ETF

 

In meinem GitHub-Repository ist nun ein kleines Programm zur Berechnung der Vorabpauschale und der Bemessungsgrundlage bei der Kapitalertragssteuer nach dem „neuen“ Investmentsteuergesetz von 2018 verfügbar.  

Wichtiger Hinweis
Ich bin kein Steuerberater. Alle Ergebnisse dieser Routine und alle angegebenen Informationen sind unverbindlich und ohne Gewähr. Jegliche Haftung meinerseits ist ausgeschlossen.

Das Programm befasst sich mit einem sehr eng gefassten aber wahrscheinlich recht häufig vorkommenden Aspekt, nämlich der Vorabpauschale und der Bemessungsgrundlage für die Kapitalertragssteuer bei Fonds und ETF, die seit dem Inkrafttreten des Gesetzes am 1.1.2018 erworben wurden. Bei älteren Fonds/ETF gibt es bei der Berechnung des Gewinns weitere Regelungen, die nicht Gegenstand dieses Programms sind.

Worum geht es?

Die Vorabpauschale kann als Steuer auf Buchgewinne beschrieben werden, fällt also auch dann an, wenn kein Geld vom Fonds zum Anleger geflossen ist.

Wenn man Fonds/ETF bei einer inländischen Bank kauft und verkauft, werden alle Berechnungen und Abzüge von der Bank vorgenommen. Die Bank bucht die Steuer automatisch von Ihrem Konto ab und kann ggf. Teile der Wertpapiere verkaufen, wenn sie nicht anders an Ihr Geld kommt. Um Überraschungen zu vermeiden, sollte man die Vorabpauschale im Auge behalten.

Grundsätzlich versteuern muss man das, was der Fonds ausschüttet, und den Kursgewinn, den man zum Schluss (hoffentlich) mit dem Verkauf macht. Dazwischen fällt u.U. die Vorabpauschale dann an, wenn der Kurswert des Fonds steigt. Teile dieser Kursgewinne müssen versteuert werden, können dann aber beim Verkauf abgezogen werden. Man bezahlt also nicht mehr Steuer, sondern nur früher (vorab).

Zweck des Programms


Das Programm berechnet die Vorabpauschale und die Bemessungsgrundlage auf der Grundlage einer geringen Anzahl von Parametern, die dem Anleger bekannt sind (oder sein müssten).

Die eigentliche Routine ist in eine separate Datei ausgelagert und kann auch von anderen Programmen eingebunden werden. Ein Großteil des restlichen Programms dient zum Einlesen der Daten und zur Ausgabe der Ergebnisse.

Die Routine ist das Ergebnis einer längeren Internetrecherche und implementiert die bei der Mehrzahl der Quellen beschriebene Vorgehensweise. Dass sich nicht alle Quellen völlig einig sind und teilweise auch zu anderen Ergebnissen kommen, ist natürlich ernüchternd. Falls Sie also Fehler finden, wäre ich für einen Hinweis dankbar.

Beschreibung der Ergebnisse

Die Vorabpauschale besteuert einen „fiktiven“ Kursgewinn, falls dieser nicht durch die Höhe der Ausschüttungen überschritten wird, und auch nur dann, wenn überhaupt ein Kursgewinn aufgetreten ist.

Um welche Beträge geht es?

Grundlage ist zunächst der Basisertrag. Er berechnet sich aus

Wert * Basiszins * 0,7

Der Basiszins ist eine Prozentzahl, die jährlich vom Bundesfinanzministerium bekanntgegeben wird. Sie beträgt für 2018 0,87%, für 2019 0,52%, für 2020 0,07% und für 2021 0,00%.

Somit errechnet sich der Basisertrag für 2019 für einen Wert von 10.000 € mit:

10.000 € * 0,52 / 100 * 0,7 = 36,40 €

Dies ist der maximal Wert, der sich ggf. noch um Ausschüttungen reduziert, und die sog. Vorabpauschale bildet*.

Zu dieser Vorabpauschale werden die Ausschüttungen wieder addiert, weil beide Teile versteuert werden müssen. Falls der Fonds nicht ausschüttend (thesaurierend) ist, bleibt es also bei diesem Maximalwert.

Von der Summe wird bei Aktienfonds/-ETF noch die sog. Teilfreistellung von 30% abgezogen. Das ergibt die sog. Bemessungsgrundlage:

36,40 € * (100% - 30%) = 25,48 €


Dagegen wird der Sparerfreibetrag von derzeit 801€ (1602 € für gemeinsam veranlagte Verheiratete/Lebenspartner) aufgerechnet - entweder in Form eines Freistellungsauftrags oder später bei der Steuererklärung.

Die Bemessungsgrundlage wird dann noch mit dem Kapitalsteuersatz von zurzeit max. 26,375% (25% + 5,5% Solidaritätszuschlag) multipliziert. Man erhält die tatsächlich zu zahlende Steuer.

25,48 € * 26,375 / 100 ≈ 6,72 €


* Genauere Informationen zum implementierten Algorithmus finden Sie in der Dokumentation im GitHub-Repository. Er deckt auch Fonds ab, bei denen eine Teilfreistellung von nur 15% bzw. 0% gilt, sowie die Jahre 2018 und 2019 und kann leicht erweitert werden.

Die implementierte Eingabe der Steuerfälle in einer Textdatei ist für Portfolios mit nur wenigen Fonds/ETF ausreichend. Größere Systeme werden wahrscheinlich mit Bildschirmmasken und Datenbanken arbeiten. Die eigentliche Routine bleibt – bis zur nächsten Gesetzesänderung – aber gleich.

Links

 

Update/Korrektur 25.02.2021:

  • Basiszins für 2020 und 2021 nachgetragen
  • Korrigiert: Der Sparerfreibetrag wird gegen die Bemessungsgrundlage aufgerechnet, nicht gegen die zu zahlende Steuer.

Donnerstag, 29. November 2018

Müllabfuhrtermine der AWB im Kalender

Die Abfallwirtschaftsbetriebe (AWB) in Köln veröffentlichen seit Jahren ihren Abfuhrkalender auch online (https://www.awbkoeln.de/) - in früheren Jahren sogar als ausdruckbares PDF.

Leider gab es nie die Möglichkeit, die Termine in eine Kalender-App einzulesen.

Mit dem kleinen Dienstprogramm awb2ical (Github) ist dies nun möglich.Es erzeugt eine iCal-Datei, die in Kalender wie NextCloud importiert werden können.

Es greift auf eine API der AWB zurück, die auf deren Website genutzt wird und wandelt das Ergebnis in eine iCal-Datei. Dabei werden mehrere Leerungen an einem Tag zu einem Termin zusammengefasst.

Donnerstag, 27. Juli 2017

Accessing data on a server with a self-signed certificate

Accessing encrypted data on the web is relatively simple. Even the somewhat more complicated API using HttpURLConnection is relatively straightforward:

(Examples in Kotlin)

val url = URL(urlString) 
val conn = url.openConnection() as HttpURLConnection 
conn.requestMethod = "GET" 
conn.connect() 
val data = conn.inputStream.bufferedReader().use { it.readText() }
...
conn.close()

This is even true for encrypted communications via https. The system simply adds another layer doing the encryption and decryption and you can use it the same way you would do with unencrypted traffic.

But there is more happening in the background that can go wrong.

When the encrypted channel is being establish, the server sends a certificate. This certificate contains among others:

  • the host name of the server
  • the public key of the server
  • the period for which the key is valid
  • and usually some signatures from well know certificate authorities (CA)


If the host name in the certificate does not match the one in the URL or the key has expired or is not yet valid Java/Kotlin will raise an exception and refuse to connect.

The problematic part with self-signed certificates is that they don't carry a signature from a well-known CA because they are “self-signed”. Well-known in this context means that the certificate of the CA is present in the Java keystore. A standard connect request will fail.

The way around this is to create a keystore with the self-signed certificate in it and tell Kotlin/Java to use it.

How you do you get this certificate?

If you use a server with a self-signed certificate, chances are that you have installed it yourself. The certificate can be found in that installation.
Or you open the connection in Firefox. The certificate info page lets you export the cert. A certificate looks similar to this:

-----BEGIN CERTIFICATE----- 
MIIEfjCCA2agAwIBAgIIGhqMkdYVlLwwDQYJKoZIhvcNAQELBQAwSTELMAkGA1UE 
cm5ld ... 
...
fv23f6eTYPc1c4zq7kuTC4Uz385+ZisEV+o0+g3pevavfYL+BeOuNAyd1muvP7Ej 
vIE= 
-----END CERTIFICATE-----

Which is essentially a base64 encoded version with a special header and footer.
You could then store that file on your filesystem or in a ressource file on Android, and tell Kotlin to use it instead of the standard keystore (that's what TlsTest.setCertSocketFactory(cert) will do for you) .

But there is a nicer way. As the certificate is sent from the server when the connection is establish, why can't we use it?

The answer is, we can. However when using the standard functions there is a “chicken and egg” problem: You can access the certificate when the connection is established but you need the certificate to make the connection in the first place...

The solve the class shown below implements a “self-signed certificate friendly” TrustManager. The Trust Manager is responsible to check the certificate validity (expiration) and the chain of trust (back to the certificate authorities). This special Trust Manager calls the functions of the original Trust Manager with one exception.  If the chain of trust has a length of 1 (which is true for self-signed certificates) it forgoes checking the chain of trust.

It uses this connection to obtain the certificate. If also provides a method to get some user readable information, so that the user can decide to trust it or not.

A third method can be used to install a keystore with the obtained self-signed certificate before opening the data connection.

Here is a typical use case:

val (cert, except) = TlsTest.testConnection("https://xxxxxxx")
if (except != null) { .. abort, there was a fatal error ... }

print(TlsTest.certInfo(cert))   // possibly asking the user for confirmation
...
val conn = java.net.URL("https://xxxxxx/foo").openConnection() as HttpURLConnection
TlsTest.setCertSocketFactory(conn, cert)
conn.connect()
...
val data = conn.inputStream.bufferedReader().use { it.readText() }

There is one edge case this class does not cover. During its executing no “real” data is being  transferred. Its all done during the establishment phase. If you try to securely connect to a server that only “speaks” http, this mismatch only becomes apparent when data is sent, which then causes a “javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?".

Here is the class – available as a Gist on Github



P.S. I'm neither a security expert nor a proficient Kotlin programmer. If you spot errors or can suggest improvements, let me know.