Skip to content

Instantly share code, notes, and snippets.

View jbpotonnier's full-sized avatar

Jean-Baptiste Potonnier jbpotonnier

View GitHub Profile
@jbpotonnier
jbpotonnier / faces.py
Created May 15, 2012 22:19
Face recognition using OpenCV
import cv
class Detector(object):
def __init__(self, haar_file):
self.haar = cv.Load(haar_file)
self.storage = cv.CreateMemStorage()
def detect(self, image):
# parameters for fast detection
@jbpotonnier
jbpotonnier / .gitignore
Created April 29, 2012 21:50
Play with Scotty web framework
.hsenv
@jbpotonnier
jbpotonnier / .gitignore
Created March 27, 2012 21:21
Try implementing a FSM
*~
.#*
\#*\#
@jbpotonnier
jbpotonnier / facture.hs
Created February 29, 2012 11:02
Try to undersdand Haskell arrows
import Control.Arrow
facture :: Double -> String
facture = (* tjm)
>>>
id &&& (* tva) &&& (* (1 + tva))
>>>
show *** show *** show
>>>
@jbpotonnier
jbpotonnier / hxt.markdown
Created February 24, 2012 14:18
Transform XML document using Haskell and XPath

I'm using HXT to transform a XML into another XML document. Selecting some nodes using XPath.

Here I want to collect all the authors in a new authors node.

Input document :

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
    <book category="COOKING">
        <title lang="en">Everyday Italian</title>
@jbpotonnier
jbpotonnier / .gitignore
Created February 16, 2012 19:53
[Flask] Routing with class
bin
include
lib
local
*.swp
*.pyc
@jbpotonnier
jbpotonnier / nimportequoi.py
Created December 8, 2011 16:10
fun avec bottle, pystache et ... redis
from bottle import Bottle
import bottle
import pystache
import redis
import json
app = Bottle()
redisse = redis.Redis()
def mustache(template, context):
@jbpotonnier
jbpotonnier / .gitignore
Created November 23, 2011 13:06
Introduction à Haskell
\#*\#
.*
@jbpotonnier
jbpotonnier / GroupBy.hs
Created October 24, 2011 21:38
groupBy in Erlang and Haskell
module GroupBy where
import Data.Map (Map)
import qualified Data.Map as Map
groupBy :: Ord b => (a -> b) -> [a] -> Map b [a]
groupBy f = foldr (\ v -> Map.insertWith (++) (f v) [v]) Map.empty
groupBy' :: Ord b => (a -> b) -> [a] -> Map b [a]
@jbpotonnier
jbpotonnier / othelllo.ml
Created October 6, 2011 18:20
othello in ocaml
type player = | Black | White
type cell = | Cell of player | Empty
type board = (cell array) array
exception Invalid_position_exception of (int * int)
let opponent = function | Black -> White | White -> Black
let init_board () : board =