Skip to content

Instantly share code, notes, and snippets.

@benravago
benravago / InputStreamArgumentsProvider.java
Created January 26, 2023 17:00
A JUnit5 parameterized test argument provider and related annotation; provides named InputStream's as test input.
package lib.junit5.tools;
import static java.util.stream.Collectors.toList;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@benravago
benravago / ANECS.md
Last active May 19, 2021 00:50
Yet Another NIO Echo Client/Server Example

This NIO example uses the new(ish) Selector.select(Consumer<?>) api which seems to solve a lot of the spurious wakeup problems in previous examples.

The example also demonstrates performing channel read/write functions asynchronously via SelectionKey interestOps() and attach() manipulation.

@benravago
benravago / flatten.js
Created January 23, 2019 22:08
flatten an arbitrary integer array
function flatten(a) {
if (!Array.isArray(a)) {
throw("Not an array: "+a);
}
let b = new Array();
append(a);
return b;
function append(x) {
@benravago
benravago / Jni-To-Jlink
Last active May 4, 2024 07:06
A jni-to-jlink cheatsheet