Fork me on GitHub
#clojure
<
2018-09-24
>
Paco01:09:13

I recently saw someone post about a workflow/library that could save your repl history as tests or something like that. I cant find that link anywhere, does someone here know of something like that?

Paco02:09:50

Awesome thanks!!

olieidel07:09:45

After spending the weekend wrapping my head around sente, I have one question which remains: * As far as I understand it, authentication state is read from the ring map, specifically here: {:session {:uid :some-uid-val}} * So, e.g. to login a user, the user has to post a rest api request to some endpoint which then sets a key there, i.e. (assoc-in response [:session :uid] :some-uid) * Then, the client has to reconnect So far, this works. But this seems to be the only mechanism to differentiate between users. Say I have a not-logged-in (anonymous) user connected. Unsurprisingly, I’ll have:

(:any @connected-uids)
;; => #{taoensso.sente/nil-uid}
Now, another anonymous user connects from a different computer. I still have:
(:any @connected-uids)
;; => #{taoensso.sente/nil-uid}
Where’s the other one? Are both users simply grouped as “nil-uid” users and I can’t sent them specific messages? Say, User 1 wants to subscribe to updates of cat videos while User 2 is more interested in dog videos. Phoenix / Elixir solves this by having some server-side state for each websocket connection, this seems not to be the case here. Am I missing anything?

henrik07:09:59

I haven’t used Sente properly, but when I tried it out, I got the impression that it’s maybe trying to handle a bit too much for me.

☝️ 4
schmee07:09:36

@olieidel you need to give anonymous users some form of id to distinguish them, such as a UUID

olieidel07:09:19

In the session then, right? This will mean that users will have to reconnect after they've been assigned a uuid, is that correct?

olieidel07:09:35

Seems a bit clunky to make all users connect twice but I can't think of another solution

schmee07:09:09

you can set the uuid on the client side IIRC, haven’t used Sente in a long while

schmee07:09:20

let me see if I can dig up some code

schmee07:09:52

I’m sure you don’t have to connect twice, but I can’t remember exactly how to do it either, sorry 😕

olieidel08:09:53

ahh I think I got it! thanks for that post, I remember having looked at it but I kinda skipped the examples below which are actually way more helpful. I’ll give it a go when I find some time in the next few days. Thanks a lot for your help! 🙂

noisesmith16:09:30

as I recall from my sente usage, the frontend can specify an id it should use (so as a known user they can know their id and present it and that should implicity be a login flow if they don't have a valid session...)

Audrius07:09:06

Hi, how to read Clojure's Source? Could someone advise a guide?

schmee07:09:09

if you’re interested in the standard library, take a look at core.clj

schmee07:09:30

if you wanna check out the compiler, start with LispReader.java and Compiler.java

Audrius07:09:25

I know where source is, thanks for that. I would like to understand how the clojure.main works. Looks difficult to start...

schmee07:09:09

AFAIK noone has written an easy-to-read guide to Clojure’s internals, so if you want to know you’re gonna have to dive right in and spend some time

schmee07:09:58

I suggest starting with the files I mentioned above, if you get stuck on something just ask here 🙂

schmee07:09:26

are you familiar with Java bytecode and/or ASM?

Audrius07:09:40

not yet 🙂

schmee07:09:09

then that is a good thing to begin with!

schmee07:09:34

I found it extremely helpful to use https://github.com/gtrak/no.disassemble and disassemble small functions in the REPL

mping14:09:46

Hi all, I have a bunch of counters in the form of [#inst "2018-03-23" 3] [#inst "2018-03-27" -1], I’d like to generate a rolling sum where for each instant, the sum is the instant’s value plus all values before. I would prefer to use an efficient solution, memoize comes to mind but I’m guessing there’s a smarter way to do it

polymeris14:09:23

clojure.core/reductions?

mping14:09:48

wow I knew there was something like that

bringe16:09:51

Has anyone successfully sent email with clojure in a Windows environment? I've been struggling with the Postal library. I'm able to successfully send mail using the same port, smtp server (gmail), and credentials with Powershell.

bringe16:09:37

I'm aware that library says "untested on Windows" in the readme, but it seems to be the main clojure library for sending email. Perhaps I'd have better luck using Java directly.

bringe16:09:15

Usually I get a connection timed out exception, just fyi, but depending on settings (like switching to tls instead of ssl), I've gotten other error messages too.

joelsanchez18:09:19

give this issue some support - Insomnia is an awesome REST client https://github.com/getinsomnia/insomnia/issues/1173

👍 24