Skip to content

Instantly share code, notes, and snippets.

(* #require "containers";; *)
(* open Containers;; *)
type expr =
| Hole
| One
| Plus of expr * expr
type t = int * (expr list -> expr)
dariusf / Makefile
Created Mar 10, 2022
Reproduce bytecode test bug
View Makefile
dune test --verbose
-> start
=== start ===
Let's begin today's standup.
// This records energy level
How are you feeling today?
+ [Green]
dariusf /
Last active Nov 1, 2021
Drawing stack and heap diagrams
#!/usr/bin/env python
# Author: Darius Foo (
# License: GPLv3
import re
from collections import namedtuple
Frame = namedtuple('Frame', ['fn', 'slots'])
Slot = namedtuple('Slot', ['name', 'value'])
dariusf /
Created Nov 1, 2021
Visualize Z3's proofs
#!/usr/bin/env python
# Author: Darius Foo (
# License: GPLv3
from z3 import *
s = Solver()
dariusf / extractHighlighted.vb
Last active Jul 22, 2021
Extract highlighted words
View extractHighlighted.vb
Sub extractHighlighted()
Dim objUndo As UndoRecord
Set objUndo = Application.UndoRecord
objUndo.StartCustomRecord ("Extract Highlighted Text")
Selection.HomeKey wdStory, wdMove

We're looking for pairs of customers who like exactly the same pizza, i.e. their respective sets of liked (and disliked) pizzas are equal.

To get this, we can find customers who differ in their preferences and take the complement of that. The general structure of the answer is thus:

all_pairs_of_customers = ...
customers_who_differ = ...
query = all_pairs_of_customers - customers_who_differ
View interstellar.lp
% clingo 5 version of
%#script (lua) function min(a,b) return math.min(a,b) end #end.
#script (python)
def min1(a,b):
return min(a,b)
%% Adam's minimal event calculus formalism:
%% - only true holds/happens are tracked
View Dockerfile
FROM openjdk:8
# Has Java, Python, git
# This installs lsb_release
RUN curl -sL | bash - && apt-get install -y nodejs
# Install Google Cloud SDK
RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl | apt-key add - && \
dariusf / pp.lp
Created Oct 31, 2017
Make clingo output JSON
View pp.lp
#script (python)
from __future__ import print_function
import clingo
import json
def to_json(symbol):
s = {}
if symbol.type == clingo.SymbolType.Number:
s['value'] = symbol.number