Skip to content

Instantly share code, notes, and snippets.

View sledorze's full-sized avatar

Stéphane Le Dorze sledorze

View GitHub Profile
@sledorze
sledorze / HttpsFilter
Last active August 29, 2015 14:01
Play Https filter for Heroku
object HttpsFilter extends Filter {
def isHttpsRequest(request : RequestHeader) =
Play.isDev || request.headers.get("x-forwarded-proto").exists(_.contains("https"))
override def apply(next: (RequestHeader) => Future[SimpleResult])(request: RequestHeader): Future[SimpleResult] = {
if (isHttpsRequest(request))
next(request)
else
Future.successful(Results.Redirect("https://"+ request.host + request.uri, request.queryString))
####################################
# 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
####################################
sudo apt-get update
####################################
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
@sledorze
sledorze / VerEx.hx
Created August 6, 2013 12:53 — forked from dpeek/VerEx.hx
class VerEx
{
public static function main()
{
var test = new VerEx()
.startOfLine()
.then("http")
.maybe("s")
.then("://")
.maybe("www.")
@sledorze
sledorze / gist:5541555
Created May 8, 2013 16:10
failing function on coursera course.
def terrainFunction(levelVector: Vector[Vector[Char]]): Pos => Boolean =
{ case Pos(x,y) =>
try {levelVector(y)(x) != '-'} catch { case (e : IndexOutOfBoundsException) => false}
}
def findChar(c: Char, levelVector: Vector[Vector[Char]]): Pos = {
val y = levelVector.indexWhere(_.contains(c))
val x = levelVector(y).indexOf(c)
Pos(x, y)
@sledorze
sledorze / unfoldScala
Created February 3, 2012 10:16
unfold in Scala
final class Unfoldable[A](a : A){
def unfold[B, This, That](f: A => Option[(B, A)])(implicit cb: CanBuildFrom[This, B, That]): That = {
val builder = cb()
@tailrec def unfolding(a: A) : That = {
f(a) match {
case Some((e, next)) =>
builder += e
unfolding(next)
case None =>
builder.result()
@sledorze
sledorze / Monax nodejs monad
Created January 4, 2012 22:14
A feeling of Monax NodeJs continuation Monad for haXe
// Fake example showing the syntax
NodeM.dO({
coll <= db.collection("avatars", _);
avatars <= coll.all("", _);
ret(avatars.length);
})(function (err, res) etc.. );
@sledorze
sledorze / 960gs.less
Created September 21, 2011 19:48 — forked from Aeon/960gs.less
LessCSS and 960gs don't play well together normally. Here's the definitions for 960gs to let LessCSS work with it. Looks like we can pull all grid data out of the HTML.
/**
* A LessCSS version of the 960 Grid System
*
* http://lesscss.org/
* http://960.gs/
*/
/*********************************************************************
* Settings *
*********************************************************************/