This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-03
Channels
- # adventofcode (49)
- # bangalore-clj (1)
- # beginners (56)
- # berlin (1)
- # chestnut (6)
- # cljs-dev (5)
- # clojure (48)
- # clojure-greece (29)
- # clojure-russia (3)
- # clojure-spec (5)
- # clojure-uk (3)
- # clojurescript (28)
- # cursive (25)
- # emacs (3)
- # fulcro (123)
- # hoplon (2)
- # klipse (6)
- # off-topic (146)
- # om (11)
- # re-frame (29)
- # reagent (7)
- # reitit (3)
- # specter (11)
- # unrepl (4)
- # yada (3)
I’ve created a new project using chestnut
template and when I do lein install
, it throws this error:
Cannot run program "sassc": error=2, No such file or directory
once I remove this bit from my project.clj it works:
:sassc [{:src "src/scss/style.scss"
:output-to "resources/public/css/style.css"}]
:auto {"sassc" {:file-pattern #"\.(scss)$"
:paths ["src/scss"]}}
(reduce * (int-array [1 2 3 4]))
<-- why does this code work? what is causing the reduce to be able to handle what I believe to be a JVM object
to be pedantic, if you are using clojure on the jvm, everything in clojure is a JVM object
clojure happens to define its core functions in terms of some basic Interfaces and Classes, including Arrays
@qqq It goes like this: reduce -> coll-reduce -> protocol on type "Object" -> seq the given array -> ArraySeq_int
-> Faster internal reduce on it.
@qqq Actually, this is wrong: Check out:
(reduce (fn [_ _]
(try (throw (Exception.)) (catch Exception ex ex)))
0 (int-array [0 1]))
It'd would use a faster internal reduce if you seq your array beforehand, it's more than 2x faster with (reduce ... (seq (int-array ...))
@bronsa It's just a little hack to see get the stacktrace so I could see how the reduce function is called. With (seq (int-array ...)
it shows nicely it's called from ArraySeq_int.reduce
@bronsa Do you think (reduce ... ... some-array)
should also end up in ArraySeq_int.reduce
? I could create a ticket for it..
has anyone ever had a problem with clj-http
when using :as :clojure
? i.e.
(client/get "" {:as :clojure})
I’m getting the following in my browser
Invalid keyword: .
and when adding
[org.clojure/tools.reader "1.1.1"]
to my deps, CIDER dumps the following
WARN: org.clojure/clojure version 1.5.1 requested, but 1.8.0 already on classpath.
WARN: org.clojure/tools.reader version 1.1.1 requested, but 1.0.0 already on classpath.
Dependencies not loaded due to conflict with previous jars :
[[org.clojure/clojure "1.5.1"] [org.clojure/tools.reader "1.1.1"]]
@bravilogy The contents of foo.clj might be up for question
@bravilogy but, valid clojure is not the same as valid json
Actually, there is… https://github.com/clojure/data.json
@bravilogy can you take a look at this.
@bravilogy Does :as :json
not do that for you already?
@bravilogy do you have a dependency on cheshire?
as I read in clj-http
docs, :as :json
requires cheshire
lib. and when I add that to my deps, I get
[[cheshire "5.8.0"]
[tigris "0.1.1"]
[com.fasterxml.jackson.core/jackson-core "2.9.0"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.9.0"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.9.0"]]
Dependencies not loaded due to conflict with previous jars :
[[org.clojure/clojure "1.5.1"]]
and it says that it could be in conflict with clj-json
but I can’t find this one in my deps
❯ boot -d clj-http -d cheshire repl
boot.user=> (require '[clj-http.client :as client])
nil
boot.user=> (client/get " " {:as :json})
{:request-time 390, :repeatable? false, :protocol-version {:name "HTTP", :major 1, :minor 1}, :streaming? true, :chunked? false, :reason-phrase "OK", :headers {"Access-Control-Allow-Origin" "*", "Content-Type" "application/json; charset=ISO-8859-1", "X-Cloud-Trace-Context" "25dfdbec80312f279ee4fa15eb026444", "Date" "Sun, 03 Dec 2017 12:32:57 GMT", "Server" "Google Frontend", "Content-Length" "25", "Connection" "close"}, :orig-content-encoding nil, :status 200, :length 25, :body {:ip "185.65.134.175"}, :trace-redirects []}
Running my repl with cheshire got the body coercion working with :as :json
[[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.671" :scope "provided"]
[ring "1.6.2"]
[ring/ring-defaults "0.3.1"]
[compojure "1.6.0"]
[environ "1.1.0"]
[com.stuartsierra/component "0.3.2"]
[org.danielsz/system "0.4.0"]
[org.clojure/tools.namespace "0.2.11"]
[reagent "0.6.0"]
[re-frame "0.9.4"]
[buddy/buddy-core "1.4.0"]
[clj-http "3.7.0"]
[cheshire "5.8.0"]]
probably. lein deps :show :tree
I think is the way to find out. I think you're cutting off part of the error message I'm afraid.
@bravilogy look for only the one you need. I've noticed the exclusions are very broad.
ok so I had lein-plz
in my ~/.lein/profiles.clj
and there were loads of exclusion recommendations for between clj-http and lein-plz. It’s one step to success I think because well, something’s working now 😄
So basically I have this handler
(defn open-orders [req]
(let [{:keys [sig uri]} (api-sig :open-orders)]
(client/get uri {:headers {"apisign" sig} :as :json})))
and then when I visit the url, it definitely outputs json because my chrome json plugin recognises it. The json
looks something like this:
{
success: true,
result: { ... }
}
But if I do something like
(defn open-orders [req]
(let [{:keys [sig uri]} (api-sig :open-orders)]
(-> (client/get uri {:headers {"apisign" sig} :as :json}) :body)))) ;; notice the :body in here
then it returns just a text version of the response and therefore I can’t take out the result
bit from it anymore. If I do
(defn open-orders [req]
(let [{:keys [sig uri]} (api-sig :open-orders)]
(-> (client/get uri {:headers {"apisign" sig} :as :json}) :result)))) ;; notice the :result in here
then it goes to 404 pagedream library: code coverage for :pre / :post like: - for each ns, 20% of defns should have preconditions, and there should be at least one pre'd defn in any case - you cannot decrease coverage % pre/post + spec + integration testing = a damn lot of code gets excercised/asserted! better approach than unit tests in certain cases, e.g. a cljs SPA. would love to write that lib sometime in 2018