This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-07
Channels
- # admin-announcements (2)
- # boot (111)
- # capetown (5)
- # cider (15)
- # clara (15)
- # cljs-dev (8)
- # clojure (78)
- # clojure-brasil (1)
- # clojure-dev (2)
- # clojure-greece (25)
- # clojure-hk (1)
- # clojure-russia (5)
- # clojure-seattle (1)
- # clojure-spec (120)
- # clojure-sweden (3)
- # clojure-uk (63)
- # clojurescript (161)
- # data-science (1)
- # datomic (21)
- # editors (43)
- # emacs (3)
- # funcool (1)
- # hoplon (72)
- # instaparse (11)
- # jobs (1)
- # off-topic (2)
- # om (212)
- # onyx (9)
- # other-languages (129)
- # proton (5)
- # re-frame (15)
- # reagent (18)
- # slack-help (4)
- # spacemacs (18)
- # untangled (224)
- # yada (21)
@sorenmacbeth: hmm, I can see vizard-0.1.6.jar appear to be uploaded in the nginx log - would you mind filing an issue for this so we can track it? https://github.com/clojars/clojars-web/issues/new
whats your guys’ favorite library for writing a web server atm? I’m looking to learn something new!
@tcrawley: yes, I tried again and it worked
@adamkowalski: compojure (https://github.com/weavejester/compojure) + ring (https://github.com/ring-clojure/ring) is nice, but can take a while to set up the first time. Luminus (http://www.luminusweb.net/), which is built on top of ring/compojure is a good option if you want to get started quickly.
I like bidi and yada! (disclaimer: I work for Juxt. But I liked both before I came here)
yada is really interesting
Is anyone accidentally working on some clojure.spec for swagger? I am and I would prefer to contribute to existing work rather than start anew 🙂
Hey guys, I am reading the joy of clojure, and at page 279 he show us a example.
(defn respond ([exchange body] (respond identity exchange body)) ([around exchange body] (.sendResponseHeaders exchange OK 0) (with-open [resp (around (.getResponseBody exchange))] (.write resp (.getBytes body)))))
I didn't figure out this (respond identity exchange body)) and (with-open [resp (around (.getResponseBody exchange))]
Why use identity to get response body ???
@mbrum: Not sure I understand. “around” appears to be a wrapper for the response body; identity is a wrapper that does nothing
I got it, it is just a extension point, and the default do nothing...
thanks @Ivh
@lvh: added some details/options to the issue. Please comment there if you are poking with it too. Cheers.
Yo folks - anyone know of any JMS wrappers - especially ones that use JMS 1.0 / AMQP - in clojure? I looked at https://github.com/sbtourist/clamq but it’s never gotten past a snapshot release, and that was 5 years ago...
@korny JMS is pretty easy to use directly.
It's a surprisingly nice API, given its age.
Just be careful with threads — most of the objects can't be safely used by multiple threads.
yeah, it seems most code I’ve seen uses the APIs. Once you’ve gone through the initial fiddling with factories and the like, agreed it’s not too bad.
and actually our usage won’t be too complex. I just felt dirty with the number of Java calls I was making 🙂
@korny: If you are using RabbitMQ then I really liked using Langohr for AMQP stuff: http://clojurerabbitmq.info
Yeah, I’ve used Langohr before, it was nice. In this case we are testing a few different AMQPs, but they are all AMQP 1.0 where Rabbit chose to stick on 0.9.something
(Kafka would be nice but the client would need some very widespread changes to go away from AMQP)
I'm implementing a Java interface and one of the methods is init
where I'll need to save some state for use in the other method implementations. The generated class needs a no-arg constructor and is called by a framework, so I can't supply an atom or anything as a field on record initialization. Any thoughts on how to do this? I'm looking to do the equivalent of setting a private instance field from a constructor in Java.
With deftype
you can create (and set) mutable fields, but you can’t do it “on construction"
but if you can construct and set the fields in init
, that would work
(definterface TheInterface
(init [])
(getx []))
(deftype Foo [^:volatile-mutable x]
TheInterface
(init [_] (set! x 100))
(getx [_] x))
(def f (Foo. 10))
(println (.getx f)) ;; 10
(.init f)
(println (.getx f)) ;; 100
The problem here is that now Foo
has a single arg constructor. The framework will attempt to instantiate this class with a no-arg ctor and it will fail because it requires an argument.
ah, right. well that won’t work then. :)
you can do that with gen-class, although it’s a lot more work
you can implement the interface, define the 0-arg constructor, and construct the initial “state"
some ok examples at https://clojuredocs.org/clojure.core/gen-class
I suggest look first episode of this excellent intro to clojure lang http://www.parens-of-the-dead.com/
@rmuslimov: thanks
what if it is more nested, like that vector element is a map, and that map contains another vector, do i have to go deep to change element in nested vector?
I’d be kind of alarmed at that level of complexity in a data structure but you could try assoc-in
to grab the far-nested item.
If you have some crazy nested thing you should check out specter (https://github.com/nathanmarz/specter) for that.
the inner vector means a list, and i want to update the item with name john, and assoc its age key with value 22
looks like this with specter:
(setval [:model :customer ALL #(= (:name %) "john") :age]
22
{:model {:customer [{:name "john" :age 21}]}})
;; => {:model {:customer [{:name "john", :age 22}]}}
@nathanmarz awesome, will try it out, thanks!
sure thing, feel free to come by #C0FVDQLQ5 channel if you have questions