This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-08
Channels
- # aws (4)
- # beginners (81)
- # boot (65)
- # cljs-dev (10)
- # cljsjs (1)
- # cljsrn (12)
- # clojure (26)
- # clojure-austin (2)
- # clojure-dusseldorf (2)
- # clojure-russia (123)
- # clojure-spec (23)
- # clojure-uk (12)
- # clojurescript (36)
- # cursive (11)
- # datomic (39)
- # events (1)
- # hoplon (25)
- # incanter (4)
- # leiningen (3)
- # off-topic (5)
- # om (31)
- # re-frame (24)
- # reagent (13)
- # ring-swagger (2)
- # rum (10)
- # untangled (3)
- # yada (10)
(def core-app
(make-handler ["/" {"" (redirect "/public/index_prod.html")
"index.html" index-handler
["articles/" :id "/article.html"] article-handler}]))
localhost:8080/index.html works
localhost:8080/articles/232/article.html works
localhost:8080/ does not work -- what am I doing wrong ?I don't know bidi but I would check to ensure that index-handler
and article-handler
return the same data shape that (redirect ...)
does. @qqq
(defn index-handler [request]
(res/response "Homepage"))
(defn article-handler [{:keys [route-params]}]
(res/response (str "You are viewing article: " (:id route-params))))
res is ring.util.response @joshjonesand does the output of those two functions match that of (redirect ...)
? I guess (redirect ...)
returns a map? Does the make-handler
function allow you to give it a route to match (`""` in your case) and then something that is (probably not) a handler function?
i guess you replaced the call to redirect
with index-handler
to see whether it is even matching ""
correctly?
actually, I just looked at the source and it appears you can use redirect
this way as it returns a handler
(defn handle-request [& rest]
(println "handle-request: " rest)
(ring.util.response/response "Hello world"))
(def routing-table
["/" {"" :root
"index.html" :index}])
(def core-app
(bidi.ring/make-handler routing-table handle-request))
(let [r (ring.mock.request/request :get "/")]
(core-app r))
^^^ this gives me
1. Unhandled java.lang.IllegalArgumentException
No implementation of method: :request of protocol: #'bidi.ring/Ring
found for class: clojure.lang.PersistentArrayMap
core_deftype.clj: 583 clojure.core/-cache-protocol-fn
core_deftype.clj: 575 clojure.core/-cache-protocol-fn
ring.clj: 12 bidi.ring/eval48095/fn/G
ring.clj: 37 bidi.ring/make-handler/fn
REPL: 110 g.apps.index/eval52126
REPL: 109 g.apps.index/eval52126
Compiler.java: 6978 clojure.lang.Compiler/eval
Compiler.java: 6941 clojure.lang.Compiler/eval
core.clj: 3187 clojure.core/eval
core.clj: 3183 clojure.core/eval
main.clj: 242 clojure.main/repl/read-eval-print/fn
main.clj: 242 clojure.main/repl/read-eval-print
main.clj: 260 clojure.main/repl/fn
main.clj: 260 clojure.main/repl
main.clj: 176 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 652 clojure.core/apply
regrow.clj: 18 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 1963 clojure.core/with-bindings*
any idea how to fix this?https://khinsen.wordpress.com/2012/03/15/python-becomes-a-platform/ <-- this blog post talks about clojure-py // is this effort still active, or has it been killed?
The github link is dead https://github.com/halgari/clojure-py
@beppu: yes, but on Google there are other results for clojure-py, and (2) halgari is in this channel, so I was hoping to get insights from him
@tbaldridge (aka halgari) ^^
@qqq the original Clojure-Py had some glaring issues. I have nothing currently to replace it with, but rewriting it is something I would like to do at some point
@tbaldridge: can I DM you about clojure-py / clojurescript-py? I'm writing a lot of numpy/tensorflow lately, completely miss the terseness of clojure + power of macros, and want to get your thoughts on potential challenges of cljX -> py
Please do!
When using clj on server and cljs on client side, is there ever any reason to pick json over edn? [This API doesn't have to work with other services; it only needs to work with my app.]
@qqq I dont know any. Also, have a look at transit. there is a transit wring middleware and cljs-ajax picks transit as default format.
how would i go about bit-shifting a float in clojure? i figured something like (unsigned-bit-shift-right (byte 1.0) 1)
but it's rounds down to zero instead of returning 0.5
I don't think the shift operators are defined on floating point types on the jvm, you would have to get the raw bits using Float/floatToIntBits
then shift that, then use Float/intBitsToFloat
to turn it back into a float
http://steve.hollasch.net/cgindex/coding/ieeefloat.html <-- given the layout of sign, fraction, exponent; what does it even mean to "bit shift" a float?
@williewillus ah, thanks! i think that's just what i was looking for, but only could find Integer/toBinaryString
. lemme give it a shot