Skip to content

Instantly share code, notes, and snippets.

@n8han
n8han / skipmap.java
Last active December 14, 2015 16:40
When a source observable emits, skip any further emissions until a second observable completes
public static <A, B> Observable<B> skipMap(Observable<A> source, Func1<A, Observable<B>> action) {
return source.first().flatMap(a -> Observable.concat(action.call(a), skipMap(source, action)));
}

Keybase proof

I hereby claim:

  • I am n8han on github.
  • I am n8han (https://keybase.io/n8han) on keybase.
  • I have a public key whose fingerprint is 43CC D81E 2B53 0E34 9295 31C8 8821 DBD1 7793 FC5F

To claim this, I am signing this object:

@n8han
n8han / gist:4745816
Last active December 12, 2015 08:39
dispatch 0.9 meetup api example

!SLIDE

Demo

import dispatch._

!SLIDE

object Stream extends Build {
lazy val stream = Project("Stream", file("."), settings = Defaults.defaultSettings ++ Seq(
scalaVersion := "2.8.1"
)) dependsOn (unfiltered)
val unfiltered = ProjectRef( file("../../unfiltered"), "unfiltered-websockets")
// ...
}
@n8han
n8han / gist:1116842
Created July 31, 2011 14:39
just some stupid idea I had
// Instead of this:
Porthole..MODULE$.apply(new AbstractFunction1() { public static final long serialVersionUID = 0L;
public final String apply(List<Object> paramList) { return Test..MODULE$.test4(paramList);
}
}
// It would be great to have more info in an "AbstractMethod1":
#!/usr/bin/env python
import stream, storage
if __name__ == "__main__":
# start piping the stream to our storage
stream.jsonizer(storage.event_callback)