Skip to content

Instantly share code, notes, and snippets.

View mthadley's full-sized avatar
💾
Loading...

Michael Hadley mthadley

💾
Loading...
View GitHub Profile
module Url.Parser.Extra exposing (const)
import Url.Parser
{-| A parser that "almost always" succeeds.
Maybe you want to convert an existing application to be an SPA
without actually adding a route type yet:
Url.Parser.Extra.const () : Url.Parser.Parser (() -> ()) ()
@mthadley
mthadley / Makefile
Created August 19, 2019 02:37
Makefile with npm and node-sass
# Get a list of all sass src files. We use the `shell` function
# to run a normal command and store the result in this variable.
SCSS_SRC = $(shell find src/scss -iname "*.scss")
# Make a list of all the files we want as output, so...
# src/scss/header.scss
# gets tranformed to...
# dist/header.css
CSS = $(addprefix dist/, $(notdir $(SCSS_SRC:.scss=.css)))
@mthadley
mthadley / haskell_elm_imports.md
Last active October 31, 2019 07:02
Elm <-> Haskell Import Cheatsheet

Elm <-> Haskell Import Cheatsheet

A small cheatsheet to help you translate between Haskell and Elm style imports.

Elm Haskell
import Foo.Bar import qualified Foo.Bar
import Foo.Bar as Bar import qualified Foo.Bar as Bar
import Foo.Bar exposing (foo) import Foo.Bar (foo)
import Foo.Bar exposing (..) import Foo.Bar
@mthadley
mthadley / point-it.hs
Last active February 11, 2019 06:21
Create async pointing threads in slack
#!/usr/bin/env stack
{- stack
script
--resolver lts-12.24
--package "aeson bytestring lens lens-aeson optparse-applicative split text wreq"
--ghc-options -Wall
-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Lens ((&), (.~), (^?))
#!/usr/bin/env bash
COUNT="20000"
INTERVAL="2000"
while [[ $COUNT -gt 0 ]]; do
echo "Pushing ${COUNT}"
git push origin HEAD~"$COUNT"
COUNT=$(($COUNT - $INTERVAL))
done
/* Put this somewhere */
class PatrickStore extends EventEmitter {
closeContainer() {
this.emit('closeContainer');
}
openContainer() {
this.emit('openContainer');
}
}
{namespace MyComponent}
{template .render}
{@param attrs: map<string, string>}
{let $attrs_ kind="attributes"}
{foreach $key in keys($attrs)}
{$key}="{$attrs[$key]}"
{/foreach}
{/let}
{namespace MyComponent}
{template .render}
{@param attributes: attributes}
<button {$attributes}>Hello World</button>
{/template}
/* Caller Side */
// Type Defs
declare namespace JSX {
interface ElementAttributesProperty {
props;
}
}
interface ConfigAttr<T> {
valueFn: () => T;
module Parser exposing (..)
import Combine exposing (..)
import Combine.Char exposing (char)
import Combine.Num exposing (int)
type Program
= Program Expr