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 java.util.*; | |
/** | |
* Nondeterministic finite automaton for recognising language of {aa, aab}*{b} | |
* | |
* @see http://www.dennis-grinch.co.uk/tutorial/nfa | |
* @author Dennis Grinch | |
*/ | |
public class NFA { |
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
/** | |
* Deterministic finite automata for recognising language of strings with | |
* following conditions: | |
* | |
* 1. It must contain only :, ), (, and _ characters. | |
* 2. :has to be followed by ) or (. | |
* 3. Has to have at least one smiley :) or sad :( face. | |
* 4. If string has more than one face, then all of them have to be separated by at least one _ character. | |
* 5. Each string can start and end with zero or more _ characters. | |
* |
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
init : Maybe Token -> Location -> ( Model, Cmd Msg ) | |
init token location = | |
let model = | |
{ initialModel | |
| token = Maybe.map RemoteData.succeed token |> Maybe.withDefault RemoteData.NotAsked | |
, route = parseLocation location | |
} | |
in | |
fetchPosts model | |
|> andThen fetchUser |
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
landing : Model -> Html Msg | |
landing model = | |
case model.posts of | |
NotAsked -> | |
div [] [] | |
Loading -> | |
withLoader (div [] []) | |
Success posts -> | |
RemoteData.map userHeader model.user | |
|> RemoteData.withDefault authHeader |
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
graphcool: String | |
graphcool = "https://api.graph.cool/simple/v1/cjbm8w2980rge0186pld48aan" | |
fetchPosts: Cmd Msg | |
fetchPosts = | |
Http.post graphcool (jsonBody <| Encoders.postsQuery) decodePosts | |
|> RemoteData.sendRequest | |
|> Cmd.map Messages.OnFetchPosts | |
createRequest : Form -> String -> Http.Request Post |
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
decodePosts : Decoder.Decoder (List Post) | |
decodePosts = | |
Decoder.list decodePost | |
|> Decoder.field "allPosts" | |
|> Decoder.field "data" | |
decodeGraphcoolToken : Decoder.Decoder String | |
decodeGraphcoolToken = | |
Decoder.string | |
|> Decoder.field "token" |
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
postsQuery : Encoder.Value | |
postsQuery = | |
Encoder.object | |
[ ( "query", Encoder.string "query {allPosts(orderBy: createdAt_DESC){id title body}}" ) ] | |
authenticate : Token -> Encoder.Value | |
authenticate token = | |
let | |
query = | |
"mutation {authenticate (accessToken: \"" ++ token.accessToken ++ "\"){token}}" |
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
{ | |
"name": "elm-blog", | |
"version": "1.0.0", | |
"description": "An example of Elm blog.", | |
"devDependencies": { | |
"graphcool-lib": "^0.1.4", | |
"isomorphic-fetch": "^2.2.1", | |
"jsonwebtoken": "^8.1.0", | |
"jwks-rsa": "^1.2.1" | |
} |
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
type AuthenticationPayload { | |
id: String! | |
token: String! | |
} | |
extend type Mutation { | |
authenticate(accessToken: String!) : AuthenticationPayload | |
} |
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
types: ./types.graphql | |
functions: | |
authenticate: | |
type: resolver | |
schema: ./src/authentication.graphql | |
handler: | |
code: | |
src: ./src/resolvers/authenticate.js | |
environment: | |
AUTH0_DOMAIN: nookit.eu.auth0.com |
NewerOlder