Skip to content

Instantly share code, notes, and snippets.

fn prepare(line: &str) -> String {
if !line.is_empty() {
let mut line = line.chars();
let prefix = line.next().unwrap();
let output_line = line.collect::<String>();
format!("{}{}", prefix, output_line)
} else {
"<empty line>".to_string()
}
}
@dandavison
dandavison / index.html
Created April 3, 2021 10:50
vue-file-agent: Preloading Exising Files Demo
<script type="text/x-template" id="vue-file-agent-demo">
<div>
<VueFileAgent
:uploadUrl="'https://www.mocky.io/v2/5d4fb20b3000005c111099e3'"
:uploadHeaders="{}"
:multiple="true"
:deletable="true"
:editable="true"
:meta="true"
:accept="'image/*,video/*,.pdf,.zip'"
@dandavison
dandavison / bayesian-brain.md
Last active December 28, 2025 18:05
Bayesian Frameworks in Cognitive Science and Computer Vision

Bayesian Frameworks in Cognitive Science and Computer Vision

A conversation about the free energy principle, predictive processing, and how these theoretical frameworks compare to practical engineering approaches in robotics and autonomous vehicles.


Q: Are you familiar with explanations and theories in cognitive science involving "free energy"?

Yes, I'm quite familiar with this area. The free energy principle (FEP) is a theoretical framework developed primarily by Karl Friston, a neuroscientist at UCL, that attempts to provide a unified account of brain function, perception, action, and learning.

@dandavison
dandavison / temporal-as-algebraic-effects.md
Created April 25, 2026 18:24
Temporal as algebraic effects: a PL-theory note for working programmers

Temporal as algebraic effects

A note on the programming-language-theory framing of Temporal — for a reader who writes Python/Go/Java daily but has not had to think about delimited continuations or effect handlers as language features.

Effects, in the PL sense

In a PL-theory context an effect is anything a function does besides return a value: read or write a variable, throw an exception, do I/O, sleep, log, fork. A pure function (input → output, no effect) is the easy case. Languages add effects in different ways: Java has unchecked I/O and checked exceptions; Python has implicit I/O and raise; Go has panic/recover and channels. Effects are how programs actually do anything useful.

The interesting question for PL designers is: can you make effects first-class — values that the language can pass around, intercept, replace? Most mainstream languages do this for one effect (exceptions, via try/catch) and not for the rest.