Skip to content

Instantly share code, notes, and snippets.

View dalewking's full-sized avatar

Dale King dalewking

View GitHub Profile
@dalewking
dalewking / gist:5744791
Last active December 18, 2015 07:09
Example of streaming text data to client in Scala on Play Framework 2.1 using OutputStream. It took me a long time to figure out how to get this working, so in case it helps someone else, here it is. The >>> Enumerator.eof is very important other wise it hangs
def index = Action {
val output = Enumerator.outputStream
{
o =>
val out = new PrintWriter(new OutputStreamWriter(o, "utf8"), true)
for(i <- 1 to 5)
{
out.println(s"Hello $i")
}
out.close()
@dalewking
dalewking / gist:947fb57e0916d24a397d
Created July 15, 2014 23:50
Build.gradle setup for running Robolectric
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.+'
}
}
@dalewking
dalewking / CamCompatListView
Created June 6, 2014 16:11
Backwards compatible Contextual Action Mode
import android.content.Context;
import android.support.v7.view.ActionMode;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
public class CamCompatListView extends ListView
{
public CamCompatListView(Context context)