Various script and code snippets I collected or created
Remove all exited containers
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker rmRemoved unnamed images
docker images | grep '^<none>.*<none>' | sed -E 's/<none> +<none> +([0-9a-f]+).*/\1/' | xargs docker rmiAside from snippets, here are some useful links:
Zip with index, similar to a combinator on Scala collections
Flow[E].zip(Source[Int](() => Iterator.from(0)))or with a custom stage
def zipWithIndex[E]: Flow[E, (E, Int), Unit] = Flow[E].transform(() => new PushStage[E, (E, Int)] {
private[this] var idx = 0
override def onPush(elem: E, ctx: Context[(E, Int)]) = {
val curIdx = idx
idx += 1
ctx.push(elem, curIdx)
}
})Frame Source[ByteString, _] splitting strings by new line character (source):
Flow[ByteString]
.via(Framing.delimiter(ByteString("\n"), maximumFrameLength = 256, allowTruncation = true))