Skip to content

Instantly share code, notes, and snippets.

@knewter
knewter / Main.elm
Last active January 27, 2024 01:43 — forked from hoelzro/Main.elm
Bug in elm-lang/core `Dict.merge`?
module Main exposing (..)
import Html.App as App
import Html exposing (Html, text)
import Dict exposing (Dict)
type alias Model =
()
@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

@knewter
knewter / contact_test.exs
Created October 8, 2015 12:24
ecto many to many query
# -*- c-basic-offset: 2; indent-tabs-mode: nil -*-
defmodule Score.ContactTest do
use Score.TestCase
@joe %{name: "joe", email: "joe@vipaar.com", sign_in_count: 0}
@joe_changeset User.changeset(%User{}, :create, @joe)
@bob %{name: "bob", email: "bob@vipaar.com", sign_in_count: 0}
@bob_changeset User.changeset(%User{}, :create, @bob)
setup do
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 / living-off-the-rails.md
Created March 1, 2013 14:45
Extraction of a post on ruby rogues parley

So there was a really good post on parley, here it is. Lots of links to different research materials re: 'living off the rails' or whatever we're calling it :)

I've been playing with this idea too lately. Unfortunately can't spend too much time on it so I didn't get very far. There are however a few links that might help you:

These are related to Micah Martin's talk, "a sequel" to Uncle Bob's architecture one: https://github.com/slagyr/cleantracker https://github.com/slagyr/cleananalytics_rb

@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