Skip to content

Instantly share code, notes, and snippets.

View cmoore's full-sized avatar
🆑

Clint Moore cmoore

🆑
View GitHub Profile
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)
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
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 ->
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
--
-- 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.
--
-- (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
oc :: IO SQLiteHandle
oc = openConnection "data.rsd"
cc :: SQLiteHandle -> IO ()
cc x = closeConnection x
--
-- "table" <<++ [("column","value")]
-- Whee!
--
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
-- 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
#!/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/;