Skip to content

Instantly share code, notes, and snippets.

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class Combine {
public static class Item {
String name;
@tomwhoiscontrary
tomwhoiscontrary / transcript.txt
Last active May 2, 2019 11:12
jpackage run on Windows 10
PS C:\Users\IEUser\Downloads\jpackage-demo-master\jpackage-demo-master> .\gradlew.bat build
> Task :jpackage
jpackage argument list:
[create-app-image, --name, demo, --input, C:\Users\IEUser\Downloads\jpackage-demo-master\jpackage-demo-master\build\libs, --output, C:\Users\IEUser\Downloads\jpackage-demo-master\jpackage-demo-master\build/app-image, --main-jar, jpackage-demo.jar]
Creating app bundle: demo in C:\Users\IEUser\Downloads\jpackage-demo-master\jpackage-demo-master\build\app-image.
Adding modules: [java.rmi, jdk.management.jfr, jdk.jdi, jdk.charsets, jdk.xml.dom, java.xml, java.datatransfer, jdk.jstatd, jdk.httpserver, java.desktop, java.security.sasl, jdk.zipfs, java.base, jdk.crypto.ec, jdk.javadoc, jdk.management.agent, jdk.jshell, jdk.editpad, jdk.sctp, jdk.jsobject, java.sql.rowset, java.smartcardio, jdk.unsupported, jdk.jlink, jdk.scripting.nashorn, java.security.jgss, java.compiler, jdk.dynalink, jdk.unsupported.desktop, jdk.accessibility, jdk.security.jgss, java.sql, java.xml.crypto, java.l
@tomwhoiscontrary
tomwhoiscontrary / ClientSubscriptionDemo.java
Created May 7, 2019 13:48
Java 11 streaming subscription
import com.sun.net.httpserver.HttpServer;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
@tomwhoiscontrary
tomwhoiscontrary / raises.java
Created June 27, 2019 17:54
The raises matcher
public static Matcher<Callable<?>> raises(Matcher<? super Throwable> sub) {
return new FeatureMatcher<Callable<?>, Throwable>(sub, "thrown exception", "thrown exception") {
@Override
protected Throwable featureValueOf(Callable<?> thing) {
try {
thing.call();
} catch (Throwable e) {
return e;
}
return null;
@tomwhoiscontrary
tomwhoiscontrary / Normal.codestyle.json
Created July 18, 2019 09:55
An IntelliJ misformatting
{
"schemeName": "Normal",
"version": "1.0",
"codeStyle": {
"all": {
"formatter_off_tag": "@formatter:off",
"formatter_on_tag": "@formatter:on",
"formatter_tags_accept_regexp": false,
"formatter_tags_enabled": false,
"max_line_length": 120,
@tomwhoiscontrary
tomwhoiscontrary / StreamTraceTest.java
Created July 18, 2019 10:11
Breaking IntelliJ stream trace
import org.junit.Test;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StreamTraceTest {
@Test
public void test() {
AtomicInteger mapCount = new AtomicInteger(0);
@tomwhoiscontrary
tomwhoiscontrary / ErrorCollector.java
Last active September 25, 2019 12:04
ErrorCollector for JUnit 5
import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.opentest4j.MultipleFailuresError;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@tomwhoiscontrary
tomwhoiscontrary / build.sh
Created October 1, 2019 14:48
Failing to price a seasoned SONIA OIS with QuantLib
#! /bin/bash -eu
cd "$(dirname "$0")"
$GCC_HOME/bin/g++ -std=c++17 -Wall -g -I $QL_PATH/include -L $QL_PATH ${GCC_OPTS:-} sonia_demo.cpp -lQuantLib -o sonia_demo
LD_LIBRARY_PATH=$QL_PATH ./sonia_demo
@tomwhoiscontrary
tomwhoiscontrary / rant.md
Created October 30, 2019 21:09
Comment on "Propose implicit named arguments for formatting macros" #2795

comment on rust-lang/rfcs#2795 which i think is actually completely wrong, so cancelling

Do i understand correctly that this would be a special case in the language, understood by the compiler itself? That this isn't a change to the definition of the format_args! macro?

Would this be specific to format_args!, or could syntax like this be used by other, user-written, macros, which don't build on format_args!?

I understand that format_args! is currently special, implemented as a compiler built-in, rather than as a real macro. However, i've always seen this as an unfortunate wart, something that had to be done because we needed good print statements, and the macro system wasn't strong enough to implement them yet. It would be nice to remove that wart one day. Even while it's in place, it's useful to be able to gloss over it, and describe format_args! as just another macro, not doing anything any other macro couldn't do.

If i've understood correctly, then adding this featur

@tomwhoiscontrary
tomwhoiscontrary / TimeTabulator.java
Created November 29, 2019 16:27
Program to help work out time correspondence between timezones
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TimeTabulator {