This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-17
Channels
- # beginners (26)
- # calva (7)
- # cider (6)
- # cljs-dev (7)
- # clojure (86)
- # clojure-europe (1)
- # clojure-finland (1)
- # clojure-spec (3)
- # clojure-uk (11)
- # clojurescript (18)
- # cursive (6)
- # data-science (1)
- # emacs (13)
- # fulcro (34)
- # juxt (8)
- # nrepl (6)
- # off-topic (11)
- # pathom (25)
- # re-frame (13)
- # reitit (11)
- # shadow-cljs (4)
- # spacemacs (3)
Kaocha seems state of the art. For simple test running, there is test-runner from cognitec-lab
Both have a CLI, so you.can run them from emacs in theory, but you dont have ab emacs mode or anything integrating them first class inside emacs
specifically I want something I can run from within Emacs. I’ve never bothered to set it up before :x
Hum, just use Cider then https://cider.readthedocs.io/en/latest/running_tests/
I'm stuck trying to write this macro:
(ns myns.util
(:require [herb.core :refer-macros [<class]]))
(defmacro defstyled [fn-name bindings el stylem]
`(defn ~fn-name [~'attrs & ~'body]
(let [body# (if (map? ~'attrs) ~'body (conj ~'body ~'attrs))
attrs# (if (map? ~'attrs) ~'attrs nil)]
(letfn [(~fn-name ~bindings ~stylem)]
(into [~el (merge {:class (herb.core/<class ~fn-name attrs#)}
attrs#)]
body#)))))
I want to make it so the call to <class
only includes attrs#
if it's non-nil.
So in the above example, if attrs#
is nil it should be (herb.core/<class ~fn-name)
instead.
I've tried many ways to do this; with a simple if or concat, but I can't get it to work.Sounds like a place where you want to unquote splice a collection instead
~@(when attrs# [attrs#])
?
The trick being that unquote splicing an empty collection yields nothing, not nil
that's cool to know! sadly I get a compiler exception syntax error, and my linter tells me it's unable to resolve the symbol attrs# inside that form. could it be because attrs# is defined when the returned function is run, not the macro?
I feel I'm a bit closer with (apply herb.core/<class ~fn-name (if (map? attrs#) [attrs#] []))
but I get Can't take value of macro herb.core/<class
so I guess I'm messing up the quoting somehow?
oh right, attrs# is defined inside the code you're generating so isn't available to unquote
I mean you could just put an if
around the call to <class in the generated code
(defmacro defstyled [fn-name bindings el stylem]
`(defn ~fn-name [~'attrs & ~'body]
(let [body# (if (map? ~'attrs) ~'body (conj ~'body ~'attrs))]
(letfn [(~fn-name ~bindings ~stylem)]
(into [~el (merge {:class (if (map? ~'attrs) (herb.core/<class ~fn-name ~'attrs) (herb.core/<class ~fn-name))}
attrs#)]
body#)))))
Today I get an idea to focus 80% of my time on open source / documentations / tutorials , because I like make solutions for other developers. But I don’t see how I could survive doing this considering money vs contracts. I didn’t think how to monetise open source before too much. Does it make sense? Probably not 🙂 Anybody here (as a person, not corporation) make money doing mostly open source? 🙂
Patreon is working quite nicely. Some software devs are making a proper salary out of it. Personally I donate to a handful of Patreon projects. I would mix that with a "N versions back" model. It's briefly mentioned here https://ayende.com/blog/186147-A/making-money-from-open-source-software-how-we-do-it (the author doesn't like it, I do) i.e. open-source n-versions-back releases on a continuous basis, while the latest-and-greatest release is closed-source and paid
Not really. Cognitect and bbatsov are only collecting a couple hundred dollars / month. But my thinking is, if you go boldly for it why would it not succeed? i.e. when you give people an incentive to use Patreon (or other), they will do it
Hmm even if I will do super great tools as open source it is for free, so who will pay for that? 😉
I am afraid it is way to do things only for fun, but not as everyday job, because of money.
I don't think many are doing n-versions-back. I'd give a think to that. Not apt for libraries, but yes for things like IDEs DBs etc
Why doesn't (doseq [f [inc dec +]] (doc f))
print doc?
the symbols are being resolved to functions and doc takes symbols. quote to avoid evaluation
actually since doc is a macro, you might need to do more than that to get doc evaluated with the actual symbol
Yeah. That didn't work 🙂
user=> (doseq [f `(inc)] (println f)(doc f))
clojure.core/inc
Hee hee. Sometimes, these things are trickier than you assume
clojure.repl/print-doc
isn't public
whats the best library to consume chunked/streamed http responses? something that takes a callback or returns a channel and can automatically parse json chunks
The closest I could get to seems to be this: https://github.com/dakrone/cheshire/issues/62 (mixing stream and laziness is confusing)…
As for the underlying stream itself, look like manifold is a widely supported substrate (you can convert it to other representations, such as core.async, later)… then use the client side of aleph/http-kit to read. (http-kit is old though)
(btw… anyone know if there’s activity in this space? my general feeling is that things almost/mostly “work”, but are not as polished as the more mainstream use case)
I'd like to serialize some data structure in EDN. (spit)
-ing it loses M
suffix on BigDecimal
objects. Is there a way to avoid that (or maybe I'm using a wrong tool?)
Shouldn’t you use (pr-str {:number 3M})
if you want to write edn?
% clojure -e '(spit "foo.edn" 3M)'
% cat foo.edn
3
% clojure -e '(spit "bar.edn" {:number 3M})'
% cat bar.edn
{:number 3M}
%
so the difference is that RT.java prints bigdecs with the M added. so if you str a map you end up here but if you just str the big dec you get the bigdec's version of what a string is
else if(x instanceof BigDecimal && readably) {
w.write(x.toString());
w.write('M');
}
Right. Now I need to trace why it happens inside a large Clojure structure as well.
any chance you have a stringbuilder anywhere and you're building up the string yourself?
Nope, I'm getting the data from API endpoint, clj-http.client
passes it through cheshire
, I wrap it into top-level map and spit.
can json express BigDecimal? and are you sure that its coming out of cheshire correctly? Also, is perhaps cheshire doing that? are you keywordizing the keys? maybe cheshire reduces over vals and strs them manually which would exemplify this behavior
(reduce (fn [acc [k v]] (assoc acc (keyword k) (str v)))
{}
{"number" 3M})
{:number "3"}
Cheshire has a specific option, and I use it: (binding [cheshire.parse/*use-bigdecimals?* true] ...)
Hmm, I wonder if clj-http
has a pool inside that might interfere with that... Let me check.
its kinda worrying that the string representation of BigDecimals changes on context due to RT
So that's the crux of the problem, one of numbers was an integer and hasn't got converted.
I would expect that str
calls into RT.print
(that falls back to .toString for types it does not know) instead of .toString
. Perforrmance? ¯\(ツ)/¯
yeah it seems like it. but i don't know the details of pr-str vs str and print-dup and all that machinery. but i'm surprised that (str 3M) and (str {:x 3M}) are so different. It feels wrong but maybe this usage is above a simple str
call
Most of special cases in RT.print
produce output different from their built-in .toString
function.
@dpsutton https://dev.clojure.org/jira/browse/CLJ-2485 — I don't expect it to be fixed though.
we'll see. I expect thoughtful discussion. I don't know what the conclusion of that will be.
I thought you would be able to use print-method
for this to change the printing of the various types, but trying to inspect the actual object leads to a StackOverflowError for some reason:
(defmethod print-method clojure.lang.PersistentArrayMap [o ^java.io.Writer w] (.write w "changed"))
#multifn[print-method 0x41358378]
user> {}
changed
;; Trying to change the print method by using the actual object leads to StackOverflowError:
user> (defmethod print-method clojure.lang.PersistentArrayMap [o ^java.io.Writer w] (.write w (str o)))
#multifn[print-method 0x41358378]
Exception updating the ns-cache #error {
:cause nil
:via
[{:type java.lang.StackOverflowError
:message nil
:at [clojure.lang.Var deref Var.java 197]}]
:trace
(...)
There’s the comma
The closest I could get to seems to be this: https://github.com/dakrone/cheshire/issues/62 (mixing stream and laziness is confusing)…