Skip to content

Instantly share code, notes, and snippets.

View moea's full-sized avatar

Moe Aboulkheir moea

  • Nervous Systems, Ltd.
  • London
View GitHub Profile
@moea
moea / gadt.clj
Last active March 26, 2025 17:52
Typechecking for GADTs in Clojure
(ns thebes.gadt
(:require [clojure.string :as str]
[clojure.walk :as walk]))
(defrecord TypeVar [name])
(defrecord Variant [name tag params ret-type])
(defrecord TypeApp [name args])
(defn type-var? [t] (instance? TypeVar t))
(defn variant? [t] (instance? Variant t))
(ns assistant.reader
(:import [java.io PushbackReader StringReader]))
(defprotocol Reader
(read-char [this])
(peek-char [this])
(unread-char [this ch])
(eof? [this]))
(extend-type PushbackReader
#lang turnstile/base
(provide (type-out →) λ #%app ann #%module-begin #%top-interaction require)
(require (for-syntax "util/filter-maximal.rkt"))
(define-binding-type ∀)
(define-typed-syntax (Λ (tv:id ...) e) ≫
[[tv ≫ tv- :: #%type] ... ⊢ e ≫ e- ⇒ τ]
@moea
moea / arcs.cljs
Last active December 27, 2022 09:15
SVG Elliptical Arc to Chord Approximation
;; NB there is a bug when switching between circles/ellipses. Anyone spot it?
(ns perturb.arcs
(:require [perturb.util
:refer [cos
sin
PI
TAU
avg
rad
@moea
moea / interp.cljc
Created December 27, 2022 09:07
Catmull-Rom Interpolation - Points to Cubic Bezier Curves
(ns perturb.interp)
(defn pts->path [pts]
(flatten
(into [(into ["M"] (first pts))]
(for [pt (rest pts)]
(into ["L"] pt)))))
(let [v 6
c (fn cubic [[x0 y0] [x1 y1] [x2 y2] [x3 y3]]
#!/usr/bin/env python3
from oso import Oso, Relation
from dataclasses import dataclass
from functools import partial
policy = """
actor User {
}
#!/usr/bin/env python3
from oso import Oso, Relation
from dataclasses import dataclass
from functools import partial
policy = """
actor User {
relations = {groups: Group};
}
@moea
moea / oso_failing_example.py
Last active December 18, 2021 08:38
Failing OSO Example
#!/usr/bin/env python3
from oso import Oso, Relation
from dataclasses import dataclass
from functools import partial
policy = """
actor User {}
resource Group {
relations = {network: Network};
(ns forestry.rb
(:require [clojure.core.match :refer [match]]
[forestry.node :as n])
(:refer-clojure :exclude [find key val replace]))
(defprotocol -RedBlackNode
(color [node])
(blacken [node])
(-add [node k v])
(balance [node])
(ns abci.example.kv
(:require [abci.host :as host]
[abci.host.middleware :as mw]
[datahike.core :as dc]
[datahike.tools :as d.tools]
[datahike.api :as d]
[konserve.core :as k]
[hasch.core :as h]
[taoensso.timbre :as log])
(:gen-class))