Skip to content

Instantly share code, notes, and snippets.

@akissinger
akissinger / comb_disintegration.py
Last active December 20, 2022 01:36
Demonstration of comb disintegration for causal inference
from sympy import *
from sympy.physics.quantum import TensorProduct
# composition is '*'
# monoidal product
def T(*args):
if len(args) == 0: return Matrix([[1]])
elif len(args) == 1: return args[0]
else: return TensorProduct(*args)
@akissinger
akissinger / zipper.ML
Created July 4, 2014 11:56
Translated from Huet's "The Zipper"
datatype 'a tree = Item of 'a | Section of 'a tree list
datatype 'a path = Top | Node of 'a tree list * 'a path * 'a tree list
exception zipper_exn of string
fun mk_zipper (t: 'a tree) = (t, Top : 'a path)
fun go_left (_, Top) = raise zipper_exn "cannot go left from Top"
| go_left (t, Node(l::left,up,right)) = (l, Node(left,up,t::right))
| go_left (_, Node([],_,_)) = raise zipper_exn "cannot go left from leftmost child"
@akissinger
akissinger / keychain.rb
Created May 16, 2012 12:55 — forked from cyberfox/keychain.rb
Convert OS X Keychain exported entries into logins for 1Password import
#!/usr/bin/env ruby
#
# Usage:
# security dump-keychain -d login.keychain > keychain_logins.txt
# # Lots of clicking 'Always Allow', or just 'Allow', until it's done...