Skip to content

Instantly share code, notes, and snippets.

View manuel-mauky's full-sized avatar

Manuel Mauky manuel-mauky

View GitHub Profile
@manuel-mauky
manuel-mauky / gist:5354000
Created April 10, 2013 11:58
Demonstrates a Bug (?) with javas DocumentBuilder for String nodes with very long text. The only difference between the two test cases is that the first "testShortText" uses a text with 100 lines (see line 21) and the second "testLongText" uses 1000 lines (see line 39). While "testShortText" is running without problems, "testLongText" is red. Th…
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.junit.Test;
import java.util.Objects;
import java.util.UUID;
public abstract class Identity {
private final String id;
public Identity() {
this.id = UUID.randomUUID().toString();
}
@manuel-mauky
manuel-mauky / RecursiveTreeItem.java
Created May 31, 2015 18:44
Recursive DataModel for JavaFX TreeView/TreeTableView
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.TreeItem;
import javafx.util.Callback;
import java.util.List;
import java.util.stream.Collectors;
public class RecursiveTreeItem<T> extends TreeItem<T> {
/**
* ```
* Does JDK8's Optional class satisfy the Monad laws?
* =================================================
* 1. Left identity: true
* 2. Right identity: true
* 3. Associativity: true
*
* Yes, it does.
* ```
@manuel-mauky
manuel-mauky / jdk8_completablefuture_monad_laws.java
Last active January 6, 2017 14:58
Does JDK8's CompletableFuture class satisfy the Monad laws? Yes, it does.
/**
* ```
* Does JDK8's CompletableFuture class satisfy the Monad laws?
* =================================================
* 1. Left identity: true
* 2. Right identity: true
* 3. Associativity: true
*
* Yes, it does.
* ```
@manuel-mauky
manuel-mauky / MvvmfxExampleApp.java
Last active April 5, 2018 02:53
mvvmFX example implementing a registration form. Dependencies needed: `de.saxsys:mvvmfx` and `eu.lestard:advanced-bindings`
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import de.saxsys.mvvmfx.FluentViewLoader;
public class MvvmfxExampleApp extends Application {
public static void main(String... args) {
@manuel-mauky
manuel-mauky / TestApp.java
Last active February 10, 2016 09:52
ComboBox Eventhandling when ENTER is pressed
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
@manuel-mauky
manuel-mauky / App.java
Created April 26, 2016 16:43
JavaFX Controller is removed by garbage collector while the fxml file is still shown
package org.example;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class App extends Application {
@manuel-mauky
manuel-mauky / ExpansionBoxClass.tsx
Created June 15, 2020 17:59
React-Hooks-Article: Expansion Box implemented as Class
import React from "react"
import "./expansion-box.css"
type Props = {
title: string
}
type State = {
expanded: boolean
}
@manuel-mauky
manuel-mauky / ExpansionBoxFunction.tsx
Created June 15, 2020 18:01
React-Hooks-Article: Expansion Box implemented as Function with useState Hook
import React, { FC, useState } from "react"
import "./expansion-box.css"
type Props = {
title: string
}
export const ExpansionBoxFunction: FC<Props> = (props) => {
const [expanded, setExpanded] = useState(false)