Vaadin 24 Paypal Components

I recently published a package with two components I wrote for vaadin 24, namely a paypal integration for donations and payments. Searching for the right plattform for announcements and sales I have chosen patreon since I already run a campagne there and it contains all options I needed.

To push the visibility, I am writing a short article here. Hope it helps somewhere!

https://www.patreon.com/padmalcom/shop/vaadin-24-paypal-components-donations-149436

Setup Nvidia Jetson AGX Xavier

Setting up Nvidia Jetson products is neither comfortable nor easy. I struggled the last weekend to get my AGX Xavier up and running and found that many other had and have problems to use the Nvidia SDK Manager correctly.

Here are the neccessary information for you to succeed:

  • You need Ubuntu 18.04.5 LTS Desktop, even though Ubuntu 20.04 is officially supported, it does not work with the AGX Xavier.
  • You can write the Ubuntu ISO image to a USB flash drive and use the Try Ubuntu feature, a full installation is not necessary (even if the Nvidia guys say so). But: You need a possibility to store ~40 GB of data which is downloaded by the SDK manager. Use a second flash drive.
  • When you boot Ubuntu 18 from a flash drive you have to activate the universe repository by executing sudo add-apt-repository universe When you do a full install of Ubuntu, the repository is installed automatically.
  • Now connect the Jetson via USB to your PC and switch it on by connecting the power cable and push the left button.
  • Install the SDK Manager. When Ubuntu says it cannot install the tool because some dependencies are not installable, you missed adding the universe repository.
  • When you start the SDK Manager the tool will show you that the AGX Xavier is connected. In case that the tool says that your current OS is not supported or that there are no versions supporting your OS you did not boot Ubuntu 18.04.5 (it happend to me using CentOS 7, CentOS 8 and Ubuntu 20.04)
  • The SDK Manager will download the required files. You might have to switch the download directory. The installation will follow.
  • After flashing the OS you will see a promt asking for an IP, a user name and a password. You now have to connect keyboard, mouse and monitor to your Jetson. On this monitor you will see that the Jetson will configure the installation. You have to enter a user name and a password that you will have to enter on your host pc (the Ubuntu 18.04).
  • It can happen (at least it happend to me and to many more other users on the net) that the Jetson does not boot but shows the Nvidia logo over and over again. I had no other option but removing the sd card and delete all partitions on it and then flash the Jetson again.
  • When you configured the Jetson correctly, the SDK Manager will continue to install the SDK on the OS. When it is done, your Jetson is ready to use.

Entwicklung eines KI-gestützten Sprachassistenten in Python

Hallo zusammen, falls ihr schon mal mit dem Gedanken gespielt habt eine eigene Alexa oder Cortana zu entwickeln, möchte ich euch meinen Kurs “Entwicklung eines KI-gestützten Sprachassistenten in Python” empfehlen. Dabei geht es darum von Grund auf ein System zu entwickeln, dass Sprache und Wünsche eines Menschen versteht und eine entsprechende Antwort oder Aktion generiert.

Der Inhalt ist so aufgebaut:

  • Aufsetzen einer Entwicklungsumgebung in Python
  • Sprachverständnis und -synthese
  • Implementierung einer Konfiguration der Anwendung
  • Erstellen eines Intent (Skill) Systems
  • Dynamisches Laden von Intents zur Laufzeit
  • Implementierung von 10 Beispiel-Intents
  • Eine einfache UI entwickeln
  • Build und Paketieren der Anwendung als Binary und Installer

Für jedes Kapitel stelle ich funktionierenden Quelltext bereit, an dem ihr euch orientieren könnt. Ich freue mich drauf den ein oder anderen hier wiederzusehen 🙂

https://www.udemy.com/course/ki-sprachassistent/

[Unity] Call Unity FBX Exporter from C# code

Unity offers a free plugin to export meshes as fbx files from the editor. Yesterday, I tried to find out how to call the export function from code. Finally, I got it running but not during runtime but only from an editor script.

FbxExporters.Editor.ConvertToModel.Convert(target.gameObject, null, savePath, null, null, null);

Whereever, you include this line of code make sure it is in a folder called Editor. Otherwise the class FbxExporters.Editor won’t be visible. Unfortunately, there remains a limitation. You can only write your fbx files to the Assets folder and not to an arbitrary folder on your hard drive. If you figure out how to solve this, please tell me 🙂

Unit testing spark 2.x applications in Java

When you specific spark questions you might get the impression that java is the black sheep of the languages supported. Nearly all answers refer to scala or python. So it is with unit testing hence I am writing this post. I will show how to create a local context (what is pretty well documented) and how to read parquet files (or other formats like csv or json – the process is the same) from a source directory within your project. This way you can unit test your classes containing spark functions without connection to another file system or resource negotiator.

In the following example it is important to register the folder src/test/resources as class path / source code folder.

The annotations beforeClass and afterClass define methods that are called once the class is loaded the first respectively the last time.

package de.jofre.spark.tests;
 
import static org.assertj.core.api.Assertions.assertThat;
 
import org.apache.spark.SparkConf;
import org.apache.spark.ml.Pipeline;
import org.apache.spark.ml.feature.SQLTransformer;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import de.jofre.test.categories.UnitTest;
 
@Category(UnitTest.class)
public class SparkSessionAndFileReadTest {
	private static Dataset<Row> df;
	private static SparkSession spark;
	private static final Logger logger = LoggerFactory.getLogger(SparkSessionAndFileReadTest.class);
 
	@BeforeClass
	public static void beforeClass() {
		spark = SparkSession.builder().master("local[*]").config(new SparkConf().set("fs.defaultFS", "file:///"))
				.appName(SparkSessionAndFileReadTest.class.getName()).getOrCreate();
		df = spark.read().parquet("src/test/resources/tests/part-r-00001-myfile.snappy.parquet");
		logger.info("Created spark context and dataset with {} rows.", df.count());
	}
 
	@Test
	public void buildClippingTransformerTest() {
		logger.info("Testing the spark sorting function.");
		Dataset<Row> sorted = df.sort("id");
		assertThat(sorted.count()).isEqualTo(df.count());
	}
 
	@AfterClass
	public static void afterClass() {
		if (spark != null) {
			spark.stop();
		}
	}
}

Permanently add a proxy to MiKTex

MiKTeX is a Tex distribution that is required when translating latex documents to target formats like e.g. PDF. One task of such a distribution is the package management of plugins that are used in your document. MiKTeX downloads such packages when they are first used or updated and hence requires an internet connection as long as you do not have those packages on a portable medium.

If you sit behind a proxy – like me – you have to configure MiKTeX to use this proxy. What I did for a long (annoying) time was to enter the proxy URL in the MiKTeX Update tool and check Authentication required. This enforces the tool to ask you every single time to enter your proxy credentials. A better way is to uncheck Authentication required and specify user and password directly in the URL. If you do so, you should never be asked again to enter you user password combination.

TensorFlow For Poets – Retrain Inception behind a Proxy

I tried to retrain Google’s Inception as described here. I failed since I use a proxy what has not been considered when implementing the retrain.py script.

So what I did to solve it is to find the following line in the script:

filepath, _ = urllib.request.urlretrieve(DATA_URL, filepath, _progress)

… and add the following code above the line:

proxy = urllib.request.ProxyHandler({'http': r'http://user:password@proxy.domain.de:8080'})
auth = urllib.request.HTTPBasicAuthHandler()
opener = urllib.request.build_opener(proxy, auth, urllib.request.HTTPHandler)
urllib.request.install_opener(opener)

Now tensorflow can download the required files.

Java / Spark – Printing RDDs from Spark Streaming

A common challenge when writing functional code in Spark is to simply output logs as we usually do it in ordinary applications where line for line is processed sequentially and a debug message could be printed at an arbitrary place using System.out.println(). Working with Spark’s RDDs is new to most of us and might be confusing at first since it is difficult to track what object type we are currently working with (is it a RDDStream, an RDD or a simple type like String or int) – but infact this tracking is important. If you make use of the print function that is offered by RDDs or RDDStreams you’ll just see more or less useless array like information in the console instead of the objects’ content.

What I commonly do is to resolve the RDD object down to a simple JavaRDD or JavaDStream<object> using e.g. flatmap(x -> x) to flatten streams or lists in a dataset or map() to break down complex objects to a simple data type (e.g. via map(person -> person.getAddress().getStreet())). On RDDs you can then do a foreach(System.out::println). On JavaDStream you can do the following:

public static void printRDD(final JavaRDD<String> s) {
  s.foreach(System.out::println);
}
 
public static void main(final String[] args) {
  SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("testApp");
  try (JavaStreamingContext sc = new JavaStreamingContext(conf, new Duration(5000))) {
    JavaDStream<String> stream = sc.textFileStream("C:/testnumbers/");
    stream.foreachRDD(Main::printRDD);
    sc.start();
    sc.awaitTermination();
  }
}

Here, I simply break down a JavaDStream to an RDD using foreachRDD() and use System.out::println as method reference to print each RDDs content.