Skip to content

Instantly share code, notes, and snippets.

@dwhitney
dwhitney / .kddrc
Created November 22, 2016 19:23
~/.kddrc
khd kwm on
khd mode layout prefix on
khd mode layout timeout 2
khd mode layout restore default
khd mode default color 0xFFFFFFFF
ctrl - tab : khd -e "mode activate layout";\
kwmc config border focused on; \
kwmc config border focused size 2; \
kwmc config padding 20 20 20 20
#kwmc config gap 0 0
kwmc config tiling bsp
kwmc config float-non-resizable on
kwmc config lock-to-container on
kwmc config focus-follows-mouse off
kwmc config standby-on-float on
kwmc config center-on-float on
kwmc config mouse-follows-focus on
kwmc config mouse-drag on
import cats._
import cats.free.Free
import cats.implicits._
import freek._
sealed trait LogDSL[A]
case class Info(msg: String) extends LogDSL[Unit]
/*
Results
[info] Running StreamsExperiments
[info] Count: 923062246
[info] Time: 5301
[info] Count: 923062246
[info] Time: 4588
[info] Count: 923062246
[info] Time: 4460
[info] Count: 923062246
@dwhitney
dwhitney / compress.scala
Created October 13, 2016 17:26
added gzip compression -- haven't made a PR yet
package fs2
import java.util.zip.{CRC32, DataFormatException, Deflater, Inflater}
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
/** Provides utilities for compressing/decompressing byte streams. */
object compress {
@dwhitney
dwhitney / fs2-with-freek.scala
Created October 7, 2016 14:18
Quick example showing fs2 and Freek. Ran it over ~8gb of data at constant memory
package scripts
import java.io.File
import scala.concurrent.{Await, ExecutionContext, Future}
import scala.concurrent.duration._
import scala.language.higherKinds
import fs2._
import fs2.Task._
import fs2.interop.cats._
import fs2.util.{Attempt, Catchable, Suspendable}
@dwhitney
dwhitney / XorExample.scala
Created June 6, 2016 21:20
Shows how the Freenion works
import freek._
import cats.{Id,~>}
import cats.data.Xor
import cats.free.Free
object XorExample extends App{
sealed trait Algebra[A]
case object Good extends Algebra[Xor[Throwable,String]]
case object Bad extends Algebra[Xor[Throwable,String]]
def graphql: Endpoint[Json] = {
post(
"graphql" ? (body :: authOptReader :: contentTypeReader :: imageOptReader :: queryReader :: variablesReader)
){ (body: String, authOpt: Option[TokenUUID], contentType: String, image: Option[FileUpload], query: Option[String], variables: Option[String]) =>
contentType.take("multipart/form-data".length) match {
case "multipart/form-data" => {
for {
auth <- getAuthorization(authOpt)
def get[T](key: String): KVStore[T] = liftF(Get[T, T](key, identity))
import sangria.schema._
import sangria.execution.Executor
import sangria.parser.QueryParser
import sangria.renderer.SchemaRenderer
import sangria.integration.PlayJsonSupport._
import scala.util.{Success}
import scala.concurrent.ExecutionContext.Implicits.global