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
-- | ToJSON and FromJSON instances for BSON Documents and Values | |
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings #-} | |
module Data.Bson.Json where | |
import qualified Data.Bson as B | |
import qualified Data.Aeson as J | |
import qualified Data.Attoparsec.Number as J (Number(..)) | |
import qualified Data.Vector as V |
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, ExtendedDefaultRules, NoMonomorphismRestriction #-} | |
import Database.MongoDB as M | |
import Control.Monad.Trans (liftIO) | |
import System.Locale | |
import Data.Time | |
import Data.Time.Format | |
import Data.Bson.Json | |
import Data.Aeson.Encode | |
import Data.Aeson |
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
/** | |
* Part Zero : 10:15 Saturday Night | |
* | |
* (In which we will see how to let the type system help you handle failure)... | |
* | |
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0) | |
*/ | |
import scalaz._ | |
import Scalaz._ |
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
import Data.List.Split | |
import qualified Data.Map as Map | |
import Data.List.HT | |
buildCipher pw = Map.fromList $ zip [ (x,y) | x <- [0..4], y <- [0..4] ] (concat $ build pw) | |
where | |
build = chunk 5 . (`union` delete 'J' ['A'..'Z']) . nub . process --calculate the list of characters in the right order | |
process = replace "J" "I" . map toUpper . filter isLetter |
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
import Data.List | |
import Data.List.Split | |
import Data.Char | |
import qualified Data.Map as Map | |
import Data.List.HT | |
type Password = String | |
type Direction = Int | |
--new implementation: change Cipher to Map |
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
import Data.List | |
import Data.Char | |
import Data.List.HT | |
type Password = String | |
type Cipher = [String] | |
--this should take 5 letters at a time, removing earlier seen letters | |
--also we should add the remaining letters of the alphabet | |
createCipherSquare :: Password -> Cipher |
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
(ns googlecodejam | |
[:use clojure.string]) | |
(def example-input ["ejp mysljylc kd kxveddknmc re jsicpdrysi" | |
"rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd" | |
"de kr kd eoya kw aej tysr re ujdr lkgc jv"]) | |
(def google ["our language is impossible to understand" | |
"there are twenty six factorial possibilities" | |
"so it is okay if you want to just give up"]) |
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
(def pp | |
(λ [f xs] | |
(reduce ƒ(concat %1 (list (f %2))) '() xs)) ) | |
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
(ns propertyresolver.test.core | |
(:use [propertyresolver.core]) | |
(:use [clojure.test]) | |
(:use midje.sweet)) | |
;; "PropertyResolver resolve single reference" | |
(facts "replace should resolve a single reference" | |
(let [map-with-placeholder {:jndiname "${jndi.ref}" :jndi.ref "MyQueue"}] | |
(expand-placeholders map-with-placeholder map-with-placeholder) => {:jndi.ref "MyQueue" :jndiname "MyQueue"})) |
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
(ns propertyresolver.core | |
(:refer-clojure :exclude [char]) | |
( :require [ clojure.java.io]) | |
( :use [the.parsatron])) | |
(defn load-properties [file-name] | |
(with-open [^java.io.Reader reader (clojure.java.io/reader file-name)] | |
(let [props (java.util.Properties.)] | |
(.load props reader) | |
(into {} (for [[k v] props] [(keyword k) v]))))) |