Skip to content

Instantly share code, notes, and snippets.

@dpsutton
dpsutton / future-utils.clj
Last active May 17, 2020 16:58
ghadi's completeable future helpers from slack
(defn ->Function
[f]
(reify java.util.function.Function
(apply [_ obj] (f obj))))
(defn future-map
[cf f]
(.thenApply cf (->Function f)))
(defn future->ch
([cf]
(future->ch cf (async/chan 1) true))
(ns app.main
(:require ["react-dom" :as rdom]
[helix.core :as hx :refer [defnc $ <>]]
[helix.dom :as d]
[helix.hooks :as hooks]
[clojure.core.async :as a :refer [go-loop]]))
(defnc greeting
"A component which greets a user."
[{:keys [name]}]
while inotifywait -e modify -r .
make test
end
@dpsutton
dpsutton / source.el
Created November 11, 2019 05:24
find source and display
(defun cider-tooltip-source ()
(interactive)
(let* ((sym (thing-at-point 'symbol))
(response (cider-nrepl-send-sync-request
(list "op" "eval"
"code"
(format
"(do (require 'clojure.repl) (with-out-str (clojure.repl/source %s)))"
sym)))))
(when-let ((source (nrepl-dict-get response "value")))
(define (atom? x) (not (pair? x)))
(define wrong 'wait)
(define the-false-value (cons "false" "boolean"))
(define (evaluate e env)
(if (atom? e)
(cond ((symbol? e) (lookup e env))
((or (number? e) (string? e) (char? e) (boolean? e) (vector? e))
e)
(else (wrong "Cannot evaluate" e)))
.collapsible button.collapsible-collapse-handle:after {
content: "►";
}
.collapsible.collapsed button.collapsible-collapse-handle:after {
content: "▼";
}
.collapsible .collapsible-collapse-handle {