Fork me on GitHub
#beginners
<
2017-04-21
>
rackdon06:04:59

Yep, I thing it could be possible

timo11:04:52

how can one reload ring/compojure when changing routes without restarting all?

timo11:04:42

I am using chestnut template and I am always restarting the repl and (run). There should be a better way!?!

plexus11:04:36

@timok the new version of chestnut will be based on component, which will make it easier to reload everything from the repl. You can already try it with lein new chestnut your_project --snapshot.

timo11:04:56

i did that:)

plexus11:04:15

then you can use reloaded.repl/reset to reload everything

timo11:04:03

life just got better:grinning:

timo14:04:03

what do you people use for openid connect?

donaldball14:04:48

I used the nimbus jose/jwt java library to validate tokens and wrote my own http and state interactions; nothing canned seemed even a little bit worth the integration hassle tbqh

timo14:04:08

that was my impression too, I'll have a look at nimbus

swizzard17:04:39

i could use some algorithm assistance

swizzard17:04:53

i want to turn [["this" "is" "one"] ["this" "is" "two"]] into [{:value "this" :idx 0 :line-no 0 :is-eol false} {:value "is" :idx 1 :line-no 0 :is-eol false} {:value "1" :idx 2 :line-no 0 :is-eol true} {:value "this" :idx 0 :line-no 1 :is-eol false} {:value "is" :idx 1 :line-no 1 :is-eol false} {:value "two" :idx 2 :line-no 1 :is-eol true}]

donaldball17:04:43

map-indexed is probably a good thing to look at

swizzard17:04:22

right now i have this:

swizzard17:04:25

(defn split-lyrics [lyrics]
  (map #(split % #"\s") (split lyrics #"\n")))

(defn- make-token [tkn line ix is-eol]
  {:value tkn :line-no line :idx ix :is-eol is-eol})

(defn parse-tokens [lines]
  (loop [[[t & ts] & ls] lines line-no 0 ix 0 parsed []]
    (let [is-eol (empty? ts)
          prsed (conj parsed (make-token t line-no ix is-eol))]
      (if (empty? ls)
        (if is-eol
          prsed
          (recur [ts] line-no (inc ix) prsed))
        (if is-eol
          (recur ls (inc line-no) 0 prsed)
          (recur (into [ts] ls) line-no (inc ix) prsed))))))

swizzard17:04:16

but it’s ugly and gross

swizzard17:04:13

if i used map-indexed i’d still have to do something like (let [is-eol (= (dec (count line)) ix)]

donaldball17:04:35

A for loop might sort you then

noisesmith18:04:02

I think calling for a loop is just confusing things

donaldball17:04:21

(for [line-no (range (count lines))
      idx (range (count (nth lines line-no)))]
  (let [line (nth lines line-no)
        value (nth line idx)
        is-eol (= idx (dec (count line)))]
    {:value value :line-no line-no :idx idx :is-eol is-eol}))

jcronk18:04:07

I’m trying to split large XML files on a specific element and then save them as individual files. The splitting part I’ve taken care of, and I have to name them based on the content of the XML, so that’s not hard either. The extra little wrinkle that got added at the last minute, though, was that I also have to write a list of the filenames to the same directory. What strategy would you use for this? The line doing all the work is (doall (map write-file (split-xml input-filename))), so I was thinking of making write-file return the filename to be written while actually writing the file as a side effect. But I’m not a huge fan of that approach.

jcronk18:04:44

My idea was to return filename from write-file and then use that somehow, but I’m stuck on just what to do from here.

sveri18:04:59

@jcronk If I understand correctly these are two different things here and I would solve them sequentially. 1. Split and store them in individual files 2. Traverse the folder, collect the file names and write them to whereever you need them.

jcronk18:04:16

I was wondering about that. I’m not 100% sure that my files will be the only ones there, but I guess in that case I could get a list of what’s there first, then a list after I write the files, then use the difference between the two lists?

sveri18:04:59

I think this is a question that need to be answered upfront, before implementing the final solution

jcronk18:04:11

Makes sense, thanks.