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.
@sova Have you verified in the browser dev tools that the token really is embedded in your form?
(it's very easy to get the middleware stack wrong and "lose" the token between it being generated and the page actually being rendered)
(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)
oh it's definitely in there
but then I hit the button, and I get an anti-forgery-token invalid x_X
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.
Oh interesting. 2 requests?
Yeah, can't remember what caused it. I found a SO post about it I think.
Right on...
Yeah it's weird, I tested it earlier and it worked fine... once
but then I must have changed something and it's not doing anything useful x_x
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...
If you changed anything, you have a trail in Git, right? π
haha
yes that is true
i think this is what you mentioneD? https://stackoverflow.com/questions/30172569/how-can-i-use-ring-anti-forgery-csrf-token-with-latest-version-ring-compojure
i just moved it to a set of routes that are not wrapped in anti-forgery for now.
too late in the day to go bug hunting
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
thanks for your help + words of encouragement
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.
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.
Was the token put into the html by the running server?
yep
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
^:static
is not a thing
^:const
instructs the compiler to inline the value of the var, it should only be used for numbers/strings
Is this macro workshop up-to-date and has anyone done it / can recommend it? https://github.com/dcolthorp/lj-macro-workspace
Is @dcolthorp call-able when is not part of the channel?
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)
What is here wrong
#(map (interleave [0] %) [1 2 3])
hi, can you provide an example of the expected behavior?
because I don't understand what you want to achieve
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?
I try to re-implement interpose. For a 4clojure challenge I have to do this
the 4clojure challenge has this test
(= (__ 0 [1 2 3]) [1 0 2 0 3])
I have to implement interpose
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
.
On your example, (interleave [1 2 3] (repeat 0))
would evaluate to (1 0 2 0 3 0)
.
??
#(map (interleave (repeat 0) %) [1 2 3])
does stil not work
try this: (#(rest (interleave (repeat 0) %)) [1 2 3])
You want to start with the input data, because you want the 0
to be in the even positions
map
is not something you want here. We're not interleaving each number, but the whole sequence itself...
thanks
exactly, with map, all you can do is to replace one element with two, but at the end you have a list of pairs ...
something like (#(map (fn [x] [0 x]) %) [1 2 3])
but this is definitly not the best way
yep, and I want to learn the best way
An equivalent to (interleave [1 2 3] (repeat 0))
is (mapcat #(vector % 0) [1 2 3])
. But interleave
and repeat
express it better IMHO.
Thanks
learned some more clojure
@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.
I know but do not wanto cheat and not think about how to solve things
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 (<https://repo1.maven.org/maven2>
In the Readme, itβs mentioned that I can add <https://jitpack.io>
repo, but I am not sure how to do that with deps.edn
You can add a :mvn/repos key for that
Thanks! That did work.
When I pull a dep from a different repo do I need to alter the :path
alias?
probably not, pull it how?
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
Try macros
oh ok I thought there is cli specific option that i might've missed thanks
btw there is new option -X which does function invocation and u can pass it single hashmap as argument so check it out
Have you seen the new -X invocation of the clojure cli?
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)SOLUTION cli version was old i repeated steps from https://www.clojure.org/guides/getting_started and -X worked