Skip to content

Instantly share code, notes, and snippets.

View micheljung's full-sized avatar
💭
The devil is in the detail

Michel Jung micheljung

💭
The devil is in the detail
View GitHub Profile
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
repositories {
jcenter()
}
@micheljung
micheljung / KeyValueThreadSafety.java
Last active April 5, 2020 20:37
Demonstrates that a default KeyValueTemplate with a standard MapKeyValueAdapter is not thread safe
import org.junit.Assert;
import org.junit.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.keyvalue.annotation.KeySpace;
import org.springframework.data.keyvalue.core.KeyValueTemplate;
import org.springframework.data.map.MapKeyValueAdapter;
import java.util.LinkedList;
import java.util.concurrent.CompletableFuture;
@micheljung
micheljung / build-tinytex.sh
Last active July 23, 2019 11:22
Script to create a truly portable TinyTeX installation without accessing any URLs other than a CTAN repository. Useful to build TinyTeX in corporate environments with restricted internet access. Since I'm not good at Shell scripting, the error handling might not work as expected.
#!/bin/bash
set -u
set -e
set -o pipefail
# Adapted from https://github.com/yihui/tinytex/blob/master/tools/install-base.sh
# Creates a truly portable TinyTeX without accessing any URLs other than the CTAN repository
# Make sure that /usr/lib64/microsoft-r/3.3/lib64/R/etc/Renviron contains http_proxy,
# https_proxy and ftp_proxy (or adjust the script accordingly)
#!/bin/sh
# Adapted from https://raw.githubusercontent.com/yihui/tinytex/master/tools/install-unx.sh
packages_file=$1
fail() {
echo $1
exit 1;
}
@micheljung
micheljung / Test.java
Created November 9, 2018 19:36
Demonstrates slow scrolling of JavaFX WebView
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage stage) {
@micheljung
micheljung / JDK8164446.java
Created April 16, 2018 20:51
Reproduces https://bugs.openjdk.java.net/browse/JDK-8164446 JavaFX's addListener() isn't thread safe.
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.stage.Stage;
public class JDK8164446 extends Application {
@Override
public void start(Stage primaryStage) {
StringProperty stringProperty = new SimpleStringProperty();
@micheljung
micheljung / JI9046113.java
Last active December 15, 2016 12:57
Code to reproduce JI-9046113
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class JI9046113 extends Application {
public static void main(String[] args) {
launch(args);
@micheljung
micheljung / WebViewBug.java
Last active December 14, 2016 00:51
Demonstration of a bug in the JavaFX WebView (tested with Java 8 u111).In order to see the bug, resize the window. Tested with jdk-9-ea+148_windows-x64_bin.exe as well. Use -Dprism.showdirty=true to see dirty regions.
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.concurrent.Worker.State;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.util.Duration;
import netscape.javascript.JSObject;
@micheljung
micheljung / AvoidComments.java
Created May 20, 2016 11:02
An example of how comments and JavaDocs can be avoided
public class AvoidComments {
/**
* Example of a superfluous comment.
*/
private void badComment() {
// Time in milliseconds before exploding
long time = 5000;
}
@micheljung
micheljung / JDK8144162.java
Created December 1, 2015 14:39
Reproduces JDK-8144162 Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.getThumb(ScrollBarThemeImpl.java:409)
package sample;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Worker;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class JDK8144162 extends Application {