This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-18
Channels
- # aleph (12)
- # beginners (31)
- # boot (67)
- # cider (17)
- # cljs-dev (14)
- # clojure (111)
- # clojure-dev (1)
- # clojure-france (4)
- # clojure-gamedev (1)
- # clojure-italy (49)
- # clojure-nl (3)
- # clojure-poland (2)
- # clojure-russia (18)
- # clojure-spec (15)
- # clojure-uk (68)
- # clojurescript (33)
- # core-typed (1)
- # datomic (15)
- # emacs (3)
- # graphql (4)
- # hoplon (36)
- # leiningen (3)
- # lumo (44)
- # mount (2)
- # off-topic (46)
- # om (21)
- # onyx (47)
- # parinfer (22)
- # pedestal (21)
- # protorepl (4)
- # quil (4)
- # re-frame (15)
- # reagent (4)
- # ring-swagger (9)
- # rum (27)
- # spacemacs (11)
- # vim (7)
- # yada (8)
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
browser dev tools have gotten a lot better but still have a long way to go to be actually user friendly
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.
CORS is enforced only by the browser, based on response headers sent in the server's response to a request
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.
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
What would you call this function?
(defn ______ [n left right]
(cond
(< left n right) n
(< n left) left
(> n right) right))
(x 10 1 9) ; => 9
(x 0 1 9) ; => 1
@martinklepsch median
@rauh thanks, reading the definition the implementation also becomes much easier 🙂
@rauh guess I should go back to school haha
couldn’t it be #(second (sort [%1 %2 %3]))
@martinklepsch my brain goes for something like constrain
@noisesmith in that simple example yes
@cored if you're interested in maths I recommend you https://projecteuler.net/
@martinklepsch simple input? or simple version of the function?
=> (def median #(nth (sort %&) (dec (Math/ceil (/ (count %&) 2)))))
@noisesmith simple example as in fixed length array of numbers to find median in
OK, right -thus my paste
@noisesmith yeah, some median definitions include averaging the two center numbers if there’s an even-numbered list
oh! OK then
@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)
sounds like a job for a silly multimethod (defmulti median (comp even? count list))
*fixed