Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Anderson tomwhoiscontrary

View GitHub Profile
View raises.java
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;
View ClientSubscriptionDemo.java
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 / transcript.txt
Last active May 2, 2019
jpackage run on Windows 10
View transcript.txt
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
View Combine.java
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 / convexMonotoneClassic.csv
Last active Jul 25, 2018
Another demonstration that not all is right with the convex monotone implementation in QuantLib - https://imgur.com/a/ksS7OD8
View convexMonotoneClassic.csv
term rate forward
0.0 -0.0033133321508 -0.0033133321508
0.1 -0.00329678287008599 -0.003263684308657968
0.2 -0.003247135027943958 -0.0031147407822318712
0.30000000000000004 -0.0031652069127224678 -0.00289212724033709
0.4 -0.00307524118684741 -0.002711931672110584
0.5 -0.0029812451740789943 -0.002491961467903277
0.6 -0.002878499729047622 -0.0022396014243447277
0.7 -0.0027726330307377965 -0.002047717424672988
0.7999999999999999 -0.002674128906090226 -0.0019474822563351547
@tomwhoiscontrary
tomwhoiscontrary / curve.cpp
Last active Jun 11, 2018
Simple attempt to build a Euribor curve
View curve.cpp
#include <iostream>
#include <vector>
#include <boost/make_shared.hpp>
#include <ql/indexes/ibor/euribor.hpp>
#include <ql/math/interpolations/all.hpp>
#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
#include <ql/termstructures/yield/ratehelpers.hpp>
#include <ql/time/daycounters/actual360.hpp>
@tomwhoiscontrary
tomwhoiscontrary / blend.cpp
Last active Jun 11, 2018
Trying to make a curve by blending futures and swaps - see https://imgur.com/a/viMGk6J
View blend.cpp
#include <iostream>
#include <vector>
#include <boost/make_shared.hpp>
#include <ql/indexes/ibor/euribor.hpp>
#include <ql/math/interpolations/convexmonotoneinterpolation.hpp>
#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
#include <ql/termstructures/yield/ratehelpers.hpp>
#include <ql/time/daycounters/actual360.hpp>
View Calculus.java
public class Calculus {
public static void main(String[] args) {
double δx = 17.0;
double δy = 23.0;
double δxノδy = δx / δy;
System.out.println("δxノδy = " + δxノδy);
}
}
View Nursery.java
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
View handle.cpp
#include <iostream>
// modified from https://wandbox.org/permlink/YnHKdrHmMFiJsjOm
template <typename T, typename Deleter>
struct handle {
handle(T value, Deleter deleter = Deleter()) : value_(value), deleter_(deleter) {
}
~handle() {
You can’t perform that action at this time.