Skip to content

Instantly share code, notes, and snippets.

Idle*
call registration API -> Register display
display connects -> Display connection
mobile message -> Mobile
display message -> Display
Message Server
Register display
display registered -> Idle
# Respond with error
@abp
abp / SketchSystems.spec
Last active June 27, 2018 12:36
Message Server
Message Server
Idle*
mobile message received -> Mobile client
display message received -> Display client
registration API called -> Register display
Register display
display registered -> Idle
# Respond with error
error occured -> Idle
Login message
(require '[schema.core :as s])
(require '[schema.coerce :as coerce])
(require '[schema.utils :as utils])
(defn filter-schema-keys
[m schema-keys extra-keys-walker]
(reduce-kv (fn [m k v]
(if (or (contains? schema-keys k)
(and extra-keys-walker
(not (utils/error? (extra-keys-walker k)))))
@abp
abp / README.md
Created July 31, 2013 11:51 — forked from bodil/README.md

core.async example thing

To run:

  • checkout https://github.com/clojure/core.async and install it using lein install
  • make a project directory for this code
  • put omgcoreasync.cljs in a src subdirectory, project.clj and index.html in the root
  • go lein cljsbuild once to build
  • load index.html in a browser and watch it go
@abp
abp / draft.txt
Last active December 13, 2015 19:59
Every request is an endpoint to start some computation.
The input is the request, the output is the response.
Typical stages between those are:
Parsing, validation, storage, retrieving stored data and rendering an output.
Based on Ring and Compojure, we do the following to integrate routes with
Prismatic Graph:
Compojure matches the request against routes, calling the route handlers,
until a non nil result is returned.
Routes for integration with the Graph return route-keys,
(def g
{:a 1
:d/b 2
:b/a (fnk [a] (* a 7))
:x (fnk [b/a [d/b 2] [c 3]] (+ b/a d/b c))})
(def cg (compile-graph g))
(iterate cg)
; => {:x 12, :b/a 7, :d/b 2, :a 1}
(defn unresolvable-syms [form]
(let [usyms (atom #{})
_ (postwalk
#(do
(when (and (symbol? %) (nil? (resolve %)))
(swap! usyms conj %))
%) form)]
@usyms))
(defmacro exk [& args]
@abp
abp / graph.clj
Last active October 13, 2015 04:57
Dependency graph iteration. (Part of lib to come soon)
(defn iterate
([graph]
(iterate graph {}))
([graph state]
(iterate graph state
(->> graph
:topo-sort
(remove nil?)
first
fnk->key)))
@abp
abp / gist:4118735
Created November 20, 2012 15:50 — forked from lynaghk/gist:4116442
Possible syntaxes for flexible unifier w/ multi-lvar constraints
;;Support for simple constraints on lvars during unification was added in 76fd4d7c:
;;
;; https://github.com/clojure/core.logic/commit/76fd4d7c155161d74ad5cd8d87955148eece1fe0
;;
;;but these constraints apply to a single lvar only.
;;The unifier could support more general constraints if it accepted an explicit predicate function.
;;For instance, given this `data-numeric?` predicate and `spec` data:
(defn data-numeric? [data dimension]
@abp
abp / codeq-examples.clj
Created November 20, 2012 02:36 — forked from richhickey/codeq-examples.clj
codeq examples used in conj talk
(require '[datomic.api :as d])
(require '[clojure.pprint :refer [pprint]])
(def uri "datomic:free://localhost:4334/git")
(def conn (d/connect uri))
(def db (d/db conn))
;; committers
(d/q '[:find ?email
:where
[_ :commit/committer ?u]