Skip to content

Instantly share code, notes, and snippets.

View joehillen's full-sized avatar
🦡

Joe Hillenbrand joehillen

🦡
View GitHub Profile
@joehillen
joehillen / server.hs
Last active June 1, 2022 17:56
A re-implementation of Simon Marlow's Async Haskell Chat Server using Conduits
{-# LANGUAGE OverloadedStrings, RecordWildCards, LambdaCase #-}
import Conduit
import Data.Conduit
import Data.Conduit.Network
import qualified Data.ByteString.Char8 as BS
import Data.Conduit.TMChan
import Text.Printf (printf)
import Control.Concurrent.STM
import qualified Data.Map as Map
@joehillen
joehillen / spellchecker_trie.py
Created July 11, 2013 08:08
A slightly better spellchecker using a Trie.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Written by Joe Hillenbrand <joehillen@gmail.com> 2012
All rights reserved!
"""
import sys
@joehillen
joehillen / bad_spellcheckers.py
Created July 11, 2013 07:40
A crappy spellchecker implementation I wrote for a job interview. I didn't get the job =P
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Written by Joe Hillenbrand <joehillen@gmail.com> 2012
All rights reserved!
"""
import string
import Control.Concurrent (forkIO, killThread,
threadDelay, newEmptyMVar,
tryTakeMVar, putMVar)
import Control.Monad (void, forever)
import Control.Concurrent.STM (atomically)
import Control.Monad.Trans (MonadIO(..))
import Control.Monad.Trans.Resource (MonadResource, allocate)
import Data.Conduit (GInfConduit, awaitE)
throttle :: (MonadResource m) => Int -> GInfConduit a m a