Skip to content

Instantly share code, notes, and snippets.

@knewter
knewter / README.md
Created November 11, 2024 17:49
single-file liveview collaborative drawing grid

Just run this like elixir grid.exs and you have a liveview collaborative grid huzzah

@knewter
knewter / Color.elm
Created November 19, 2018 18:14
Material Colors for Elm
module Material.Color exposing
( red50, red100, red200, red300, red400, red500, red600, red700, red800, red900, redA100, redA200, redA400, redA700
, pink50, pink100, pink200, pink300, pink400, pink500, pink600, pink700, pink800, pink900, pinkA100, pinkA200, pinkA400, pinkA700
, purple50, purple100, purple200, purple300, purple400, purple500, purple600, purple700, purple800, purple900, purpleA100, purpleA200, purpleA400, purpleA700
, deepPurple50, deepPurple100, deepPurple200, deepPurple300, deepPurple400, deepPurple500, deepPurple600, deepPurple700, deepPurple800, deepPurple900, deepPurpleA100, deepPurpleA200, deepPurpleA400, deepPurpleA700
, indigo50, indigo100, indigo200, indigo300, indigo400, indigo500, indigo600, indigo700, indigo800, indigo900, indigoA100, indigoA200, indigoA400, indigoA700
, blue50, blue100, blue200, blue300, blue400, blue500, blue600, blue700, blue800, blue900, blueA100, blueA200, blueA400, blueA700
, lightBlue50, lightBlue100, lightBlue200, lightBlue300, li
@knewter
knewter / erlang_releases_bug.md
Created October 26, 2017 00:22
erlang releases bug re linux acls? distillery or something else?
  • give $currentuser access to read the project files:
    • chmod -R g+w .
    • chown -R $otheruser:$commongroup .
  • then attempt to build a release with distillery:
    • MIX_ENV=prod mix release --env=prod

expected result

yay i have a release

actual result

defmodule SomeModule do
def func(map, key) do
for {k, v} <- map, into: %{} do
{k, v/map[key]}
end
end
end
defmodule MapDivisionTest do
use ExUnit.Case
@knewter
knewter / hello.eve
Created July 3, 2017 14:09
Hello World for Eve
# Hello World
Eve is based on the concept of a single data store that you can search in and
commit to. Let's start by committing a record:
~~~
commit
[#greeting message: "hello world"]
~~~
@knewter
knewter / Main.elm
Created November 27, 2016 10:15
Counter for Elm 0.18
module Main exposing (..)
import Html exposing (..)
import Html.Events exposing (onClick)
type alias Model =
{ count : Int
, increment : Int
, decrement : Int
@knewter
knewter / processes.markdown
Last active August 20, 2016 15:27
A discussion to try to help explain processes and GenServer to early elixir users

me: have you ever done the ‘make a process that runs a function that does a receive and calls that function again after receiving every message’ thing yet?

person1: that was a sentence that I have no idea what it means

me: I had already done erlang for like 3 months when I got into elixir, and kind of dug in hard on erlang, so I had these concepts in the brain already

me: ok, let me show you real quick

me: this is like the thing about elixir

@knewter
knewter / elm_update_separation.md
Last active August 18, 2016 02:20
A discussion around an idea for separating the bits of `update` internally

A discussion around an idea for separating the bits of update internally

NOTE: I really just want to have a discussion around this, see if someone's tried it, what dumb things I'm ignoring, etc.

Premise

update is Msg -> Model -> (Model, Cmd Msg). Very often (I think every time I've ever done anything?) I will end up with things that "update the model" based on new Msg (I am enjoying thinking of these as strictly events in the EventSourcing/WAL sense), and then either some Cmd Msg or none. Every time I

@knewter
knewter / Main.elm
Created August 9, 2016 21:18
Introduction to elm-mdl - 10
view : Model -> Html Msg
view model =
Material.Scheme.topWithScheme Color.Teal Color.LightGreen <|
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
, Layout.selectedTab model.selectedTab
, Layout.onSelectTab SelectTab
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
@knewter
knewter / Main.elm
Created August 9, 2016 21:18
Introduction to elm-mdl - 9
view : Model -> Html Msg
view model =
Material.Scheme.topWithScheme Color.Teal Color.LightGreen <|
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
, Layout.selectedTab model.selectedTab
, Layout.onSelectTab SelectTab
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]