Skip to content

Instantly share code, notes, and snippets.

View cmoore's full-sized avatar
🆑

Clint Moore cmoore

🆑
View GitHub Profile
{-
CouchDB 0.11.0:
[error] [<0.95.0>] attempted upload of invalid JSON undefined
[info] [<0.95.0>] 127.0.0.1 - - 'PUT' /honks/cmoore? 400
CouchDB Trunk as of 5/28 - 10:26 PST:
[info] [<0.95.0>] 127.0.0.1 - - 'PUT' /honks? 201
[debug] [<0.114.0>] 'PUT' /honks/cmoore? {1,1}
Headers: [{'Connection',"keep-alive"},
Copyright (c)2011, Clint Moore
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@cmoore
cmoore / oxymoron.css
Created October 26, 2010 06:23
oxymoron
body {
width: 960px;
margin-left: auto;
margin-right: auto;
}
.oxymoron {
display:table;
width: 100%;
border-collapse:collapse;
@cmoore
cmoore / gist:784949
Created January 18, 2011 19:08
web-mongrel2 example
module Main where
import Web.Mongrel2
import Control.Monad (forever)
import Text.Groom (groom)
import Data.Default (def)
main :: IO ()
main = do
let b = def { m2_publish = "tcp://127.0.0.1:9996"
migrate = runQ $ runMigration migrateAll
runQ :: MonadControlIO m => SqlPersist m a -> m a
runQ a =
withPostgresqlConn "host=localhost password=fart user=postgres dbname=fart" $
runSqlConn $ do a
share [mkPersist, mkMigrate "migrateAll"] [persist|
@cmoore
cmoore / rounding.hs
Created May 19, 2011 05:13
Sanely rounding a number.
roundp :: (RealFrac a1, Integral a, Floating a1) => a1 -> a -> a1
roundp n s = fromIntegral (round (n * factor)) / factor
where
shift = s - (floor (logBase 10 n) + 1)
factor = 10 ** fromIntegral shift
@cmoore
cmoore / df.hs
Created July 11, 2011 01:24
digestive-functors
data LoginF = LoginF String String
login :: Application ()
login = do
fx <- eitherSnapForm login_form "login-form"
case fx of
Left s -> heistLocal (bindSplices s) $ render "login"
Right (LoginF email passw) -> do
us <- account_by_email $ B.pack email
maybe e404 ((huser $ B.pack passw) . snd) us
where
@cmoore
cmoore / prax-solution.hs
Created August 21, 2011 19:40
2011 08 19
module Solution where
import List
solution :: String -> IO ()
solution a =
case reduce a of
[] -> putStrLn "No repeating characters!"
(x:_) -> putStrLn $ "Solution: " ++ x
I have two interviews coming up with the real-deal companies where 'real-deal'
means that I'm fairly confident that I have to have my shit together to make
an impression on them and thus get offered a job. This is my boning-up
scratchpad.
Note that this is a brain-dump and not a carefully edited how-to, tutorial, or
otherwise.
> module Merge where
module BST where
import Data.Time
import Control.Concurrent.STM
data Account = Account { aemail :: String
, apass :: String
, auid :: String }
deriving (Show)