This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-24
Channels
- # beginners (64)
- # calva (40)
- # cider (76)
- # clara (13)
- # clojure (72)
- # clojure-dev (34)
- # clojure-italy (4)
- # clojure-nl (14)
- # clojure-poland (1)
- # clojure-uk (30)
- # clojurescript (58)
- # clr (10)
- # core-async (101)
- # cursive (31)
- # datomic (9)
- # emacs (20)
- # fulcro (2)
- # jackdaw (1)
- # jobs (3)
- # juxt (3)
- # luminus (4)
- # lumo (15)
- # mount (4)
- # nrepl (29)
- # nyc (1)
- # off-topic (27)
- # qlkit (1)
- # quil (5)
- # re-frame (19)
- # reitit (8)
- # remote-jobs (4)
- # rewrite-clj (5)
- # shadow-cljs (45)
- # spacemacs (22)
- # sql (9)
- # uncomplicate (1)
- # xtdb (14)
Hello.
I'm trying to use org.apache.commons.io.input.ObservableInputStream
to make sure that I remove the file that I just streamed.
For that I need to extend the abstract class org.apache.commons.io.input.ObservableInputStream$Observer
and override some of its methods. I tried using proxy
but the overridden methods are not called.
Is this because they're not public and have the default visibility instead?
My next step is to use gen-class
. Is there anything simpler for this task?
Ah, my Java's a bit rusty - package private methods cannot be overridden from another package at all. And the corresponding bug in Common's JIRA says: "Fixed, will be in 2.7, whenever that comes." Oh well.
New question - is there any way to use Java files in a Clojure project while keeping the working REPL? I don't want to reload Java files, I just want them to work. Right now I just keep getting ClassNotFoundException
.
It seems that Leiningen allows you to specify :java-source-paths
. The thing is, I don't use Leiningen and Boot - I just use clj
.
@p-himik from https://clojuredocs.org/clojure.core/import
;; For cases when 'import' does not do it for you, i.e. "live-coding"
;; You can use the DynamicClassLoader, ClassReader and the Resolver.
;;
(def dcl (clojure.lang.DynamicClassLoader.))
(defn dynamically-load-class!
[class-loader class-name]
(let [class-reader (clojure.asm.ClassReader. class-name)]
(when class-reader
(let [bytes (.-b class-reader)]
(.defineClass class-loader
class-name
bytes
"")))))
(dynamically-load-class! dcl "java.lang.Long")
(dynamically-load-class! dcl 'org.joda.time.DateTime)
;; From that point the dynamically loaded class can be
;; used by the Reflector to invoke constructors, methods and to get fields.
But it requires a corresponding .class
file, doesn't' it? I'm getting `Execution error (IOException) at clojure.asm.ClassReader/readStream (ClassReader.java:300).
Class not found` with it.
found https://github.com/ztellman/virgil for lein and boot
Yep, I could use https://github.com/tailrecursion/javastar that it mentions to just slurp
that java file. 😄
Found this: https://www.mail-archive.com/[email protected]/msg103900.html More than half a year old but is probably still true.
clj is not a build tool, only a pure Clojure runner, so without something
additional to do Java compilation, you can’t use it in a mixed source project.
Any suggestions/reads/libs on how to stub an external RESTAPI service in my tests? So far I am thinking of https://github.com/myfreeweb/clj-http-fake
I'm curious too. I think Clojure is missing a library like this https://github.com/lostisland/faraday
the one I mentioned above is the Clojure adaptation of https://github.com/chrisk/fakeweb. Have you heard of that?
No I haven't heard of it (but doesn't say much actually)
Also saw this https://github.com/johanhaleby/stub-http
Is the rest API has swagger, you could maybe use one of the java generated servers https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO to bad clojure is no option.
very good tip @U26FJ5FDM thank you
I used it to 'mock' a notification server (actually the mock worked better than the .not real version :))
what's the best way to modify a macro that expects a literal Seq to evaluate functions/symbols passed to it?
(defmacro old-printy
[print-this]
(if (seq print-this)
`(print ~print-this)))
Passing '[a b c]
works, but (def print-these '[a b c])
/`(old-printy print-these)` throws exception.
So far I have this
(defmacro new-printy
[print-this]
(let [evaluated-print-this (cond
(fn? print-this) `(~print-this)
(seqable? print-this) `(seq ~print-this)
(symbol? print-this) `(into [] ~print-this)
:else print-this)]
`(print ~evaluated-print-this)))
I forgot the (if (seq evaluated-print-this))
in the second one :face_with_rolling_eyes:
Not sure if this handles all of the intended cases, @UHK8B8STX:
(defmacro new-printy
[print-this]
`(let [evaluated-print-this# (cond
(fn? ~print-this) (~print-this)
(seqable? ~print-this) (seq ~print-this)
(symbol? ~print-this) (into [] ~print-this)
:else ~print-this)]
(print evaluated-print-this#)))
I missed out keyword and probably a few more, but it seems overly laborious to have to cond based on type. I wonder if there's a better method?
i'm just starting with core async, if i want some transformations on a channel data is that a proper way to do it?
(defn filter
([c] (filter (chan) c))
([c' c]
(go (while true
(>! c' (<! c)))) ;; logic here
c'))
no, channels can take a transducer
(chan 10 (filter odd?))
that's a channel, buffer size 10, that you can put numbers into and only odds will come out
also, fyi there's #core-async for more in-depth questions
I have something like this:
src/
- clj/
- my-namespace/...
- java/
- my-namespace/...
@pablore: tools.deps
is not a build tool, so you can’t do that without compiling those java classes — and for that you need to look into build tools
or just use leiningen
which will do that
did you set https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L306 ?
Hi, is there something like https://github.com/metosin/ring-swagger but which does the reverse? So it transforms a swagger spec (or open api spec) into a working mock API endpoint?
It’s not Clojure, but this is close: https://github.com/yayoc/swagger-to-mock
those of you that use Schema for data spec, there is any way to validate some data against a schema without returning an exception, only true or false ?
@jlmr if you find something like that, let me know, i'm using swagger too
you can replace
oh, schema not spec, - plumatic/schema also has a function that you can use s/check
it appears schema and spec us valid vs. check in opposite ways(?)s/check
with s/valid?
i'll try
check returns nil if data matches the schema
how weird
s/validate throws an exception, so i have to handle it in order to not break my entire app. and i don't want to handle it
because there's often only one way to be correct, and many ways to be wrong
guess i'll have to make a wrapper fn to handle it
and make it return true or false
or i can use s/check with nil?
which i think it's very weird to read
@cybersapiens97 (complement s/check)
- returns a function which returns true or false in the way you want
oohh, how smart
thanks!
Hello everyone 👋. I just created an account here so it would be nice to introduce myself 🙂 My name is Radek, I'm from Poland. Not yet a clojure dev yet aiming to become one in some time. Currently working as a PHP/JS dev (w/ +10 years of experience). Proud owner of ErgoDox, VIM maniac. Currently watching season 2 of One Punch Man 😛
Be sure to check out the wide range of channels here -- you'll find #beginners very helpful for early questions as you're learning the language (folks in there have opted in to helping new folks!). Pretty much every library in common use has a channel here somewhere -- and if you have questions about Slack itself (or this Slack in particular), there's #slack-help
awesome, thanks for quick introduction 🙂
@U3BUZ2BPZ IKR ? Awesome stress reliever 🙂