Yeah, trying out doom-themes
has been in my backlog for a long time đ
A few years ago I had a emacs "theme bankrupcy", I removed all my aesthetic customizations and I'm now running the default light theme đ
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?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.
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
it'd have to be a macro since .foo
is not a first class thing but it's syntax
but... really #()
is not bad :)
you could also make a dedicated namespace for function that suppose to deal with some specific Java classes.
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
Cool, thatâs good to keep in mind. Thanks!
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 Ć
- clojure.core/bean
- https://github.com/clojure/java.data
today I learned what a Java Bean is. Thanks dude.
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â
đđ 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
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
io/file doesnât like that type of file url
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, <http://clojure.java.io/resource|clojure.java.io/resource>
returns a url which is handy as well: (slurp (io/resource "my-thing"))
will yield the contents of the file
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!
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
There is #reveal :)
Lol, a REVEALation !
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?
@caumond 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.
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
Cool, I'll suggest a direct contribution then !
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
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)
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
sounds about right đ
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.
(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â
I would expect something around the timezone maybe. But thats a guess at best
Yea it looks like a message queue will be needed to accomplish this
thanks guys
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.
Yes, I read that before I post here.
@sb Joda Time and clj-time are both deprecated, in favor of using Java Time (and, possibly, a Clojure wrapper library). Just FYI.
Thanks the information! đ I donât know that..
since this is fire and forget, a distributed log / event system (which can be simpler than a queue) would work too
The clj-time README talks about it and recommends some modern wrappers for Java Time to use instead.