Skip to content

Instantly share code, notes, and snippets.

View julien-lafont's full-sized avatar

Julien Lafont julien-lafont

View GitHub Profile
@julien-lafont
julien-lafont / 01_basic.scala
Created March 16, 2017 07:57
Scala: pseudo "union type" with sealed trait & pattern matching
import play.api.libs.json.{JsNull, JsValue, Json}
trait FooServiceError
case object ApiNotFound extends FooServiceError
case class BackendNotAvailable(endpoint: String) extends FooServiceError
case class ErrorDuringProcessingEvent(payload: JsValue, error: String) extends FooServiceError
case class PermissionRefused(providedScopes: Seq[String], missingScopes: Seq[String]) extends FooServiceError
def callBackendToGeneratePiValue(decimal: Int): Either[FooServiceError, Double] = {
// fake code
@julien-lafont
julien-lafont / keybase.md
Last active August 14, 2017 07:58
keybase.md

Keybase proof

I hereby claim:

  • I am julien-lafont on github.
  • I am julienlafont (https://keybase.io/julienlafont) on keybase.
  • I have a public key whose fingerprint is BDC2 71A6 6206 523A 46B1 A9A3 AA34 CF63 8009 F841

To claim this, I am signing this object:

@julien-lafont
julien-lafont / editor.codeinsight.xml
Last active August 29, 2015 14:15
Exclusion list for IDEA autoimport/completion on Play2/Scala projects
<!--
Exclude all Play-java classes from auto-import (play.libs, play.mvc...)
Exclude some generally unused classes from java.awt, javax.swing, sun.security... WIP! Many more can be added
Where to configure that?
- cat ~/.IntelliJIdea14/config/options/editor.codeinsight.xml
- or from Settings/General/editor/Auto Import
-->
<application>
<component name="CodeInsightSettings">
@julien-lafont
julien-lafont / unscrap.sh
Created February 6, 2015 21:51
Ubuntu unscrap
sudo apt-get autoremove gnome-contacts gnome-mahjongg gnome-mines gnome-sudoku gnome-orca xterm aisleriot webbrowser-app brasero cheese rhythmbox totem unity-webapps-common unity-lens-photos unity-scope-gdrive empathy thunderbird landscape-client-ui-install
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDX6uNOBrRlzUOkzP2O34dTu/yuHMfzu0XxBJsiN/nP806NvdQWrxOS8mFoSPPo8uvcy0et5U1EgU27L5DqEUwxV2uCPpFZXXY0atcqtueyMO7PQAb12ZslPm89PRwBKtCizUmZTuztnfINUttRZeZxsLZBfkIBqDuCDKR4iw8SImpBFrJZUAFredItc50ut7lEQZs2PYCgke71yuaie7qser208GbanOvCQ0ZUwnCPtMH7JOavAasqWFn7jb5+JhsKZuM8NWDAxJn7Pe2CipfVejfwy18MflEPNam6DfzScs1aSrSnf3WbZrTfZKiHiwa1sRRQPwZTCmPuTV+6xV577+qjWXdiRRqRPgJZq8LZb0+W7mz1zMzEU6giWVBQuZc06cQi7slNQg6Zi9fLocH1a2AwOUGKISJATOikQuneTDljGs5cavNz/No7f2aFGtJdGCBaklosOXFOO9UNboPD9M9XGnXaiNcMsHhE4/LxMAJHSAwHqoddyw1lQ5yaASfAR6o4cPkzSJMk5XViw+iBCP5UYIMwGTVE15hjh34gyrq0PpE4xQ+WA6jTmfr/G5Fb3UIUT8Tm/ULmRyBbHNERjtOyjxPu5KaNxSyARftsZYllOaSr9IfWclySWsnunxvrZa/YMbIgxJM+qmRccCLG1hj9rqz9sQxvhQRlMWKQrQ== jla@MacBook-Pro-de-dbo-2.local
@julien-lafont
julien-lafont / gol.scala
Created January 13, 2013 13:50
Code Retreat 2012 : Game of Life #scala
object Monde {
def apply() : Monde = {
val cells = (1 until 100).toList.map(i => Cellule(i, i+1, 9))
Monde(cells)
}
def fusion(possibles: List[Cellule]) : List[Cellule] = {
possibles./:[List[Cellule]](Nil){ (acc, cell) =>
acc.partition{ c => c.x == cell.x && c.y == cell.y } match {
@julien-lafont
julien-lafont / iteratees_humains.md
Created September 15, 2012 14:58 — forked from loicdescotte/iteratees_humains.md
Play2 : Les Iteratees expliqués aux humains... francophones!

#Play2 : Les Iteratees expliqués aux humains... francophones!

Disclamer : Ce qui suit est la traduction d'un article anglophone paru sur le blog mandubian.com

Vous pouvez retrouver l'article original ici

Vous avez probablement remarqué une nouvelle fonctionnalité intrigante de Play2 nommée Iteratee (ainsi queb ses compagnons Enumerators et Enumeratee). Le but de cet article est d'essayer de rendre le concept d'Iteratee compréhensible pour le plus grand nombre avec des arguments simples, en évitant l'approche mathématique / fonctionnelle.

Cet article ne prétend pas tout expliquer à propos des Iteratee / Enumerator / Enumeratee mais traite plutôt les idées qui se cachent derrière.

@julien-lafont
julien-lafont / Decomposate conditional.java
Created December 10, 2011 22:36
Top 5 des meilleures techniques pour améliorer son code
// Avant
public double calculerCharge(Date date, double qtt) {
if (date.before(SUMMER_START) || date.after(SUMMER_END))
// Logique métier
else
// Logique métier
return charge;
}