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 Control.Parallel | |
import Control.Monad | |
import Text.Printf | |
cutoff = 35 | |
fib' :: Int -> Integer | |
fib' 0 = 0 | |
fib' 1 = 1 | |
fib' n = fib' (n-1) + fib' (n-2) |
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 Main where | |
import Text.Printf | |
import Control.Monad | |
import Control.Parallel | |
fib :: Int -> Int | |
fib 0 = 0 | |
fib 1 = 1 | |
fib n = r `par` (l `pseq` l+r) | |
where |
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 Main where | |
import Text.Printf | |
import Control.Monad | |
fib :: Int -> Int | |
fib 0 = 0 | |
fib 1 = 1 | |
fib n = fib (n-1) + fib (n-2) | |
main = forM_ [0..45] $ \x -> |
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
localSession = do | |
h <- oc | |
res <- (execStatement h "SELECT session from facebook limit 1") :: IO (Either String [[Row String]]) | |
cc h | |
case res of | |
Right [[[(_,xx)]]] -> return xx | |
_ -> return "-1" | |
{- | |
How can I condense this? I can tell that I will probably need to do {} the case |
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
-- | |
-- bt spits out a template without any options parsing. | |
-- | |
bt :: String -> IO Response | |
bt x = do | |
templates <- directoryGroup "templates" | |
return $ def { body = pack $ renderTemplateGroup templates ([]::[(String,String)]) x, status = 200 } | |
-- | |
-- btt gives a template with the provides options subtituted. |
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
-- | |
-- (env .> "first_name") = the post-ed field "first_name" | |
-- | |
(.>) :: Env -> String -> String | |
(.>) env k = | |
case requestMethod env of | |
POST -> | |
do | |
let ( posts, _ ) = parsePost ctype clen $ hackInput env | |
fromMaybe "" $ lookup k posts |
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
oc :: IO SQLiteHandle | |
oc = openConnection "data.rsd" | |
cc :: SQLiteHandle -> IO () | |
cc x = closeConnection x | |
-- | |
-- "table" <<++ [("column","value")] | |
-- Whee! | |
-- |
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
key_from_row :: String -> [(String,String)] -> String | |
key_from_row key (row:x) = do | |
let (k,v) = row | |
if k == key then v else key_from_row key x |
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
-- Utils | |
conn :: IO Server | |
conn = Single.connect "192.168.0.33" 1111 | |
dconn x = Single.disconnect x | |
m_set :: Server -> String -> String -> IO Bool | |
m_set ss x y = do | |
Network.Memcache.set ss x y |
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
#!/usr/bin/env perl | |
# | |
$ghc = '/usr/bin/ghc'; # where is ghc | |
@ghc_options = (); # e.g. ('-fglasgow-exts') | |
@ghc_packages = (); # e.g. ('QuickCheck') | |
### the following should not been edited ### | |
use File::Temp qw /tempfile tempdir/; |