workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
and it says that it could be in conflict with `clj-json` but I can’t find this one in my deps
2017-12-03T07:33:04.000108
Tameka
clojurians
clojure
``` ❯ boot -d clj-http -d cheshire repl boot.user=&gt; (require '[clj-http.client :as client]) nil boot.user=&gt; (client/get "<http://ip.jsontest.com/>" {: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`
2017-12-03T07:33:39.000008
Jodie
clojurians
clojure
``` [[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"]] ```
2017-12-03T07:34:16.000024
Tameka
clojurians
clojure
these are all the deps I have
2017-12-03T07:34:22.000025
Tameka
clojurians
clojure
I’m thinking, perhaps there’s a version conflict somewhere
2017-12-03T07:35:24.000029
Tameka
clojurians
clojure
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.
2017-12-03T07:36:39.000012
Jodie
clojurians
clojure
```Wrong number of arguments to deps task. Expected [] or [command]```
2017-12-03T07:38:48.000010
Tameka
clojurians
clojure
```lein deps :tree``` worked
2017-12-03T07:41:01.000055
Tameka
clojurians
clojure
ok I’ll go through these exclusion recommendations and will try again thanks :smile:
2017-12-03T07:41:29.000031
Tameka
clojurians
clojure
<@Tameka> look for only the one you need. I've noticed the exclusions are very broad.
2017-12-03T07:42:07.000056
Jodie
clojurians
clojure
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 :smile: 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)] (-&gt; (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)] (-&gt; (client/get uri {:headers {"apisign" sig} :as :json}) :result)))) ;; notice the :result in here ``` then it goes to 404 page
2017-12-03T07:58:29.000042
Tameka
clojurians
clojure
such a simple task is so complicated :sob: gonna have a major breakdown here haha
2017-12-03T08:40:27.000055
Tameka
clojurians
clojure
have you tried to spin up a nginx docker container and proxying requests to your local server? This is probably more than what you need, but you could use as reference to create your own config. <https://github.com/jwilder/nginx-proxy>
2017-12-03T08:58:45.000085
Inell
clojurians
clojure
to be pedantic, if you are using clojure on the jvm, *everything* in clojure is a JVM object
2017-12-03T11:26:01.000059
Margaret
clojurians
clojure
clojure happens to define its core functions in terms of some basic Interfaces and Classes, including Arrays
2017-12-03T11:26:45.000044
Margaret
clojurians
clojure
dream 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
2017-12-03T18:05:13.000160
Kristy
clojurians
clojure
except those pre/post conditions often come with a performance hit
2017-12-03T19:33:44.000120
Sandy
clojurians
clojure
<@Tameka> You need `(-&gt; (client/get uri {:headers {"apisign" sig} :as :json}) :body :result)` -- You are trying to get the `:result` element out of the `:body` of the `client/get` response.
2017-12-03T19:52:01.000066
Daniell
clojurians
clojure
The conversion to text happens when Ring is rendering the result.
2017-12-03T19:53:32.000045
Daniell
clojurians
clojure
Random brain firing - is there a way to capture the current function's actual object instance? There are some recursion patterns which would be a lot easier to implement if you could just recursively pass the current function with its closure and all.
2017-12-03T20:33:31.000108
Charity
clojurians
clojure
Or is the "right way" to do this some partial/y-combinator trickery
2017-12-03T20:33:47.000114
Charity
clojurians
clojure
<@Charity> I'm probably misunderstanding, but does this help? ```+user=&gt; (defn foo [] foo) #'user/foo +user=&gt; (= (foo) foo) true ```
2017-12-03T22:14:44.000026
Margaret
clojurians
clojure
does it need to be a way to automatically capture the current fn where you can't know the name (or even work in a case where a name is impossible like comp or partial) ?
2017-12-03T22:15:26.000133
Margaret
clojurians
clojure
oh iiiiinteresting
2017-12-03T22:16:40.000066
Charity
clojurians
clojure
``` user=&gt; (def a (fn [x] (fn foo [] (println x) foo))) #'user/a user=&gt; ((a 1)) 1 #object[user$a$foo__135 0x542e560f "user$a$foo__135@542e560f"] user=&gt; (((a 1))) 1 1 #object[user$a$foo__135 0x1d730606 "user$a$foo__135@1d730606"] user=&gt; ```
2017-12-03T22:16:50.000098
Charity
clojurians
clojure
named lambdas can refer to themselves by instance using their name.
2017-12-03T22:17:14.000206
Charity
clojurians
clojure
yup!
2017-12-03T22:17:22.000145
Margaret
clojurians
clojure
guess I didn't need to patch the compiler to add `this` as an implicit local :stuck_out_tongue:
2017-12-03T22:17:38.000054
Charity
clojurians
clojure
oh no I have become a tool of evil
2017-12-03T22:17:51.000054
Margaret
clojurians
clojure
Oh no this is great
2017-12-03T22:18:08.000018
Charity
clojurians
clojure
totally happy to not have to run some goofy patchset to get what I want
2017-12-03T22:18:20.000238
Charity
clojurians
clojure
(it was a nice patchset tho)
2017-12-03T22:18:28.000053
Charity
clojurians
clojure
Hi, can anyone suggest me some small learning project which would give me some idea about handling concurrency in clojure. Something which can be finished in a week.
2017-12-04T00:38:19.000051
Stefany
clojurians
clojure
I'm writing a macro in a *.cljc file. Is there a way to make it expand to different things depending on whether it is being expanded in CLJ or CLJS code ?
2017-12-04T01:09:01.000130
Berry
clojurians
clojure
<@Berry> You may find this helpful: <http://blog.fikesfarm.com/posts/2015-06-19-portable-macro-musing.html>
2017-12-04T01:11:51.000091
Carolann
clojurians
clojure
Long story short is its a bit of a pain
2017-12-04T01:11:59.000118
Carolann
clojurians
clojure
actually, how is it painful? ``` (defmacro str-&gt;int [s] #?(:clj (Integer/parseInt s) :cljs (js/parseInt s))) ``` looks straightforward -- and I was already doing this, without even realizing it
2017-12-04T02:15:23.000137
Berry
clojurians
clojure
Sure, I turn them off in production in clj and cljs - `(set! *assert* false)` / `:elide-asserts true` respectively
2017-12-04T02:20:53.000013
Kristy
clojurians
clojure
A small 'simulation' program where you model a world, with interacting 'actors' (not in the Erlang sense) of some sort. - A toy factory, where many workers work independently and collaborate - An aquarium, where creatures eat each other / survive / reproduce - etc Those are particularly suited for concurrency. For parallelism, try doing either a CPU-bound (math? parsing?) or IO bound (web crawling?) workload as efficiently as possible
2017-12-04T02:31:46.000152
Kristy
clojurians
clojure
<@Berry> I think you example macro is not right, it’s evaluating the expression at compile-time.
2017-12-04T04:43:33.000372
Alla
clojurians
clojure
You should return the code to do the work instead.
2017-12-04T04:43:53.000179
Alla
clojurians
clojure
e.g. this fails: ``` (let [s "1"] (str-&gt;int s)) ```
2017-12-04T04:44:11.000133
Alla
clojurians
clojure
also, you need to know what you are emitting from the macro: clj or cljs. There are hacks to get this info. And a awesome lib hiding the details: <https://github.com/cgrand/macrovich>
2017-12-04T04:47:43.000277
Alla
clojurians
clojure
``` (defn select-rename [m ks] (into {} (for [[old-k new-k] ks] [new-k (get m old-k)]))) (select-rename {:a 20 :b 30 :c 40} [[:a :foo] [:c :bar]]) ``` Is there a builtin for this ?
2017-12-04T05:18:25.000046
Berry
clojurians
clojure
<@Berry> There're two functions - `rename-keys` and `select-keys`.
2017-12-04T05:22:20.000356
Rogelio
clojurians
clojure
there's `clojure.set/rename-keys` and `select-keys`
2017-12-04T05:22:23.000202
Basil
clojurians
clojure
Also note that you can implement this without an intermedia seq by using a transducer: (into {} (map (fn [[old new]] ...)) ks)
2017-12-04T05:23:11.000160
Basil
clojurians
clojure
<@Basil>: I agree that unnecessary intermedaite seqs are bad. Can you clarify where my code is generating it ?
2017-12-04T05:34:46.000101
Berry
clojurians
clojure
``` (= 2 (+ 1 1)) (comment true) (= (int-array [2]) (int-array [(+ 1 1)])) (comment false) ``` I'm okay with the int-array returning false. My question is: is there a way I can overload/hack equality so it returns true if they're elementwise equal ?
2017-12-04T05:35:51.000307
Berry
clojurians
clojure
<@Kristy> thanks for the reply, this seems interesting.
2017-12-04T05:58:47.000097
Stefany
clojurians
clojure
What is the best way to run all unit tests (assuming that they are in different namespaces) in a project, without requiring them first, from the repl?
2017-12-04T05:59:00.000099
Vernice
clojurians
clojure
I can take a look at the project as you progress on it, why not
2017-12-04T06:01:37.000324
Kristy
clojurians
clojure
thanks that would be great help, I have done some projects like parser &amp; interpreter in clojure but nothing related to concurrency
2017-12-04T06:08:38.000068
Stefany
clojurians
clojure
if you feel like taking a look: <https://github.com/sumitkumar15/supergit> <https://github.com/sumitkumar15/relisp> :slightly_smiling_face:
2017-12-04T06:11:06.000197
Stefany
clojurians
clojure
<@Edwin> any idea ? :point_up:
2017-12-04T06:25:21.000362
Vernice
clojurians
clojure
<@Vernice> why don't you want to require them?
2017-12-04T06:27:42.000248
Jodie
clojurians
clojure
You can't run a test, without require the namespace that test is in.
2017-12-04T06:28:02.000058
Jodie
clojurians
clojure
<@Jodie> say I have 10 test namespaces.
2017-12-04T06:28:58.000005
Vernice
clojurians
clojure
<@Vernice> tools.namespace will require all namespaces it can find.
2017-12-04T06:31:58.000225
Jodie
clojurians
clojure
This should solve your problem if you perform a refresh before running your tests.
2017-12-04T06:32:17.000199
Jodie
clojurians
clojure
Thanks <@Jodie>!
2017-12-04T06:54:56.000096
Vernice
clojurians
clojure
Count result of a transduction, which one is preferable? ``` ;; 1 (count (sequence (map identity) [1 2 3])) ;; vs ;; 2 (transduce (map (constantly 1)) + [1 2 3]) ```
2017-12-04T06:59:03.000303
Johana
clojurians
clojure
<@Johana> the first one makes more sense to me. I think you could use `eduction` in place of `sequence` if this is the exact usage, as it will be faster.
2017-12-04T07:00:30.000273
Jodie
clojurians
clojure
I get `count` is not supported on `eduction`
2017-12-04T07:01:17.000392
Johana
clojurians
clojure
Really? I figured count worked on any reducible.
2017-12-04T07:03:42.000308
Jodie
clojurians
clojure
<@Johana> What are you optimizing for here? Performance or readability?
2017-12-04T07:04:42.000180
Jodie
clojurians
clojure
<@Jodie> Both :slightly_smiling_face:
2017-12-04T07:05:15.000526
Johana
clojurians
clojure
In that case, use `sequence` if it's not fast enough, benchmark the transduce (but I wouldn't expect that to be faster, it's potentially slower!)
2017-12-04T07:05:55.000416
Jodie
clojurians
clojure
thanks
2017-12-04T07:06:43.000342
Johana
clojurians
clojure
last but not least, use `eduction` with a `fold` to parallelise the `count`, if your resulting collection will be large enough. Also benchmark this approach.
2017-12-04T07:06:48.000187
Jodie
clojurians
clojure
<@Jodie> This is just <#C0GLTDB2T|adventofcode> related, so I guess readability is slightly more important. I’ll go with sequence.
2017-12-04T07:07:18.000145
Johana
clojurians
clojure
sorry for the crosspost - has anyone seen this before? <https://clojurians.slack.com/archives/C075TNSSC/p1512387863000190>
2017-12-04T07:39:39.000233
Pat
clojurians
clojure
<@Pat> Try <https://confluence.atlassian.com/jira/connecting-to-ssl-services-117455.html> (see Resolution section)
2017-12-04T07:49:36.000280
Heriberto
clojurians
clojure
it tells how to get certificate for your url and to import into Java cert store to trust it
2017-12-04T07:50:34.000520
Heriberto
clojurians
clojure
thanks, but I'm just trying to use `boot` or `lein`
2017-12-04T08:19:55.000050
Pat
clojurians
clojure
which seems like it should work? it's not my servers
2017-12-04T08:20:23.000225
Pat
clojurians
clojure
<@Pat> those instructions are to be done at client computer
2017-12-04T08:21:55.000176
Heriberto
clojurians
clojure
i. e. at your work machine
2017-12-04T08:22:05.000399
Heriberto
clojurians
clojure
it's not required for it to be a server
2017-12-04T08:22:15.000271
Heriberto
clojurians
clojure
to successfully run Portecle app, to get <http://github.com|github.com> certificate by it and to import that certificate to local cert store
2017-12-04T08:24:00.000318
Heriberto
clojurians
clojure
well, I fixed it by uninstalling and reinstalling `openjdk-8-jdk`constantly throughout the day
2017-12-04T08:27:30.000443
Pat
clojurians
clojure
¯\_(ツ)_/¯
2017-12-04T08:27:32.000122
Pat
clojurians
clojure
FWIW, the last line I ran, from having no jdk installed, was ```sudo apt install openjdk-8-jdk```
2017-12-04T08:29:24.000095
Pat
clojurians
clojure
<@Jodie> using net.cgrand.xforms: `(x/count xform input)`
2017-12-04T08:44:51.000223
Johana
clojurians
clojure
<@Johana> Yep, xforms is always the correct answer in these cases.
2017-12-04T08:45:20.000348
Jodie
clojurians
clojure
I'l have to remember that xforms has a count
2017-12-04T08:45:39.000527
Jodie
clojurians
clojure
(thanks <@Almeda>)
2017-12-04T08:45:50.000297
Johana
clojurians
clojure
Any rumors about 1.9's stability and its final release? :slightly_smiling_face:
2017-12-04T09:42:56.000535
Kalyn
clojurians
clojure
1.9.0-RC2 is pretty much what 1.9.0 should be in a short while
2017-12-04T09:43:29.000561
Kareen
clojurians
clojure
Wow
2017-12-04T09:43:36.000562
Kalyn
clojurians
clojure
I expect 1.9.0-RC2 is exactly what 1.9.0 will be :)
2017-12-04T12:57:06.000440
Sonny
clojurians
clojure
``` (let [a (if editing? edit-a (-&gt; data :foo :bar :a)) b (if editing? edit-b (-&gt; data :quux :b format-b-for-display)) c (if editing? edit-c (-&gt; data :otherkey :c))] [1 2 a b c 3 4]) ``` Can I write this more concise without repeating `(if editing?)` so often?
2017-12-04T13:37:03.000145
Altagracia
clojurians
clojure
(Without repeating the `1 2 3 4`.)
2017-12-04T13:38:08.000722
Altagracia
clojurians
clojure
I want to keep the readable `[1 2 a b c 3 4]` at the end.
2017-12-04T13:39:02.000186
Altagracia
clojurians
clojure
Using vectors and destructuring perhaps? ``` (let [[a b c] (if editing? [edit-a edit-b edit-c] [(-&gt; data :foo :bar :a) (-&gt; data :quux :b format-b-for-display) (-&gt; data :otherkey :c)])] [1 2 a b c 3 4]) ```
2017-12-04T13:46:16.000776
Adrien
clojurians
clojure
Good to know about this!
2017-12-04T14:06:37.000107
Carolann
clojurians
clojure
Agreed
2017-12-04T14:07:07.000088
Carolann
clojurians
clojure
<@Kalyn> Re: stability -- we've had all the 1.9 Alpha and Beta builds in production for ages. We have RC1 in production right now with RC2 going to production at 2pm Pacific today.
2017-12-04T14:22:11.000392
Daniell
clojurians
clojure
whats the main difference between `float?` and `double?`
2017-12-04T14:39:28.000395
Amado
clojurians
clojure
i want to validate input from a string and check if its content is a valid double
2017-12-04T14:41:21.000186
Amado