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 SMSRelayCommon | |
| extend Blather::DSL | |
| def self.log(msg) | |
| t = Time.now | |
| puts "LOG %d.%09d: %s" % [t.to_i, t.nsec, msg] | |
| end | |
| def self.log_raw(msg) | |
| puts msg |
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
| -- A type of IO that does not contain any non-error, synchronous exceptions | |
| module SafeIO (SafeIO, unsafeFromIO, fromIO, fromIO', runSafeIO, runEitherIO) where | |
| import Control.Applicative (Applicative(..)) | |
| import Control.Monad (liftM, ap, (<=<)) | |
| import Control.Monad.Fix (MonadFix(..)) | |
| import Control.Error (syncIO, mapEitherT, EitherT(..), fmapLT) | |
| import Control.Exception (SomeException, Exception, fromException, throwIO) | |
| import Control.Monad.IO.Class (liftIO, MonadIO) |
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
| -- | Simple in-process key/value cache | |
| -- | |
| -- Of course, for really simple stuff you could probably use unsafeInterleaveIO | |
| module Cache (Cache, newCache, fromCache) where | |
| import Control.Monad (void) | |
| -- Could also use STM instead | |
| import Control.Concurrent (forkIO, Chan, newChan, readChan, writeChan, MVar, newEmptyMVar, putMVar, takeMVar) |
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
| data UnGet a = Get Int | UnGet a | |
| data UnGot a = Got a | UnGot | |
| -- | Take a length function, a splitAt function, an an append function and | |
| -- add the ability to "unget" to any Server for which such functions can be | |
| -- defined | |
| canUnGet :: (Monad m) => | |
| (a -> Int) -- ^ length | |
| -> (Int -> a -> (a, a)) -- ^ splitAt | |
| -> (a -> a -> a) -- ^ append |
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
| WaioiEnv := Map clone do( | |
| with := method( | |
| clone mergeInPlace(resend) atPut("waioi.version", list(0, 1, 0)) | |
| ) | |
| forward := method(at(call message name)) | |
| ) | |
| WaioiContentLength := Object clone do( | |
| call := method(env, |
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
| test: test.c | |
| gcc -o test -ansi -pedantic -Wall test.c `sdl-config --cflags --libs` -lSDL_ttf |
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
| -- | A wrapper around 'IO' and 'EitherT' to get rid of exceptions | |
| -- | |
| -- If you type-restrict something to 'EitherIO' then any exceptions or | |
| -- other errors will have to be caught explicitly or else the compiler | |
| -- will complain. | |
| -- | |
| -- Only 'IOError's are caught. No other sort of exception should be caught | |
| -- in normal code (since they either represent programmer error or program or | |
| -- thread termination). The one exception is 'bracketEitherIO', which will | |
| -- ensure that the cleanup routine is run even if another exception occurs. |
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 NumberStuff where | |
| import qualified Prelude | |
| class CanAdd a where | |
| (+) :: a -> a -> a | |
| class CanNegate a where | |
| negate :: 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.Monoid | |
| import Control.Monad | |
| import Control.Applicative | |
| import Control.Monad.ST | |
| import qualified Data.Vault.ST as Vault | |
| import Prelude hiding (take) | |
| import Data.Attoparsec.Text | |
| import Data.Text (pack) |
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 PipeUtil where | |
| import Prelude hiding (getContents) | |
| import Control.Arrow | |
| import Control.Monad | |
| import Control.Proxy | |
| import System.IO (openFile, hClose, hIsEOF, hIsClosed, Handle, IOMode(ReadMode)) | |
| import Control.Monad.Trans | |
| import Control.Monad.Trans.Resource |