Skip to content

Instantly share code, notes, and snippets.

View betehess's full-sized avatar

Alexandre Bertails betehess

View GitHub Profile
@YoEight
YoEight / Exo.scala
Created November 27, 2013 13:13
Mu exercise (Scala 2.10)
import scala.language.higherKinds
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
object Functor {
def apply[F[_], A, B](fa: F[A])(f: A => B)(implicit F: Functor[F]): F[B] =
F.map(fa)(f)
}
@jrudolph
jrudolph / ToLowerCase.scala
Created October 31, 2013 15:27
ToLowerCase
object Test extends App {
import DefaultJsonProtocol._
trait ToLowerCase
object ToLowerCase {
def apply(str: String): String with ToLowerCase = str.toLowerCase.asInstanceOf[String with ToLowerCase]
implicit val strWithToLowerCaseFormat: JsonFormat[String with ToLowerCase] =
new JsonFormat[String with ToLowerCase] {
def write(obj: String with ToLowerCase): JsValue = JsString(obj)
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
@deiu
deiu / deploy.sh
Last active December 25, 2015 00:58
RWW.IO Web app deployer
#!/bin/sh
# RWW.IO Web app deployer. Simply run `sh deploy.sh` inside your Web app dir and follow the steps.
CERTCMD=""
# get target URI
read -p "Please provide the URI of the target dir (ex: http://example.org/apps/myapp/): " HOST
if [ "$HOST" = "" ]
then
@raichoo
raichoo / Vect.scala
Created October 1, 2013 16:31
Playing with dependent types in Scala
package Vect
import scala.language.higherKinds
sealed trait Nat
sealed trait Z extends Nat
sealed trait S[N <: Nat] extends Nat
trait Exists[A, +B[_ <: A]] {
type fst <: A
@jbenet
jbenet / simple-git-branching-model.md
Last active May 3, 2025 18:07
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@mathieuancelin
mathieuancelin / WSEnumerator.scala
Last active December 21, 2015 10:48
Scala class to transform an HTTP GET stream into Enumerator[Whatever]
package play.api.libs.ws
import play.api.libs.iteratee.{Enumeratee, Concurrent, Enumerator}
import play.api.libs.concurrent.Execution.Implicits._
import com.ning.http.client._
import com.ning.http.client.AsyncHandler.STATE
import play.api.Logger
import scala.concurrent.{Future, Promise}
@YoEight
YoEight / Server.scala
Created July 4, 2013 12:17
Chunk encoded response using Unfiltered, Netty and Scalaz-Stream
package deiko
import java.nio.charset.Charset
import java.util.concurrent.CancellationException
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.channel.{ Channel, ChannelFuture, ChannelFutureListener }
import org.jboss.netty.handler.codec.http.{ DefaultHttpChunk, HttpChunk }
import scalaz.stream.{ Process, process1, processes }
import scalaz.concurrent.Task
import Process.{ Process1, Sink }
@etorreborre
etorreborre / gist:5078824
Last active November 16, 2024 17:40
A good summary of Scala types from http://bit.ly/XjSVKw
class Outer {
class Inner
type Type
}
trait Trait
object Object extends Outer {
val inner = new Inner
}
class OuterP[A] {
class InnerP[B]
// Author: Olivier Chafik (http://ochafik.com)
// Feel free to modify and reuse this for any purpose ("public domain / I don't care").
package scalaxy.pretyping.example
import scala.reflect.internal._
import scala.tools.nsc.CompilerCommand
import scala.tools.nsc.Global
import scala.tools.nsc.Phase
import scala.tools.nsc.plugins.Plugin
import scala.tools.nsc.plugins.PluginComponent