Skip to content

Instantly share code, notes, and snippets.

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

Michael Hadley mthadley

💾
Loading...
View GitHub Profile
{namespace MyComponent}
{template .render}
{@param attrs: map<string, string>}
{let $attrs_ kind="attributes"}
{foreach $key in keys($attrs)}
{$key}="{$attrs[$key]}"
{/foreach}
{/let}
/* Put this somewhere */
class PatrickStore extends EventEmitter {
closeContainer() {
this.emit('closeContainer');
}
openContainer() {
this.emit('openContainer');
}
}
#!/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
@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 ((&), (.~), (^?))
@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 / 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)))
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 / start_pihole.sh
Created January 10, 2020 19:27
Pihole startup script
#!/bin/bash
# Remove existing container
docker stop pihole
docker rm pihole
docker run -d \
--name pihole \
-e TZ="America/Los_Angeles" \
-e ServerIP="192.168.1.201" \
@mthadley
mthadley / server.rb
Created March 29, 2020 00:31
Portable Nix/Ruby Web Server
#! /usr/bin/env nix-shell
#! nix-shell -i ruby -p ruby bundler --pure
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.03.tar.gz
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem 'sinatra'
gem 'thin'
@mthadley
mthadley / randomize_server.rb
Created March 29, 2020 01:24
The Randomizer™️
#! /usr/bin/env nix-shell
#! nix-shell -i ruby -p ruby bundler --pure
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.03.tar.gz
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem 'sinatra'
gem 'thin'