Skip to content

Instantly share code, notes, and snippets.

Joe Ferris jferris

  • thoughtbot, inc.
  • Cambridge, MA
Block or report user

Report or block jferris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jferris / BufferedCommitter.scala
Created Mar 1, 2019
Buffered commit to Kafka
View BufferedCommitter.scala
import cats.effect.{ContextShift, IO}
import cats.effect.concurrent.Ref
import cats.implicits._
import fs2.{Chunk, Pipe, Stream}
class BufferedCommitter(
config: Config,
consumer: Consumer,
pipe: Pipe[IO, Record, Unit])(implicit cs: ContextShift[IO]) {
def run: IO[Unit] =
jferris / EitherT.scala
Created Nov 30, 2017
EitherT, partially applied
View EitherT.scala
import cats.{Applicative, Functor}
import scala.language.higherKinds
object EitherTF {
def apply[F[_], A]: EitherTPartiallyApplied[F, A] =
new EitherTPartiallyApplied[F, A]
jferris / Demo.scala
Created Nov 16, 2017
Type Inference
View Demo.scala
import cats.instances.future._
import cats.syntax.all._
import scala.concurrent.{ExecutionContext, Future}
* Compiled with:
* Scala 2.12.4
* cats-core 1.0.0-RC1
* -Ypartial-unification
jferris / Wrap2.scala
Last active Apr 20, 2017
Reproduction for Shapeless Issue: Can't Comap a type with two type parameters
View Wrap2.scala
import shapeless._
import ops.hlist._
case class Wrap2[T, U](t: T, u: U)
class WrapTest[T, WL <: HList, L <: HList] {
def unwrap
(wrapped: WL)
(implicit comapped: Comapped.Aux[WL, ({ type l[U] = Wrap2[T, U] })#l, L])
= true
jferris / defaults.json
Created Sep 6, 2016
Chart.js defaults
View defaults.json
"global": {
"responsive": true,
"responsiveAnimationDuration": 0,
"maintainAspectRatio": true,
"events": [
View Example.hs
{-# LANGUAGE Arrows #-}
import Control.Arrow
double :: Int -> Int
double x = x * 2
triple :: Int -> Int
triple x = x * 3
jferris / JSON.hs
Created Apr 14, 2016
View JSON.hs
module Test.Hspec.JSON
( shouldBeJson
) where
import Control.Monad (when)
import Control.Monad.State (StateT, get, modify, runStateT)
import Control.Monad.Writer (Writer, execWriter, tell)
import Data.ByteString.Lazy (ByteString)
import Data.Function (on)
import Data.Monoid ((<>))
jferris / empty.hs
Created Mar 31, 2016
Empty Operator
View empty.hs
(?) :: Foldable t => t a -> t a -> t a
a ? b
| null a = b
| otherwise = a
View asoundrc
pcm.dmixed {
type asym
playback.pcm {
type dmix
ipc_key_add_uid true
ipc_key 5678293
ipc_perm 0660
ipc_gid audio
slave {
View combine.rb
def combine_ranges(ranges)
if ranges.empty?
first, *rest = ranges
rest.reduce([first]) do |result, current|
previous = result.pop
if previous.max + >= current.min
result << previous.min..current.min
You can’t perform that action at this time.