Skip to content

Instantly share code, notes, and snippets.

Johannes Rudolph jrudolph

Block or report user

Report or block jrudolph

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jrudolph
jrudolph / BetterTestOnly.scala
Last active Oct 23, 2019
sbt camel case and dot expanding testOnly see https://asciinema.org/a/276464?t=20 for a demo
View BetterTestOnly.scala
// copy into project
import sbt._
import Keys._
import Def._
import sbt.Def
import sbt.Defaults.allTestGroupsTask
import sbt.Defaults.loadForParser
import sbt.Project.inConfig
import sbt.internal.util.complete.DefaultParsers
@jrudolph
jrudolph / SimpleQuicClientMain.scala
Last active Nov 4, 2019
"Simple" "Http/3" "client"
View SimpleQuicClientMain.scala
import java.math.BigInteger
import java.net.DatagramPacket
import java.net.DatagramSocket
import java.net.InetAddress
import java.security.KeyPairGenerator
import java.security.MessageDigest
import java.security.SecureRandom
import java.security.interfaces.ECPrivateKey
import java.security.interfaces.ECPublicKey
import java.security.spec.ECPoint
@jrudolph
jrudolph / JmhCompletion.scala
Created Apr 30, 2019
A smart sbt parser for the most used jmh parameters (copy to project dir and use jmh:runny)
View JmhCompletion.scala
package akka.sbt.jmh.completion
import java.io.FileInputStream
import java.util.Collections
import pl.project13.scala.sbt.SbtJmh.JmhKeys.Jmh
import sbt._
import Keys._
import org.openjdk.jmh.runner.BenchmarkList
import org.openjdk.jmh.runner.BenchmarkListEntry
@jrudolph
jrudolph / script.sh
Created Oct 11, 2018
Biometrisches Passfoto erstellen zum selbst Ausdrucken
View script.sh
# use persofoto.de 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
@jrudolph
jrudolph / THX.scala
Created Sep 8, 2018
8-bit THX Deep Note sound generation with Scala
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
// https://twitter.com/THX/status/1000077588415447040
object THX extends App {
val sampleRate = 44100f
val af = new AudioFormat(
sampleRate,
@jrudolph
jrudolph / GraphStageOrGraphDSL.md
Created Dec 18, 2017
Should I use GraphStage or GraphDSL?
View GraphStageOrGraphDSL.md

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

@jrudolph
jrudolph / CleanupImports.scala
Last active Jan 17, 2018
Cleanup Imports for sbt 1.0
View CleanupImports.scala
/*
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
*/
import sbt._
import Keys._
package sbt {
object Access {
def compilerReporter = sbt.Keys.compilerReporter
@jrudolph
jrudolph / analysis.txt
Last active Nov 18, 2019
Scala 2.13 Release Train
View analysis.txt
TargetVersion: Scala 2.13 LastVersion: Scala 2.12
49 libraries available for Scala 2.13 (see the end for sbt config lines)
akka-actor 13 versions: 2.6.0, 2.6.0-RC2, 2.6.0-RC1, 2.6.0-M8, 2.6.0-M7, ... [8 more]
akka-stream 13 versions: 2.6.0, 2.6.0-RC2, 2.6.0-RC1, 2.6.0-M8, 2.6.0-M7, ... [8 more]
akka-http-core 3 versions: 10.1.9, 10.1.8, 10.1.10
akka-http 3 versions: 10.1.9, 10.1.8, 10.1.10
akka-osgi 13 versions: 2.6.0, 2.6.0-RC2, 2.6.0-RC1, 2.6.0-M8, 2.6.0-M7, ... [8 more]
akka-slf4j 13 versions: 2.6.0, 2.6.0-RC2, 2.6.0-RC1, 2.6.0-M8, 2.6.0-M7, ... [8 more]
akka-testkit 13 versions: 2.6.0, 2.6.0-RC2, 2.6.0-RC1, 2.6.0-M8, 2.6.0-M7, ... [8 more]
@jrudolph
jrudolph / StackDumpAnalyzer.scala
Created Sep 27, 2017
Ongoing effort to parse stack dumps generated e.g. by jstack or the JVM directly
View StackDumpAnalyzer.scala
import java.io.File
import scala.io.Source
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)
@jrudolph
jrudolph / SuperInspectTree.scala
Last active Oct 1, 2019
Better sbt `inspect tree`
View SuperInspectTree.scala
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah, Eugene Yokota
*/
package sbt
package myinspect
import java.io.File
import Def.{ScopedKey, compiled, flattenLocals}
You can’t perform that action at this time.