Fork me on GitHub
#beginners
<
2017-07-18
>
mobileink00:07:05

so the error msg is bogus.

mobileink00:07:55

it conflates browser-side and server-side msgs.

dees00:07:12

well, you're misinterpreting it, but yeah it's a little unclear

dees00:07:36

the browser is telling you about something it is doing in reaction to the server's response, which it is also telling you some contextual details about

dees00:07:25

browser dev tools have gotten a lot better but still have a long way to go to be actually user friendly

mobileink00:07:10

how misinterpeting? the msg @alice got was not just about the server - that would be just 500. why is the browser entitled to say sth about cors? after all her request could have been cors compliant, but her server app tried 1/0. how does the browser know that there is more to it than server 500? i know this is out of scope but it does not make sense to me for the browser to send a msg that it already knows violates cors. if it does not already know that, then how can it know to add a cors violation to the error msg? something is going over my head. simple_smile

dees00:07:42

CORS is enforced only by the browser, based on response headers sent in the server's response to a request

dees00:07:43

the subject of the CORS policy is the response itself, so if you have a problem with that, it's helpful to get some context for what happened, which I presume is why the browser tells you some other information about the response in question. in this case, it's definitely helpful because 500 means the server crashed and sent a failure response instead of processing the request normally, which may well be the only reason it doesn't also have the appropriate CORS header. There are probably other response codes for which a CORS header would be irrelevant, which also might help you understand how to troubleshoot as a client developer.

dees00:07:23

telling you that the server had a failure is directly helpful because it tells you you need not waste time troubleshooting anything on the client side until the server's bug can be resolved

cored13:07:06

are there any specific clojure resources for beginners ?

cored13:07:09

like a learning path ?

martinklepsch14:07:52

What would you call this function?

(defn ______ [n left right]
  (cond
    (< left n right) n
    (< n left)       left
    (> n right)      right))

tap14:07:17

An idea, val-in-bounds

martinklepsch14:07:25

(x 10 1 9) ; => 9

martinklepsch14:07:38

(x 0 1 9)  ; => 1

rauh14:07:41

@martinklepsch median

martinklepsch15:07:15

@rauh thanks, reading the definition the implementation also becomes much easier 🙂

martinklepsch15:07:26

@rauh guess I should go back to school haha

noisesmith16:07:08

couldn’t it be #(second (sort [%1 %2 %3]))

moogey16:07:11

@martinklepsch my brain goes for something like constrain

martinklepsch16:07:10

@noisesmith in that simple example yes

qle-guen16:07:31

@cored if you're interested in maths I recommend you https://projecteuler.net/

noisesmith16:07:52

@martinklepsch simple input? or simple version of the function?

=> (def median #(nth (sort %&) (dec (Math/ceil (/ (count %&) 2)))))

martinklepsch16:07:35

@noisesmith simple example as in fixed length array of numbers to find median in

noisesmith16:07:51

OK, right -thus my paste

martinklepsch16:07:23

@noisesmith yeah, some median definitions include averaging the two center numbers if there’s an even-numbered list

martinklepsch16:07:59

@noisesmith (I didn’t know this until 5min ago, but that’s why I just went with (second [1 2 3]) instead of implementing something fancy)

noisesmith16:07:05

sounds like a job for a silly multimethod (defmulti median (comp even? count list)) *fixed