Fork me on GitHub
#beginners
<
2021-01-24
>
sova-soars-the-sora04:01:31

Hi, my ring anti forgery token is invalid... even though I am including it in the page. I think it might have to do with the slashes in the aft.

seancorfield05:01:55

@sova Have you verified in the browser dev tools that the token really is embedded in your form?

seancorfield05:01:32

(it's very easy to get the middleware stack wrong and "lose" the token between it being generated and the page actually being rendered)

seancorfield05:01:06

(it's also easy to get the stack wrong so that the token is "lost" before it gets back to the piece of code that checks for it)

sova-soars-the-sora05:01:59

oh it's definitely in there

sova-soars-the-sora05:01:34

but then I hit the button, and I get an anti-forgery-token invalid x_X

seancorfield05:01:35

OK, that's good. So then either it's being lost on the return path or you have something that is causing "two requests" which was a problem I ran into.

sova-soars-the-sora05:01:47

Oh interesting. 2 requests?

seancorfield05:01:14

Yeah, can't remember what caused it. I found a SO post about it I think.

sova-soars-the-sora05:01:48

Yeah it's weird, I tested it earlier and it worked fine... once

sova-soars-the-sora05:01:34

but then I must have changed something and it's not doing anything useful x_x

seancorfield05:01:00

In the past, I've always turned it off because it seems so fragile. But recently I've managed to get it to working, but I haven't used it in anger...

seancorfield05:01:16

If you changed anything, you have a trail in Git, right? πŸ™‚

sova-soars-the-sora05:01:55

i just moved it to a set of routes that are not wrapped in anti-forgery for now.

sova-soars-the-sora05:01:05

too late in the day to go bug hunting

πŸ‘ 3
sova-soars-the-sora05:01:38

it's weird though none of my other anti-forgery-token paths have a problem... will check it again with fresh eyes... mark it a wontfix xD

sova-soars-the-sora05:01:46

thanks for your help + words of encouragement

seancorfield05:01:22

Hmm, I don't think it was that -- which was caused by a switch from explicit generation to implicit generation -- as I ran into it without even knowing about manual generation.

seancorfield05:01:17

I think it's a bit like the CORS middleware: it is just really fussy as to how you use it and how you place it in the middleware stack.

dpsutton05:01:29

Was the token put into the html by the running server?

o-hassidi12:01:43

Hello all, wondering about ^:const and ^:static are they efficient? should I use them? what more like these exists and where can I find it? Thanks

bronsa13:01:09

^:static is not a thing

bronsa13:01:39

^:const instructs the compiler to inline the value of the var, it should only be used for numbers/strings

Christian13:01:41

Is this macro workshop up-to-date and has anyone done it / can recommend it? https://github.com/dcolthorp/lj-macro-workspace

Christian13:01:37

Hm. Sounds like a little more traction than I thought with VS Code and Calva. Not sure if I want to spend a lot of time fixing this, to see that it's not up-to-date in the end.

Warning: cider-nrepl requires Clojure 1.8 or greater.
Warning: cider-nrepl will not be included in your project.
As of 2.8.2, the repl task is incompatible with Clojure versions older than 1.7.0. 
You can downgrade to 2.8.1 or use `lein trampoline run -m clojure.main` for a simpler fallback repl.
Subprocess failed (exit code: 1)

Christian13:01:15

Is @dcolthorp call-able when is not part of the channel?

roelof17:01:58

What is here wrong

#(map (interleave [0] %) [1 2 3])

jaihindhreddy17:01:52

interleave takes sequences as arguments. In this case, interleave is called thrice, with 1, 2 and 3 as the second arguments respectively. And they aren't sequences. Can you give us an example of an input and expected output, so that we can help you better?

roelof17:01:17

the 4clojure challenge has this test

(= (__ 0 [1 2 3]) [1 0 2 0 3])
I have to implement interpose

jaihindhreddy17:01:48

I see, if you're trying to re-implement interpose, you could interleave the input sequence with (repeat 0), and then getting rid of the last element, with butlast.

jaihindhreddy17:01:56

On your example, (interleave [1 2 3] (repeat 0)) would evaluate to (1 0 2 0 3 0).

roelof17:01:02

??

#(map (interleave (repeat 0) %) [1 2 3])

roelof17:01:12

does stil not work

caumond17:01:26

try this: (#(rest (interleave (repeat 0) %)) [1 2 3])

jaihindhreddy17:01:41

You want to start with the input data, because you want the 0 to be in the even positions

jaihindhreddy17:01:27

map is not something you want here. We're not interleaving each number, but the whole sequence itself...

caumond17:01:23

exactly, with map, all you can do is to replace one element with two, but at the end you have a list of pairs ...

caumond17:01:33

something like (#(map (fn [x] [0 x]) %) [1 2 3]) but this is definitly not the best way

roelof17:01:37

yep, and I want to learn the best way

jaihindhreddy17:01:23

An equivalent to (interleave [1 2 3] (repeat 0)) is (mapcat #(vector % 0) [1 2 3]). But interleave and repeat express it better IMHO.

roelof18:01:30

learned some more clojure

caumond17:01:38

hi, can you provide an example of the expected behavior?

caumond17:01:23

because I don't understand what you want to achieve

roelof17:01:57

I try to re-implement interpose. For a 4clojure challenge I have to do this

caumond18:01:02

@roelof, it's not that I'm happy to help ! but you can have a look to other candidates solutions in 4clojure. By selecting high score guys, I used to check the quality of my solution.

πŸ™‚ 3
roelof18:01:44

I know but do not wanto cheat and not think about how to solve things

yiorgos19:01:50

I have a small toy project and I would like to try this Java lib https://github.com/trystan/AsciiPanel I am using deps.edn for my deps and I have added this line net.trystan/ascii-panel {:mvn/version "1.1"} When I run clj thought I am getting the following error: Error building classpath. Could not find artifact net.trystan:ascii-panel:jar:1.1 in central (

yiorgos19:01:32

In the Readme, it’s mentioned that I can add repo, but I am not sure how to do that with deps.edn

Alex Miller (Clojure team)19:01:24

You can add a :mvn/repos key for that

yiorgos20:01:26

Thanks! That did work.

yiorgos20:01:50

When I pull a dep from a different repo do I need to alter the :path alias?

Alex Miller (Clojure team)21:01:10

probably not, pull it how?

lepistane21:01:19

Hello, i was wondering if we can pass clojure data structures as arguments to basic cli program? Currently i am sending string and doing clojure.end/read-string but that feels awkward

lepistane09:01:56

oh ok I thought there is cli specific option that i might've missed thanks

πŸ‘ 3
lepistane12:01:05

btw there is new option -X which does function invocation and u can pass it single hashmap as argument so check it out

dpsutton22:01:24

Have you seen the new -X invocation of the clojure cli?

lepistane09:01:39

yes i did but i am always getting

Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-X (No such file or directory)

Full report at:
i have deps.edn , src/data.clj that has fn foo, and when i do clj -X data/foo i get this error did i do anything wrong? (clojure version 1.10.1)

lepistane12:01:40

SOLUTION cli version was old i repeated steps from https://www.clojure.org/guides/getting_started and -X worked