planck

Planck ClojureScript REPL
slipset 2017-03-07T09:03:31.000702Z

almost seems (from your, I imagine, way too simple example) that you could stick a set of parens around the string and read it.

slipset 2017-03-07T09:05:13.000703Z

as in (clojure.edn/read (make-stream (str “(” the-thing-to-parse “)”)))

slipset 2017-03-07T09:05:29.000704Z

where make-stream is left as an exercise for the interested reader.

gamecubate 2017-03-07T17:15:59.000705Z

@slipset I guess I like to complicate things. The planck test is however for a larger front-end (web, i.e., CLJS) project. Just needed to do some tests w. planck.

gamecubate 2017-03-07T17:17:43.000706Z

New topic. I’ve been given a dataviz project this morning. I need to parse a 15,000,000 row csv file of traffic measurements data and a planck script seems appropriate for the processing/reduction of said data so that it can be mapped affordably (small bandwidth requirements) by client browsers.

gamecubate 2017-03-07T17:18:26.000707Z

Hence this quick question: what would you recommend for conversion of clojure structures into json strings?

gamecubate 2017-03-07T17:18:41.000708Z

This may seem simple but I have never had to deal with clj->json stuff.

gamecubate 2017-03-07T17:18:52.000709Z

So, sorry for what may seem like too simple a question.

gamecubate 2017-03-07T17:20:06.000710Z

Googled for it…

org.clojure/data.json
seems good for that.

gamecubate 2017-03-07T17:28:46.000711Z

Question: is there an equivalent to “planck -c <jar>” for (planck) shell scripts?

mfikes 2017-03-07T17:30:26.000712Z

On macOS, the shabang mechanism lets you add the desired arguments

gamecubate 2017-03-07T17:36:06.000713Z

Hmmm, as in

#!/usr/bin/env planck -c some.jar
… I hadn’t thought of that. Thanks @mfikes.

mfikes 2017-03-07T17:36:24.000714Z

Yes. I believe this won’t work on Linux.

gamecubate 2017-03-07T17:50:38.000715Z

Not working it seems (at least for org.clojure/data.json)...

gamecubate 2017-03-07T17:50:57.000716Z

The jar is in my .m2 repository

gamecubate 2017-03-07T17:51:17.000717Z

More precisely:

~/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar

mfikes 2017-03-07T17:52:47.000718Z

clojure data.json is a Clojure library

gamecubate 2017-03-07T17:53:22.000719Z

Yet,

#!/usr/bin/env planck -c "src:~/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar"

(ns process.core
  (:require [planck.core :as core :refer [slurp *command-line-args*]]
                 [org.clojure/data.json :as json]))
reports
No such namespace: org.clojure/data.json, could not locate org/clojure_SLASH_data/json.cljs, org/clojure_SLASH_data/json.cljc, or Closure namespace “data.json”

gamecubate 2017-03-07T17:53:33.000720Z

Thought that was the problem.

mfikes 2017-03-07T17:53:42.000721Z

Right; it speaks the truth.

gamecubate 2017-03-07T17:53:52.000722Z

Need to find a cljs-bootstrapped data -> json lib.

gamecubate 2017-03-07T17:53:59.000723Z

Search continues.

gamecubate 2017-03-07T17:58:32.000724Z

Almost too simple. What was I thinking?!

(defn -&gt;json [edn]
  (.stringify js/JSON (clj-&gt;js edn)))
and
(defn -&gt;edn [json]
  (js-&gt;clj (.parse js/JSON json) :keywordize-keys true))