This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-17
Channels
- # bangalore-clj (2)
- # beginners (51)
- # boot (20)
- # cider (14)
- # clara (1)
- # cljs-dev (14)
- # cljsrn (50)
- # clojure (140)
- # clojure-dev (5)
- # clojure-france (1)
- # clojure-gamedev (3)
- # clojure-italy (4)
- # clojure-poland (3)
- # clojure-russia (8)
- # clojure-sg (1)
- # clojure-spec (64)
- # clojure-uk (51)
- # clojurescript (54)
- # core-typed (1)
- # data-science (2)
- # datomic (61)
- # docker (1)
- # emacs (6)
- # events (1)
- # graphql (1)
- # hoplon (14)
- # leiningen (8)
- # luminus (3)
- # mount (6)
- # off-topic (18)
- # om (17)
- # parinfer (34)
- # pedestal (47)
- # play-clj (1)
- # protorepl (1)
- # re-frame (56)
- # reagent (11)
- # ring-swagger (5)
- # rum (6)
- # sql (1)
- # uncomplicate (2)
- # vim (3)
- # yada (31)
is there a way to get the emacs repl to display reagent/hiccup/react/dom/svg elements ? so I want to write sexps that return hiccup, then have emacs, instead of displaying the raw clojure data, to render it and display it
So I'm thinking about writing a clojure desktop app. Does https://github.com/halgari/fn-fx seem relatively stable and usable?
config: nomad, aero, environ, cprop, ... who uses which library and why? (it's always nice to have some kind of experience reports before deciding)
@plins why should it be based on core async?
@kurt-o-sys We wrote our own. We haven't gotten around to open sourcing it yet tho'. It's partly inspired by outpace/config
but does some specific stuff we needed, and it's Component-based. This is a good article comparing some of the config libraries: http://realworldclojure.com/application-configuration/
Hmm, actually now I re-read that article, I suspect Sonian's carica
is more likely the inspiration for what we ended up with.
@seancorfield right, thx
@kurt-o-sys we use aero, I like it's philosophy of centralising as much config as possible, and just separating out sensitive config
Does clojure have any sort of plugin loading library? I'd like to create an application which loads plugins, but I haven't seen anything around.
@kurt-o-sys we use https://github.com/typesafehub/config with a tiny clojure wrapper
@kurt-o-sys aero here too, it's just edn + some data readers. nothing too fancy, but quite powerfull. And you can extend it if you need it to do something it can't. It's quite lightweight.
{:keys [in out] :or {in chan out chan}}
I am familiar with {:keys [...]} . What does the :or mean?@danielcompton @mpenet ok... I've been using cprop before. I might try aero for a change. @dm3 any reason why you don't use one of the clojure config libs?
question: In Clojurescript it seems that the &env
passed to macros contains the def
vars as well as locals. How do I get the same in Clojure?
I need to filter this out by matching the inner vector for example this [[:x [3 2]] [:y [1 1]] [:z [3 2]] [:i [3 1]] should be [[:x [3 2]] [:y [1 1]] [:z [3 2]]]
[:i [3 1]] will be removed because the first element of the inner vector appeared before with a different value of the last element
is there a clojure naming convention preference for a function which returns a predicate? Assumption here is that some extra data is required to create the predicate and we need a separate function taking that extra data and returning the predicate function
did anyone try to call an external program with clojure with timeout? none of the examples (conch), (clojure.contrib.shell-out with java.util.concurrent.TimeUni) did work... stuff runs forever
I think you need to do the bookeeping yourself and call destroy on the Process instance if not completed
(let [x (.exec (Runtime/getRuntime) "htop")]
(try
(Thread/sleep 10)
(.exitValue x) ;; check value possibly
(catch java.lang.IllegalThreadStateException e
(.destroy x))))
the problem wit conch was that stdot/err was flushed at the end, which would never happen when process was destroyed earlier
should it be possible to do stuff like (let [x (.exec (Runtime/getRuntime) "htop > mylogfile")] with mentioed example?
I don’t think any of the process stuff uses sh, and >
is sh syntax, so you need to wrap up your call into a string passed to /bin/sh
to make that work
or you can create the redirection using the file handles Process gives you if you want to do it the hard/portable way, of course
I have a seq like [:a :b :c]
and want to get a lazy seq like [:a :b :c :a :b :c :a :b ....]
— any suggestions?
@martinklepsch (cycle [:a :b :c])
@schmee thanks, that’s what I missed! 🙂
Hello. I'm looking at https://dev.clojure.org/display/community/Maven+Settings+and+Repositories and wondering about SNAPSHOT releases. In the example, is 1.1.0-SNAPSHOT before or after the 1.1.0 release? In other words, is it supposed to be a pre-release snapshot or a post-release patch?
under the hood, every time you lein install
a snapshot version, a timestamped artifact is added to your maven repo, and the SNAPSHOT name just points to the latest of these
if you use the lein-release
plugin then when you're ready to release it, you run lein release
and it'll transition your 1.1.0-SNAPSHOT
to 1.1.0
, commit, tag and deploy that to your maven repo, and then bump the version to 1.1.1-SNAPSHOT
, so you're ready to start working on the future 1.1.1
release.
Hate to interrupt, but I'm having trouble splitting up the middleware for my different routes in Compojure
I have a question about structural sharing in nested maps. Suppose I have a map called mymap that looks like this
mymap
=> {:mykey [{:A 1, :B 2} {:A 2, :B 2} {:A 3, :B 2}]}
I want to write a function that goes down and increments each value for :A
I can do this with
(assoc mymap :mykey (map #(assoc % :A (inc (:A %))) (:mykey mymap)))
{:mykey ({:A 2, :B 2} {:A 3, :B 2} {:A 4, :B 2})}
do the keys :B "point to the same place in memory" after this modification as the original maps? That is, is there structural sharing going on between the maps in the vector before and after this modification?Yes, there is. You can verify yourself whether this is so using identical? on the pieces you hope are being shared, as shown below
user=> (def mymap {:mykey [{:A 1, :B 2} {:A 2, :B 2} {:A 3, :B 2}]}) #'user/mymap user=> (def m2 (assoc mymap :mykey (map #(assoc % :A (inc (:A %))) (:mykey mymap)))) #'user/m2 user=> (identical? (-> mymap :mykey (nth 0) :B) (-> m2 :mykey (nth 0) :B)) true
This would be a better test:
user=> (identical? {:test 1} {:test 1})
false
user=> (def mymap {:mykey [{:A 1, :B {:test 1}} {:A 2, :B {:test 1}} {:A 3, :B {:test 1}}]})
#'user/mymap
user=> (def m2 (assoc mymap :mykey (map #(assoc % :A (inc (:A %))) (:mykey mymap))))
#'user/m2
user=> (identical? (-> mymap :mykey (nth 0) :B) (-> m2 :mykey (nth 0) :B))
true
The better test works, too, as I expected it would. Thanks.
Also, for clarity, there isn't any structural sharing going on within the vectors themselves - only at the same key "paths" between mymap
and m2
:
user=> (identical? (-> mymap :mykey first :B) (-> mymap :mykey last :B))
false
user=> (identical? (-> m2 :mykey first :B) (-> m2 :mykey last :B))
false
user=> (-> mymap :mykey first :B)
{:test 1}
user=> (-> mymap :mykey last :B)
{:test 1}
Yeah - this is a cool approach to discover the structural sharing. I hadn't thought of using identical?
for this.
hey @U0DATSMH6 , @U0CMVHBL2 , I didn't know that identical?
could be uesd in such a way to examine structural sharing - thanks!
Asymmetry in string/split
and string/join
makes me sad : (
parts (string/split kafka #":")
host (string/join ":" (butlast parts))
Hi all, I am trying to write some test in clojure and I need to do some Mocks and proxies, however I cannot figure out how to proxy some java objects and methods I have this function
(defn singletest
[cert]
(let [x500principal (.getSubjectX500Principal cert)
dn (.getName x500principal)]
(apply str "abcdefg")))
(deftest singletest
(let [cert (.X509CertImpl)
x500principal (proxy [X509CertImpl] []
(getSubjectX500Principal [] nil))
dn (proxy [X500Principal] []
(getName [] "works"))]
(is (= "" (c/singletest cert)))))
throws me java.lang.IllegalArgumentException: Malformed member expression, expecting (.member target ...)
I change it to
(deftest singletest
(let [cert (proxy [X509CertImpl] []
(getSubjectX500Principal [] nil))
x500principal (proxy [X500Principal] []
(getName [] "works"))]
(is (= "" (c/singletest cert)))))
ditto you probably want to implement X509Certificate not X509CertImpl (program against abstractions, not concretions)
So you are saying the inconsistency is actually an example of a greater consistency?
Still, why not always have "the thing being operated on" either always last or always first? What value does having one rule for single objects and a different rule for collections provide?
@spangler I didn't read all of these but it's exactly your question: https://stackoverflow.com/questions/18234818/why-is-the-argument-position-of-split-and-join-in-clojure-string-mixed-up
think of the threading macros ->
vs ->>
. basically one is do stuff to object and one is do stuff to collection
@joshjones Thanks!
i thought the question was why do these seem inconsistent. so then yes the "greater consistency" sounds good to me
I did ask a few questions. The one I was referring to was this: "Still, why not always have "the thing being operated on" either always last or always first? What value does having one rule for single objects and a different rule for collections provide?"
@joshjones Funny, they don't answer it there either : )
I think it's nice having it obviously clear whether code is working on collections or objects myself
@spangler with things like this I think you are bound to find reasons for doing it one way or another, and just as with anything, there are likely to be differences of opinion. Particularly with functions one does not use very often, you'll need to look at the docstring or IDE hints anyway to determine what it takes, so unless if vexes you greatly, I'd say this is not much of an irritation 😉
@joshjones Appreciated, though it does irritate me every time I have to look it up
Really I gripe because clojure is so well-designed in most other ways, these funny inconsistencies stand out all the more
Your point is well taken, and justifying its correctness may or may not be a losing battle -- if that's one of your irritations then I'd say you'll be just fine :thumbsup::skin-tone-2: 😉