This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharpx.Option | |
/// Type synonims | |
type ProductId = string | |
type Price = float | |
type Inventory() = | |
let inv_ = new System.Collections.Generic.Dictionary<ProductId, Price>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A syntactic sugar corresponding to the Lisp's when. Execute the body | |
* when the pred evaluates to true. | |
* @param condition A predicate or value that evaluate to a Boolean | |
* @param block A valid block of scala code | |
*/ | |
def when (condition : => Boolean)( block : => Unit) | |
{ | |
if (condition){ block } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g prefix C-a | |
bind C-a send-prefix | |
unbind C-b | |
set -sg escape-time 1 | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
bind | split-window -h | |
bind - split-window -v | |
bind h select-pane -L |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createUser :: Text -- ^ Username | |
-> ByteString -- ^ Password | |
-> Handler b (AuthManager b) (Either String AuthUser) | |
createUser "" _ = return $ Left "Username cannot be empty" | |
createUser unm pwd = withBackend (\r -> liftM (\x -> Right x) $ liftIO $ buildAuthUser r unm pwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createUser unm pwd | |
| null (strip unm) = return $ Left "Username cannot be empty" | |
| otherwise = withBackend $ \r -> do | |
u <- liftIO $ buildAuthUser r unm pwd | |
return $ Right u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Blackbox.MusicStoreSnaplet where | |
------------------------------------------------------------------------------ | |
import Control.Applicative | |
import qualified Data.ByteString.Char8 as B | |
import Data.Lens.Lazy | |
import Data.Lens.Template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loginUser | |
:: ByteString | |
-- ^ Username field | |
-> ByteString | |
-- ^ Password field | |
-> Maybe ByteString | |
-- ^ Remember field; Nothing if you want no remember function. | |
-> (AuthFailure -> Handler b (AuthManager b) ()) | |
-- ^ Upon failure | |
-> Handler b (AuthManager b) () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
------------------------------------------------------------------------------ | |
import Control.Monad.State | |
import Data.Lens.Template | |
import qualified Data.Map as Map | |
import Data.Text as T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
import Data.ByteString (ByteString) | |
import qualified Data.ByteString.Char8 as B | |
import Data.Enumerator (Iteratee, Enumeratee, ($=), (=$), (=$=), (==<<)) | |
import qualified Data.Enumerator as E | |
import qualified Data.Enumerator.Binary as EB | |
import qualified Data.Enumerator.Text as ET | |
import qualified Data.Enumerator.List as EL | |
import Data.Text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Codification of discussion at http://code.google.com/p/xmonad/issues/detail?id=177 | |
# Probably better to run each of these lines one by one instead of as a shell | |
# script, since there's a high probability of `cabal install` failing (usually | |
# fixed by installing the relevant libfoo-dev package) | |
# One person said these steps did not work. | |
# My Java version is: | |
# java version "1.6.0_34" | |
# Java(TM) SE Runtime Environment (build 1.6.0_34-b04) | |
# Java HotSpot(TM) Server VM (build 20.9-b04, mixed mode) |
OlderNewer