Skip to content

Instantly share code, notes, and snippets.


David Barri japgolly

View GitHub Profile
xian /
Last active Dec 14, 2015 — forked from JakeWharton/
Here's the magic to get ActionBarSherlock working with Robolectric 2.0-alpha-2!

You need to add the files below, and do this once in your base test runner:

shangaslammi / webspider.hs
Created Oct 4, 2011
Haskell Web Spider example
View webspider.hs
import Control.Exception
import Control.Monad
import Control.Monad.IO.Class
import Data.ByteString.Lazy (ByteString)
import Data.ByteString.Lazy.UTF8 (toString)
import Data.Function
import Data.Enumerator
import Data.List
import Data.Maybe
arosien / runar-io-free.scala
Last active Sep 10, 2016
Translation of Runar's ScalaIO 2013 presentation on IO and Free monads ( to scalaz.
View runar-io-free.scala
import scalaz._
import Scalaz._
import Free._
/** "Pure" interactions with a console. */
sealed trait Console[+A]
case class GetLine[A](k: String => A) extends Console[A]
case class PutLine[A](s: String, a: A) extends Console[A]
object Console {
nponeccop / Unfold.hs
Created Aug 16, 2015
Unfolds, coalgebras and anamorphisms
View Unfold.hs
{-# LANGUAGE DeriveFunctor #-}
import Data.Functor.Foldable
import Data.Function
unfold1 :: Unfold Int [Int]
unfold1 = xana coalgebra1
xana :: Unfoldable b => Coalgebra a b -> Unfold a b
xana = ana
holoed / JsonParser.hs
Last active Mar 31, 2017
Json Parser Example
View JsonParser.hs
{-#LANGUAGE DeriveFunctor#-}
module Main where
fix :: ((a -> b) -> a -> b) -> a -> b
fix f = f (fix f)
newtype Fix f = In { out :: f (Fix f) }
type Algebra f a = f a -> a
zraffer / package.scala
Last active Apr 26, 2017
a few operations with functors
View package.scala
package object types {
import scala.language.reflectiveCalls
import scala.language.higherKinds
// quantifiers aka (co)ends
type Forall[+F[_]] = { def apply[X]: F[X] }
type Exists[+F[_]] = F[_]
// basic categorical notions
Mzk-Levi / ncompositions.scala
Last active Mar 24, 2018
Horizontal & Vertical Compositions of Natural Transformations
View ncompositions.scala
trait Functor[F[_]] {
def map[A, B](as: F[A])(f: A => B): F[B]
object Functor {
def apply[F[_]](implicit e: Functor[F]): Functor[F] = e
trait ~>[F[_], G[_]] {
def apply[A](x: F[A]): G[A]
gkossakowski /
Last active Jun 19, 2018
Understand Scala's core typechecking rules

Scala's "type T in class C as seen from a prefix type S" with examples


Recently, I found myself in need to precisely understand Scala's core typechecking rules. I was particulary interested in understanding rules responsible for typechecking signatures of members defined in classes (and all types derived from them). Scala Language Specification (SLS) contains definition of the rules but lacks any examples. The definition of the rules uses mutual recursion and nested switch-like constructs that make it hard to follow. I've written down examples together with explanation how specific set of rules (grouped thematically) is applied. These notes helped me gain confidence that I fully understand Scala's core typechecking algorithm.

As Seen From

Let's quote the Scala spec for As Seen From (ASF) rules numbered for an easier reference:

JasonSwindle / DockerCleanup-Task.json
Last active Oct 7, 2019
A task definition for ECS using MeltWater's Docker Container and Image clean-up containerized script. Please see for more details on correct usage.
View DockerCleanup-Task.json
"containerDefinitions": [
"volumesFrom": null,
"memory": 32,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": true,
"dnsSearchDomains": null,
"portMappings": [],
kdrakon / ConsistentHashGroupedStreams.scala
Created Sep 6, 2016
Example of Consistent Hashing for Akka groupBy Streams
View ConsistentHashGroupedStreams.scala
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.{Executors, TimeUnit}
import{ActorSystem, Props}
import akka.routing.ConsistentHash
import{Flow, GraphDSL, RunnableGraph, Sink, Source}
import{ActorMaterializer, ClosedShape, ThrottleMode}
import com.kifi.franz.{MessageId, SQSMessage}
You can’t perform that action at this time.