This is a practical tutorial, where you will learn how you can create your own custom annotation types in your Java program. But also an introduction into the Java annotation package, which can be useful for you.
In Java you have annotations such as “@Override”, “@Id” and more. These are used to adjust the behavior of objects, functions and more.
But you can also create your own annotation (annotation type), where you can define what the annotation should do on the target (objects, functions, etc.) where it’s called. …
This is an introduction tutorial on how to create a REST API that performs CRUD operations. It can get, add, updated and delete data.
You need to add the dependency “spring-boot-starter-web”, besides your standard Spring dependency (“spring-boot-starter-parent”).
A REST API has endpoints which are a “URL” that can be accessed to send or retrieve data from the API. You have to use “HTTP” commands such as “GET”, “POST”, “DELETE”, “UPDATE” and more to communicate with the API.
This is an introduction into the differences regarding the features, the assert commands (“assertFalse”, “assertEquals”, etc.) and the annotations (“@BeforeEach”, etc.) of the two popular testing frameworks “JUnit” and “TestNg”.
The decision for the suitable testing framework is important to ensure the quality of your software. The best testing framework can differ regarding the size and type of your software and its dependencies.
The JUnit version 5 and TestNG version 7 are used here.
Both frameworks have parameterized tests, timeout feature and exception tests. But TestNG has some more advanced features and it is also possible to do more than…
Make your app multilingual with the Angular package “localize”.
This package allows you to generate “xlf” files which contain texts of every HTML tags (marked with “i18n”) and strings with the command “localize” from your Angular application.
This package can be installed with the following command:
ng add @angular/localize
“xlf” files can be generated with this command:
ng xi18n --output-path src/i18n
If you want to translate your tags in your HTML file, then you have to use the tag “i18n”.
<h3 i18n>Welcome to my website.</h3>
Your text is then translated into the tag “trans-unit” of your “xlf” file…
Now it is possible to create a switch with other syntax. This feature was introduced as a suggested in Java 12 and it is now available as a preview feature in Java 13.
You have to enable or add the command “ — enable-preview” in your project properties of your IDE.
Besides the usual way to create a switch in Java. Now you can use an arrow and yield for your switch cases. But you can also the return value from a switch case to a variable.
If you use an arrow instead of an double point “:”, then you…
How to use a shell script to make automatic announcements in audio format. This can be used, for example, to automatically output error messages (from services, applications), messages or the weather via an audio interface (e.g.: Internet radio station in the intranet or Internet, RSS podcast, etc.).
A use case is here shown where this shell script automatically creates and outputs announcements over a radio stream. This use case is similar to the announcements you hear at the airport or train station. …
This is an introductory example in Machine Learning and Pattern Recognition of certain data. A Python program is programmed to predict the type of plants.
The iris dataset is used for this. A decision tree is used to classify data. This tutorial uses Python 3.6. Python 3.5 or later is required for this tutorial. It shows how to use Machine Learning to teach a program to create patterns from existing data and calculate predictions from them.
The Iris Dataset is a multivariate dataset containing 50 data samples of three “iris” plant species each. From this dataset you can identify certain…
This commands work on Linux (Ubuntu, Debian, etc.)
Search in the whole filesystem:
grep -r "TEXTPATTERN" /
Search in a certain folder (home folder):
grep -r "TEXTPATTERN" /home
How to create a fail2ban filter for the application “matrix” (matrix-synapse)
Matrix is a chat/messaging server which can be used with the app Riot. We have to create a new filter and add that as a jail to fail2ban.
Important: You need to have at least the version fail2ban 0.9.1, because this filter uses multiple lines for the regex.
# matrix-synapse configuration file
maxlines = 3[Definition]# Option: failregex # Notes.: regex to match the password failures messages in the logfile. The # host must be matched by a group named "host". The tag "<HOST>" can #…
How to tutorial for UBUNTU 12.04 LTS. This tutorial was tested till Ubuntu 16.04 LTS.
Mp3 Streaming with an internet radio statio.
apt-get install icecast2
Afterwards we must edit /etc/icecast2/icecast.xml. Most default values should work fine for now, but you should change the passwords in the <authentication>…</authentication> section. The source-password is the password that Ices2 will later on use to connect to Icecast2; the admin-password is the password that the admin will use in Icecast2’s web interface; we won’t use the relay-password, but anyway you should change it.
[....] <authentication> <!-- Sources log in with username…