Skip to content

Instantly share code, notes, and snippets.

View cmoore's full-sized avatar
🆑

Clint Moore cmoore

🆑
View GitHub Profile
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
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 ->
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
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)
for f in `cabal list | grep \* | cut -f 2 -d \ `; do cabal fetch $f; done
{- Types.hs -}
{-# LANGUAGE DeriveDataTypeable #-}
module Brazil.Types where
import Data.Typeable ()
import Data.Generics
import Text.StringTemplate.GenericStandard ()
{- No, it's not live. Just testing. :) -}
{-# LANGUAGE ViewPatterns #-}
galleryDispatch ai@(\x -> head (pElements x) -> "u") =
case requestMethod (a_env ai) of
POST -> do
let env = a_env ai -- Hack's Env
case ((,) <$> lookup "Content-Type" (http env)
<*> lookup "Content-Length" (http env)) of
Nothing -> do
import Hack
import qualified Web.Encodings as Web
galleryDispatch ai@(\x -> head (pElements x) -> "u") =
case requestMethod (a_env ai) of
POST -> do
dbg "galleryDispatch: POST on /upload."
let env = a_env ai
case ((,) <$> lookup "Content-Type" (http env)
<*> lookup "Content-Length" (http env)) of
galleryDispatch ai@(\x -> head (pElements x) -> "u") =
case requestMethod (a_env ai) of
POST -> do
dbg "galleryDispatch: POST on /upload."
let env = a_env ai
case ((,) <$> lookup "Content-Type" (http env)
<*> lookup "Content-Length" (http env)) of
Nothing -> do
dbg "Ack!"
redirect' "/profile"
import Hack
import qualified Web.Encodings as Web
import Data.ByteString.Lazy.Char8 as BS
galleryDispatch ai@(\x -> head (pElements x) -> "u") =
case requestMethod (a_env ai) of
POST -> do
dbg "galleryDispatch: POST on /upload."
let env = a_env ai
case ((,) <$> lookup "Content-Type" (http env)