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
package strava | |
import ( | |
"fmt" | |
stravalib "github.com/svdberg/syncmysport-runkeeper/Godeps/_workspace/src/github.com/strava/go.strava" | |
"strings" | |
) | |
type StravaClientInt interface { | |
GetSTVActivitiesSince(timestamp int) ([]*stravalib.ActivitySummary, error) |
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
module Main where | |
data BTree a = Nil | Node (BTree a) a (BTree a) | |
deriving (Show, Eq) | |
inverse :: BTree a -> BTree a | |
inverse Nil = Nil | |
inverse (Node a b c) = Node (inverse c) b (inverse a) | |
buildBalanced :: [a] -> BTree a | |
buildBalanced [] = Nil |
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 Main where | |
import Data.Digest.Pure.MD5 | |
import Data.List.Split | |
import Data.List | |
import System.Environment | |
import qualified Data.ByteString.Lazy as LBS | |
import qualified Data.ByteString.Char8 as C |
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 CommandParser where | |
import Data.Attoparsec.Char8 | |
import Control.Applicative | |
import qualified Data.Text.Lazy as L | |
import Data.Text.Encoding | |
data Command = Retrieve | Delete | New deriving Show |
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 CommandParser where | |
import Data.Attoparsec.Char8 | |
import Control.Applicative | |
import Data.ByteString | |
data Command = Retrieve | Delete | New deriving Show | |
parseCommand :: Parser Command |
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
postFeedingsR :: Handler RepJson | |
postFeedingsR = do | |
muser <- maybeAuth | |
parsedFeeding <- parseJsonBody_ --get content as JSON | |
let userId = getUserId muser | |
let feedingWithUser = Feeding (feedingDate parsedFeeding) (feedingSide parsedFeeding) (feedingTime parsedFeeding) (feedingExcrements parsedFeeding) (feedingRemarks parsedFeeding) userId --should be linked to user.. | |
fid <- runDB $ insert feedingWithUser --store in database | |
--runDB $ update fid [ FeedingUserId =. userId ] --Old mongo style of linking the feeding to the user | |
sendResponseCreated $ FeedingR fid --return the id |
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
postFeedingsR :: Handler RepJson | |
postFeedingsR = do | |
muser <- maybeAuth | |
parsedFeeding <- parseJsonBody_ --get content as JSON | |
let userId = getUserId muser | |
feedingWithUser = Feeding (feedingDate parsedFeeding) (feedingSide parsedFeeding) (feedingTime parsedFeeding) (feedingExcrements parsedFeeding) (feedingRemarks parsedFeeding) userId --should be linked to user.. | |
fid <- runDB $ insert parsedFeeding --feedingWithUser --store in database | |
--runDB $ update fid [ FeedingUserId =. userId ] --link the feeding to the user | |
sendResponseCreated $ FeedingR fid --return the id |
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 TupleSections, OverloadedStrings #-} | |
module Handler.Feeding where | |
import Import | |
import Network.HTTP.Types (status201, status204, status200) | |
import Data.Maybe | |
{- This module contains the Feeding resource -} | |
getFeedingR :: FeedingId -> Handler RepJson |
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 TupleSections, OverloadedStrings #-} | |
module Handler.Feeding where | |
import Import | |
import Network.HTTP.Types (status201, status204, status200) | |
{- This module contains the Feeding resource -} | |
getFeedingR :: FeedingId -> Handler RepJson | |
getFeedingR fid = runDB (get404 fid) >>= jsonToRepJson . Entity fid |
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
main :: IO () | |
main = scotty 3000 app | |
app :: ScottyM () | |
app = do | |
get "/favicon.ico" $ html "ಠ_ಠ" | |
get "/:method" $ do | |
r <- request |
NewerOlder