Skip to content

Instantly share code, notes, and snippets.

View japgolly's full-sized avatar
☠️
Non-existant

David Barri japgolly

☠️
Non-existant
View GitHub Profile
@xian
xian / 00_README.md
Last active December 14, 2015 07:48 — forked from JakeWharton/ActionBarSherlockRobolectric.java
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:

ActionBarSherlock.registerImplementation(ActionBarSherlockRobolectric.class);
ActionBarSherlock.unregisterImplementation(ActionBarSherlockNative.class);
ActionBarSherlock.unregisterImplementation(ActionBarSherlockCompat.class);
@shangaslammi
shangaslammi / webspider.hs
Created October 4, 2011 08:25
Haskell Web Spider example
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
arosien / runar-io-free.scala
Last active September 10, 2016 07:17
Translation of Runar's ScalaIO 2013 presentation on IO and Free monads (http://blog.higher-order.com/assets/scalaio.pdf) to scalaz.
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
nponeccop / Unfold.hs
Created August 16, 2015 01:22
Unfolds, coalgebras and anamorphisms
{-# 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
holoed / JsonParser.hs
Last active March 31, 2017 16:01
Json Parser Example
{-#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
zraffer / package.scala
Last active April 26, 2017 11:17
a few operations with functors
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
Mzk-Levi / ncompositions.scala
Last active March 24, 2018 03:06
Horizontal & Vertical Compositions of Natural Transformations
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
gkossakowski / asSeenFrom.md
Last active June 19, 2018 18:27
Understand Scala's core typechecking rules

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

Introduction

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
JasonSwindle / DockerCleanup-Task.json
Last active October 7, 2019 00:52
A task definition for ECS using MeltWater's Docker Container and Image clean-up containerized script. Please see https://github.com/meltwater/docker-cleanup for more details on correct usage.
{
"containerDefinitions": [
{
"volumesFrom": null,
"memory": 32,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": true,
"dnsSearchDomains": null,
"portMappings": [],
@kdrakon
kdrakon / ConsistentHashGroupedStreams.scala
Created September 6, 2016 05:29
Example of Consistent Hashing for Akka groupBy Streams
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.{Executors, TimeUnit}
import akka.actor.{ActorSystem, Props}
import akka.routing.ConsistentHash
import akka.stream.actor._
import akka.stream.scaladsl.{Flow, GraphDSL, RunnableGraph, Sink, Source}
import akka.stream.{ActorMaterializer, ClosedShape, ThrottleMode}
import com.kifi.franz.{MessageId, SQSMessage}