Skip to content

Instantly share code, notes, and snippets.


Martin Krasser krasserm

View GitHub Profile
bmc / StaticFile.scala
Last active Sep 3, 2021
I needed code to serve static files from an Akka HTTP server. I wanted to use fs2 to read the static file. Michael Pilquist recommended using streamz to convert from an fs2 Task to an Akka Source. This is what I came up with. (It does actually work.)
View StaticFile.scala
object StaticFile {
// Various necessary imports. Notes:
// 1. fs2 is necessary. See
// 2. streamz is necessary. See
// 3. Apache Tika is used to infer MIME types from file names, because it's more reliable and
// fully-featured than using java.nio.file.Files.probeContentType().
// If using SBT, you'll want these library dependencies and resolvers:
View gist:c645e28cc708b26177eb1444d077d09a
import java.nio.ByteBuffer
import java.util.concurrent.TimeUnit
import org.apache.kafka.clients._
import org.apache.kafka.common.metrics.{MetricConfig, Metrics, MetricsReporter}
import org.apache.kafka.common.protocol.ApiKeys
import org.apache.kafka.common.record.{CompressionType, MemoryRecords}
import org.apache.kafka.common.requests.{ProduceRequest, RequestSend}
import org.apache.kafka.common.utils.SystemTime
squadbox /
Last active Aug 9, 2022
A script to control Nvidia GPU fan speed on headless (non-X) linux nodes
# This script will enable or disable fixed gpu fan speed
# Description: A script to control GPU fan speed on headless (non-X) linux nodes
# Original Script by Axel Kohlmeyer <>
# Modified for newer drivers and removed old work-arounds