Skip to content

Instantly share code, notes, and snippets.

View betehess's full-sized avatar

Alexandre Bertails betehess

View GitHub Profile
@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
@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
@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)
@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)
}
import scalaz._
import Scalaz._
import scalaz.effect._
package object types {
type Bytes = String
type Path = String
}
@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 }
#!/bin/bash
# This script is the reference implementation of how to start the
# ENSIME server given an ENSIME config file, bootstrapping via sbt[1].
# It is not intended to be portable across operating systems, or
# efficient at caching the results of previous invocations.
# Typically it is best to take the basic concepts of this script and
# to port it to the natural language of the extensible editor that
# intends to support ENSIME.
@przemek-pokrywka
przemek-pokrywka / hello-coursier-ammonite-play.sh
Last active May 7, 2016 22:55
Serve a webpage using Play framework with a simple script. Nothing more, than Linux and Java required. Thanks to brilliant work of Alexandre Archambault, @li_haoyi and Play developers.
#!/bin/bash
test -e ~/.coursier/cr || (mkdir -p ~/.coursier && wget -q -O ~/.coursier/cr https://git.io/vgvpD && chmod +x ~/.coursier/cr)
CLASSPATH="$(~/.coursier/cr fetch -q -p \
\
com.typesafe.play:play-netty-server_2.11:2.5.0 \
com.typesafe.play:play_2.11:2.5.0 \
com.lihaoyi:ammonite-repl_2.11.7:0.5.2 \
\
)" java \
-Dplay.crypto.secret=foo.bar.baz \
@syllog1sm
syllog1sm / bootreact
Created January 13, 2014 15:09
Draft proposals for wrapping Bootstrap components with React.js
/** @jsx React.DOM */
'use strict';
// Components wrapping Twitter Bootstrap stuff
//
var BSNames = {
// This isn't exhaustive. Need to think through what should go here. Should
// be exclusive.
bsClass: {'column': 'col', 'button': 'btn', 'btn-group': 'btn-group', 'label': 'label',
@sadache
sadache / gist:3026886
Created July 1, 2012 05:01
Bits'bout Play2 Architecture

Bits'bout Play2 Architecture

Play2 Simple HTTP API

Essential blueprint of Play2 architecture is pretty simple and it should be easy to explain in a fairly short blog post. The framework can be understood progressively at different levels; each time having better exposure to some aspects of its design.

The core of Play2 is really small, surrounded by a fair amount of useful APIs, services and structure to make Web Programming tasks easier.

Basically, Play2 is an API that abstractly have the folllowing type