Skip to content

Instantly share code, notes, and snippets.

@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.

@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 / 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'"
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()
}
}
#!/usr/bin/env python
from scipy.optimize import bisect
def record_optimization(func):
def recorder(self, *args, **kwargs):
if not hasattr(self, '_recorder_inputs'):
self._recorder_inputs = []
#!/bin/bash
set -e
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
make
sudo make install
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dandavison
dandavison / gist:4780d40a866e0b942ff9
Last active August 29, 2015 14:18
One-to-one question

Two columns satisfy a "one-to-one" constraint if each value in column 1 is associated with exactly one value in column 2, and vice versa. E.g. in this data, the person column and the email column satisfy a one-to-one constraint:

>>> table = [('pablo', '[email protected]'),
             ('georgia', '[email protected]'),
    	     ('mark', '[email protected]')]
>>> is_one_to_one(table)
width = 500
height = 300
cube =
nodes: [
{x: 0, y: 0, z:0},
{x: 0, y: 0, z:1},
{x: 0, y: 1, z:0},
{x: 0, y: 1, z:1},
{x: 1, y: 0, z:0},