Skip to content

Instantly share code, notes, and snippets.

Marius Soutier mariussoutier

Block or report user

Report or block mariussoutier

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mariussoutier / Example.scala
Last active Aug 29, 2015
Use typed message in actors
View Example.scala
class MyActor extends TypedMessageActor {
import MyActor._
def receive = ReceiveMessage[AllowedMessage] {
case Message1(text) =>
case Message2 =>
mariussoutier / AkkaSpecification.scala
Last active Aug 29, 2015 — forked from cessationoftime/AkkaSpecification.scala
Test Akka from Specs2, versions as of Play 2.2.x
View AkkaSpecification.scala
import org.specs2.mutable._
import org.specs2.specification._
import org.specs2.matcher._
import org.specs2.execute._
import org.specs2.control.Debug
import org.specs2.main.ArgumentsShortcuts
import akka.testkit.TestKitBase
mariussoutier / togglewatch.js
Last active Aug 13, 2018
Toggle an AngularJS $watch expression. The default $watch can only be toggled once.
View togglewatch.js
var toggleWatch = function(watchExpr, fn) {
var watchFn;
return function() {
if (watchFn) {
watchFn = undefined;
console.log("Disabled " + watchExpr);
} else {
watchFn = $scope.$watch(watchExpr, fn);
console.log("Enabled " + watchExpr);
mariussoutier /
Created Jun 12, 2013
Different ways of calling functions with call-backs (i.e. multiple parameters that are functions) in CoffeeScript.
# Separate functions
success = (data, status, header) ->
promise.resolve data.user
error = (data, status, header) ->
promise.reject data.error
user = getUserById id, success, error
# Comma in front of each function
user = getUserById id
mariussoutier / 1Problem.scala
Last active Dec 16, 2015
Bridge Pattern in Scala
View 1Problem.scala
// Adding new functionality via inheritance leads to combinatorial explanation
abstract class Serializer {
def write(string: String): Unit
class CsvFileWriter extends FileWriter {
def writeFile(file: = //...
mariussoutier / JsonFormats.scala
Last active Dec 6, 2016
ReactiveMongo Play Plugin Extensions
View JsonFormats.scala
package json
import reactivemongo.bson._
import reactivemongo.bson.handlers.DefaultBSONHandlers._
import play.api.libs.json._
import play.api.libs.json.Json._
import play.api.libs.json.util._
import play.api.libs.json.Writes._
import play.api.libs.functional.syntax._
View Twitter.scala
package controllers
import play.api._
import play.api.mvc._
import play.api.libs.oauth._
import play.api.libs.iteratee._
object Twitter extends Controller {
View Routes1
# Map to language via RegEx
/$language<[a-z]{2}>/videos/:id controllers.Video.showVideo(id: Long, language: String)
# Hard-code supported languages
/de/videos/:id controllers.Video.showVideo(id: Long, language = "de")
/en/videos/:id controllers.Video.showVideo(id: Long, language = "en")
mariussoutier / Mail.scala
Created Aug 23, 2012
Sending mails fluently in Scala
View Mail.scala
package object mail {
implicit def stringToSeq(single: String): Seq[String] = Seq(single)
implicit def liftToOption[T](t: T): Option[T] = Some(t)
sealed abstract class MailType
case object Plain extends MailType
case object Rich extends MailType
case object MultiPart extends MailType
mariussoutier / Helper.scala
Created Aug 21, 2012
More template sequence helpers
View Helper.scala
package views.html.helper
import play.api.templates.Html
// Executes the first block if non-empty, the second otherwise
// Passes the entire seq (as in defining)
object ifEmptyOrElse {
def apply[T <: Seq[_]](t: T)(nonEmptyBlock: (T) => Html)(emptyBlock: => Html) = {
if (t.nonEmpty) nonEmptyBlock(t) else emptyBlock
You can’t perform that action at this time.