Skip to content

Instantly share code, notes, and snippets.

@emdash
emdash / gggist.idr
Created March 4, 2023 03:24
Ch14 Verified Guessing Game
module Main
import Data.Vect
namespace Game
data State : Type where
NotRunning : State
Running : (guesses : Nat) -> (letters : Nat) -> State
@emdash
emdash / ch14gist.idr
Last active March 1, 2023 17:36
Ch 14 Question
module Main
import Data.Vect
namespace ATM
total
PIN : Type
PIN = Vect 4 Char
@emdash
emdash / ssttp.sh
Created May 26, 2022 02:40
Shorter Benchmark
set -eo pipefail
function just_count {
local -i i=0
local -i n="$1"
while test "${i}" -lt "${n}"
do
i="$(( i + 1 ))"
done
@emdash
emdash / iobenchmarks.sh
Created May 26, 2022 01:42
Bash IO Benchmarks
set -eo pipefail
shopt -s inherit_errexit
while getopts "s" option; do
case "${option}" in
s) declare -r "SLOW_MODE"=1;;
*) : ;;
esac
done
@emdash
emdash / shell_actors.md
Last active January 2, 2022 05:47
On "Shell Actors" [Working Title]

Overview

I propose extending the the existing notion of "structured data over pipes" to a paradigm that embraces explicit message-passing semantics.

I outline a set of complementary ideas, united under the banner of some suitably pithy term of art -- such as: shell actors, record streams, shell sockets, etc (the bikeshedding about which I wholeheartedly encourage).

@emdash
emdash / calories.py
Created January 17, 2020 02:00
BMR Calculator for various scenarios
# source:
# https://www.bodybuilding.com/content/nutrient-ratios-and-aloric-needs.html
def body_fat_coef(body_fat_percentage):
if 10 <= body_fat_percentage <= 14:
return 1.0
elif 14 <= body_fat_percentage <= 20:
return 0.95
elif 20 <= body_fat_percentage <= 28:
return 0.90
elif body_fat_percentage >= 28: