Skip to content

Instantly share code, notes, and snippets.

View pinx's full-sized avatar

Marcel van Pinxteren pinx

  • 's-Hertogenbosch, Netherlands
View GitHub Profile
@pinx
pinx / schema.ex
Last active March 16, 2018 07:44
Repo pattern for ArangoDB
defmodule MyApp.Post do
use Arango.Document
schema "posts" do
.....
def changeset(...)
# stuff for validation
end
end
defmodule Post do
schema "posts" do
field :_id, :string
field :_key, :string
field :_data, :map
end
end
@pinx
pinx / assemblyDecoder.elm
Last active April 16, 2017 13:33
Arango Elm assemblies decoder
assembliesDecoder : Decode.Decoder (List Assembly)
assembliesDecoder =
field "result" (Decode.list (Decode.dict Decode.string))
-- or --
assembliesDecoder : Decode.Decoder (List Assembly)
assembliesDecoder =
field "result" <|
Decode.list <|
@pinx
pinx / encoded_query.elm
Created April 16, 2017 12:56
Arango Elm encoded query
query : Http.Body
query =
Encode.object
[ ( "query", Encode.string "FOR assy IN assemblies FILTER assy.parent_id == NULL LIMIT 100 RETURN assy" )
, ( "batchSize", Encode.int 100 )
]
|> Http.jsonBody
@pinx
pinx / authenticate.elm
Created April 9, 2017 14:24
Arango Elm authenticate function
authenticate : Model -> Cmd Msg
authenticate model =
let
url =
Endpoint.authUrl
|> Debug.log ("url")
body =
Http.jsonBody (credentials model)
@pinx
pinx / update_view.elm
Created April 9, 2017 14:17
Arango Elm update and view for authentication
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
SetUsername username ->
{ model | username = username } ! []
SetPassword password ->
{ model | password = password } ! []
SetDb db ->
@pinx
pinx / index.html
Created April 9, 2017 13:57
index.html for Arango Elm
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arango Elm</title>
<!-- MDL -->
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500|Roboto+Mono|Roboto+Condensed:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://getmdl.io/material.teal-red.min.css" />
@pinx
pinx / assemblies.json
Created April 9, 2017 12:41
Assemblies to import into Arango
[
{
"_key": "3210959",
"_id": "assemblies/3210959",
"_rev": "_Uvsu1GG--_",
"id": "30.70",
"name": "30.70 Walls",
"parent_id": "30"
},
{
@pinx
pinx / Tests.elm
Created July 16, 2016 07:31
Example of testing Elm decoders
module Tests (..) where
import ElmTest exposing (..)
import Json.Decode as Decode
import Json.Encode as Encode
import Check exposing (Claim, Evidence, check, claim, that, is, for)
import Check.Producer exposing (..)
import Check.Test exposing (evidenceToTest)
import String
import Ober exposing (..)