Skip to content

Instantly share code, notes, and snippets.

@john-kelly
john-kelly / post.md
Last active August 9, 2022 03:25
Remote Data Request API

A Remote Data Request API in Elm

This post is about the core abstractions found in the elm-postgrest package and how those abstractions may be relevant to similar packages.


In Elm, the design space of remote data request APIs has seen its fair share of work. We have APIs like lukewestby/elm-http-builder which provide a thin convenience layer over elm-lang/http.

addItem : String -> Cmd Msg
import json
import operator
class expect(object):
"""Represents a logical expectation.
"""
# a static class variable for storing all expectations
@john-kelly
john-kelly / subprocess_pipe.md
Created September 30, 2021 04:18 — forked from waylan/subprocess_pipe.md
Writing to a python subprocess pipe

Here's a few things I tried to write output to a python subprocess pipe.

from subprocess import Popen, PIPE

p = Popen('less', stdin=PIPE)
for x in xrange(100):
    p.communicate('Line number %d.\n' % x)
import turtle
__turtle = turtle.Turtle()
__turtle.shape("turtle")
def degrees(n=None):
return __turtle.degrees(n)
def radians():
return __turtle.radians()
module Schema exposing (school)
import PostgRest exposing (Attribute, Schema, schema, string)
type School
= School School
school :
module Main exposing (..)
import Color
import Element exposing (..)
import Element.Background as Background
import Element.Border as Border
import Element.Events as Events
import Element.Font as Font
import Html exposing (Html)
@john-kelly
john-kelly / Experiment2ElmRecordUpdate.elm
Last active March 8, 2017 03:46
ExperimentElmRecordUpdate.elm
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}]
|> List.map (\u -> {u | name = toUpper u.name})
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}]
|> List.map {u | name = toUpper u.name}
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}]
|> List.map (\u -> !name (toUpper u.name) u)
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}]
import PostgRest exposing (..)
type Relation schema
= Relation String schema
-- subQuery based on query6 api
{-| -}
subQuery : (schema1 -> Relation schema2) -> (a -> b) -> Query schema1 c -> Query schema2 (a -> b)
subQuery getRelation recordCtor (Query name schema params decoder) =
case getRelation schema of
@john-kelly
john-kelly / Nested.elm
Created October 21, 2016 17:16
Example of nested entities using elm-postgrest
import Task
import PostgRest exposing (..)
trainerResource =
resource "trainer"
{ id = int "id"
, name = string "name"
}
@john-kelly
john-kelly / Main-0.16.elm
Last active May 9, 2016 07:17
Elm 0.16 vs 0.17 for simple circle dragging program.
import Effects
import Html exposing (Html)
import Mouse
import StartApp exposing (start)
import Svg exposing (..)
import Svg.Attributes exposing (..)