Skip to content

Instantly share code, notes, and snippets.

View ajurasz's full-sized avatar

Arek Jurasz ajurasz

View GitHub Profile
@ajurasz
ajurasz / EveryItemTest.java
Created May 14, 2019 17:29
EveryItem hamcrest matcher usage
import static org.hamcrest.core.Every.everyItem;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
def executor = new ThreadPoolExecutor(
cores, cores,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1000))
DefaultFiberNode addFiber(OperationDefinition fiberDefinition) {
RxHelper.toObservable(vertx.eventBus().consumer(fiberDefinition.address()))
.flatMap({ data ->
Observable.just(data)
.subscribeOn(Schedulers.from(executor))
@ajurasz
ajurasz / RpiScanner
Last active November 22, 2015 14:10
private static class ScannerRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("bluetooth://scan?consumer.delay=1000")
.to("pi4j-gpio://1?mode=DIGITAL_OUTPUT&state=LOW&action=BLINK")
.choice()
.when(deviceWithName(DEVICE_NAME))
.process(p -> p.getIn().setHeader(DEVICE_FOUND, true))
.otherwise()
restConfiguration().component("netty4-http").host("0.0.0.0").port(8081).bindingMode(RestBindingMode.json);
rest("/api/devices").get().route().to("bluetooth://scan?serviceDiscovery=true");
println("Start")