Skip to content

Instantly share code, notes, and snippets.

View dschobel's full-sized avatar

Daniel Schobel dschobel

  • Twitter
View GitHub Profile
@dschobel
dschobel / LoggingFilter
Created October 23, 2014 20:55
finagle filter in java
import com.twitter.finagle.Service;
import com.twitter.finagle.SimpleFilter;
import com.twitter.util.Future;
public class MyThriftRequest { public int Attribute = 123; }
public class LoggingFilter extends SimpleFilter<MyThriftRequest, MyThriftResponse> {
private static final Logger LOG = Logger.getLogger(LoggingFilter.class);
@dschobel
dschobel / build.sbt
Last active August 29, 2015 14:16
basic build.sbt
lazy val root = (project in file(".")).
settings(
name := "My Project",
version := "1.0",
scalaVersion := "2.11.6"
)
libraryDependencies += "com.twitter" % "util-core_2.11" % "6.23.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.1" % "test"
@dschobel
dschobel / State.scala
Created June 6, 2015 06:41
calculating fibonacci numbers and manipulating a stack with the State monad
// no external dependencies, just :paste the entire gist into a scala 2.11 repl
// scala> import State._
// scala> StackExample.computed.run(List.empty)
// #result of push(1), push(2), push(3), pop()
// res0: (List[Int], Option[Int]) = (List(2, 1),Some(3))
// #naive fibonacci impl
// scala> time(FibExample.fib(42))
// took 1204 ms