Instantly share code, notes, and snippets.

# use to crop a foto to the right dimensions
# then use this script to lay it out on a 1600x2312 jpg to print as 9x13
montage mein-passfoto.jpg mein-passfoto.jpg mein-passfoto.jpg mein-passfoto.jpg -geometry 622x898+89+129 out.jpg
View THX.scala
import java.util.concurrent.ThreadLocalRandom
import javax.sound.sampled._
// Program to generate THX Deep Note sound according to the sheet music
// published to celebrate its 35th birthday
object THX extends App {
val sampleRate = 44100f
val af = new AudioFormat(

In general, performance differences are usually negligible as long as they don't turn up during benchmarking (you probably know what people say about premature optimization...).

So, it's mostly a matter of style. Writing a GraphStage is the lowest level you can implement something in akka-stream. It's very explicit and somewhat predictable what happens but the amount of code to write can be quite cumbersome and with a growing number of ports, managing the state space and all the possible interactions can be quite a challenge.

Wiring up predefined combinators using the GraphDSL is therefore often recommended. In the best case it's just "plug and play". On the other hand, it also introduces new degrees of freedom and non-determinism as elements flow

View CleanupImports.scala
* Copyright (C) 2009-2017 Lightbend Inc. <>
import sbt._
import Keys._
package sbt {
object Access {
def compilerReporter = sbt.Keys.compilerReporter
View analysis.txt
TargetVersion: Scala 2.13.0-M5 LastVersion: Scala 2.12
15 libraries available for Scala 2.13.0-M5 (see the end for sbt config lines)
scala-xml 2 versions: 1.1.1, 1.1.0
scala-parser-combinators 1 versions: 1.1.1
scalatest 1 versions: 3.0.6-SNAP3
specs2 1 versions: 4.3.5
scalacheck 1 versions: 1.14.0
squeryl 1 versions: 0.9.12
scalikejdbc-interpolation 1 versions: 3.3.1
View StackDumpAnalyzer.scala
object StackDumpAnalyzer extends App {
val ThreadLine = """"([^"]+)" #(\d+) prio=(\d+) os_prio=(\d+) tid=0x([0-9a-f]+) nid=0x([0-9a-f]+) (.*)""".r
val file = "ThreadDump.txt"
case class ThreadState(name: String, id: Int, prio: Int, osPrio: Int, tid: Long, nid: Int, state: String)
View SuperInspectTree.scala
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah, Eugene Yokota
package sbt
package myinspect
import Def.{ScopedKey, compiled, flattenLocals}
View AffinityVsFJP.log
Intel(R) Core(TM) i7-3840QM CPU @ 2.80GHz
Turbo off
Linux 64bit
jmh:run -i 4 -wi 4 -f 1 -p throughPut=1 -p dispatcher=affinity-dispatcher,default-fj-dispatcher .*AffinityPoolReq.*
[info] Benchmark (dispatcher) (mailbox) (throughPut) Mode Cnt Score Error Units
[info] AffinityPoolRequestResponseBenchmark.queryUserServiceActor affinity-dispatcher SingleConsumerOnlyUnboundedMailbox 1 thrpt 4 3634030.863 ± 3728431.081 ops/s
[info] AffinityPoolRequestResponseBenchmark.queryUserServiceActor default-fj-dispatcher SingleConsumerOnlyUnboundedMailbox 1 thrpt 4 4031047.752 ± 1552394.546 ops/s
View TestCase1219.scala
package akka.http
import akka.http.impl.util.ExampleHttpContexts
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.http.scaladsl.{Http, HttpsConnectionContext}
import com.typesafe.config.ConfigFactory
View TestCase1023.scala
import java.util.concurrent.atomic.AtomicLong
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import{ Sink, Source }
import com.typesafe.config.ConfigFactory
import scala.concurrent.Future