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
defmodule Util.Tree do | |
def transform_keys(map, transform) when is_map(map) do | |
Map.new( | |
Enum.map(map, fn {k, v} -> | |
{transform.(k) |> IO.inspect(label: "transformed"), transform_keys(v, transform)} | |
end) | |
) | |
end | |
def transform_keys(list, transform) when is_list(list) do |
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 Cursor exposing (cursor, Cursor(..)) | |
import Element exposing (Element, Attribute, htmlAttribute) | |
import Html.Attributes | |
cursor : Cursor -> Attribute msg | |
cursor cursor_ = | |
htmlAttribute <| Html.Attributes.style "cursor" (cursorName cursor_) | |
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
defmodule Util.Ecto do | |
def export(model = %{__meta__: _meta, __struct__: _struct}) when is_map(model) do | |
stripped = | |
model | |
|> Map.from_struct() | |
|> Map.delete(:__meta__) | |
associations = model.__struct__.__schema__(:associations) | |
Enum.reduce(associations, stripped, fn assoc, model -> |
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
view model = | |
HolyGrail.view | |
|> HolyGrail.header | |
(HeaderCard.config | |
|> HeaderCard.leftGutter Avatar.small | |
|> HeaderCard.title "Using AI to Detect Emotions in text" | |
) | |
|> HolyGrail.body | |
(ScrollPaneCard.view | |
[ ChatDay.config |
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
AppState (Main.elm delegates to one of these) | |
LoggedIn | |
Context.elm | |
Init.elm | |
Model.elm | |
Msg.elm | |
Subscriptions.elm | |
Update.elm | |
UrlUpdate.elm | |
View.elm |
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
defmodule Helpers.Actions do | |
def set_text(parent, %Query{} = query, text) when is_binary(text) do | |
parent |> find(query) | |
case Query.compile(query) do | |
{:css, selector} -> | |
parent | |
|> pipeline_script("document.querySelector('#{selector}').value = '#{text}'") | |
|> pipeline_script("document.querySelector('#{selector}').dispatchEvent(new Event('input'))") | |
{:xpath, xpath} -> |
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
<html> | |
<head> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.ns-autogrow/1.1.6/jquery.ns-autogrow.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
$('.new-message textarea').autogrow({vertical: true, horizontal: false}); | |
}); | |
</script> |
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
onEnter : Msg -> Attribute Msg | |
onEnter msg = | |
let | |
filterKey ( code, shift ) = | |
if (isEnter code) && (not shift) then | |
Ok "triggering" | |
else | |
Err "not triggering" | |
decoder = |
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
Go the settings page/section: Clients > ClientABC > Advanced Settings > advanced > Application Metadata | |
And add the metadata, e.g. Key: tenantId, Value: "tenant123" | |
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 Html exposing (div, button, text) | |
import Html.App exposing (program) | |
import Html.Events exposing (onClick) | |
import Time | |
import Task | |
main = | |
program { init = init, view = view, update = update, subscriptions = always Sub.none } |