Skip to content

Instantly share code, notes, and snippets.

View manuel-mauky's full-sized avatar

Manuel Mauky manuel-mauky

View GitHub Profile
/**
* ```
* 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 / 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> {
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 / 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;