This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-17
Channels
- # announcements (6)
- # babashka-sci-dev (6)
- # beginners (99)
- # biff (3)
- # cider (4)
- # clerk (44)
- # clj-kondo (2)
- # clojure (65)
- # clojure-europe (57)
- # clojure-germany (5)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-spec (19)
- # clojure-uk (3)
- # clojurescript (8)
- # conjure (3)
- # cursive (21)
- # datahike (19)
- # datomic (1)
- # events (7)
- # fulcro (14)
- # graalvm (3)
- # gratitude (1)
- # guix (5)
- # honeysql (1)
- # humbleui (19)
- # hyperfiddle (39)
- # lsp (4)
- # malli (7)
- # music (1)
- # off-topic (33)
- # pathom (65)
- # re-frame (9)
- # reagent (3)
- # reitit (6)
- # releases (1)
- # sql (15)
- # tools-build (7)
- # vim (5)
- # xtdb (16)
hello, team. First of all thanks for this wonderful tool it's great! I was wondering if if was possible to use clojure-mode to display a code editor instead of just rendering code?
hello, yes, there’s some examples around this in https://github.com/nextjournal/clerk/blob/471c270f492f3d9ffa427aeaefe29a375770c8b4/notebooks/viewers/code.clj
thanks!
Let's say I setup these code viewers and I edit some code in the browser. How would you eval it? Is is possible?
Yeah you have the full SCI environment available
https://github.com/mentat-collective/clerk-utils/tree/main/resources/clerk_utils/custom
I'm thinking about kind of codox replacement done in Clerk. With a little macro it's doable and looks nice for me. The only question is: is it possible to add entries to the TOC? 🧵
(def source-files " ")
(defn args->call [f args] (conj (seq args) f))
(defn make-public-fns-table
[ns]
(let [publics (->> (ns-publics ns)
(map (comp meta second))
(sort-by :name))]
(clerk/html
[:div (for [{:keys [name file macro arglists doc line const]} publics
:when arglists]
[:div {:class "pb-8"} ;; add border
(clerk/html [:span [:b {:class "underline decoration-2 decoration-sky-500"} name]
[:sup [:a {:href (str source-files file "#L" line)} " [source]"]]
(when macro [:sup " MACRO"])
(when const [:sup " CONST"])])
[:p]
[:div (for [args arglists]
(clerk/code (args->call name args)))]
[:p]
[:div (clerk/md (str (or doc "\n")))]])])))
(make-public-fns-table 'fastmath.core)
@U017QJZ9M7W got it:
Amazing
(def source-files " ")
(defn args->call [f args] (conj (seq args) f))
(defn fix-tex [s] (str/replace s #"\\\\\(|\\\\\)" "\\$"))
(defn fix-anchor [s] (str/replace s #"\[\[(.+?)\]\]" "[$1](#LOS-$1)"))
(defn make-public-fns-table
[ns]
(let [publics (->> (ns-publics ns)
(sort-by first)
(map second))]
(clerk/html
[:div (for [v publics
:let [{:keys [name file macro arglists doc line const]} (meta v)]]
[:div {:class "pb-8" :id (str "LOS-" (clojure.core/name name))} ;; add border
(clerk/html [:span [:b {:class "underline decoration-2 decoration-gray-400"} name]
(when macro [:sup " MACRO"])
(when const [:sup " CONST"])
[:sup [:a {:href (str source-files file "#L" line)} " [source]"]]])
[:p]
(when const [:div (clerk/code (var-get v)) [:p]])
(when arglists [:div
[:div (for [args arglists]
(clerk/code (args->call name args)))]
[:p]])
[:div (clerk/md (->> (or doc "\n") str fix-tex fix-anchor))]])])))
https://generateme.github.io/fastmath/notebooks/notebooks/random.html#list-of-symbols
hello, when using clerk/vl
how do we actually pass it data? is it required to write data out to a CSV file which is then somehow served by clerk server to clerk on the browser?
alright, thanks!
@U050AACJB some bad helper code I've made for doing line and line/ribbon charts https://gist.github.com/otfrom/2785ab6767d2e887d6f44e357b968f9f (don't know if this is what you need or not)
@U0525KG62 thanks! I don’t even know what ribbon charts are, but I’ll study your code closely as I’m just starting out with clerk!
axes and legends clipped to protect clients. This was tricky due to how vega handles legends
oh these look nice
(thx to @U04JZRX0GV7 for figuring out how to do it)
I have stuff that takes too long to run (10+ minutes) so I think I’ll isolate these in namespaces that clerk doesn’t watch and use the workbook namespaces for the lighter results exploration/viz part of the job
not if it’s 1000 requests to a 3rd party service 😅
> I have stuff that takes too long to run (10+ minutes) so I think I’ll isolate these in namespaces that clerk doesn’t watch and use the workbook namespaces for the lighter results exploration/viz part of the job (edited)
I was in a similar situation some time ago -- loading lots of usage data from https://www.sanity.io/ to analyze what kind of usage we had over the last few years. I tried using Clerk for everything at first, but wan't happy with the performance. Randomly having to wait a minute or two for the first clerk page load wasn't too nice!
I ended up with a solution similar to yours -- splitting the "load all the data" code from "analyze it", and was really happy with that. Pulled out the "load all the data" code as a function I could execute with clj -x my.stuff/load-my-data
. Then the clerk notebooks read that data from disk, and were snappy and easy to work with.
It was also really nice to have a clean separation between raw data and "the data in the shape that I'd like".
That’s nice, and saving to disk is something I also ended up doing. Was the load-my-data
part a long doseq
?
yup! Something like this:
(doseq [y (range 2019 2023)]
(print "Dumping transactions for" y "...")
(dump-transactions-year! y)
(println " done!"))
I’m thinking about how long running jobs like that could be monitored on a personal REPL level (rather than monitoring in a production deployment which is a solved problem).
oh, gotcha. For me, downloading all the data took about a minute, so perhaps less than you have to deal with. Splitting the data into chunks so that (A) each chunk was quite fast (seconds) to download, and (B) was stored in its own file helped a lot for me. I had lots of data like this:
data-dump/DOMAINTERM-2019.edn
data-dump/DOMAINTERM-2019.json
[...]
My download functions reported some progress (println) as they were going. I could run them from a REPL. In that case, I could cider-interrupt
to stop downloading. I got some measure of progress from looking at the folder content.There might be better solutions -- I didn't spend more time than I needed to. I was more curious about what I could learn from the data than the downloading itself.
Yeah doesn’t sound like you needed anything more sophisticated than that! I have a more granular list of items
Let's say I setup these code viewers and I edit some code in the browser. How would you eval it? Is is possible?