Skip to content

Instantly share code, notes, and snippets.

View JesterXL's full-sized avatar
🔊
writing

Jesse Warden JesterXL

🔊
writing
View GitHub Profile
app "AoC Day 2 - Rock Paper Scissors"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br" }
imports [pf.Stdout, pf.Path, pf.File, pf.Task]
provides [main] to pf
# saysYeah = \yup ->
# "\(yup) yeah!"
# expect saysYeah "cactus" == "cactus yeah!"
class Ok {
constructor(data) {
this.data = data
this._type = "Ok"
this.then.bind(this)
this.match.bind(this)
}
then(func) {
const result = func(this.data)
@JesterXL
JesterXL / elm-review-rules-adr.md
Last active February 28, 2022 20:44
Elm Review Rules on Mon, Feb 28th, 2022

Elm Review Rules Architectural Design Record

Status

Proposed

Context

While Elm has an idiomatic way to do things regarding the architecture, there are various ways to use types and code. Much like JavaScript and Python have linting rules, Elm does as well to help enforce best practices that the team deems important.

const binaryBody = await res.buffer()
const body = binaryBody.toString('binary')
debug("first 255 of string body: %s", body.substr(0, 255))
const { isAnError, parsedResult } = verifyNotJSONErrorMessage(body)
debug("isAnError: %o", isAnError)
if(isAnError) {
return failure({ isAnError, parsedResult })
}
const boundaryHeader = res.headers.get('content-type')
debug("boundaryHeader: %s", boundaryHeader)
@JesterXL
JesterXL / default-value-ramda-propOr-lodash-getOr.js
Created March 1, 2021 00:02
People think you don't need Lodash or Ramda, but ... you just have to have patience and love and empathy.
// keep in mind this does NOT do paths
const getOr = (defaultValue, prop, object) =>
(object ?? {})?.[prop] ?? defaultValue
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
import Html.Attributes exposing (style)
import Draggable
type alias Model =
type applicationLoadBalancerEvent = {
path: string,
httpMethod: string,
queryStringParameters: option<string>,
body: option<string>
}
type header = (string, string)
local module = {}
function module.puzzleInput()
return [[light red bags contain 1 bright white bag, 2 muted yellow bags.
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
dark olive bags contain 3 faded blue bags, 4 dotted black bags.
vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
@JesterXL
JesterXL / day2-puzzle1.lua
Created December 2, 2020 14:22
Advent of Code 2020 - Roblox Lua - Day 2
local module = {}
local Puzzle1Input = require(script.Parent.Puzzle1Input)
local LuaFP = require(script.Parent.Parent.LuaFP)
local map, filter, some, reduce = LuaFP.collection.map, LuaFP.collection.filter, LuaFP.collection.some, LuaFP.collection.reduce
local repr = require(workspace.repr)
local function containsCount(targetLetter, list)
return reduce(
function(acc, letter)
@JesterXL
JesterXL / day1-puzzle1.lua
Created December 2, 2020 14:21
Advent of Code 2020 - Roblox Lua - Day 1
local module = {}
local Puzzle1Input = require(script.Parent.Puzzle1Input)
local LuaFP = require(script.Parent.Parent.LuaFP)
local map, reduce = LuaFP.collection.map, LuaFP.collection.reduce
function module.main()
print("Day 1, Puzzle 1")
local input = Puzzle1Input.input()