Skip to content

Instantly share code, notes, and snippets.

(page "index.html"
(:require-macros [fogus.datalog.bacwn.macros :refer (facts <- ?- make-database)])
(:require [fogus.datalog.bacwn :as bacwn]
[fogus.datalog.bacwn.impl.rules :refer [rules-set]]
[fogus.datalog.bacwn.impl.database :refer [add-tuples]]
[fogus.datalog.bacwn.impl.syntax :refer [explode]]
[tailrecursion.hoplon :refer [do!]]))
;;; Schema & initial data
(import 'clojure.lang.ExceptionInfo)
(defn call-cc [f]
(let [v (promise)
e (ex-info "cc" {:v v})]
(try (f #(do (deliver v %) (throw e)))
(catch ExceptionInfo ex
(if (identical? ex e)
@(:v (ex-data ex))
(throw ex))))))
(extend-type js/jQuery.Event
cljs.core/IDeref
(-deref [this] (-> this .-target js/jQuery .val)))
;; (input :type "text"
;; :click #(.log js/console @%)
;; :value "hello")
(page "index.html"
(:require-macros [paranav :refer [dbg]])
(:require [tailrecursion.hoplon.reload :refer [reload-all]]
[clojure.zip :as z]))
(def $ js/jQuery)
(when (-> js/window .-location .-hostname (= "localhost")) (reload-all))
(defn ->attr-map "(HLisp attrs workaround)" [m]
@alandipert
alandipert / seeing.clj
Created April 22, 2014 19:28
seeing.clj
(defmacro seeing [& body]
`(do
(println "environment"
~(->> (keys &env)
(mapcat #(vector `'~% %))
(apply hash-map)))
(let [res# (do ~@body)]
(println "return value" res#)
res#)))
@alandipert
alandipert / gist:11369611
Last active August 29, 2015 14:00
index.cljs.hl
(page "index.html"
(:require [tailrecursion.hoplon.reload :refer [reload-all]]
[goog.string.format]
[goog.string :as gstr]))
(when (-> js/window .-location .-hostname (= "localhost")) (reload-all))
;;; cells
(defc persons

And now, by the immortal gods! I think nothing more happy than that generation of men we commonly call fools, idiots, lack-wits, and dolts; splendid titles too, as I conceive them. I'll tell you a thing, which at first perhaps may seem foolish and absurd, yet nothing more true. And first they are not afraid of death—no small evil, by Jupiter! They are not tormented with the conscience of evil acts, not terrified with the fables of ghosts, nor frightened with spirits and goblins. They are not distracted with the fear of evils to come nor the hopes of future good. In short, they are not disturbed with those thousand of cares to which this life is subject. They are neither modest, nor fearful, nor ambitious, nor envious, nor love they any man. And lastly, if they should come nearer even to the very ignorance of brutes, they could not sin, for so hold the divines. And now tell me, you wise fool, with how many troublesome cares your mind is continually perplexed; heap together all the discommodities of your life,

In gherkin line 37:
pb_get="^$"
^-- SC1000: $ is not used specially and should therefore be escaped.
In gherkin line 38:
pb_unget="^$"
^-- SC1000: $ is not used specially and should therefore be escaped.
(defn make-page
[text form-zippers]
(flow/build-dataflow
[(flow/cell :source cursor 0)
(flow/cell :source zippers form-zippers)
(flow/cell current-zipper (get ?zippers ?cursor))
(flow/cell printed-zippers (mapv (comp print-clojure z/root) ?zippers))
(flow/cell strings (mapv str ?printed-zippers))
(flow/cell offsets (vec (cons 0 (reductions + (map (comp inc count) ?strings)))))
(flow/cell current-printed (?printed-zippers ?cursor))
//my broken thing :-(
macro formula {
rule {
$name ($args (,) ...) { $body ... }
} => {
// how to splice args?
var $name = mori.formula(function($args) { $body })($args);
}
}