This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-16
Channels
- # admin-announcements (14)
- # announcements (1)
- # aws (1)
- # beginners (105)
- # boot (609)
- # braid-chat (4)
- # braveandtrue (3)
- # cider (24)
- # cljs-dev (13)
- # cljsrn (2)
- # clojure (142)
- # clojure-berlin (7)
- # clojure-ireland (7)
- # clojure-japan (10)
- # clojure-nl (4)
- # clojure-poland (76)
- # clojure-russia (198)
- # clojure-sg (4)
- # clojure-taiwan (1)
- # clojurebridge (1)
- # clojured (4)
- # clojurescript (73)
- # conf-proposals (11)
- # cursive (10)
- # datomic (32)
- # devcards (1)
- # dirac (22)
- # editors (5)
- # emacs (3)
- # events (4)
- # funcool (19)
- # hoplon (18)
- # job (1)
- # jobs (3)
- # jobs-rus (16)
- # keechma (25)
- # ldnclj (33)
- # lein-figwheel (10)
- # leiningen (4)
- # luminus (1)
- # off-topic (19)
- # om (255)
- # onyx (51)
- # overtone (1)
- # parinfer (206)
- # perun (5)
- # proton (2)
- # re-frame (3)
- # reagent (2)
- # remote-jobs (13)
- # ring-swagger (7)
- # slack-help (4)
- # yada (7)
Yes, last minute packing for a trip.
I know the idea but no experience with it.
i think it’s better to just ask your question, oli
ok. i'm writing something to query a datomic schema and generate a map which i'm passing to def schema
{:contacts [s/Any], :name s/Str, :type s/Any, :id s/Str, :aliases [s/Str], :relationships [s/Any]}
what if you inspect Party at the repl? what do you see then?
might help for you to be aware that you shouldn’t do things with your database connection during the compilation phase of your app
as it’ll try to connect when e.g. building a jar
{:party {:contacts [s/Any], :name s/Str, :type s/Any, :id s/Str, :aliases [s/Str], :relationships [s/Any]}}
Have you been able to use Party to validate anything? If so, datomic->prismatic may not be at fault for the failure in swagger-ui.
It's possible that defschema as a macro does not do what you expect when computing its body. Prismatic might have an equivalent function version.
It's a very simple macro, thin wrapper around def, so that isn't likely to be the problem. https://github.com/plumatic/schema/blob/master/src/cljx/schema/core.cljx#L1088
Another possibility is that datomic->prismatic returns something that looks the same as your literal, but is not the same. For example, quoted symbols vs the evaluated equivalent of those symbols.
Try using "=" to compare the literal that works, with the computed value that doesn't work.
You can also try calling "eval" on the result from datomic->prismatic to see if that makes the difference.
Yes, that looks like it. Try throwing "eval" around "my code".
No problem.
guys, i'm quite new to clojure (but not FP). i'm writing test cases for a REST server i'm developing using luminus. now, this REST server is sending JSON responses, with a correct Content-Type -- but how do I make ring parse the request body as JSON? for example, i have this:
(let [response (app (request
:post "/company"
{:name "Big Blue"}))]
...)
at that point, (:body response) is just a plain string. i tried wrapping app
in a wrap-json-body and wrap-json-response, but that doesn't seem to work.
any pointers on some example code or things i should search for? google isn't very usefulThere are some (very simple) examples on the ring-json github page. https://github.com/ring-clojure/ring-json
well, i'm not getting it. look at this: https://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj#L7 why is the ring-json middleware checking for the request content-type to determine whether to parse the response body?!
it appears as if all these utilities are written from a server perspective, rather than a client perspective?
Yes, ring is used for writing HTTP servers only. What are you trying to do?
For a client, use this instead: https://github.com/dakrone/clj-http
i'm using ring-mock-request to mock the requests, i'm getting a response back (which is just a "regular" object that my app would hand off to the actual ring server), and now i want my response body to be parsed
I expect there is, but it's not something I have experience with.
hi! I'm using component and I need to delay the initialization of a part of a component until the system in initialized
this is because on some big projects it can take over a minute to initialize and makes the web api take a minute to be available
do you have any recomendation on how to do this?
@dm3: yes, my first approach would be that
the second would be to have some channel or similar component that can be injected in other components and will receive a message when the system is running so the component can start the initialization
I can't figure out how to match multiple values of cmd
to the same dispatch function
jethroksy: you would need to map them to a single value in your defmulti
e.g. (defmulti process-cmd (fn [cmd params] (if (#{:a :b} cmd) :a-or-b cmd)))
In this case I usually write a dispatch-function which can be tested easier: (defmulti process-cmd process-cmd-dispatch)
ok - just in case this helps anyone - swagger-ui / compojure-api really doesn't like s/Any much
Hi all. I’m looking for some advice on best practices porting a java lib to clojure. I need to port a class that implements two different Interfaces each having a variable argument method with the same name, and I’m not sure how to do that?
i.e.:
Interface A
has methods m(x)
, m(x,y)
, ...
Interface B
has methods m(u)
, m(u,v)
, ...
Class C
implements both interfaces A
and B
The question is how to expose all this in clojure?
@joachim: I think it's not documented, but I used this and it worked https://groups.google.com/forum/#!topic/clojure/TVRsy4Gnf70
@oli: s/Any
-support should be better (despite would not be supported by the current swagger-ui) and there is an issue for it https://github.com/metosin/ring-swagger/issues/85#issuecomment-175228136. Hoperfully will get a patch for it soon.
Thanks @marianoguerra .So if I understand you’re suggesting that I implement a gen-class for extending class C
and implementing all methods in both interfaces? I was hoping to not have to use gen-class though (it requires AOT-compilation). And I still wouldn’t have a clojure-way of calling the methods (i.e. I’d have to do (.m x)
instead of (m x)
, right?)
@joachim: yes, I used gen-class, do you want to use proxy?
@jan.zy: y thanks, makes sense. It’s just a petty that the clojure functions then wouldn’t have the same name as the java methods
@marianoguerra: possibly I was hoping to be able to use multimethods, but I can’t use two different multimethods with the same name at once … maybe I should just give up trying to keep the java class structure etc ...
https://clojurians.slack.com/archives/clojure/p1455485849000012 I'm just circling back to @jbaiter's comment yesterday since I was offline. Your frustration with Yesql almost exactly mirrors mine, and it was for this reason that I created HugSQL. The library is still just a few months old, but its feature set is significantly larger than Yesql right now. I've tried hard to have good docs (http://www.hugsql.org) and be responsive to any issues encountered. Yesterday was the 0.4.0 release of HugSQL, which features Clojure expressions and Snippets support. So, that said, if you like the idea of Yesql but have hit some pain points, give HugSQL a try. I welcome all feedback in making HugSQL a better product.
Is clojure-liberator
the goto library to setup a rest service, or are there other libraries as well?
@slotkenov: https://github.com/juxt/yada is an alternative
Tried sparkling. Seemed like flambo was a predecessor.
@slotkenov https://github.com/metosin/compojure-api . It not for pure for rest, but looks nice.
Hello everyone, I’m trying to read a json string containing several objects, but clojure.data.json/read-str only read the first one, how can I do?
If you can add dependence, look at https://github.com/dakrone/cheshire
yes i’m doing so but the parse-string function seems to do the same as clj.data.json/read-str
I wonder if Clojure 1.8 could help w/ performance on Raspberry Pi
initial benchmark of Clojure on Raspberry Pi is 1/20 the speed of my laptop
Any recommendations here?
@mj_langford: this is a good presentation on performance: http://yellerapp.com/posts/2015-06-29-performance-and-lies.html
there is some advice on JVM tuning in there. Here is the JVM manual also: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/toc.html
hey @mj_langford: yeah, jvm tuning is a complex topic, and is almost always application-specific. Using Clojure itself isn't a significant factor; the requirements around and implementation of your application logic, management of data, etc, are much more salient considerations
I am not a Java programmer, so @jonahbenton, the “right book”/article for JVM tuning is good to find out about as well
that t-crayford presentation looks like what I want
@mj_langford: sure- this is a good high level introduction: http://blog.takipi.com/java-performance-tuning-how-to-get-the-most-out-of-your-garbage-collector/ with pointers to other resources. it's best to start simple- give the jvm an appropriate max heap size and tell it to log garbage collection events (described in that post)- and then go ahead and run your app under load and see how things go. if you run into problems that turn out to be memory management/garbage collection related, then the log gives you a starting point for tuning
this is good coverage of some common tweaks: http://blog.sokolenko.me/2014/11/javavm-options-production.html that said, as with all optimization, don't do it prematurely
has anyone run into an issue where Transit interprets UTC datetimes as local datetimes?
on the backend they’re read as midnight UTC, frontend I get 5am UTC
Are you sure you're not converting it on the front end to UTC with a JavaScript function or similar?
If so and your local time is different to UTC you'd get similar results
it looks like, for example, the date is being serialized as 1449810000000
and it looks like on the front end when transit deserializes it is defaults to the local timezone, utc+5
there might be something else messing with the date somewhere along the line that I’m not aware of I guess
just wanted to do a quick sanity check to see if anyone else had encountered the same thing
if the front end is setup as UTC+5 it should give you 5am UTC+5
maybe the front says it is UTC when it is not ?
cool ok so that’s the expected behavior - good to know. I’m inferring that transit does basically new Date(1449810000000)
, which uses the local time zone and results in the date actually being 5 hours off (not just presenting as 5 hours off)
it’s actually giving me midnight UTC+5
or 5am UTC
so like on the backend I have the value #inst "2015-12-11T00:00:00.000000000-00:00”
. I send it over transit, and after it’s read, I have the value #inst "2015-12-11T05:00:00.000-00:00”
ok it looks like this can be solved by using “json-verbose” for the writer