This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-14
Channels
- # admin-announcements (21)
- # aws (5)
- # boot (41)
- # cider (76)
- # cljs-dev (15)
- # clojure (251)
- # clojure-brasil (25)
- # clojure-dev (16)
- # clojure-japan (8)
- # clojure-nl (1)
- # clojure-russia (110)
- # clojure-uk (7)
- # clojurescript (168)
- # clojurewerkz (1)
- # cursive (10)
- # datomic (45)
- # devcards (50)
- # emacs (5)
- # hoplon (6)
- # instaparse (6)
- # ldnclj (73)
- # lein-figwheel (4)
- # leiningen (6)
- # liberator (7)
- # luminus (2)
- # off-topic (19)
- # om (80)
- # onyx (2)
- # re-frame (11)
- # testing (12)
hi I am new to clojure, and I got a question I have not being able to find a definitive answer on google I work with a big java desktop application, where I have managed to embedd jython to provide a scripting framework it works well, but I hate java scientific libraries, jython cannot use numpy and Co. I got interested in Inchanter instead. Now I am wondering if I can also embedd clojure into the java app in the same way as I did for jython. What I do with jython, is on java, I create an interpreter, set paths to different modules I need dynamically then I put a 2D matrix (a list of lists) into the interpreter and then I load the script I want and execute a function that will always be in every script by convention, and which takes that 2D matrix I put into the interpreter the function returns another 2D matrix, which then I can recover from java side and cast to java types and then some other small things like redirecting jython stdout and stderr to java so that I can print nicely on the java app, etc Would it be possible with clojure? Somehow I got the feeling it is not designed for this purpose.
Hi @sidrero you should be able to use core.matrix for most of what you need. It supports conversions to / from various different matrix representations
core.matrix is roughly equivalent to numpy in terms of scope, most of the same functionality is there too
I have a small question regarding clj-http. How can I emulate a curl post that does this? curl -X POST 'https://website.com/endpoint' -d 'request_body={ ... }'
@nnbosko: this should do it
(require '[cheshire.core :as json])
(require '[clj-http.client :as http])
(http/post "" {:body (json/encode {...})})
there are a lot of excellent examples in the readme on github https://github.com/dakrone/clj-httpSorry, I should have been more specific. The issue isn't that per se, I know more or less how to deal with clj-http, the issue is specifically sending 'request_body = { ... }' as data
Not request body as a json parameter itself, but request_body={ "api_key" : "xxxxxx", "name" : "xxxxx" etc }
hence -d 'request_body={...}'
Am I clear, @oliy?
I wouldn't say that, because doing (http/post "website" {:body "request_body={...}"}) fails
@nnbosko: "I wouldn't say that, because doing (http/post "website" {:body "request_body={...}"}) fails" fails how?
It says request_body is empty
More specifically this is the body of the request I'm getting from the server
:body "{\"status\":\"ERROR\",\"status_code\":\"BP-DPAR-1\",\"status_message\":\"request_body is empty\"}"
I think it's something on your server side. I tried here and (client/post "
works fine, the server gets the string "request_body={...}"
typically you need to set application/x-www-form-urlencoded
to get standard parsing behaviors to work, this is often automatic
yeah, if it works with curl but doesn't work with clj-http, it's probably a matter of the default content-type being different for each one, which causes the server to misunderstand the body