Fork me on GitHub
#beginners
<
2017-06-15
>
Drew Verlee01:06:17

random thought. Iā€™m working my way though 4clojure. I was playing with clojure.spec to. I could create specs for the 4clojure problems and run them against ppls submitted solutions. I wonder what we could find out from that.

eslachance04:06:24

Sigh. very nub question, here goes. Still getting used to data structures. I'm getting this as params from compojure/ring as a POST:

{image {:filename avatar.jpg, :content-type image/jpeg, :tempfile #object[java.io.File 0x47a213e8 /tmp/ring-multipart-4338227995799003474.tmp], :size 28460}} 
I'm just trying to get the filename, and tempfile, but I can't seem to figure it out, I do (get params :image) or (get params :filename) and whatever else and it's always returning nil. Please someone wack me with a clue-by-four?

eslachance04:06:34

welp. never stop trying, heh. it was (get params "image"). Nice little touch there šŸ˜„

madstap05:06:08

@eslachance You seem to be using println or similar to print your data structure. When it's data, it's better to use prn, which prints strings with quotes. Like: {"image" {:filename "avatar.jpg",,,}} Then it would maybe be more obvious to use (get params "image"). Also, check out get-in.

eslachance05:06:01

Thanks for the tip, madstap!

jlmr05:06:46

@noisesmith, thanks. Just to see if I understand, it could work with: (testmacro {:a 1 :b 2} '(1 2 3)) but not with (def t {:a 1 :b 2}) (testmacro t '(1 2 3))

eslachance06:06:34

Welp, I'm pretty happy with the way this turned out! https://github.com/eslachance/eviemg

eslachance06:06:09

Will have to make a little readme and instructions for ShareX but otherwise, it's a great start for a little project šŸ˜„