Skip to content

Instantly share code, notes, and snippets.

View Fristi's full-sized avatar

Mark Fristi

View GitHub Profile
@laszloh
laszloh / 50-bluetooth-hci-auto-poweron.rules
Last active May 8, 2018 19:36
Bluetooth support for RuneAudio on the Raspberry Pi 3
# Set bluetooth power up
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]*", RUN+="/bin/hciconfig %k up"
package akka.kafka.scaladsl
import java.util.concurrent.TimeUnit
import java.util.{Properties, UUID}
import akka.actor.ActorSystem
import akka.kafka.{ConsumerSettings, ProducerSettings}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Sink
import akka.testkit.TestKit
@lihaoyi
lihaoyi / play.scala
Last active April 18, 2017 08:18
play.scala
/**
* Single-file play framework application! Make sure everything
* works, as this is the test case that un-earthed #371
*/
load.ivy("com.typesafe.play" %% "play" % "2.5.0")
load.ivy("com.typesafe.play" %% "play-netty-server" % "2.5.0")
load.ivy("org.scalaj" %% "scalaj-http" % "2.2.1")
@
package cats.bench
import cats.data.Xor
import cats.instances.either._
import cats.syntax.all._
import org.openjdk.jmh.annotations.{ Benchmark, Scope, State }
@State(Scope.Benchmark)
class EitherBench {
val ea: Either[String, Int] = Right(1)
import scalaz._, Scalaz._
/** Abstraction over functions of the shape `A => F[A]`. */
case class EndoT[F[_], A](run: A => F[A]) {
def apply(a: A): F[A] =
run(a)
def andThen(e: EndoT[F, A])(implicit ev: Bind[F]): EndoT[F, A] =
e.compose(this)
@tel
tel / Lenses.scala
Created April 18, 2017 04:38
Pure profunctor lenses in Scala
import scala.language.higherKinds
object Lenses {
trait Profunctor[P[_, _]] {
def dimap[A, B, C, D](f: C => A, g: B => D)(p: P[A, B]): P[C, D]
}
object Profunctor {
@aaronlevin
aaronlevin / cats-mtl.scala
Last active May 26, 2017 17:38
Does the cats-mtl design support for-comprehensions with multiple Monad constraints? Looks like it does!
package cats
import cats.data.{StateT, WriterT}
import cats.implicits._
/**
* TypeLevel is working on some alternative encodings of the Monad Transformer
* Library (MTL). The existing solution in cats was broken for a few reasons.
* One annoying issue made it imposisible to use for-comprehension with more
* than one Monad$FOO constraint owing to implicit resolution ambiguities.