Die drei ??? Telegram Bot

Since the publisher Europa uploads new Die drei ??? episodes on Spotify quite frequently, I have been wanting to get an update every time they upload something new. For me the most convenient way to be notified is to get a message on my smartphone. The free messenger Telegram is predestinated for that task because of its open API and bot capabilities.

A bot is like a Telegram user. The only difference: You are not chatting with a person but a program that is running on a server somewhere else. For my bot that is a Node.js script, being executed on my Raspberry Pi.

How does it Work?

To get updates you have to search for the bot on Telegram (the name is @DieDreiFragezeichenBot) or click on that link: @DieDreiFragezeichenBot

Then you have to subscribe by writing /start. The bot will respond with a success message. Now you are on a list of subscribed clients and the next time the bot detects new episodes, you will get an update pretty much like that:

Once there are new episodes you'll get an instant update.
Once there are new episodes you will get an instant update.
The bot just looks like a normal chat partner.
The bot just looks like a normal chat partner.

Continue reading “Die drei ??? Telegram Bot”

ABAP Objects Quick Reference

This is the second (and final) part of a quick reference for the programming language ABAP. Extending the first part, this one is primarily focusing on ABAP’s object oriented programming features, like classes, OOP-exceptions, and inheritance.

The first part can be found here: ABAP Quick Reference

Encapsulation using function groups
FUNCTION-POOL s_person.

* age is a global variable in the function-pool
DATA: age TYPE i.

FUNCTION inc_age.
  ADD 1 to age.
ENDFUNCTION.
Local class definition
REPORT ... .
DATA: ...
...
CLASS lcl_classname DEFINITION.
  " class definition
  ...
ENDCLASS.

CLASS lcl_classname IMPLEMENTATION.
  " class implementation
  ...
ENDCLASS.

* report content

CREATE OBJECT ...
Public and private attributes

ABAP has the visibilities publicprivate, and protected.

CLASS lcl_classname DEFINITION.

  PUBLIC SECTION.
    DATA: mv_publicvar TYPE i.

  PRIVATE SECTION.
    DATA: mv_privatevar1 TYPE i READ-ONLY, " const
          mv_privatevar2 LIKE mv_privatevar1.
    
    " static variable
    CLASS-DATA: gv_n_o_staticvar TYPE i.

ENDCLASS.

Continue reading “ABAP Objects Quick Reference”

ABAP Quick Reference

This is the first of two posts, providing a quick reference for ABAP developers. It primarily consists of code examples and doesn’t include major object oriented programming features, introduced in newer language versions.

The second part of this series, targeting OOP related topics, can be found here: ABAP Objects Quick Reference

ABAP (Advanced Business Application Programming) is a high-level programming language created by the German software company SAP SE. It is currently positioned, alongside Java, as the language for programming the SAP Application Server, which is part of the NetWeaver platform for building business applications.
Wikipedia ABAP article

Basic program structure
PARAMETERS pa_num TYPE i.

* declare a variable
DATA gv_output TYPE i.

* assign value from pa_num to gv_output
MOVE pa_num TO gv_output.

WRITE: 'Input value', gv_output.

NEW-LINE. " this is an inline comment

WRITE 'Done'.
Types

Standardtypes

  • I: Integer (4 bytes)
  • F: Floating point number (8 bytes)
  • D: Date JJJJMMTT (8 bytes)
  • T: Time HHMMSS (6 bytes)
  • STRING: String of dynamic length
  • XSTRING: Hexadecimal string
  • DECFLOAT16: Decimal floating point (8 bytes)
  • DECFLOAT34: Decimal floating point (16 bytes)
  • The common data type “boolean” doesn’t exist in ABAP. Use a custom solution (e.g. X for true and (whitespace) for false)

Incomplete data types

  • C: Character array of fixed length
  • N: Numerical character of fixed length
  • X: Hexadecimal byte array of fixed length
  • P: Packed number of fixed length (and optionally number of digits)
Type definition
TYPES gty_default_float TYPE p LENGTH 16 DECIMALS 2.

Continue reading “ABAP Quick Reference”

Trigonometric Functions Formulary

This formulary has been created during the online onboarding process at Baden-Wuerttemberg Cooperative State University (DHBW). It is suitable for the related online tests and might be helpful for other people, seeking for formulas in this field of mathematics.

Basics

$$\begin{array}{l} \tan x = \frac{{\sin x}}{{\cos x}}\\ \cot x = {\tan ^{ – 1}}x = \frac{{\cos x}}{{\sin x}} \end{array}$$

Radian and degree conversion
$$\frac{b}{\pi } = \frac{\alpha }{{180}}$$

Sign

Quadrant 1 2 3 4
sin      + + - -
cos      + - - + 
tan      + - + -
cot      + - + -
 Addition theorems

$$\begin{array}{l} \sin \left( {\alpha + \beta } \right) = \sin \alpha \cos \beta + \cos \alpha \sin \beta \\ \sin \left( {\alpha – \beta } \right) = \sin \alpha \cos \beta – \cos \alpha \sin \beta \\ \cos \left( {\alpha + \beta } \right) = \cos \alpha \cos \beta – \sin \alpha \sin \beta \\ \cos \left( {\alpha – \beta } \right) = \cos \alpha \cos \beta + \sin \alpha \sin \beta \end{array}$$

$$\begin{array}{l} \tan \left( {\alpha + \beta } \right) = \frac{{\tan \alpha + \tan \beta }}{{1 – \tan \alpha \tan \beta }}\\ \tan \left( {\alpha – \beta } \right) = \frac{{\tan \alpha – \tan \beta }}{{1 + \tan \alpha \tan \beta }}\\ \cot \left( {\alpha + \beta } \right) = \frac{{\cot \alpha \cot \beta – 1}}{{\cot \beta + \cot \alpha }}\\ \cot \left( {\alpha – \beta } \right) = \frac{{\cot \alpha \cot \beta + 1}}{{\cot \beta – \cot \alpha }} \end{array}$$

Relations

$$\begin{array}{l} {\sin ^2}x + {\cos ^2}x = 1\\ {\tan ^2}x + 1 = \frac{1}{{{{\cos }^2}x}}\\ {\cot ^2}x + 1 = \frac{1}{{{{\sin }^2}x}}\\ \cot x = \frac{1}{{\tan x}} \end{array}$$ Continue reading “Trigonometric Functions Formulary”

Node.js: Develop on Mac, Run on Raspberry Pi

For me the solution for productive Node.js development on Mac, with code execution on a Raspberry Pi was usage of Samba. After following the steps you will be able to develop Node.js applications right on your Mac, execute them on your Raspberry Pi (just by pressing cmd+S) and see the console output and errors on your Mac, without much hassle. This tutorial covers the entire setup.

Login to your router interface and assign a static IP address to your Raspberry Pi’s MAC address (e.g. 192.168.0.120). The router menus differ from each other, if you have trouble check the router manual.

IP Address Reservation Router Interface

Then connect to your Raspberry Pi via Secure Shell (SSH) from your Mac.

ssh pi@192.168.0.120

Install Node.js and the npm packet manager on the Raspberry Pi.

apt-get upgrade
apt-get update

apt-get install nodejs npm
ln -s /usr/bin/nodejs /usr/bin/node

Continue reading “Node.js: Develop on Mac, Run on Raspberry Pi”

Periodic Table Trainer (Android Wear)

Memorize the Elements of the Periodic Table Right on Your Wrist

This Android Wear app shows the chemical elements of the periodic table. Starting with Hydrogen you can continue with a simple tap on the center of the screen. Before you do that, you should think of the name of the following element. What comes after Hydrogen (H)?

Let’s drop in the app icon and some screenshots so that you have time to think about the name of the second element in the periodic table.

Periodic Table Trainer App IconPeriodic Table Trainer Screenshot 1 Periodic Table Trainer Screenshot 2 Continue reading “Periodic Table Trainer (Android Wear)”

Guided Tour at CERN

On August 24th 2016, I took a guided tour for individuals at the European Organization for Nuclear Research (CERN, Conseil Européen pour la Recherche Nucléaire) headquarters in Geneva, Switzerland.

This post is about that kind of tour. So what did we do at the research organization that operates the largest particle physics laboratory in the world?

The tour started at 11 a.m. at the reception. Parking was for free and so was the whole tour. After all people (about 20 folks) arrived, we started with a 4 min video about CERN. The video contained safety instructions and told us what to expect. After that, the group walked over to a visitor building.

There, our guide started another video which came with some kind of a light show: Beamers pointed at the first particle accelerator (built in 1957) which was on exhibition. The movie was primarily about the history of CERN and its major discoveries.

Synchrocyclotron
The 600 MeV Synchrocyclotron (SC), built in 1957, was CERN’s first accelerator. It provided beams for CERN’s first experiments in particle and nuclear physics. Image source

The next stop was at the ATLAS control room and detector building. Since the detector is 100 m below the surface, we could only see the control room which was quite impressive though.

Continue reading “Guided Tour at CERN”

Fuel Consumption in Neutral Gear

When a car is in neutral gear it still consumes fuel. The reason is that it has to keep the engine running which means keeping it above the engine’s specific min. revolutions per minute (rpm). For my testing car, a Toyota Yaris XP 90 (second generation; 3 doors; 1.33 liter 4 cylinder engine) this value equals approximately 600 rpm. Continue reading “Fuel Consumption in Neutral Gear”