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
(ns replicate.tree
[clojure.walk
:refer [postwalk]]))
(defprotocol NodeStore
(persist [store node])
(fetch [store node-hash]))
(defprotocol Node
(insert [node k store])
@moea
moea / datahike_scratch.clj
Last active July 19, 2020 13:56
invariant + Datahike Example
(ns invariant.datahike-scratch
(:refer-clojure :exclude [+])
(:require [invariant.datahike
:refer [+]]
[datahike.api :as d]
[datahike.core :as dc]))
(defn query [q conn tx]
(d/q q
@conn
;; I would suggest that we use either 'datopia' or 'datopia.db' as the namespace
;; for the schemas, rather than 'db'. For users, I suspect 'db' will seem arbitrary
;; and incongruous (as it does to me, in this context).
#:datopia {:attribute :datopia.ednt/balance
:schema #:db {:cardinality :db.cardinality/one
:valueType :db.type/bigdec}
:invariant <inline query graph as map of keyword -> query,
or maybe just inline query, initially. having
@moea
moea / input.clj
Last active November 13, 2018 14:12
(ns stickler.core
(:require [clojure.java.io :as io]
[camel-snake-kebab.core :refer [->kebab-case]])
(:import [com.squareup.wire.schema Schema SchemaLoader ProtoType])
(:gen-class))
(def ^:dynamic package-renames {})
(def ^:dynamic ->field-name ->kebab-case)
(def ^:dynamic ->type-name ->kebab-case)
@moea
moea / 0.sh
Last active October 12, 2018 19:42
Machine Setup
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
set -e
sudo add-apt-repository universe
apt-add-repository -y ppa:teejee2008/ppa
apt-get update
apt-get install -y ukuu
import sys, rlp, leveldb
from ethereum import trie
db = leveldb.LevelDB('/tmp/xyz')
class X:
def get(self, a):
return db.Get(a)
def put(self, a, b):
(let [bid-duration (t/days 10)
reveal-duration (t/days 12)]
(fsm
:store {high-bid 0
high-bidder nil
returns {}
created (from :time)}
:states [:bid (<= bid-duration (t/interval created (:time tx)))
:reveal (<= reveal-duration (t/interval created (:time tx)))
:finish
@moea
moea / gl.py
Last active March 29, 2018 10:31
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from PIL import Image
from PIL import ImageOps
import sys
width, height = 3840, 1920
service: aws-polling-task-scheduler
provider:
name: aws
runtime: nodejs4.3
environment:
RATE: 300
TASK_TABLE: ${self:service}-${opt:stage, self:provider.stage}-tasks
TOKEN_INDEX: ${self:service}-${opt:stage, self:provider.stage}-tasks-by-token
iamRoleStatements:
@moea
moea / x.sh
Last active March 15, 2016 22:28
#!/usr/bin/env bash
set -e -o pipefail
API_NAME=
SLACK_TOKEN=
while [[ 1 < $# ]]; do
key="$1"
case $key in