Skip to content

Instantly share code, notes, and snippets.

View lilactown's full-sized avatar
🌊
Do not follow in the footsteps of the sages. Seek what they sought.

Will Acton lilactown

🌊
Do not follow in the footsteps of the sages. Seek what they sought.
View GitHub Profile
@lilactown
lilactown / css.cljs
Last active November 12, 2018 21:06
(ns my-app.css
(:require ["emotion" :as emotion]))
(defn edn [& styles]
(apply emotion/css (map clj->js styles))
@lilactown
lilactown / install-emacs.sh
Last active April 15, 2019 15:04
Installs Emacs with my favorite things
#!/usr/local/bin/zsh
brew tap railwaycat/emacsmacport
brew install emacs-mac --with-xml2 --with-ctags --with-spacemacs-icon --with-gnutls --with-natural-title-bar
osascript -e 'tell application "Finder" to make alias file to POSIX file "/usr/local/opt/emacs-mac/Emacs.app" at POSIX file "/Applications"'
# For opening from term: https://gist.github.com/railwaycat/4043945
# Install spacemacs
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
@lilactown
lilactown / cljs-serverless.md
Last active January 27, 2020 05:06
CLJS in AWS Lambda Quick Start
module Components = {
module Box = {
let jsComponent = [%bs.raw
{|
({ children, ...props }) => React.createElement("box", props, children)
|}
];
let make = (~width, ~height, ~top, ~left, children) =>
ReasonReact.wrapJsForReason(
~reactClass=jsComponent,
@lilactown
lilactown / dayFour.re
Created December 4, 2017 18:38
Advent of Code, 2017: Day 4
module StringSet = Set.Make(String);
let arrayToStringSet = (arr) => StringSet.of_list(Array.to_list(arr));
let noDuplicates = (cardinal, pass) => {
let phrases = Js.String.split(" ", pass);
cardinal(arrayToStringSet(phrases)) == Array.length(phrases)
};
let part1 = (input) =>
@lilactown
lilactown / dayThree.re
Created December 4, 2017 09:00
Advent of Code, 2017: Day 3
let abs = Js.Math.abs_int;
/*
Desired output:
1 => (0, 0)
2 => (1, 0)
3 => (1, 1)
4 => (0, 1)
5 => (-1, 1)
6 => (-1, 0)
@lilactown
lilactown / dayTwo.re
Created December 2, 2017 21:10
Advent of Code, 2017, Day Two
let splitLines = (input) => Js.String.split("\n", input) |> Array.to_list;
let splitDigits = (line) =>
Js.String.split("\t", line) |> Array.map(int_of_string) |> Array.to_list;
let debug = (input) => {
Js.log(input);
input
};
@lilactown
lilactown / dayOne.re
Last active December 2, 2017 04:13
Advent of Code, 2017 Day 1: A more general solution
let explode = (input) =>
Js.String.split("", input)
|> Array.map(int_of_string);
let rec solver = (digits, len, step, xPos, total) => {
let x = digits[xPos];
let yPos = (xPos + step) mod len;
let y = digits[yPos];
/* curry the next call to solver */
@lilactown
lilactown / halfway.re
Last active December 1, 2017 22:01
Advent of Code, 2017 Day 1 (2/2)
let explode = (input) =>
Js.String.split("", input)
|> Array.map(int_of_string)
|> Array.to_list;
let solve = (input) => {
let len = String.length(input);
let step = len / 2;
let listInput = explode(input);
let nth = List.nth(listInput);
@lilactown
lilactown / captcha.re
Last active December 1, 2017 21:42
Advent of Code, 2017 Day 1 (1/2)
let explode = (input) =>
Js.String.split("", input)
|> Array.map(int_of_string)
|> Array.to_list;
let rec solver = (current, next, rest, first, total) =>
switch (next == first, current == next, rest) {
/* when we're on the last item in the list */
| (true, true, []) => total + current + next
| (false, true, []) => total + current