Skip to content

Instantly share code, notes, and snippets.

View EECOLOR's full-sized avatar

EECOLOR EECOLOR

  • Kaliber
  • Utrecht, Netherlands
View GitHub Profile
@EECOLOR
EECOLOR / .bashrc
Created January 31, 2016 10:26
Git situational awareness
source ~/.git_sit_awareness.sh
const ACTION = 'my-app/widgets/ACTION';
export default function reducer(state = {}, action = {}) {
switch (action.type) {
case ACTION:
return action.reduce(state)
default:
return state;
}
}
@EECOLOR
EECOLOR / commands.json
Created November 10, 2015 07:40
Elasticsearch nested sort problem
PUT /testindex
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"testtype": {
"dynamic": "strict",
"properties": {
_ = magic
Option[A] = Some[A] | None
/*
O: Objects
A: Arrows
*/
O_00 = { _, X }
O_00 = { _ -> X }
@EECOLOR
EECOLOR / Party.scala
Created March 12, 2015 19:52
If characters were chocolate and parsers were girls, what would happen? (this code has not been tested, that would have been a mess)
object Party {
type Chocolate = Char
type Sticker = Any
def complain(c: Chocolate) = abort(s"You should have asked me if I wanted `$c`")
sealed trait Girl {
def willYouEat(c: Chocolate): VagueAnswer
def eat(c: Chocolate): (Rating, Girl)
@EECOLOR
EECOLOR / como.scala
Last active August 29, 2015 14:15 — forked from paulp/como.scala
package p {
object Test {
import construction.Monadic
import execution.Bimonad
def main(args: Array[String]): Unit = {
val expression = Monadic[List](10) flatMap (1 to _ toList) coflatMap (_.sum)
@EECOLOR
EECOLOR / ProgramTypeHelpers.scala
Created October 5, 2014 11:31
Clean construction of coproducts
trait Co[F[_], G[_]] {
case class Product[A](value: Either[F[A], G[A]])
}
trait ProgramType[F[_]]
object ProgramType {
def apply[T](implicit to: ToParameterized[T]): ProgramType[to.Out] = ???
}
trait ToParameterized[T] {
@EECOLOR
EECOLOR / Test.scala
Last active August 18, 2017 16:20
Branching with free monads
package test
import scala.language.implicitConversions
import scala.language.higherKinds
import scalaz.Free.FreeC
import scalaz.Free
import scalaz.Monad
import scalaz.Coyoneda
@EECOLOR
EECOLOR / cyclic.sbt
Created September 17, 2014 19:38
Sbt cyclic project dependencies. Helps in tying projects together if they depend on eachother.
internalDependencyClasspath in Compile in `play-cms-testing` +=
interProjectDependency(`play-cms`, Compile).value
internalDependencyClasspath in Test in `play-cms` +=
interProjectDependency(`play-cms-testing`, Compile).value
def interProjectDependency(project:Project, configuration:Configuration) = Def.task {
Attributed.blank(
(classDirectory in configuration in project)
.map(identity) // convert the setting into a task
@EECOLOR
EECOLOR / _1_TypedActor.scala
Last active August 29, 2015 14:06
An alternative version of typed actors. Actors can only receive messages of a certain type, the type parameter determines the return type.
package experiment
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.language.higherKinds
import scala.language.implicitConversions
import scala.reflect.ClassTag
import akka.actor.Actor
import akka.actor.ActorRef