Fork me on GitHub
#beginners
<
2018-12-23
>
peter-kehl00:12:49

How do I check source of a dependancy for deps.edn or project.clj being used? I had several (parts of core.typed) downloaded through :mvn/version. Now I changed deps.edn to use :local/root (a git clone of the same). However, some of the dependencies refer to others, so I also changed their deps.edn. To double-check, is there a way to recursively list sources of all dependancies, please?

enforser00:12:56

with a lein project you can do lein deps :tree

enforser00:12:17

oh, after re-reading I realized that I didn't fully understand what you wanted to accomplish - lein deps does not do what you want. sorry about that

seancorfield01:12:24

@peter.kehl Are you looking for clj -Spath ?

peter-kehl02:12:49

Thank you @seancorfield and @trailcapital. Yes, clj -Spathlists all dependancies.

ghadi02:12:45

-Stree not -Spath

seancorfield04:12:21

-Spath tells you exactly which files are in your class path but, yeah, -Stree will be much more readable and tell you which versions you are using.

Vincent Cantin16:12:06

Hi. I am wondering if there is somewhere in the standard library a function to convert a set into a map, similar to:

(defn set->map [s]
  (into {} (map (fn [k] [k true])) s))

madstap18:12:28

Alternative implementation:

(defn set->map [s]
  (zipmap s (repeat true)))

dpsutton16:12:54

are you sure you need that? it encodes the same information and even the invocation would be the same (if (#{:a} :a) ..) is identical to (if ({:a true} :a) ..)

dpsutton16:12:26

but if you do actually need this this seems like the best way to achieve it although it might be faster if you slip the s out of the map form so it uses a transducer version. Into will user transients in this case

Vincent Cantin16:12:43

The library that I am using requires a map and does not work with a set.

dpsutton16:12:36

which library? this sounds like a strange mismatch (if you don't mind me looking)

Vincent Cantin16:12:28

That library https://github.com/davidsantiago/stencil I am using it for my lein template.

seancorfield19:12:29

I'm curious how/where Stencil requires a hash map instead of a set @U8MJBRSR5?

dpsutton21:12:40

Presumably it's in a mapping of variable to replacement text in the template

Vincent Cantin05:12:33

Yes, thatโ€™s for the data used to populate the templates.

Vincent Cantin05:12:40

From the template, I cannot simply test if a key is present in a set, stencil requires you to have key-value pairs.

seancorfield06:12:02

OK, gotcha. I did a test and was a bit surprised that you couldn't test some-set.member in Stencil. That seems like a bug to me.

seancorfield06:12:38

But I would need to test how it works in Selmer as well before really deciding it's a bug ๐Ÿ™‚

Vincent Cantin06:12:19

Sets may not be in the specs of Mustache.

seancorfield06:12:18

Sets works in Selmer

seancorfield06:12:22

user=> (use 'selmer.parser)
nil
user=> (render "{{set.a}}" {:set #{:a}})
":a"
user=> (render "{% if set.a %}yes{% endif %}" {:set #{:a}})
"yes"
user=>    

seancorfield06:12:19

That doesn't work in Stencil.

Vincent Cantin16:12:43

It feels like a function like set->map may exist under a different name somewhere, I would like to make sure that I am not duplicating code.

dpsutton16:12:56

if it did it would be identical to yours. it requires information (what to map each key to) so there's none with the signature you have but would be similar to what you have there. but this seems like a very nonstandard thing. and in this case the standard library gives you the building blocks to make what you need concisely. and in this case it is a one liner ๐Ÿ™‚

๐Ÿ‘Œ 4
๐Ÿ‘ 4
_rj_r_17:12:05

dammit... so I asked this before and I don't remember the answer and Google is still not being helpful.... I deleted the contents of my .m2 directory, and now when running clj I get Error: could not find or load main class clojure.main. I know there is a simple command to correct this, and I can't for the life of me find it again ๐Ÿ˜• Anyone remember?

_rj_r_17:12:25

nevermind.. found it... clj -Sforce

_rj_r_17:12:18

it's only the 11th option down in the clj manpages for dep-opts.. I missed it the first 5 times I read through.. it's going to be a long day haha

๐Ÿ˜… 4
sova-soars-the-sora19:12:36

Hi I have a rum and react question. I want to serverside render some components. I have cljs code in the :on-click events and therefore ... i can throw them all into a cljc and selectively render via reader conditional, or i can just strip out the js myself on the serverside code... problem being that my (rum/hydrate (component)) is not overwriting the component and not giving it the javascript from the client. tricky getting to the bottom of

sova-soars-the-sora21:12:54

Nevermind I got all that jazz working ^.^

sova-soars-the-sora21:12:04

But, I don't know how to extract keys from my ajax-resp using ajax-lite

sova-soars-the-sora21:12:23

Logging in with username vskill
Ajax login response: {:raw-resp #object[Object [object Object]], :xhr #object[Object [object Object]], :success? true, :?status 200, :?content-type "application/octet-stream", :?content "[:uid \"vskill\"][:login-time 1545599249][:auth-token \"AYag$C7dYUulnMTw=$fEY5fv7BfKvgZePQGtOMd/eLKRI=\"]", :?error nil}
Login successful
contents of success map: 
auth token is
login time is

sova-soars-the-sora21:12:49

trying to indicate login-time via (:login-time ajax-resp) doesn't work because the response body looks like...

sova-soars-the-sora21:12:08

[:uid "vskill"][:login-time 1545599249][:auth-token "AYag$C7dYUulnMTw=$fEY5fv7BfKvgZePQGtOMd/eLKRI="]

sova-soars-the-sora21:12:29

how can I get :uid and the rest from something that looks like that? Can i mess with Content-Type to get json back?

sova-soars-the-sora21:12:00

What's the EDN Content-Type ?

sova-soars-the-sora21:12:37

no idea how to get what I want from {:raw-resp #object[Object [object Object]], :xhr #object[Object [object Object]], :success? true, :?status 200, :?content-type "application/transit+json", :?content "", :?error nil}

sova-soars-the-sora21:12:48

how do I make use of :raw-resp?

sova-soars-the-sora22:12:10

it comes back as a sequence of vectors [:key val] [:key val] [:key val] and clojurescript thinks it's a string.

sova-soars-the-sora22:12:50

I did (type ajax-resp) and got Function...

sova-soars-the-sora22:12:49

am i a newb or is shit just overly complected

didibus23:12:00

Are all the parts tightly coupled and dependant on each other in a web of interwoven effects? If so, it would be complected. But it sounds to me like it's just that you are unfamiliar with it, though clearly it's not self explanatory or obvious, since you struggled with it. But having not used Rum or ajax-lite, I can't really say.

sova-soars-the-sora22:12:32

The Missing Link betwixt ajax-lite and cljs