Skip to content

Instantly share code, notes, and snippets.

View vjousse's full-sized avatar

Vincent Jousse vjousse

View GitHub Profile

Lightning Talk proposal for ReactiveConf 2017 http://www.reactiveconf.com #ReactiveConf

Porting Prezi to Elm in 99 lines of code

Elm is a statically-typed functional programming language. Its compiler produces safe JavaScript which is guaranteed to be free of runtime exceptions. Moreover Elm is packed with a bunch of powerful abstractions which let us build visual and reactive Web applications in a few lines of code.

As an example, I show the implementation of a simple framework for building Prezi-like presentations. It's just 99 lines of code!

@guillaumebort
guillaumebort / Secured.scala
Created April 7, 2012 12:05
HTTP Basic Authorization for Play 2.0
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request =>
request.headers.get("Authorization").flatMap { authorization =>
authorization.split(" ").drop(1).headOption.filter { encoded =>
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match {
case u :: p :: Nil if u == username && password == p => true
case _ => false
}
}.map(_ => action(request))
}.getOrElse {
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""")
@naholyr
naholyr / block-social-networks.sh
Created December 21, 2011 15:09
Bash Pomodoro using libnotify
#!/bin/bash
# Destination: ~/.pomodoro/hooks/work.d/
# Goal: block access to Twitter and Facebook while in a Pomodoro
# Note: won't work if you use Chrome, as it maintains an internal (not flushable from CLI) DNS cache. Fuck it.
# This file must be able to touch "/etc/hosts":
# The best way would be to create a group able to modify the "/etc/hosts" file:
# $ sudo addgroup host-manager
# $ sudo chgrp host-manager /etc/hosts