Skip to content

Instantly share code, notes, and snippets.

@eed3si9n
eed3si9n / source-dep.sbt
Created December 31, 2011 20:30
displays internal source deps
TaskKey[Unit]("source-dep") <<= (fullClasspath in Runtime) map { (cp) =>
cp map { dir =>
val analysis = Defaults.extractAnalysis(dir)._2
analysis.relations.allSources map { file =>
println(file.getName.toString + " depends on " + analysis.relations.internalSrcDeps(file))
}
}
()
}
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@tonymorris
tonymorris / gist:3087504
Created July 11, 2012 02:09
Comonad/Monad
trait Functor[F[_]] {
def fmap[A, B](f: A => B): F[A] => F[B]
}
trait Extend[F[_]] extends Functor[F] {
// coflatmap
def extend[A, B](f: F[A] => B): F[A] => F[B]
}
trait Comonad[F[_]] extends Extend[F] {
@jgeurts
jgeurts / install-graphite-ubuntu-12.04.sh
Created July 14, 2012 16:36 — forked from tkoeppen/install-graphite-ubuntu-10.04.sh
Install Graphite 0.9.10 on Ubuntu 12.04
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
@seanparsons
seanparsons / SKI_Applicative.scala
Created August 2, 2012 09:06 — forked from tonymorris/SKI_Applicative.scala
Applicative Functor / SKI combinator calculus
object SKI_Applicative {
/*
First, let's talk about the SK combinator calculus and how it contributes to solving your problem.
The SK combinator calculus is made of two functions (aka combinators): S and K. It is sometimes called the SKI combinator calculus,
however, the I combinator can be derived from S and K. The key observation of SK is that it is a turing-complete system and therefore,
anything that can be expressed as SK is also turing-complete. Here is a demonstration that Scala's type system is turing-complete
(and therefore, undecidable) for example[1].
The K combinator is the most trivial of the two. It is sometimes called "const" (as in Haskell). There is also some discussion about
@tonymorris
tonymorris / WTF.scala
Created September 5, 2012 01:36
Scala WTF?
case class X[A](a: A)
object X {
// succeeds
def q: X[String] = X("abc")
// succeeds
def r: X[Unit] = X("abc")
// fails
@tonymorris
tonymorris / Balance.scala
Created September 23, 2012 01:43
Balance Parentheses
// Missing support libraries
object MissingLibraries {
case class State[S, +A](run: S => (A, S)) {
def map[B](f: A => B): State[S, B] =
State(s => {
val (a, t) = run(s)
(f(a), t)
})
def flatMap[B](f: A => State[S, B]): State[S, B] =
@danieltreacy
danieltreacy / jvm-companies.md
Created September 26, 2012 02:40
Tech companies/startups migrated to the JVM

Tech companies who have migrated to the JVM

NB: Does not include companies that started with a JVM language. The purpose of this gist is to list the companies that decided to move their stack (or some part of it) to the JVM.

@tonymorris
tonymorris / TypeClass.hs
Last active September 15, 2020 13:17
Type-class hierarchy
Moved to https://github.com/tonymorris/type-class
@ayosec
ayosec / CORSDirectives.scala
Created December 18, 2012 03:28
CORS with Spray
package foo.bar
import spray.routing._
import spray.http._
import spray.http.StatusCodes.Forbidden
// See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
case class Origin(origin: String) extends HttpHeader {