Skip to content

Instantly share code, notes, and snippets.

View dmolesUC's full-sized avatar

David Moles dmolesUC

View GitHub Profile
@dmolesUC
dmolesUC / travis-ci.md
Last active August 18, 2016 19:50
Travis-CI lightning talk notes

Travis CI

  • developers check in early, check in often
  • automated build verifies every check-in

Why continuous integration

  • catch issues quickly
@dmolesUC
dmolesUC / hide-network-questions.js
Last active July 9, 2019 20:00
Tampermonkey script for hiding certain StackExchange sites from the "Hot Network Questions" section
// ==UserScript==
// @name Hide Hot Network Questions
// @namespace GreaseMonkeyStackOverflow
// @description Hides certain Hot Network Questions on Stack Overflow
// @include http://*.stackexchange.com/*
// @include http://stackoverflow.com/*
// @include http://*.stackoverflow.com/*
// @include http://*.askubuntu.com/*
// @include http://*.mathoverflow.com/*
// @include http://*.serverfault.com/*
@dmolesUC
dmolesUC / neo4j-gd.md
Created July 6, 2017 20:57
Neo4J Graph Days: notes

username/password: neo4j/neo4j1

building blocks

  • nodes = nouns
  • relationships = verbs
    • no dangling relationships
  • properties = adjectives or adverbs
    • on nodes or relationships
  • strings, floats, longs, arrays, etc.
@dmolesUC
dmolesUC / VertxThreadTest.java
Created November 16, 2017 23:26
Vert.x test example with thread debugging
/*
Output (with org.slf4j:slf4j-simple:1.7.25):
[main] INFO VertxThreadTest - setUp running
[main] INFO VertxThreadTest - deploying on port 53539
[main] INFO VertxThreadTest - Test status200 running
[vert.x-eventloop-thread-0] INFO VertxThreadTest - Handling request
[vert.x-eventloop-thread-2] INFO VertxThreadTest - Test status200 got response
[main] INFO VertxThreadTest - tearDown running
[main] INFO VertxThreadTest - setUp running
@dmolesUC
dmolesUC / compareTo.java
Last active November 30, 2017 22:19
Java compareTo() in functional style
import io.vavr.collection.Array;
import java.net.URI;
import java.util.Objects;
import java.util.function.IntSupplier;
import java.util.stream.Stream;
class Vocab implements Comparable<Vocab> {
private final String prefix;
private final URI uri;
@dmolesUC
dmolesUC / supplementary.md
Created December 18, 2017 23:12
Match Unicode supplementary characters (U+10000–U+EFFFF) with regex in Java

A naive regex to match supplementary characters in the range U+10000–U+EFFFF produces nonsensical results:

jshell> Pattern.matches("[\u10000-\uEFFFF]+", "abc")
    ==> true

Likewise the version using regex escapes rather than character escapes:

jshell> Pattern.matches("[\\u10000-\\uEFFFF]+", "abc")
    ==> true
@dmolesUC
dmolesUC / TableHeightDemo.java
Created December 19, 2017 19:08
Showing only populated rows in a JavaFx TableView
import javafx.application.Application;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.skin.TableHeaderRow;
import javafx.stage.Stage;
@dmolesUC
dmolesUC / IndexColumnDemo.java
Created December 19, 2017 19:12
Displaying JavaFX TableView row number in a column
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
@dmolesUC
dmolesUC / jruby-openssl-x509-storeerror.txt
Created January 3, 2018 18:42
Stack trace: "OpenSSL::X509::StoreError: setting default path failed: No password supplied for PKCS#12 KeyStore"
$ ./gradlew check
> Configure project :buildSrc
2018-01-03 10:41:04.718:INFO::Daemon worker Thread 10: Logging initialized @6632166ms
2018-01-03 10:41:04.763:INFO:oejs.Server:Daemon worker Thread 10: jetty-9.2.12.v20150709
OpenSSL::X509::StoreError: setting default path failed: No password supplied for PKCS#12 KeyStore.
set_default_paths at org/jruby/ext/openssl/X509Store.java:165
SSLContext at uri:classloader:/META-INF/jruby.home/lib/ruby/shared/jopenssl19/openssl/ssl-internal.rb:31
SSL at uri:classloader:/META-INF/jruby.home/lib/ruby/shared/jopenssl19/openssl/ssl-internal.rb:22
@dmolesUC
dmolesUC / Arguments.java
Created January 3, 2018 23:40
Argument assertions
public class Arguments {
// ------------------------------------------------------------
// Checks
public static <T> T require(T argument, Predicate<T> condition, Supplier<String> msgSupplier) {
return require(argument, () -> condition.test(argument), msgSupplier);
}
public static <T> T requireNot(T argument, Predicate<T> condition, Supplier<String> msgSupplier) {