This file contains 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
{-# LANGUAGE DeriveDataTypeable #-} | |
module Main where | |
{- | |
Example FRP/zeromq app. | |
The idea is that messages come into a zeromq socket in the form "id state". The state is of each id is tracked until it's complete. | |
-} | |
import Control.Monad |
This file contains 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 eventlet | |
from eventlet import wsgi | |
from paste.httpserver import serve | |
from pyramid.config import Configurator | |
from pyramid.response import Response | |
from pyramid.view import view_config | |
from stargate import WebSocketAwareResource, WebSocketView, is_websocket | |
import simplejson as json | |
host = "127.0.0.1" |
This file contains 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 Automata where | |
import Prelude hiding (map, head, foldl, take) | |
import qualified Prelude as P | |
import qualified Data.ByteString as BS | |
import qualified Data.ByteString.Char8 as C | |
import Data.ByteString.Internal (c2w) | |
import qualified Data.Map as M | |
import Data.List (sort) | |
import Data.Tuple |
This file contains 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
{- | |
One process starts the master process | |
Other start do-nothing process | |
master distributes the work among the other processes | |
-} | |
module Main where | |
import Remote | |
import Control.Monad |
This file contains 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
{-# LANGUAGE NoMonomorphismRestriction #-} | |
module Data.Pcap.Source ( | |
sourcePcap | |
, parsePcap | |
) where | |
import Control.Monad.IO.Class | |
import qualified Data.ByteString as BS | |
import Data.Conduit | |
import qualified Data.Conduit.List as CL | |
import Data.DateTime |
This file contains 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
-- Arrow definitions | |
arr = arrC | |
first = firstC | |
second = secondC | |
(<<<) :: Coroutine b o -> Coroutine i b -> Coroutine i o | |
cof <<< cog = Coroutine $ \i -> | |
let (x, cog') = runC cog i | |
(y, cof') = runC cof x | |
in (y, cof' <<< cog') |
This file contains 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
alias gbr='for k in `git branch|sed "s/^..//"`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t\\t"$k";done | sort -r | sed -e "s/\(^.*\):[0-9]\{2\} +\?[0-9]\{4\} /\1 /" -e "s/minutes/mins/"' | |
alias gbra='for k in `git branch -a|sed "s/^..//"`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t\\t"$k";done | sort -r | sed -e "s/\(^.*\):[0-9]\{2\} +\?[0-9]\{4\} /\1 /" -e "s/minutes/mins/"' |
This file contains 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
insert | |
:: (KnownSymbol k, Typeable i, ChannelType k api ~ i) | |
=> Proxy api -> Proxy k -> f i -> RouteMap f routes -> RouteMap f ((k :> i) ': routes) | |
insert _ pKey i = Routes . Map.insert k (I i) . unRoutes | |
where | |
k = (symbolVal pKey) ^. packed | |
type family Chan (chan :: *) :: * where | |
Chan (chan :> a) = a |
This file contains 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 pyramid.view import view_config | |
from sqlalchemy.ext.associationproxy import AssociationProxy | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import scoped_session, sessionmaker, object_mapper, ColumnProperty, SynonymProperty | |
Session = scoped_session(sessionmaker()) | |
class _PrettyPrintBase(object): | |
"""Base mixin for all of our declarative tables |
This file contains 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 eventlet.pools import Pool | |
from eventlet.timeout import Timeout | |
class SocketPool(Pool): | |
"""A pool of sockets connected to a component | |
If a socket times out in use, simply close if before handing it back to the | |
pool and it will be discarded and a replacement inserted into the pool.""" | |
def __init__(self, address, **kwargs): |