Skip to content

Instantly share code, notes, and snippets.

View benjchristensen's full-sized avatar

Ben Christensen benjchristensen

View GitHub Profile
@benjchristensen
benjchristensen / Fibonacci.java
Last active August 14, 2017 10:01
Fibonacci + Rx
import java.util.HashMap;
import rx.Observable;
import rx.Subscriber;
public class Fibonacci {
public static void main(String... args) {
// via Observable.create
fib.take(13).forEach(System.out::println);
company CLA
@benjchristensen
benjchristensen / ReactivePullHotOnBackpressureDrop.java
Last active February 22, 2017 17:23
Handling a hot Observable producing faster than the Subscriber with onBackpressureDrop
import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;
/**
* This demonstrates how to use onBackpressureDrop when a hot stream doesn't itself handle "reactive pull"
*
*/
public class ReactivePullHotOnBackpressureDrop {
@benjchristensen
benjchristensen / ParallelExecution.java
Created February 26, 2015 20:25
ParallelExecution Examples
import java.util.concurrent.atomic.AtomicInteger;
import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;
public class ParallelExecution {
public static void main(String[] args) {
// System.out.println("------------ mergingAsync");
@benjchristensen
benjchristensen / Obsurvable.java
Last active January 31, 2017 09:45
Playing with Observable.bind
/**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package lithium;
import org.reactivestreams.Publisher;
//import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
import io.reactivesocket.AbstractReactiveSocket;
import io.reactivesocket.ConnectionSetupPayload;
import io.reactivesocket.Payload;
import io.reactivesocket.ReactiveSocket;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@benjchristensen
benjchristensen / index.html
Created December 16, 2011 22:45
Dynamic Stacked Bar Chart using d3.js
<html>
<head>
<title>Dynamic Stacked Bar Chart using d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
rect.a {
fill: green;
}
rect.b {
fill: orange;
@benjchristensen
benjchristensen / gist:1284824
Created October 13, 2011 17:09
JUnit and Mockito with Reflection
/**
* Use reflection to allow performing the same tests on all GETTER methods.
*
* @param cache
* @param m
* @param argArray
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
private void testGetMethod(Method m, Object[] argArray) throws IllegalAccessException, InvocationTargetException {