This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-18
Channels
- # announcements (43)
- # aws (28)
- # babashka (32)
- # beginners (80)
- # calva (13)
- # chlorine-clover (2)
- # cider (11)
- # clj-kondo (15)
- # cljs-dev (1)
- # clojure (151)
- # clojure-dev (11)
- # clojure-europe (11)
- # clojure-italy (3)
- # clojure-losangeles (3)
- # clojure-nl (4)
- # clojure-spec (20)
- # clojure-uk (58)
- # clojured (3)
- # clojuredesign-podcast (2)
- # clojurescript (37)
- # core-async (4)
- # core-typed (1)
- # cursive (53)
- # datascript (5)
- # datomic (26)
- # duct (23)
- # emacs (3)
- # fulcro (22)
- # graalvm (1)
- # jobs (2)
- # joker (11)
- # juxt (24)
- # lumo (1)
- # mid-cities-meetup (2)
- # nyc (1)
- # off-topic (54)
- # parinfer (1)
- # reagent (13)
- # shadow-cljs (16)
- # sql (9)
- # tree-sitter (9)
- # vim (9)
Mornin'
mΓ₯ning
Anyone missing @peterwestmacott 's RCFOTD as much as I do? π
Risking stealing Peter's thunder, and using his own code:
clojure.core/unreduced
([x])
If x is reduced?, returns (deref x), else returns x
How does one feel if I was to create a twitter bot that sent a new function every day?
sounds good @dharrigan
repo for the reframe workshop we ran at lambda lounge mcr yesterday (instrux are in the readme, itβs based off of the default reframe example and is pitched at beginners to clj as well as beginners to reframe, we have a broad range of experience among attendees)
the final task we gave 10 mins to complete and pleasingly somebody with clj experience but no reframe got it solved as did a first year CS student who had done some scheme⦠after some Q&A I think everybody got there. shows the benefit of limiting the scope/ambition of workshops so that all attendees get the basics down I think
anyway
That looks nice. I never quite got the hang of reframe so I'm bookmarking that.
You know, one of the joys I get from Clojure is the ease on which I can parallelise "things" to split up workload when appropriate, without having to stress about my data structures being fubar'ed π
Has anyone used googles calendar api before? I was thinking about just starting with the java api and going from there
I was going to start with these after looking at the java implementation: https://github.com/SparkFund/google-apps-clj https://gist.github.com/arohner/8d94ee5704b1c0c1b206186525d9f7a7 https://github.com/jonneale/gcal
Inspired by your inspiration @dharrigan
what was it ?
(let [workers (pmap #(cleanup-stagnant-data % app-config) [:funky-table-1 :funky-table-2 :funky-table-3])]
(map #(deref % five-minutes-ms :failure) workers)
I'm sure there are multitude of ways of skinning that cat, but this works for me π
pmap
doesn't return a sequence of futures so that doesn't look right to me...
(doall (pmap ...))
will realize the whole result. Or you could map
a function that does produce a future over a collection and then map deref
over that (but you'd still need to force realization).
we map over manifold streams for that use-case @dharrigan , and use a buffered-stream to get concurrency control
And you also have the problem that if the first few elements take a long time, pmap
won't necessarily have even started the futures for elements further along the sequence so you don't get the concurrency you might desire anyway π
Hence why people say pmap
is pretty much always the wrong solution π And executors are easy to use from Clojure anyway.
And yet, we don't know what was @U052SB76Mβs usage of pmap
π
maybe worth looking at https://github.com/reborg/parallel it has its own pmap implementation https://github.com/reborg/parallel#ppmap
I am familiar with the advice surrounding pmap
(and should probably look at reborg's alternative implementation) but my use case fit the bill so well it was too hard to resist
For the record it's some DB queries (n<5) which are all eventually merged into a cache object. Simplified...
(->> queries
(pmap execute-query)
(reduce merge))
This fuels some of our server-side HTML rendering. This was previously done using map
so switching to pmap
was very easy and actually produces a measurable improvement (~100-200ms)I have found today that a keyword, when used as a fn, admits a 2nd argument, exactly like the default value on get
.. I found it in something like this:
(defmulti multimethod :my-kw)
(defmethod multimethod :my-val-1 [m n] ,,,)
(defmethod multimethod :my-val-2 [m n] ,,,)
(multimethod {:my-kw :my-val-1} 42)
And for a while I couldn't understand how that was not throwing an exception!! π
(:my-kw {} :not-found)
=> :not-found
Good to know! π@U9CQCSTUZ You may be already aware of that, but all the following writings are equivalent:
(:my-kw {} :not-found)
({} :my-kw :not-found)
(get {} :my-kw :not-found)
Note: this form wonβt work when the map is nil
however.
(nil :my-kw :not-found)