Fork me on GitHub

I want to call several Java methods and:

((juxt #(.getYear %) #(.getMonthValue %) #(.getDayOfMonth %) )
does the job, but it doenst look pretty. Is there a shorcut for this like the ..?
((juxt .getYear .getMonthValue .getDayOfMont))
Will not compile, because these are not clojure functions, right?


you could also make a dedicated namespace for function that suppose to deal with some specific Java classes.


right, you can use memfn but it's not worth it IMO


#() is your best choice


If I had a lot of code that calls juxt with java methods, would this be a valid reason to write a macro that behaves like the original juxt?


well you don’t need to make a macro… I think


Or is it possible to do that with a function?


(defn javajuxt [& fns]
  (apply juxt (map memfn fns))]))


I have no idea if that’ll work 😅


memfn is a macro, so it wouldn’t work in combination with map


aaah.. ok that won’t work then.

Alex Miller (Clojure team)14:02:57

you have to be a little careful around this kind of thing to avoid reflection

Alex Miller (Clojure team)14:02:19

but really, it's probably the most straightforward to just do what you're doing


it'd have to be a macro since .foo is not a first class thing but it's syntax


but... really #() is not bad :)


if you really dislike it would wrapping the ones that you use a lot with clojure fns work? (defn get-year [obj] (.getYear obj))

Alex Miller (Clojure team)14:02:19

people have written wrappers that do this kind of thing across big chunks of api but you're just adding layers and layers have cost


Cool, that’s good to keep in mind. Thanks!


today I learned what a Java Bean is. Thanks dude.


Hello fellow Clojure beginners! I wanted to drop a line in this channel real quick and let you know that I'm doing daily Clojure coding livestreams over on my Twitch channel: I'm embarking on an ambitious project this year: 12 startups in 12 months. Each month I'm going to build and release a startup MVP from start to finish, all in Clojure and ClojureScript. I'm now officially in Month Two of the project, which means I'm in month two of learning how to code in Clojure! It's been a trip so far, but I think I'm catching on to the rudiments of the language fairly well. I start each morning with a 30-minute warmup, so if you want to watch a fellow beginner bungle through a coding challenge or two and learn how the language works, you can join me every weekday at 9:30 AM EST. I've also got a back-catalog of livestreams over on Youtube (although I only started the morning warmup segment last week: Cheers ƛ

Daniel Stephens16:02:57

looks interesting, good luck!


Welp, the stream crashed halfway through 😬 But at any rate, if you're interested in joining hopefully it'll behave next time!

Daniel Stephens17:02:48

👍 will try to pop in, interested to see what ideas you come up with!


hey I noticed when you started this, I think I got wind of it via the reddit/clojure channel... Love the ambition. Glad you're doing it and streaming it! 😃


anyone familiar with how to deal with calling io/resource on a resource directory?


closest I’ve come is doing (io/file (str (io/resourece "path")))


but the str call returns a path prefixed with file: that io/file doesn’t like, I could regex that bit out of the string but that seems bad


ignore all code and say what you want to happen. "i want to get all the files in my resources directory", "i need the edn from resources/foo.edn" or something like that


right on, you nailed it really “i want to get all the files in a resources sub-directory”

Alex Miller (Clojure team)16:02:26

this is not a thing you can generically do with resources


🌊👋 I'm new to cljs, so i've been working on a template fork for others and myself down the road, that is currently in a protect-your-eyes state, so any feedback would be appreciated 😅


i'm not finding any good way to do this. I believe just like java packages, in a jar there is no hierarchy or container. just "addresses" that share a prefix. "resources/foo/bar" and "resources/foo/quux". we can "see" a hierarchy but there's no node containing the two

Alex Miller (Clojure team)16:02:25

directories are not a resource thing, they're a file thing


the resource returns the path which is really all I need, but it’s got this file: prefix which I can just remove


io/file doesn’t like that type of file url

Alex Miller (Clojure team)16:02:53

you pass the path to resource - why use resource at all?

Alex Miller (Clojure team)16:02:34

resources are a generic feature and classloaders can provide them from an open set of "places"


I only know the path relative to the resources directory, so I pass the relative path to io/resource


using io/resource shields the differences between my local machine and the jar in a docker image

Alex Miller (Clojure team)16:02:26

it does, but you give up the concept of directories or "all things in a directory"

Alex Miller (Clojure team)16:02:49

you just have resources, which have paths, no notion of resource container

Alex Miller (Clojure team)16:02:26

you're loading resources from the classpath, which includes all the jars as well


if you know you'll have files, use just a path to make files. If you lose the filesystem because of packaging into a jar, returns a url which is handy as well: (slurp (io/resource "my-thing")) will yield the contents of the file


Hi guys, I want to use reveal with leiningen, and for me it was not straightforward. As I'm not a leiningen expert, could you all check my proposal to @vlaaad. Reveal need to launch a repl function, I used the :repl-options { :init ...} option . @vlaaad, I did not find how to contribute directly to your website, a few lines in that readme I suggest you add in your tutorial:


There is #reveal :)


Lol, a REVEALation !


@U018QDQGZ9Q FYI, is the website repo (in general, you'll find <username>/<username>. is the repo behind any github-hosted website.

👍 3

Cool, I'll suggest a direct contribution then !


This is the file that contains the source of all the Reveal information I think


sounds about right 🙂

Mario C.21:02:08

I am trying to add web-sockets into an application I am working on.  My general understanding of WS is that Client A establishes a connection to Server A and they can send messages to each other. The issue I am seeing with this type of architecture is that we have multiple stateless servers.  So if Server B receives a request to process some information, that Client A is expecting to get a notification via WS, how will Server B Push out a message to Client A if Server B has no connection with Client A.  Sticky sessions doesn’t seem like the solution since its another system that is making requests to our API which would trigger a notification message sent to the connected client. And any node can potentially receive that request.  Is there a way a server can ask “Hey, who is connected to client Y?” And then have the server that responds with “Hey, I am connected to that client!” Send out the notification via WS?


did that at the last job. broadcast to the nodes please let user zzz know this message. one (and only one) of them had a connection open and fulfilled it. the rest looked, saw that client wasn't connected and just kept humming

Mario C.21:02:15

Do you have any links for this sort of thing? I am guessing this would require setting up some sort of messaging passing service or can this be done with pure clojure?


yeah i was assuming your machines already had some queue they could all talk to. if so its pretty trivial. there's an atom of connected clients and a message of who to send to


if no queue already you've got some plumbing to do


Likely a dumb question, but is it feasible to have a dedicated websocket node as a proxy?


(in your situation)

Mario C.21:02:50

No there is no queue set up at the moment. As far as a dedicated ws node, Im not familiar with that so I can't say to be honest. How would that work? Would the load balancer see that a client is trying to make a WS connection and then route the request to the dedicated server?

Mario C.21:02:57

Seems like at the end of the day it would sort of be the same situation, Some Node would need to send a message to the dedicated node. But honestly im not sure


Could rabbit mq work for you here? We have agents at my work that sit connected to rmq. Can send a message to a particular machine or many machines. You just need to setup your routing keys appropriately. If a machine is offline its messages will sit in its queue ready to be picked up when it reconnects.


I have to say I don’t quite have a complete picture in my mind. But it seems like you want a queue like the others suggested, since your services are behind a load balancer and you need some way to coordinate messages.

Mario C.21:02:15

Yea it looks like a message queue will be needed to accomplish this

Mario C.21:02:23

thanks guys


since this is fire and forget, a distributed log / event system (which can be simpler than a queue) would work too

🎯 3

(def custom-formatter (tf/formatter "yyyyMMddHHmm"))
  (l/to-local-date-time (tf/parse custom-formatter "202011141555")) >> works
  ; "Jul 12, 2020, 5:03:24 PM GMT+2"
  (def custom-eg-google (tf/formatter "MM dd, yyyy, hh:mm:ss aa zz"))
  (tf/parse custom-eg-google  "Jul 12, 2020, 5:03:24 PM GMT+2") >> not valid


What do I wrong with clj-time? at custom formatter “”MM dd, yyyy, hh:mm:ss aa zz”

Lennart Buit21:02:03

I would expect something around the timezone maybe. But thats a guess at best


Yes, i tried in several way. I read yoda time documentation about, but not clear (no example for this case).

Lennart Buit22:02:55

My eye fell on this piece of doc of Joda: > Zone names: Time zone names (‘z’) cannot be parsed. (Here: )

👍 3

Yes, I read that before I post here.


I found a few example on the Github [not exact but good starter points], maybe first I check before I drop here the question.


@sb Joda Time and clj-time are both deprecated, in favor of using Java Time (and, possibly, a Clojure wrapper library). Just FYI.

👍 3

Thanks the information! 👍 I don’t know that..


The clj-time README talks about it and recommends some modern wrappers for Java Time to use instead.

👍 6

Yes, this is little bit painful. I solved without clj-time.. (I hope tick will have better documentation later.)


clj-time is so cool though... ;_;


@U3ES97LAC Seriously? I mean, I'm one of the maintainers and I don't think there's anything "cool" about it...


yes i think it's awesome ... but the latest state-of-the-art recommendation is to use java-time via interop?

👍 3

Or or tick (although we use at work because it was available first). Mostly we use interop.