Skip to content

Instantly share code, notes, and snippets.

package org.beryx.test;
import org.kohsuke.github.*;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class GHApiTest {
private static String REPO_NAME = "sandboxx/GHTreeBuilderTest";
private static String GITHUB_OAUTH = System.getenv("GITHUB_OAUTH");
@siordache
siordache / .block
Last active August 10, 2018 19:07
Parametric curves
license: apache-2.0
@siordache
siordache / JooqUpsertV1.java
Last active April 30, 2018 18:41
Programmatically create updatable table with JOOQ (see https://groups.google.com/forum/#!topic/jooq-user/K1Fe3UIWLr8)
import org.hsqldb.Server;
import org.hsqldb.persist.HsqlProperties;
import org.jooq.*;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.jooq.impl.DSL.*;
public class JooqUpsertV1 {
package org.beryx.textio.demo;
import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal;
import java.util.Locale;
import java.util.Random;
public class TestFlickering {
private static final Random rnd = new Random();
@siordache
siordache / MultiCommit.java
Last active November 7, 2019 21:49
Committing multiple files with github-api (PR #361 - https://github.com/kohsuke/github-api/pull/361)
import org.apache.commons.io.IOUtils;
import org.kohsuke.github.*;
import java.net.URL;
public class MultiCommit {
public static void main(String[] args) throws Exception {
String userId = "your-user-id";
String password = "your-password";
String repoName = "your-repo-name";
@siordache
siordache / FeatureCombiner.java
Created October 13, 2016 20:50
Answer to http://stackoverflow.com/questions/40023754 using the Streamplify library
import javafx.scene.effect.BoxBlur;
import javafx.scene.effect.Effect;
import javafx.scene.effect.Shadow;
import javafx.scene.paint.Color;
import org.beryx.streamplify.product.CartesianProduct;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
@siordache
siordache / InMemoryProtocol.groovy
Last active June 2, 2016 20:21
URL protocol for in-memory resources
class InMemoryProtocol {
static final String PROTOCOL_NAME = 'inmemory'
static final Map inMemoryMap = [:]
static int inMemoryIndex = 0
static {
URL.URLStreamHandlerFactory = new URLStreamHandlerFactory() {
@Override URLStreamHandler createURLStreamHandler(String protocol) {
(protocol == PROTOCOL_NAME) ? new URLStreamHandler() {
@Override protected URLConnection openConnection(URL url) throws IOException {
@siordache
siordache / RegularPoly.java
Created January 22, 2016 16:07
Mocking method from Java abstract class
public abstract class RegularPoly {
public double getLength() {
return Math.abs(System.identityHashCode(this)) % 100;
}
public abstract double getArea();
}
@siordache
siordache / GuiSpecification.groovy
Created December 3, 2015 01:52
TestFX 4.0.1-alpha with Spock - adapted from https://gist.github.com/hastebrot/8375513
package github.gist.testfx
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
import org.testfx.framework.junit.ApplicationTest
import spock.lang.Specification
abstract class GuiSpecification extends Specification {
ApplicationTest fx
@siordache
siordache / Range.java
Created August 11, 2015 15:28
A Spock specification that fails in Java 8 with CGLIB 3.1 but works with CGLIB 3.2
public class Range<T extends Number> implements Comparable<Range<T>> {
private final T minVal;
private final T maxVal;
public Range(T minVal, T maxVal) {
this.minVal = minVal;
this.maxVal = maxVal;
}
@Override