Skip to content

Instantly share code, notes, and snippets.

@dariusf
dariusf / shiftreset3.ml
Last active October 26, 2025 16:16
Genuine shift/reset
(* Based on
https://okmij.org/ftp/continuations/implementations.html
https://okmij.org/ftp/Haskell/ShiftResetGenuine.hs
https://www.cs.tsukuba.ac.jp/~kam/paper/aplas07.pdf *)
(* Parameterised monads *)
module type GM = sig
type ('i, 'o, 'a) t
@dariusf
dariusf / ShiftReset.hs
Last active August 9, 2025 02:06
Shift/reset monad with ATM
-- h ttps://stackoverflow.com/questions/72833519/how-to-extract-delimited-continuation-reset-shift-for-future-use-in-haskell/72836141#72836141
{-# LANGUAGE RebindableSyntax #-}
import Data.String
import Prelude hiding ((>>=), return)
newtype Cont i o a = Cont { runCont :: (a -> i) -> o }
return :: a -> Cont r r a
return x = Cont ($ x)

Using Apron on macOS

Install PPL.

brew install ppl

For some reason, installing from opam doesn't pick up the presence of PPL. We run ./configure manually to fix that.

@dariusf
dariusf / softmark.js
Last active October 9, 2023 10:05
Softmark workflow hacks
// Keybindings for compound rubrics
document.onkeypress = function(e) {
if (e.key === 'n') {
setTimeout(() => {
// both events have to be sent
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'j'}));
document.dispatchEvent(new KeyboardEvent('keyup', {'key': 'j'}));
setTimeout(() => {
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'k'}));
document.dispatchEvent(new KeyboardEvent('keyup', {'key': 'k'}));
@dariusf
dariusf / zipper-merged.ml
Created September 19, 2023 03:05
Various zippers
type 'a tree =
| Section of {
item : 'a;
children : 'a tree list;
}
let item a = Section { item = a; children = [] }
type 'a path =
| Top

Pandas

Mental model

Pandas is oriented around performing SIMD operations on arrays, and its API directly reflects this. Some operations may be less intuitive than they are in the SQL or stream processing worlds. Operations like apply and iter* which involve user-defined Python are generally slow.

Basics

@dariusf
dariusf / equations.md
Last active September 10, 2024 09:14
Equations spotted in the wild
@dariusf
dariusf / hello-shiviz.md
Created August 2, 2023 08:05
A ShiViz Hello World

Updated Feb 2022.

ShiViz visualizes space-time diagrams, a succinct way to represent distributed system executions.

The examples on the site are all rather large, so here's a tiny Hello World example which illustrates the input format and basic ideas.

client1 "message 1 sent" {"client1":1}
client2 "message 2 sent" {"client2":1}
server "message 2 received" {"server":1, "client2":1}
@dariusf
dariusf / zoom-chat-notifications-macos.md
Created August 2, 2023 08:01
Zoom chat notification hacks (macOS)

Updated Dec 2021.

Zoom doesn't have chat notifications. This is a problem when invigilating online exams.

If you're using macOS, notifications can be hacked on by using a bunch of scripts to tell when something on the screen changes.

Rectangles

The first piece is how to capture a small region of the screen.

@dariusf
dariusf / docker-virtualbox.md
Created August 2, 2023 07:58
VirtualBox for Docker users

VirtualBox for Docker users

Sometimes you need VirtualBox instead of Docker - when more isolation is required, or because a desktop environment is too hard to configure.

(Updated Sep 2021)