Skip to content

Instantly share code, notes, and snippets.

@scott-fleischman
scott-fleischman / english.txt
Last active May 20, 2023 23:40
Psalm 119 Hebrew & English Acrostic
Astound me, for Your laws are delightful.
As Your servant, keep me dedicated to Your words.
Always let me keep Your laws, hidden in my heart.
Abide in me and instruct me in Your ways.
Advocate for Your decrees, I will, by recounting all Your laws.
Amidst Your statutes, I will rejoice, as if over a great treasure.
Affectionately, I will meditate on Your precepts and consider Your ways.
Admire Your decrees I will, never forgetting Your word.
Blessed are You, Lord; teach me Your statutes.
By my lips, I recount all the judgments from Your mouth.
@scott-fleischman
scott-fleischman / MeasureChild.re
Created May 23, 2019 18:10
ReasonML/React Hooks Measuring DOM Node
[@react.component]
let make = (~measureRef) => {
let (show, setShow) = React.useState(_ => false);
if (!show) {
<button onClick={_ => setShow(_ => true)}>
{ReasonReact.string("Show child")}
</button>;
} else {
<h1 ref={ReactDOMRe.Ref.callbackDomRef(measureRef)}>
{ReasonReact.string("Hello, world")}
@scott-fleischman
scott-fleischman / git-submodule-rewrite
Created April 12, 2019 16:10
Add git repository with history
#!/usr/bin/env bash
# NOTE: This is a modified version of another script (not sure the location at the moment).
# This script builds on the excellent work by Lucas Jenß, described in his blog
# post "Integrating a submodule into the parent repository", but automates the
# entire process and cleans up a few other corner cases.
# https://x3ro.de/2013/09/01/Integrating-a-submodule-into-the-parent-repository.html
function usage(){
@scott-fleischman
scott-fleischman / Main.hs
Last active April 11, 2019 23:46
Multiplicative persistence
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import qualified Data.Digits
biggie :: Integer
biggie = 277777788888899
mDecimalDigitsRev :: Integer -> Maybe [Integer]
@scott-fleischman
scott-fleischman / Main.hs
Created January 14, 2019 21:59
Simple State + IO
module Main where
import Control.Monad.Trans.State.Lazy
import Control.Monad.IO.Class (liftIO)
nextIntAndPrint :: StateT Int IO Int
nextIntAndPrint = do
currentValue <- get
let newValue = succ currentValue
@scott-fleischman
scott-fleischman / DeBruijn.hs
Created December 20, 2018 22:34
DeBruijn Haskell type class
-- https://twitter.com/pigworker/status/1068897189227913223
newtype B t = B t
class DeBruijn d where
deBruijn :: Applicative f => (s -> Int -> f t) -> d s -> Int -> f (d t)
instance DeBruijn B where
deBruijn f (B s) i = B <$> f s (i + 1)
module _ where
_⟨╯°□°⟩╯_ : {a b c : Set} → (a -> b -> c) -> b -> a -> c
(f ⟨╯°□°⟩╯ b) a = f a b
@scott-fleischman
scott-fleischman / Day1-redone.agda
Last active February 23, 2018 00:11
OPLSS 2014 - My reworkings of Ulf Norell's Introduction to Agda
module _ where
data 𝔹 : Set where
true false : 𝔹
if_then_else_ : {A : Set} (b : 𝔹) (t f : A) → A
if true then t else f = t
if false then t else f = f
data ℕ : Set where