Skip to content

Instantly share code, notes, and snippets.

View karlosmid's full-sized avatar

Karlo Smid karlosmid

View GitHub Profile
module Picshare exposing (main)
import Browser
import Html exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
import Html.Attributes exposing (class, src, placeholder, type_, disabled, value)
import Json.Decode exposing (Decoder, bool, int, list, string, succeed)
import Json.Decode.Pipeline exposing (hardcoded, required)
import Http
type alias Id =
Int
module Picshare exposing (main)
import Browser
import Html exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
import Html.Attributes exposing (class, src, placeholder, type_, disabled, value)
import Json.Decode exposing (Decoder, bool, int, list, string, succeed)
import Json.Decode.Pipeline exposing (hardcoded, required)
import Http
type alias Id =
Int
@karlosmid
karlosmid / picshare_with_http_get.elm
Created December 16, 2020 15:12
elm Picshare with HTTP Cmd
module Picshare exposing (main)
import Browser
import Html exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
import Html.Attributes exposing (class, src, placeholder, type_, disabled, value)
import Json.Decode exposing (Decoder, bool, int, list, string, succeed)
import Json.Decode.Pipeline exposing (hardcoded, required)
-- 1. add http lib
import Http
type alias Id =
@karlosmid
karlosmid / picshare_with_json_decoder.elm
Last active December 1, 2020 18:13
Elm Pichsare example application with implemented JSON decoder
-- 8. temporary expose to test in elm repl
module Picshare exposing (main, photoDecoder)
import Browser
import Html exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
import Html.Attributes exposing (class, src, placeholder, type_, disabled, value)
-- 1. import Json modules
import Json.Decode exposing (Decoder, bool, int, list, string, succeed)
import Json.Decode.Pipeline exposing (hardcoded, required)
type alias Id =
@karlosmid
karlosmid / script_example.exs
Created November 15, 2020 09:27
elixir exs script example
defmodule ScriptExample do
def work() do
IO.puts(Date.utc_today())
end
end
ScriptExample.work()
module Picshare exposing (main)
import Browser
import Html exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
import Html.Attributes exposing (class, src, placeholder, type_, disabled, value)
-- 1. add alias Id
type alias Id =
Int
-- 2. rename Model => Photo
type alias Photo =
@karlosmid
karlosmid / picshare_model_2.json
Created November 1, 2020 09:27
Not compatible JSON with Elm Picshare Model Record
{
"id": 1,
"src": "https://programming-elm.surge.sh/1.jpg",
"caption": null,
"liked": "no"
}
@karlosmid
karlosmid / picshare_model.json
Created November 1, 2020 09:20
json example for Picshare Model Record
{
"id": 1,
"url": "https://programming-elm.surge.sh/1.jpg", "caption": "Surfing",
"liked": false,
"comments": ["Cowabunga, dude!"],
"username": "surfing_usa" }
module Picshare exposing (main)
import Browser
import Html exposing (..)
-- 2. add onInput and onSubmit
import Html.Events exposing (onClick, onInput, onSubmit)
-- 1. add disabled and value
import Html.Attributes exposing (class, src, placeholder, type_, disabled, value)
type alias Model =
{ url : String
, caption : String
@karlosmid
karlosmid / if_macro.ex
Last active October 24, 2020 12:03
example of using elixir macros
defmodule If do
defmacro if(clause, do: expression) do
quote do
if(unquote(clause) == :true, do: unquote(expression))
end
end
end