This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aatree (257)
- # admin-announcements (13)
- # beginners (3)
- # boot (327)
- # cider (2)
- # cljs-dev (1)
- # clojure (127)
- # clojure-art (72)
- # clojure-russia (273)
- # clojure-sg (1)
- # clojurescript (39)
- # cursive (8)
- # datomic (6)
- # editors (2)
- # emacs (4)
- # hoplon (261)
- # immutant (2)
- # ldnclj (15)
- # liberator (10)
- # luminus (1)
- # off-topic (8)
- # om (9)
- # parinfer (1)
- # re-frame (11)
- # reagent (2)
- # yada (9)
Anyone know of a
re-cond macro in a library somewhere? Looking thinking of
(re-cond [bindings regexp form]*) implemented as chained if-lets on the regexp match and thought I'd take a minute to check for prior art.
@trancehime: I've never used
lein uberjar but my understanding is that it will give you a self contained server with all your dependencies in it, that you can easily try out as long as you know the url your web application is served from. You just need to find the jar file produced and run it with
java -jar ..., I would think.
Hmm... 'Cause I'm trying to figure out a way to deploy the immutant app on a server. I remember I have 2 options, either
uberjar or to deploy to Wildfly.
lein install - try that - then use a zip program to see what's in the jar file produced.
Actually the jar produced does not need to refer to the jars it needs in any way. Just normal code references is all that's required.
If it is anything like jetty / tomcat under your partic webapp directory there will (need to) be a WEB-INF/lib directory.
lein install is more for making your own library so I'm not 100% that's the right lein command, but it's better than
lein immutant war is what you want. The resultant jar there will be worth looking into with 7-zip (or whatever you use), because iirc you will see the whole structure - WEB-INF directory etc. A 'war' is just a jar 'jar' made for deployment to a web server - so exactly what you want.
If it is like the others just install it then put the war in the webapps folder and restart WildFly. Know where WildFly's log file is for stack traces. However open the webapp in the browser first to see if you even need to look in the log file.
Well it's less the actual deployment and more virtual host/URL setups since I don't usually do that stuff
It's not really a problem i've run into so much as it is "I need to deploy this app ASAP instead of running locally"
Anyway, you create the jar with the boot/lein plugin. IIRC you don't need to AOT, but you need to include sources.
You just download WildFly from http://download.jboss.org/wildfly/9.0.2.Final/wildfly-9.0.2.Final.tar.gz, unzip it and run
./bin/standalone.sh -c standalone-full.xml from the directory.
When it's up and running you just shove the war into
./standalone/deployments/ and that's it.
with my other clojure app which I have to deploy into Tomcat, there's already some
Yeah, so you would set the context path to
/ if you want to access it under
server/, I think.
So you will get a
jboss-web.xml file looking like so:
<jboss-web> <virtual-host>your-virtual-host</virtual-host> <context-root>your-context-root</context-root> </jboss-web>
You don't need to touch Wildfly's configuration, this all will be done by the immutant task and Wildfly should respect it. But if I'm misuderstanding something, then sorry.
My question is actually server-specific, ie: how do I configure the main host path
URL so that when I deploy the application on a WildFly instance I can access the app at that URL.
Like I said, not necessarily clojure related, so prolly don't belong here anymore, quite off-topic
Huh. A quick google around and it looks like you the closest equivalent is
split, but it partitions only in two halves. Interesting why they omitted a function to split into multiple sublists.
Are there any major drawbacks of interleaving the midje specs with the implementation? I see a few upsides, like 1. I don't have to jump between implementation and test files constantly 2. I don't have to have twice as many files in my directory tree (also repeating the same namespace segments)
I wrote this Scala solution (because I'm learning it right now) and then tried the Clojure solution of @bhauman. Not only is it shorter, it's much faster. I wonder what's up with that: https://gist.github.com/borkdude/3d080f43c2097ddf26b8
Well, that sounds plausible - I think Scala's lists and function on interables are strict by default, whereas Clojure's are lazy. Maybe changing list to a stream would help?
I think I found the culprit: if I replace the intermediate strings with a StringBuilder in Scala, it is as fast. Could it be the Clojure version 'magically' compiles to StringBuilders in Java?
Well, I don't think you need
iterate explicitly, you can just map over an infinite stream just as well - http://www.scala-lang.org/api/2.10.2/index.html#scala.collection.immutable.Stream
Took me a while, but now it's fast and reasonable... learned some new things today. https://www.reddit.com/r/adventofcode/comments/3w6h3m/day_10_solutions/cy5jdse
Hi, can you create a Prismatic Schema for a vector that contains at least 1 s/Int?
[(s/optional s/Any "head") (s/one s/Int "integer") (s/optional s/Any "tail")], but starting with optional schema is not allowed.
seancorfield: do you have any thoughts on the relationship between clj-time and the new java.time classes? e.g., could clj-time expand to support them, or would a parallel library be appropriate?
jindrichm: oh you mean it can have various other things throughout as long as there's an integer?
Maybe more appropriate for #C053AK3F9, but given two maps with identical keys in both, I want to return kv pairs where the values differ. Is
clojure.data/diff a reasonable solution there?
@gfredericks: Yes, I've made it up to have a simpler example. Actually, I need to check a vector that contains maps, of which at least 1 needs to match a specific schema.
I've come up with
(s/both (s/pred (partial some integer?)) [s/Any]), but
s/both is deprected and its translation to
s/conditional is unclear to me.
but I can see why you'd want it the other way and am still confused about s/conditional myself
As I develop this REST API, I'm noticing a lot of common functions between resource types. I had been putting them in type-specific namespaces:
(user/create!), and so on. I'm starting to think that one of Clojure's OO-like features would be nice to use here. Protocols and records? Or if I don't need true polymorphism—that is, I always know the data type I'm working on—maybe I should stick with my namespaced functions?
I'm never going to be calling
(create! <some-map>) and not know/care what type of thing I'm trying to create, after all.
I recommend keeping functions that create / deal with different types of things separate
protocols only really make sense if it is actually exactly the same operation (just needs to handle different argument types)
Thanks. When you're new to a language, it's tempting to use all the features, even when they are not strictly appropriate.
e.g. much better have "create-user" and "create-video" functions than a single "create" function with really complex arguments
also makes it easier to verify such functions with tests and/or tools like prismatic schema
True. In my case, 100% of activity will go through the API, so I have Schema set up on my routes, enforcing arguments/returns, but I'm not using it in the business logic. This saves me time in the short run... any opinions on the long run?
@gfredericks: re: clj-time -- to use the new Java time stuff requires the new Java version, whereas clj-time runs on several Java versions. Not sure how much of a concern that is in the real world but that would be my first reaction. Does the Java time stuff bring any real benefits over using Joda Time?
anyone know of a clojure-equivalent to https://github.com/dmendel/bindata (used for parsing structured binary data)? i've looked at gloss, buffy, and binary but none seem to support the
onlyif specification that bindata has. buffy comes closest w dynamic frames.
seancorfield: you could do compile-time conditionals to preserve backwards compatibility; I don't know of any direct benefits, I just get antsy with "if everything's going to move to this new API anyhow I'd like to do it sooner"
We rely on clj-time heavily at work, we're on Java 8 but I have no desire to switch from Joda Time to Java 8 just "because". I'd worry about changing the behavior of clj-time.
I can see some argument for modifying the coercions to/from java.util.Date to use the new Java API but even there I don't really see a benefit.
Feel free to send a PR with an enhancement then, to add coercion support for the new types.
As long as it still works on older JVMs and older Clojure versions -- and is purely additive -- I'm sure the clj-time maintainers will be happy to accept it.
I was thinking, would it make sense to have persistent immutable strings on the JVM instead of just immutable?
I ran into this problem with a 'reduce' on a lot of intermediate strings. StringBuffer was the answer, but I think persistent (shared) strings would have saved me there also
I suppose they would share some downsides of ropes - https://en.wikipedia.org/wiki/Rope_(data_structure)