This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: iso-8859-15 -*- | |
import Tkinter as tkinter | |
import urllib2, urllib | |
import json | |
TRANSLATE_URL = 'http://ajax.googleapis.com/ajax/services/language/translate' | |
TO_ENGLISH = 'fr|en' | |
TO_FRENCH = 'en|fr' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Array (Array, array, (//), (!), assocs, elems) | |
import Data.List (sortBy, groupBy, group) | |
import Data.IORef (IORef, newIORef, readIORef, writeIORef) | |
import Control.Monad (forever, when) | |
import Data.Maybe (isJust, isNothing) | |
import Data.Ord (comparing) | |
data Player = Black | White deriving (Show, Eq) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ListZipper ( | |
focused, focusedIndex,setFocusedIndex, setUnfocused, | |
forward, backward, | |
append, | |
toList, fromList | |
) | |
where | |
type Zipper a = ([a], [a]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (insertBy) | |
import Data.Ord (comparing) | |
data Trie = Trie {final :: Bool, children::[(Char,Trie)]} | |
deriving Show | |
empty :: Trie | |
empty = Trie {final=False, children=[]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Utils where | |
import Data.Array (Ix, Array, assocs) | |
makeRows :: Int -> [a] -> [[a]] | |
makeRows _ [] = [] | |
makeRows len elts = | |
(take len elts) : makeRows len (drop len elts) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require-extension ansi-escape-sequences) | |
(require-extension srfi-13) | |
(require-extension extras) | |
(define (colorize txt) | |
(set-text | |
(cond | |
((string-prefix? "---" txt) '(bold)) | |
((string-prefix? "+++" txt) '(bold)) | |
((string-prefix? "-" txt) '(fg-red )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\#*\# | |
.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import Bottle | |
import bottle | |
import pystache | |
import redis | |
import json | |
app = Bottle() | |
redisse = redis.Redis() | |
def mustache(template, context): |
OlderNewer