Skip to content

Instantly share code, notes, and snippets.

@mfeineis
mfeineis / git-stats.sh
Created February 28, 2018 08:10
Display the amount of lines added and removed by a specific author in your git repo
#!/bin/bash
git log --author="John Doe" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'
@mfeineis
mfeineis / docker-image-rm-all.sh
Created February 28, 2018 08:11
Remove all docker images from your machine
#!/bin/bash
docker rmi $(docker images -a -q)
@mfeineis
mfeineis / elm-meetup-2018-02-28
Created February 28, 2018 22:44
Notes for the Elm Meetup Leipzig 2018-02-28
* autojump - bookmark console
* mosh - mobileshell
* sshuttle - easy vpn with python?
* ripgrep (rg) - better silversurfer (ag)
* https://github.com/asdf-vm/asdf
* https://github.com/junegunn/fzf
* https://github.com/abo-abo/swiper
Tasks
@mfeineis
mfeineis / ElmFsaPorts.elm
Last active March 6, 2018 01:53
This is a "minimal" example for integrating Elm with Flux-Standard-Actions of ReactJS fame (https://ellie-app.com/d6C53Vf3Pa1/0).
port module ElmFsaPorts exposing (main)
import Html exposing (Html, text)
import Json.Decode as Decode exposing (Decoder, Value)
import Json.Encode as Encode
port fromElm : Value -> Cmd msg
@mfeineis
mfeineis / ElmWithReact.elm
Last active March 6, 2018 01:53
A minimal example for integrating Elm into a React 16 App (https://ellie-app.com/bCchkr7cYa1/2)
port module Main exposing (main)
import Html exposing (Html)
port fromElm : String -> Cmd msg
port toElm : (String -> msg) -> Sub msg
@mfeineis
mfeineis / ElmTurnResultIntoDecoder.elm
Created March 7, 2018 07:44
A snippet for making a `Json.Decoder` from a result
-- From https://robots.thoughtbot.com/5-common-json-decoders#1---decoding-union-types
fromResult : Result String a -> Decoder a
fromResult result =
case result of
Ok a -> JD.succeed a
Err errorMessage -> JD.fail errorMessage
parseDirection : String -> Result String Direction
@mfeineis
mfeineis / FromReduxToElm.elm
Created March 11, 2018 01:48
A self-contained attempt at explaining The Elm Architecture (TEA) in terms of Redux - https://ellie-app.com/kKcXHF8fJa1/0
port module FromReduxToElm exposing (main)
import Html exposing (Html)
port sayHello : (String -> msg) -> Sub msg
type alias Model =
{ who : String
@mfeineis
mfeineis / ElmFxAndCmds.elm
Last active March 13, 2018 13:55
A gist for making the update function better testable by allowing it to return union types that are then interpreted https://ellie-app.com/SZCJ3rJ3a1/3
module ElmFxAndCmds exposing (main)
import Html exposing (Html)
import Html.Events exposing (onClick)
import Http
import Json.Decode as Decode exposing (Decoder, Value)
type alias Model =
{}
@mfeineis
mfeineis / ElmCqrs.elm
Last active March 14, 2018 21:32
A gist for doing proper CQRS with a run-of-the-mill Elm program - see https://ellie-app.com/7GHTBPxy3a1/1
port module Main exposing (main)
import Html exposing (Html)
import Html.Events exposing (onClick)
import Http
import Json.Decode as Decode exposing (Decoder, Value)
import Json.Encode as Encode
port toElm : (Value -> msg) -> Sub msg
@mfeineis
mfeineis / ElmClipboard.elm
Created March 14, 2018 12:58
WIP: A gist for trying to get the `copy` event working with ports in Elm. https://ellie-app.com/pyMQZgFwga1/1
port module Main exposing (main)
import Html exposing (Html)
import Html.Events as Events exposing (onWithOptions)
import Json.Decode as Decode exposing (Value)
port saveToClipboard : Value -> Cmd msg