This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-02
Channels
- # announcements (13)
- # architecture (18)
- # babashka (90)
- # beginners (80)
- # calva (35)
- # chlorine-clover (29)
- # cider (24)
- # clj-kondo (4)
- # cljfx (3)
- # clojure (60)
- # clojure-australia (2)
- # clojure-europe (60)
- # clojure-france (2)
- # clojure-germany (3)
- # clojure-italy (4)
- # clojure-nl (84)
- # clojure-norway (7)
- # clojure-uk (53)
- # clojurescript (54)
- # clojureverse-ops (1)
- # community-development (6)
- # conjure (1)
- # contributions-welcome (1)
- # cursive (12)
- # datomic (1)
- # fulcro (16)
- # garden (61)
- # girouette (1)
- # graalvm (14)
- # hugsql (1)
- # instaparse (5)
- # jobs-discuss (11)
- # keechma (1)
- # lambdaisland (3)
- # off-topic (20)
- # pathom (1)
- # re-frame (3)
- # reitit (2)
- # releases (1)
- # remote-jobs (2)
- # reveal (11)
- # shadow-cljs (58)
- # spacemacs (5)
- # sql (3)
- # startup-in-a-month (1)
- # vim (2)
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.
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?
memfn is a macro, so it wouldn’t work in combination with map
you have to be a little careful around this kind of thing to avoid reflection
but really, it's probably the most straightforward to just do what you're doing
if you really dislike it would wrapping the ones that you use a lot with clojure fns work? (defn get-year [obj] (.getYear obj))
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
- clojure.core/bean
- https://github.com/clojure/java.data
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: https://www.twitch.tv/a_fry_ 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: https://www.youtube.com/channel/UCkDn7Pnyeq3SJha1x3GXTkQ). Cheers ƛ
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!
👍 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! 😃
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”
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 😅 https://github.com/teachtyler/Fraction
this is not a thing you can generically do with resources
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
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
you pass the path to resource - why use resource at all?
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
it does, but you give up the concept of directories or "all things in a directory"
you just have resources, which have paths, no notion of resource container
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: https://gitlab.com/caumond/reveal-lein-tuto
@U018QDQGZ9Q FYI, https://github.com/vlaaad/vlaaad.github.io is the website repo (in general, you'll find <username>/<username>.http://github.io is the repo behind any github-hosted website.
This is the file that contains the source of all the Reveal information I think https://github.com/vlaaad/vlaaad.github.io/blob/master/reveal.md
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
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
Likely a dumb question, but is it feasible to have a dedicated websocket node as a proxy?
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?
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.
since this is fire and forget, a distributed log / event system (which can be simpler than a queue) would work too
(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
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).
My eye fell on this piece of doc of Joda: > Zone names: Time zone names (‘z’) cannot be parsed. (Here: https://www.joda.org/joda-time/key_format.html )
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.
The clj-time README talks about it and recommends some modern wrappers for Java Time to use instead.
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?
Or cljc.java-time
or tick
(although we use clojure.java-time
at work because it was available first). Mostly we use interop.