Skip to content

Instantly share code, notes, and snippets.

View cmoore's full-sized avatar
🆑

Clint Moore cmoore

🆑
View GitHub Profile
@cmoore
cmoore / ghc-pkg.el
Created November 25, 2011 09:33
Autoloader for package.el for emacs > 24
(let ((gmod-have-package (featurep 'package)))
(defun gmod-install-package-el ()
(let (buf (url-retrieve-synchronously
"http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/package.el"))
(save-excursion
(set-buffer buf)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer)))))
(defun clm*flymake-colors ()
(custom-set-faces
'(flymake-errline ((((class color)) (:underline "Red"))))
'(flymake-warnline ((((class color)) (:underline "Orange"))))))
(load (expand-file-name "~/emacs/haskell-mode/haskell-site-file.el"))
(require 'inf-haskell)
(load (expand-file-name "~/clones/ghc-mod/elisp/ghc"))
(add-hook 'haskell-mode-hook (lambda nil
(clm*flymake-colors)
(ql:quickload 'hunchentoot)
(ql:quickload 'cl-who)
(ql:quickload 'routes)
(ql:quickload 'css-lite)
(defpackage :rss-view
(:use :cl :hunchentoot :cl-who :css-lite)
(:export :rss-start :rss-stop))
(in-package :rss-view)
class TimelineController < ApplicationController
def index
@messages = Message.order("status_id DESC")
@newest_id = newest_id
end
# Just do a simple update to the timeline for the latest
# greatest messages.
#
# 1. Pull 100 messages
module BST where
import Data.Time
import Control.Concurrent.STM
data Account = Account { aemail :: String
, apass :: String
, auid :: String }
deriving (Show)
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
@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
@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 / 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
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|