Skip to content

Instantly share code, notes, and snippets.

Async {
Logger.debug(s"Start $duration second wait")
Akka.system.scheduler.scheduleOnce(duration seconds){
val blocker = Future { duration }
blocker map { duration =>
Logger.debug(s"Finished $duration second wait")
Ok(duration.toString)
}
}
}
@jamie-allen
jamie-allen / gist:4121396
Created November 20, 2012 21:45
Console stack trace
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jamie/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jamie/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
13:31:11.616 [consoletest-akka.actor.default-dispatcher-1] INFO a.a.t.Slf4jTraceContextEventHandler - Slf4jEventHandler started
13:31:11.620 [consoletest-akka.actor.default-dispatcher-2] DEBUG akka.event.EventStream - logger log1-Slf4jTraceContextEventHandler started
13:31:11.620 [consoletest-akka.actor.default-dispatcher-2] DEBUG akka.event.EventStream - Default Loggers started
13:31:11.639 [consoletest-akka.actor.default-dispatcher-4] INFO o.j.c.Bootstrap$$anonfun$5$$anon$1 - **** Starting balance retrieval ****
13:31:11.672 [consoletest-akka.actor.default-dispatc
@jamie-allen
jamie-allen / gist:4069114
Created November 13, 2012 23:24
NPE in DefaultPromise.future.map
package org.jamieallen.consoletest
import akka.util.duration._
import akka.actor._
import akka.dispatch.ExecutionContext
import akka.dispatch.Promise
import java.util.concurrent.TimeoutException
import akka.dispatch.Await
import akka.pattern.pipe
@jamie-allen
jamie-allen / gist:4067714
Created November 13, 2012 19:06
Console build.sbt
scalaVersion := "2.9.2"
name := "Console Playground"
scalacOptions ++= Seq("-unchecked", "-deprecation", "-optimize")
resolvers ++= Seq("akka-snapshots" at "http://repo.akka.io/snapshots",
"akka-releases" at "http://repo.akka.io/releases",
"Atmos Repo" at "http://repo.typesafe.com/typesafe/atmos-releases",
"Cloudera Repo" at "https://repository.cloudera.com/content/groups/public",
@jamie-allen
jamie-allen / IoManagerBootstrap.scala
Created August 10, 2012 20:37
Simple example of how to use Akka IOManager Iteratee and exporting work to another actor
import akka.actor._
import akka.pattern.ask
import akka.util._
import akka.util.duration._
import scala.util.control.Exception._
/**
* To test, execute this code and use this command in a shell: "telnet localhost 8080"
* At the prompt, type in numbers and press enter, and they will be accumulated, returning
* the total value each time.
@jamie-allen
jamie-allen / gist:2631366
Created May 7, 2012 23:18
PatternMatchTest.scala
import scala.annotation.switch
/**
* Simple test of how quickly Scala can perform typed pattern matches, both of primitive types and complex object types.
*/
object PatternMatchRunner extends App {
name := "Akka ActorSystem Test"
version := "1.0"
scalaVersion := "2.9.1-1"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.1"
@jamie-allen
jamie-allen / gist:2565539
Created May 1, 2012 06:13
Large table/lookupswitch pattern match by hashed type
import scala.annotation.switch
/**
* Simple test of how quickly Scala can perform typed pattern matches, both of primitive types and complex object types.
*/
object PatternMatchRunner extends App {
val numberOfOperations = 10000000
@jamie-allen
jamie-allen / gist:2341725
Created April 9, 2012 05:44
Simple test of the pattern matching by Types in Scala
import scala.annotation.switch
/**
* Simple test of how quickly Scala can perform typed pattern
* matches, both of primitive types and complex object types.
*/
object PatternMatchTest extends App {
val numberOfOperations = 10000000
println("Performing baseline test...")
/**
* I'm trying to create a basic supervisor hierarchy with four actors. If any fail for
* any reason, tear them all down and restart them to re-process any unhandled
* data. When I run, I see the "Blowing up!" log output. I expect the ensuing throw
* to blow up my actors, and then I should see all of my actors restarted per my
* supervision strategy, but I just get a message timeout (None response to the
* producer).
*
* The online Akka docs say this about sending a message with a ?: "The receiving
* actor should reply to this message, which will complete the future with the