I hereby claim:
- I am wpcarro on github.
- I am wpcarro (https://keybase.io/wpcarro) on keybase.
- I have a public key ASCrkXvNTrQIjM9mWqWFJBIhrDe1__hfVe1r-8uo8VsAKQo
To claim this, I am signing this object:
defmodule DriverRegistry do | |
@moduledoc """ | |
Most key-value registries in Elixir can and perhaps should be created with a | |
`GenServer`. This module illustrates an alternative implementation of a | |
registry using macros that eliminates the need for a `GenServer`. This removes | |
OTP dependencies like a supervision tree and also reduces unnecessary | |
"process noise" in your application. | |
The use-case for such a registry is a driver registry where consumers opt-in | |
to drivers by declaring which drivers they would like to use in the |
defmodule Tree do | |
@moduledoc """ | |
Simple implementation of a breadth-first tree traversal. | |
Author: William Carroll | |
""" | |
@type value :: any | |
@type tree :: {value [tree]} |
I hereby claim:
To claim this, I am signing this object:
;; versions 1 & 2 -- structure remains the same | |
(defn render [{:keys [data]}] | |
(reagent/create-class | |
{:reagent-render (constantly [:svg.canvas]) | |
:component-did-mount #(-> data clj->js do-render-graph)})) |
defmodule PrivateMacros do | |
@moduledoc false | |
defmacrop test() do | |
quote do | |
IO.inspect("I compiled") | |
end | |
end | |
test() |
#!/usr/bin/env bash | |
################################################################################ | |
# This script will run ESLint over all staged files with js or jsx extensions. | |
# Author: William Carroll | |
################################################################################ | |
for file in $(git diff --name-only --cached | grep -E '\.jsx?$'); do | |
npx eslint ${file} | |
done |
#!/usr/bin/env bash | |
# short-circuit script for any non-zero exit | |
set -e | |
################################################################################ | |
# This script will run ESLint over all staged files with js or jsx extensions. | |
# Author: William Carroll | |
################################################################################ |
(defun wpcarro/tmux-emacs-windmove (dir) | |
"Move windows in a Tmux-friendly way." | |
(let* ((dir->opts '((left . ("-L" . windmove-left)) | |
(right . ("-R" . windmove-right)) | |
(above . ("-U" . windmove-up)) | |
(below . ("-D" . windmove-down)))) | |
(opts (alist-get dir dir->opts)) | |
(tmux-opt (car opts)) | |
(emacs-fn (cdr opts))) | |
(if (window-in-direction dir) |
#!/bin/bash | |
# To set this up, open iTerm2 -> Preferences -> Profiles -> Advanced | |
# In the "Semantic History" section, choose "Always run command..." from the | |
# dropdown and set the input text to: | |
# `~/dotfiles/emacs.d/open-from-iterm.sh \1` | |
# Alias applications since $PATH is unavailable | |
emacs=/usr/local/bin/emacsclient | |
grep=/usr/local/bin/ggrep |
-------------------------------------------------------------------------------- | |
import Data.Function ((&)) | |
-------------------------------------------------------------------------------- | |
main :: IO () | |
main = | |
[2,3,5,1,4,6,8,7,9] & mergeSort & show & putStrLn | |
mergeSort :: (Ord a) => [a] -> [a] | |
mergeSort [] = [] | |
mergeSort [x] = [x] |