Fork me on GitHub
#clojure
<
2016-01-05
>
domkm00:01:06

Anyone know why Clojure doesn't have ex-message and ex-cause? ClojureScript has them. Is it an oversight?

surreal.analysis01:01:20

Is there a way to determine what template was used to build a leiningen app?

jonahbenton04:01:07

@surreal.analysis: not really. lein templates are just a mechanism to produce an initial project directory tree populated with files, themselves produced through a standard templating mechanism. Saves a little work, using code generation in place of manual copy/paste, to set up a project. Maybe a unique snippet left unchanged after the project's author publishes their project could be used to identify a particular origin template. Curious- what problem would be solved by knowing if a particular project was originally seeded by a template?

surreal.analysis04:01:44

Not really a huge problem - there was an error in the project.clj of a leiningen template I used recently, but couldn't quite pin down a date

surreal.analysis04:01:56

I saw that aspect of the template had been edited within the past month

surreal.analysis04:01:05

So I wanted to know whether or not my version was before or after

surreal.analysis04:01:01

Just making a new project with the template confirmed that the issue was still there, and I could have browsed the source, but it would have been nice to know right away if it was the right version

surreal.analysis04:01:44

I could also see people using it as a sort of "best practices diff" tool

surreal.analysis04:01:21

e.g.

lein new my-template@commit123 old-scaffolding
lein new my-template new-scaffolding
diff —brief -r old-scaffolding/ new-scaffolding/

jonahbenton04:01:08

thanks, makes sense. now that I think of it I have asked similar questions- which template version did I use for X project, and did template Y get subsequent downstream enhancements back from project Z.

srdjan04:01:08

Good evening. Anyone available to help me out with a Pedestal SSE usage problem?

jimmy07:01:34

hi guys, I really love the idea of data driven system from this video https://www.youtube.com/watch?v=BNkYYYyfF48. Do we have any good example of how to do this ? thanks

robert-stuttaford07:01:22

@nxqd: i heartily recommend reaching out to Paul on twitter @ohpauleez and asking him simple_smile

jimmy07:01:01

awesome, I would do that, I'm still very new to clojure, but I can magine with this kind of system we would build CRUD backend pretty fast. 😄

danielgrosse10:01:49

How can I set the dev key with environ?

shanekilkelly11:01:09

@danielgrosse: Have you tried this section of the documentation? https://github.com/weavejester/environ#example-usage. It mentions how to set keys.

shanekilkelly11:01:24

If that doesn’t help, can you give an example of what you’d like to achieve?

danielgrosse11:01:52

I set a {:profile {:dev {:env {:debug true} in the project.clj, but it is ignored. The map in the profiles.clj is recognized.

shanekilkelly11:01:47

should the :profile key not be :profiles, with an ’s' ?

shanekilkelly11:01:18

Here’s a project.clj from one of my apps, it uses environ for settings, may be useful as an example: https://github.com/ShaneKilkelly/jetcan-server/blob/master/project.clj#L40

shanekilkelly11:01:02

also, if you have a profiles.clj file, is there a reason for not making the change in that file? It might be a good idea to not spread the configuration out amongst multiple files.

danielgrosse12:01:55

The key is :profiles, I just mistyped it here. I uses the luminus template as a reference, where it is working. I use the profiles.clj only for the database url

spacepluk12:01:30

I'm yet to see a popular library that uses reader conditionals instead of cljx, is there any reason for that besides lack of time?

shanekilkelly12:01:30

mount uses reader conditionals, I think. Aside from lack of time, some library authors may not be willing to insist on 1.7 as the minimum version of clojure that they’ll support just yet.

shanekilkelly12:01:13

updating a project to use reader conditionals would mean deprecating 1.6 and below, on top of the time investment.

magomimmo12:01:10

@spacepluk: after having used reader conditionals I would never use again cljx but as @shanekilkelly said, you may not want to deprecate 1.6.0 ands below

spacepluk12:01:34

oh I see, that makes sense simple_smile

solicode12:01:10

A couple of others that use cljc that I know of are datascript and component.

magomimmo12:01:15

@solicode: and clojure(script) as well, which is full of #? reader macro

spacepluk13:01:32

I guess I need to read more code hehe

spacepluk13:01:33

@shanekilkelly: I didn't know about mount it looks very interesting

magomimmo13:01:41

@spacepluk: you can find a tutorial on reader conditional here https://github.com/magomimmo/modern-cljs/blob/2ed53774fe22075ae9c74a3394c617ae9994c64e/doc/second-edition/tutorial-12.md take also in consideration that both :crossover feature of cljsbuild and cljx are now deprecated. One more thing: I’m in the process of publishing a new tutorial of the series where I explain in depth the accommodation of reader conditionals to make a library portable on CLJ and CLJS… I think I should finished it in a couple of days...

spacepluk13:01:49

@magomimmo: that's great, thanks

magomimmo13:01:48

@spacepluk: you’re welcome

solicode13:01:22

test.check is another good example. I forgot about that one.

magomimmo13:01:06

@solicode: I love test.check, as anyone that does not want to write too many tests. It allows you to discover very difficult bugs to be killed.

jimmy13:01:14

hi guys how to define a schema (prismatic schema) to validate empty list ?

gsnewmark13:01:19

@nxqd: you could use something like (schema.core/eq []) or (schema.core/eq '())

nberger14:01:54

tools.namespace is another example of a library that was ported to cljc

srdjan15:01:44

Good morning, all

srdjan15:01:19

Is anyone able to help me out with a Pedestal SSE issue? I’ve posted the details here, https://groups.google.com/forum/#!topic/pedestal-users/J8oj33cg_e0

danielgrosse15:01:28

I set a key to the env in the uberjar profile, when I run the jar locally, the key is set. When I copy the jar to my server and run it there, its not. What could be the cause of this?

danielgrosse15:01:52

Oh its read from the .lein-env. Is this the normal behaviour?

danielgrosse15:01:13

Shouldn't this been compiled to the package?

bozhidar15:01:47

Enjoy irresponsibly! simple_smile

Alex Miller (Clojure team)16:01:52

We're happy to announce that Clojure/west 2016 will be held in Seattle, Apr 15-16th - please see http://clojurewest.org for more info.

Alex Miller (Clojure team)16:01:18

See http://clojurewest.org/cfp for more info on the call for presentations and http://clojurewest.org/sponsorship for more info on sponsoring!

prasincs17:01:19

hey, so I’m trying to use/extend @pyr’s riemann-acknowledgement library.. and can’t quite seem to get the events get tagged properly

prasincs17:01:14

based on the print messages, the events do get tagged when there’s an ack for the host/service combo

prasincs17:01:27

but it’s not making all the way through

rcanepa18:01:58

Hey guys!… I am creating some tests for my REST API to validate/check simple things such as the response status code and the shape of the returned data. However, the response body comes comes as a java.io.BufferedInputStream I don’t why and how to deal with it. In short, I am getting something like this: '#object[java.io.BufferedInputStream 0x6a5dd0ef "java.io.BufferedInputStream@6a5dd0ef"] (class java.io.BufferedInputStream)’

rcanepa18:01:45

I am using ring.mock.request to create request maps.

rcanepa18:01:57

Is this the reason behind using something like the wrap-json-response middleware, right?

jr18:01:22

wrap-json-response is returning the input stream. you can slurp the input stream to create a string

jr18:01:57

(update-in response [:body] slurp)

rcanepa19:01:37

Oh, right… Clearly I lack the understanding of some parts of the process. Thanks

spieden19:01:18

alexmiller: i’m excited to have Clojure/west in my home town this year 😃

jcomplex19:01:24

Suppose I had a collection: {:id 1 :name "Jane Doe" :images []} and I wanted to add [{:count 3 :monitor 12}] to :images is that allowed in clojure or do I have to create a completely new collection

spieden19:01:11

jcomplex: i think you want update-in

srdjan19:01:14

you should be able to

jcomplex19:01:24

hmm let me look that up

jcomplex19:01:34

lol thanks for the link

srdjan19:01:35

@jcomplex: (update-in coll [:images] conj whatever-you-need-to-add)

spieden19:01:26

i guess regular update would also work as the key is only one deep

srdjan19:01:16

@jcomplex: do be careful, as this doesn’t modify the coll in place

spieden19:01:07

jcomplex: yes, this does (efficiently) create a completely new collection, so use the return value

jcomplex19:01:41

I plan to use a swap to replace the old with the new

spieden19:01:54

sounds legit

jaredly19:01:35

is there a way to jack into the clojure compilation process? for example, to do some extra analysis, constant folding, etc. I imagine it would take the form of a lein/boot plugin, but I’m not sure where to start. Are there any projects that already do a similar thing?

jr19:01:47

have you checked out tools.analyzer?

srdjan20:01:27

OK, so I have half a solution regarding my Pedestal SSE problem

srdjan20:01:03

it seems that if there’s no value available on the event-chan that’s setup when the request for the event source is received, something closes the connection

srdjan20:01:37

it’s controlling the output immediately

srdjan20:01:54

so, my question is, how do I keep that channel open until a value is received?

srdjan20:01:33

@jonahbenton: yeah, I posted that in the morning

srdjan20:01:45

I’ve been struggling with this problem for a while

jonahbenton20:01:24

is the code still the same?

srdjan20:01:55

yeah, I haven’t changed it

srdjan20:01:07

I’m trying to understand what’s happening

jonahbenton20:01:15

presumably the minimal stream-ready implementation from https://github.com/pedestal/pedestal/blob/master/guides/documentation/service-sse.md is confirmed to work?

jonahbenton20:01:16

so a fully static dummy version of link-update like: (defn link-update "Sends the updated link record when the value is put on the channel" [channel] (dotimes [_ 20] (let [;; record (<! update-chan) output "your data here"] ;; (view-models/single-item record)] (log/debug channel) (log/debug output) (>!! channel {:name "link-update" :data output}))))

srdjan20:01:26

that one does, because the events are generated on the server

jonahbenton20:01:44

in the published link-update, where does update-chan come from?

srdjan20:01:17

this is a part of a pipeline

srdjan20:01:23

the process is like this

srdjan20:01:34

1) I create a record with a URL

srdjan20:01:52

2) After persisting to the database, that record is put on a channel

srdjan20:01:30

3) A function takes it off, uses Enlive to fetch <title> tag and updates the record

srdjan20:01:49

4) That function, at the end, puts the final map on to update-chan

srdjan20:01:01

so that 5) an SSE can be sent

jonahbenton20:01:50

so when a map is put onto update-chan and the rendered event is pushed onto the sse channel, pedestal is throwing an exception and the client doesn't see the event?

jonahbenton20:01:03

what data does (view-models/single-item ...) produce?

srdjan20:01:56

it takes a db-sources hashmap, converts the date, fills in the title if the column value is nil

srdjan20:01:03

converts to json

jonahbenton20:01:43

hmm. i am curious about what happens if you remove the go block from link-update and use dotimes instead

jonahbenton20:01:07

i suspect what's happening is this:

jonahbenton20:01:34

actually, scratch that

jonahbenton21:01:25

change link-update, and its callers, to return the sse channel

jonahbenton21:01:41

might be faster to remove the go block

jonahbenton21:01:53

i think what's happening is pedestal is getting confused about the response to this request

jonahbenton21:01:11

your call train is returning null

jonahbenton21:01:19

in response to the /stream request

jonahbenton21:01:27

so pedestal will close the response channel

jonahbenton21:01:42

the response socket

jonahbenton21:01:21

i have not used sse but in other situations pedestal needs interceptors to return either a context or a channel

srdjan21:01:40

yeah, I figured it’s the null return that’s closing it, but I didn’t know how to return a non-null value while waiting for the “real” value to show up on the channel

srdjan21:01:33

I’ll try to return the sse channel

jonahbenton21:01:43

will be curious to hear if it works. sse channel would make sense, and would be a more natural example in the documentation

srdjan21:01:38

I’ll come back and let you know

jonahbenton21:01:14

cool, thank you

jaredly22:01:40

@jr yeah, I’m planning on using tools.analyzer, but you do you plug that into lein run?

jr22:01:48

tools.analyzer is meant for static analysis

Alex Miller (Clojure team)22:01:13

the normal Clojure compiler is not open for manipulation like that

jcomplex23:01:19

Question with Monger could you set up a watcher to the collections that would allow you to know if was updated?

jcomplex23:01:38

I know of such a mechanism in Datomic just was wondering if that existed in Monger

shanekilkelly23:01:32

It's not a general solution, but it may be useful. Otherwise, there's no way to be notified of changes to a collection (at least none that I'm aware of)

chr0nu523:01:43

Hi guys, when defn a method, what is the difference of using a dash and not using a dash? like in defn -doThis and defn doThis both can be called with and without the dash.

taylor.sando23:01:58

There is no difference between the two, only defining it with defn- will make it private.

vito23:01:11

Sorry for stepping up, but why can we invoke the function with and without the leading dash? I read somewhere that it has something to do with :gen-class, but it is not clear enough. 😞

Alex Miller (Clojure team)23:01:17

the leading dash is the default prefix for genclass

Alex Miller (Clojure team)23:01:59

So you see it with -main most commonly to generate a class with a static main

vito23:01:23

@alexmiller: Makes sense! Thank you!