Fork me on GitHub
#clojure
<
2016-06-20
>
alexmiller02:06:21

@leifp the Clojure repl in clojure.main/repl is highly customizable (perhaps too customizable even :)

leifp02:06:34

Thanks, @alexmiller, I'll take a look there, too. The number of dependencies is certainly optimal 🙂

danplz08:06:43

What is the recommended way to define a route for serving a directory of static assets in Compojure API? There is a short example at https://github.com/metosin/compojure-api/wiki/Migration-Guide-to-1.0.0#seeing-extra-warnings, but it excludes a classic Compojure route from the swagger docs. I see no reason to make an exception of the static files, amirite?

danplz08:06:53

I mean, it would be nice to be able to fetch a JS file when playing with the swagger UI, and that would also be a good place for me to suggest caching strategies for static assets

danplz08:06:48

Also, I assume that resources handler in that example is compojure.route/resources, not something in compojure-api, correct?

danplz08:06:58

ack, sorry, I should have posted in ring-swagger room. I'll refrain from cross posting.

danplz08:06:33

Since I want to document the JS client, it makes sense to create a regular compojure-api route, in a "/public" context. No need for route/resources, yet.

meowy08:06:41

@danplz A compojure-api route is just that, a route, so you can compose it with anything else you like.

meowy08:06:40

Something like that.

bcbradley09:06:02

these aren't equivalent, can you explain why?

bcbradley09:06:50

(defn space-grid [m n] (map #({:space [(quot % m) (mod % n)]}) (range (* m n)))) (defn space-grid [m n] (map (fn [i] {:space [(quot i m) (mod i n)]}) (range (* m n))))

hans10:06:42

@bcbradley: #({...}) is not the same as (fn [i] {...}). In the first form, the map is actually evaluated as a function, because it is in the function position (<here>). in the second version, it is not and thus just returned.

hans10:06:14

@bcbradley: you could use #(hash-map :space [(quot % m) (mod % n)]) to replace the first form with something equivalent to the second

hans10:06:58

@bcbradley: maybe it helps to understand if you know that both #(...) and {...} are special reader syntax. if you use both in a nested form, they both do their thing. parentheses are not just a grouping device in lisps, but they're very significant.

mpenet10:06:57

you can think of fn as having an implicit "do"

mpenet10:06:04

unlike #()

mpenet10:06:11

well the bot is not cooperative

mateus.henrique.brum13:06:28

Hey guys, what are you using to work with micro-services, something like spring boot or dropwizard ?

leo.ribeiro14:06:46

@mbrum: I’m using both.. I have them in production

leo.ribeiro14:06:18

guys, I’m trying to join this wonderful clojure world (I’ve started dirtying my hands last saturday)… and it’s pretty awesome… I’ve started from Brave Clojure and Aphyr - Clojure From ground up… But actually I’m not liking it anymore… because I don’t feel the examples are going to fit the real world, I would like something more enterprise… whole scenarios, not only algorithms… structure full projects, manage db access with connection pool, jdbc, serve and process json, etc… do you suggest me any good content that I can find all of it?

borkdude14:06:00

@leo.ribeiro: check out Luminus

borkdude14:06:30

@leo.ribeiro: also read Clojure Applied

leo.ribeiro14:06:42

@borkdude: thank you very much my friend!

leo.ribeiro14:06:48

I will give it a shot of course! 😄

leo.ribeiro14:06:51

@borkdude: is it the clojure applied from ben vandgrift and alex miller?

anmonteiro14:06:32

can I make the generated defrecord constructors private somehow?

anmonteiro14:06:01

(without using alter-meta!)

dm315:06:28

what's the proper way to check if something is a list? that would also catch cons?

dm315:06:18

(and (list? %) (instance? clojure.lang.Cons %)) ?

pataprogramming17:06:34

edn question: I'm using edn/read-string to turn fields in a CSV into Clojure values. This is working great for everything except strings, as strings are not quoted in the CSV. Is there a straightforward way to have read-string interpret them as strings, not symbols?

pataprogramming17:06:33

Currently fixing it with a post-processing step, but was wondering if there was a way to tweak the reader.

kauko17:06:50

@dm3: curious, why do you need to test if something is a list? Can you test whether it's a sequence with seq?, and then convert it into a list?

ebaxt17:06:56

Heisenbug alert: Have you experienced something similar? We're using friend as auth lib and are currently experiencing a strange bug in our test env. When calling

(friend/current-authentication request)
we're getting a "stale" user even though the request contains the correct data. (For those who haven't used friend, it's basically a lookup in the request map
(-> request :session :cemerick.friend/identity :authentications (get ""))
. By stale I mean it returns a previously logged in user. The issue is extremely strange, since it boils down to a simple nested map lookup returning a "stale" value. We've tried in-lining the current-authentication function into the calling ns, and that seems to work. We're starting to run out of ideas, so if you have any ideas I would be really grateful for any input!

pvinis18:06:45

guys, in a build.boot, how can i upgrade the dependencies to a newer version?

pvinis18:06:14

do i have to go check the websites and see? or is there an easy way to see or update the version number?

spinningtopsofdoom18:06:52

@pvinis: you could try the #C053K90BR channel

pvinis18:06:12

oh thanks. didnt know about the channel

dgellow18:06:20

quick question. Any idea how I can make a CSS selector input[type=text] using garden? (garden.core/css [:input [(attr= :type "text") {}]]) gives me ”input [type=\"text\"] {\n\n}” (notice the extra space between input and the attribute selector). (garden.core/css [:input (attr= :type "text") {}]) gives me "input, [type=\"text\"] {\n\n}”.

dgellow18:06:25

aaah, I found a solution! (garden.selectors/input (attr= :type "text"))

ikitommi18:06:27

thanks @meowy for the example! Added a wiki-page to describe the two options & the caveat, https://github.com/metosin/compojure-api/wiki/Serving-static-resources, ping @danplz

dm318:06:35

@kauko - thanks, seq? works! Always get confused in the type hierarchy...

kauko18:06:55

Glad I could help 🙂

Bryan19:06:41

Quick question... if I'm writing a Clojure cli utility and want to use unix pipes to get data into the utility i.e. echo "abcdef" | java -jar my-utility.jar the data should come in on *in*, correct?

alexmiller19:06:49

@dm3 something broader is sequential? but depends what you're doing

Bryan19:06:22

nevermind, figured it out 🙂 For anyone else reading, yes, it comes in on *in*

alexmiller19:06:35

There is with-in-str @mystickphoenix

alexmiller19:06:42

If it's helpful

Bryan19:06:45

@alexmiller: Thanks, I was working on code that's expecting either a filename or data streaming in on stdin and was fighting with *in* for a while until I realized that my conditional statement wasn't working correctly 🙂

fabrao23:06:26

Hello, anyone knows a library to ajax-somthing from clojure, not clojurescript to use with https? I´ve tried cljs-ajax but it didn´t work.

bostonaholic23:06:52

@fabrao: I’m not sure I know what you mean about “ajax-something from clojure”, but have you tried clj-http

fabrao23:06:47

make ajax like call from Clojure as we do in Clojurescript

bostonaholic23:06:55

do you just mean an http call?

bostonaholic23:06:34

then use clj-http

bostonaholic23:06:32

and if you need it to be async you can use core.async

fabrao23:06:06

ok, I´ll try it