Skip to content

Instantly share code, notes, and snippets.

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

Michael Hadley mthadley

💾
Loading...
View GitHub Profile
@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
@mthadley
mthadley / test.js
Created December 6, 2016 01:44
concat vs union
const {OrderedSet} = Immutable;
const x = OrderedSet([]);
const y = OrderedSet([2, 3, 4, 5, 6]);
const z = x.concat(y);
console.log(z === y);
// This will log `false`.
@mthadley
mthadley / Util.elm
Last active November 21, 2016 19:37
Elm Url
import Http exposing (encodeUri)
url : String -> List ( String, String ) -> String
url base =
let
encodeParts ( key, value ) =
(encodeUri key) ++ "=" ++ (encodeUri value)
in
(++) base << (++) "?" << String.join "&" << List.map encodeParts