Skip to content

Instantly share code, notes, and snippets.

Bill Burcham Bill

Block or report user

Report or block Bill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Bill
Bill / docker-compose.yml
Last active Sep 4, 2019
Run a local Hypothes.is annotation server (and the services it needs) via docker-compose
View docker-compose.yml
# This docker-compose.yml will run the Hypothes.is annotation server.
# (adapted from instructions here https://h.readthedocs.org/en/latest/INSTALL.html)
#
# Place this file in the working directory (clone of https://github.com/hypothesis/h)
# run with docker-compose up -d
#
# Now browse to Hypothes.is at http://192.168.59.103:8000/ and create an account
# You'll see the invitation email in Mailcatcher at http://192.168.59.103:1080/
# Click that invitation link and log in on your local Hypothes.is
# And you are ready to annotate!
@Bill
Bill / set-intersection.java
Last active Aug 21, 2019
one way to intersect sets
View set-intersection.java
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
class Scratch {
public static void main(String[] args) {
final Set<Integer> a = Set.of(1, 2, 3);
final Set<Integer> b = Set.of(3, 4, 5);
System.out.println("intersection: " + intersect(a, b));
}
@Bill
Bill / ServerConfiguration1.java
Created Aug 10, 2019
Spring configuration of RSocketServerFactory that runs WEBSOCKET transport
View ServerConfiguration1.java
package com.thoughtpropulsion.reactrode.server;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import java.util.stream.Collectors;
import com.thoughtpropulsion.reactrode.model.Cell;
import com.thoughtpropulsion.reactrode.model.CoordinateSystem;
import com.thoughtpropulsion.reactrode.model.GameOfLife;
@Bill
Bill / state-machine.kt
Last active Jul 31, 2019
Kotlin turnstile state machine using a sealed class
View state-machine.kt
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.selects.select
sealed class State {
/**
* Process the first input from the channel(s) [perform a side-effect] and return a new functional.State
@Bill
Bill / state-machine-function-states.kt
Created Jul 31, 2019
Kotlin turnstile state machine using fun to implement states
View state-machine-function-states.kt
package functional
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.selects.select
@FunctionalInterface
@Bill
Bill / CallCoroutineFromJava.java
Last active Jul 26, 2019
Demonstrate a Java-callable wrapper on a Kotlin coroutine
View CallCoroutineFromJava.java
import static java.lang.Thread.sleep;
import java.time.LocalDateTime;
import java.util.Collection;
public class CallCoroutineFromJava {
public static void main(String[] args) throws InterruptedException {
final JavaCallableCoroutineScope jccs = new JavaCallableCoroutineScope();
@Bill
Bill / deferred.kt
Created Jul 23, 2019
use CompletableDeferred to do request-response style messaging to a coroutine
View deferred.kt
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.channels.ticker
import kotlinx.coroutines.selects.select
import java.time.LocalDateTime
fun log2(msg:String) {
println("$msg in thread ${Thread.currentThread()}")
}
@Bill
Bill / window.kt
Created Jul 22, 2019
CoroutineScope.timeWindow(producer: ReceiveChannel<T>, delayMillis: Long): ReceiveChannel<List<T>>
View window.kt
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancelChildren
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.channels.ticker
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.selects.select
import java.time.LocalDateTime
@Bill
Bill / RingBufferSequential.java
Last active Jul 13, 2019
A non-thread-safe ring buffer thingie
View RingBufferSequential.java
package com.thoughtpropulsion.reactrode;
import static com.thoughtpropulsion.reactrode.Functional.returning;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import io.vavr.Tuple2;
import io.vavr.control.Option;
@Bill
Bill / VirtualTimeSchedulerInaccurate.java
Last active Jul 5, 2019
Project Reactor VirtualTimeScheduler subclass that introduces (controlled) error into schedule times in order to cause changes to task interleaving.
View VirtualTimeSchedulerInaccurate.java
package com.thoughtpropulsion.reactrode;
import static com.thoughtpropulsion.reactrode.Functional.returning;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import reactor.core.Disposable;
You can’t perform that action at this time.