Skip to content

Instantly share code, notes, and snippets.

View henrikengstrom's full-sized avatar

Henrik Engstrom (@h3nk3) henrikengstrom

  • grandcloud.com
  • Boulder, CO, USA
  • X @h3nk3
View GitHub Profile
@henrikengstrom
henrikengstrom / DataDogTracerFactory.scala
Last active August 27, 2018 20:41
Example of Cinnamon + DataDog OT integration
/**
* Add the following setting to the application.conf to wire things up.
*
* cinnamon.opentracing {
* tracers = [datadog]
*
* datadog {
* factory-class = "sample.DataDogTracerFactory"
* }
* }
@henrikengstrom
henrikengstrom / HelloAkka.scala
Created May 6, 2017 17:30
New HelloAkka example
import akka.actor.{ ActorRef, ActorSystem, Props, Actor, ActorLogging }
import scala.concurrent.duration._
object Common {
case class Greeting(greeting: String)
}
object Greeter {
def props(message: String, printerActor: ActorRef): Props = Props(new Greeter(message, printerActor))
case object Greet

Keybase proof

I hereby claim:

  • I am henrikengstrom on github.
  • I am h3nk3 (https://keybase.io/h3nk3) on keybase.
  • I have a public key ASAX3TmieeXD65G9RyuVRIlnm0PC0xeetfKmZPNMboxDigo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am henrikengstrom on github.
  • I am h3nk3 (https://keybase.io/h3nk3) on keybase.
  • I have a public key whose fingerprint is 31C1 1375 AC5C 0575 AD34 EE7D 35CE 457A A97A C6B8

To claim this, I am signing this object:

@henrikengstrom
henrikengstrom / gist:2239565
Created March 29, 2012 16:35
Using specific config settings with TestActorRef
import akka.testkit.TestActorRef
import org.scalatest.matchers.MustMatchers
import org.scalatest.WordSpec
import com.typesafe.config.ConfigFactory
import akka.actor.{Actor, ActorSystem}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class Example2 extends WordSpec with MustMatchers {
implicit val actorSystem = ActorSystem("TestSystem", ConfigFactory.parseString("""{ test.value = "Hey, it works!" }"""))
@henrikengstrom
henrikengstrom / gist:2239521
Created March 29, 2012 16:32
Using specific config settings with TestKit - example 1
import akka.testkit.{TestActorRef, TestKit}
import com.typesafe.config.ConfigFactory
import org.scalatest.matchers.MustMatchers
import org.scalatest.WordSpec
import akka.actor.{Actor, ActorSystem}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class Example1 extends TestKit(
ActorSystem("TestSystem", ConfigFactory.parseString("""{ test.value = "Hey, it works!" }""")))
with WordSpec
@henrikengstrom
henrikengstrom / gist:1863424
Created February 19, 2012 11:54
Shakespeare actor
def receive = {
case actors: Int =>
val futures = for (x <- 1 to actors) yield {
context.actorOf(Props[MonkeyWorker]) ? randomGenerator.nextInt(100) mapTo manifest[Set[String]]
}
Future.sequence(futures) map { wordSets =>
val mergedSet = wordSets reduce ( (a, b) => a ++ b )
val (shakespeare, unworthy) = mergedSet partition (x => Blueprint.contains(x))
Result(shakespeare, unworthy)
@henrikengstrom
henrikengstrom / gist:1863329
Created February 19, 2012 11:38
play-mini HTTP POST
case POST(Path("/write")) ⇒ Action { implicit request =>
val start = System.nanoTime
val numberMonkeys = writeForm.bindFromRequest.get
AsyncResult {
(shakespeare ? numberMonkeys).mapTo[Result].asPromise.map { result ⇒
// We have a result - make some fancy pantsy presentation of it
val builder = new StringBuilder
builder.append("SHAKESPEARE WORDS:\n")
result.shakespeareMagic.foreach { w => builder.append(w + "\n") }
builder.append("UNWORTHY WORDS CREATED: " + result.unworthyWords.size + "\n")
@henrikengstrom
henrikengstrom / gist:1843428
Created February 16, 2012 08:50
Akka2.0-RC1 example of using futures to re-start long running task
import akka.actor.{ Props, ActorSystem, Actor }
import akka.pattern.ask
import akka.util.Timeout
import akka.util.duration._
import akka.dispatch.Await
import util.Random
object DangerousOpTest extends App {
println("starting system")
val system = ActorSystem("daOp")
calculator {
include "common"
akka {
remote.netty.port = 2552
}
}
remotelookup {
include "common"