Skip to content

Instantly share code, notes, and snippets.

@michaeljones
michaeljones / HtmlString.elm
Created July 25, 2019 14:11
Elm port of Lodash Html Escape & Unescape
{- Escaping & unescaping some html in strings
We port over the lodash approach to escaping & unescaping. This does a more minimal approach suitable for large
blocks of html rather than for, say, strings that you're going to put into an html attribute or something. For
reasoning and more aggressive escaping see:
- https://wonko.com/post/html-escaping/
- https://package.elm-lang.org/packages/marcosh/elm-html-to-unicode/latest/
These have been introduced as the more aggressive escaping ends up escaping spaces as well which feels like than
@michaeljones
michaeljones / Main.elm
Created April 3, 2019 17:38
Elm Browser.application example with an attempted 'preventDefault'
module Main exposing (main)
import Browser
import Browser.Navigation
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (preventDefaultOn)
import Json.Decode as Json
import Url exposing (Url)
@michaeljones
michaeljones / Main.elm
Created November 6, 2016 14:43
Initial Elm project
port module Main exposing (..)
import Html exposing (..)
import Html.App
import Html.Events
import Html.Attributes
main =
Html.App.programWithFlags
@michaeljones
michaeljones / Main.elm
Last active May 18, 2016 20:07
Elm - TypeError: Cannot read property 'decoder' of null
import Html.Events exposing (onClick)
import Html exposing (..)
import Html.App
type alias Model =
{ clicks : Int
}
@michaeljones
michaeljones / gist:888008
Created March 26, 2011 03:49
git view-all-objects: reflog for the lazy
#!/bin/sh
# This is a command to visualise all the commit objects in a git repository
# in gitk. The benefit is that you see all of the orphaned commit objects
# which you have left behind when rebasing or deleting branches.
# I was interested in this partly as an educational tool to show people how
# safe some of these history editing operations are, as the commits are all
# still there. I'm also keen to see how useful it is as a kind of visual
# alternative to the reflog command. The reflog is awesome and I'm getting