Skip to content

Instantly share code, notes, and snippets.

@creichert
creichert / Angular.hs
Last active August 29, 2015 14:02
Updated Yesod Angular JS Integration
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{- AngularJS and Yesod integration.
-
- This example is taken from https://github.com/snoyberg/yesod-js
- and updated to work with Yesod 1.2.5.
-
{-# LANGUAGE FlexibleInstances #-}
module Handler.JSRoutes where
import Import
import qualified Data.Text as T
import Database.Persist.Sql (toSqlKey)
import Control.Monad.Random
jsRoutes :: (MonadRandom m, Applicative m) => [m Text]
jsRoutes =
@creichert
creichert / Makefile
Last active August 29, 2015 14:11
Yesod Scaffold Makefile
# Yesod Makefile
# yesod init --bare && make
# Running `make` in a fresh scaffold will build the sandbox and dependencies
# `yesod-devel` will be executed on each call to `make` assuming all the
# dependencies have been installed correctly.
@creichert
creichert / WebSocketExample.patch
Last active August 29, 2015 14:13
WebSockets Help
diff --git a/yesod-websockets/Game-Example/Fm.hs b/yesod-websockets/Game-Example/Fm.hs
index cf31bef..a799eca 100755
--- a/yesod-websockets/Game-Example/Fm.hs
+++ b/yesod-websockets/Game-Example/Fm.hs
@@ -1,21 +1,27 @@
{-# LANGUAGE OverloadedStrings #-}
module Fm where
-import Data.List
-import Text.Julius
{-# LANGUAGE OverloadedStrings #-}
module SimpleThings where
import Control.Applicative ((<$>), (<*>))
import Control.Monad (mzero)
import Data.Aeson
import qualified Data.Aeson as A
-- | sum type containing all possible payloads
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Monad.IO.Class (liftIO)
import Network.HTTP.Types
import Network.Wai.Middleware.RequestLogger
import Network.Wai.Middleware.Static
@creichert
creichert / PersistentStandalone.hs
Last active August 29, 2015 14:21
Haskell Persistent Postgresql (Load Configuration, Use Pooling, Custom runDB).
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.HashMap.Strict as M
import Data.Maybe
import Data.Text (Text)
import Data.Yaml
import Database.Persist.Postgresql
import Database.Persist.Sql hiding (Active)
@creichert
creichert / sml.el
Last active August 29, 2015 14:23
smart-mode-line projectile project and magit branch
"{"
'(:eval (propertize (projectile-project-name)
'face 'font-lock-preprocessor-face))
;; branch
":"
'(:eval (propertize (magit-get-current-branch)
'face 'font-lock-preprocessor-face))
;; branch
"} "
;; org schedule first monday of every month
;; SCHEDULED: <%%(diary-float t 1 1)>
(diary-float t 1 1)
;; org schedule mon-fri
;; SCHEDULED: <%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>
(memq (calendar-day-of-week date) '(1 2 3 4 5))
-- An example Shakefile originally written by Brent Yorgey
-- for the CIS 194 class.
{-# LANGUAGE DeriveDataTypeable #-}
import Control.Monad (forM_, replicateM_, when)
import Data.Functor ((<$>))
import Data.List (find, isPrefixOf)
import Data.Monoid ((<>))