Skip to content

Instantly share code, notes, and snippets.

View jbpotonnier's full-sized avatar

Jean-Baptiste Potonnier jbpotonnier

View GitHub Profile
LOCKED = 'locked'
UNLOCKED = 'unlocked'
PUSH = 'push'
COIN = 'coin'
class Fsm(object):
def __init__(self, init_state, transitions, handler=None):
self.state = init_state

Kata manipulation des collections en Erlang

  • Une personne est un tuple {sexe, Nom, Age}, ou sexe peut prendre les valeurs homme ou femme. Ecrire un accesseur pour le nom de la personne.

  • Créer une liste de personnes.

  • Extraire la liste des noms des personnes contenues dans la liste

    1. sans utilier lists:map
    2. puis en utilisant lists:map.
@jbpotonnier
jbpotonnier / Main.hs
Last active October 8, 2015 21:38
Extract tweets
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.Conduit.List as CL
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Conduit (($$))
import Control.Lens ((^.))
import Control.Monad.IO.Class (liftIO)
import Web.Twitter.Conduit(sourceWithMaxId,
@jbpotonnier
jbpotonnier / Singleton.hs
Created October 13, 2014 23:56
Singleton types and sized lists : making size of a list part of its type
{-#LANGUAGE GADTs #-}
module Singleton where
data S n = Succ n
data Z = Zero
class Nat n
instance Nat Z
instance Nat n => Nat (S n)
@jbpotonnier
jbpotonnier / Main.hs
Created April 20, 2015 22:32
intercooler.js + Spock + Lucid
{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules, DataKinds #-}
import Web.Spock.Safe
import Lucid
import Lucid.Base (makeAttribute)
import Data.Text.Lazy (toStrict)
import Data.Text (Text)
import Network.Wai.Middleware.Static
@jbpotonnier
jbpotonnier / Main.hs
Created June 1, 2015 23:23
Render messages into HTML bubbles
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Data.List (groupBy)
import Data.Function (on)
import Data.Text (Text)
import qualified Data.Text.Lazy as LT
import qualified Data.Text.IO as TextIO
import Lucid