Fork me on GitHub

So I just put my open dispatch stuff up in a lib here, mostly to piss off @hiredman 😉 But if it raises anyone else's ire, I'd be happy to hear your critical feedback (or collaboration!)


If no baby seals are harmed over the next few days by the lib, I'll probably drop it in the #ann channel


Translating it to CLJC would be a great contribution, if anyone's looking to help out!


Here's a puzzle for someone: I have an input-stream. I want to print each line immediately as data is available. I also want that content to go to a corresponding function that will consume it at its own pace. Is there a simple way to "tap" and print an input-stream like this?


@bmaddy here is what i would do..


@bmaddy Here's another one:

((fn [in f]
     (with-open [r (io/reader in)]
       (run! #(doto % prn f)
             (line-seq r))))
    ( (.getBytes "foo\nbar\n"))


is there a best practice for syntax quoting without fully qualified namespaces? (similar to this: The options that I see are ~' (unquote/quote) every symbol or use a library that provides such a macro but isn't maintained ( Am I missing anything? (aside from writing my own macro)


did you try the backtick library and it didn’t work, or are you concerned that it doesn’t work cause there is no activity on the repo?


@schmee I'm about to give that a go. usually not keen on using 3rd party libraries that don't seem maintained. wondering if it's not maintained because there's a more idiomatic way that I'm missing here


I think it’s not unmaintained, it’s just “done”. some clojure libs are like that


activity on the repo usually signals new features (not the case here cause it’s a one-feature lib), adapting to other peoples breaking changes (this lib has no deps so not relevant), or fixing bugs (this is <100 LOC so most bugs have probably been ironed out by now)


Hi. I'm delivering micro service as jar file which is run on the client's sever. How can I add some license solution which can limit time of usage (e.g. 12 months) and number of API requests (e.g. 10k)? There are situations when my app doesn't have access to the Internet. I know that it is very general question and maybe more Java related, but I need at least some tips or ideas or links. Thanks in advance for help


@U0ARSC79A you basically need some kind of license key which will encode the license validity. In your app, you can then decode that license key and check if current time is still less than the end time encoded in the license key. Otherwise, you show an error to the user. Of course, you rely on system clock setting but you could add some more checks if that's an issue. As regards to the license key format it should be encrypted somehow - symmetric encryption isn't ideal since you'd have to hardcode encryption key somewhere in your app. An alternative would be license key signed with your private key and decoded (in the app) with the corresponding public key.


I used buddy's compact message signing for a similar purpose in the past:


Note that anybody can see the content of license key but that shouldn't be an issue - you just want to make sure that user cannot generate a fake license key.


ok, thanks for a good approach


hi, does anyone know a way to include maven :classifier artifacts in a deps.edn given that they have the same mvn coordinates & :deps is a map ?


Does anyone know if it's possible to specify a different dependency file than deps.edn in the clojure script?


@weavejester don’t know, but this workaround may work for you: clj -Sdeps "$(cat deps2.edn)"


I figured I might need to do something like that 🙂


you can point to a folder where a deps.edn lives though: CLJ_CONFIG=foo clojure -A:my-alias


any deps.edn in $PWD overrides values from foo/deps.edn, but it also works when $PWD/deps.edn does not exist.


Soo I am working on a project where we have to run Clojure in OSGI. And it works pretty flawlessly actually, apart from one thing. For some reason if a ns requires it fails to load the OSGI bundle with the following error:

Caused by: java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: nrepl.misc, compiling:(nrepl/misc.clj:7:1)                                                          [INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyzeSeq(                                                                                                                                          
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(                                                                                                                                              [INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyzeSeq(           
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(                          
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.access$300(                                                                                                                                             [INFO] [talledLocalContainer]   at clojure.lang.Compiler$DefExpr$Parser.parse(
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyzeSeq(                                                                                                                                           [INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(                                                                                                                                             
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(                                                                                                                                              [INFO] .......
We are using com.theoryinpractise/clojure.osgi is there anyone who has any knowledge about this?


Bump. Is there anyone with knowledge about clojure+osgi?


I want to make a command line tools in clojure, but the startup time makes it a bad experience. Is there anything I can do to improve the startup time. I'm talking about tools to add stuff to my bind configuration (dns), managing some vhosts,...


I am a Clojure newbee. Have read about GraalVm for speeding up command line apps. No personal experience though.


I'll look into it, thank you


If the JVM isn't a requirement, you might get better startup time with ClojureScript/Node.js


@robin.broeck Planck and Lumo are suited for this if you want to run scripts on the fly.

❤️ 1

Happy Thanksgiving to all of you who are US based! For what it's worth, I am incredibly, unironically grateful for the support and expertise that live in the clojure community. You've made my life so much better.

🦃 1

@robin.broeck I made some tools to help with GraalVM native-image building and CLI apps: (contains a few examples) (same as above but for deps.edn projects) is a project template of sorts, with example Clojure->native-image app

❤️ 1
👍 2

Yeah, I must say those were pretty helpful the other day.

👏 1

using tagged-literal as shown here, what is the best way to further process a data structure containing these? I want to process them down stream further by providing reader functions. the only way I found was to pr-str and then clojure.edn/read them providing the reader functions. but the round trip to a string feels unnecessary


can you give an example what you want to do? you can pass a :readers argument to the read function that is a map of data readers for whatever tags you want


I want to read forms from a network socket, but at the time of reading I don’t yet know all values which the tagged literals need to be replaced with later, thus providing :readers at that time is of no use to me, I think. the forms are more like templates I want to store for later use, and only then I know all the things which can go into :readers.


what’s the win?


so much complexity for so little gain..


Thanks @pradyumna and @petterik; those are both tons better than the route I was heading down!


Hi, do you agree that It would be nice if the following comparison returned true?

(= #"\d" #"\d")
=> false


Would be hard to implement equality for two regex patterns because two patterns that match the same things could look very different


(fn [x #^Key y] ...) wtf is #^Key ???


old syntax for ^Key

👍 1

Is anyone familiar with this error: java.lang.Exception: Unable to find data source: $__in__2 in: ($ $__in__2)?


@yogidevbear it's a #datomic query?


Yup - should I take the question to #datomic instead?


not really. this error probably due missing db argument. can you share the :in part of the query?


Funny thing is it's inconsistent - the code seems to be working as results are being updated, but this error is happening too


The :in is :in $ [?e ...]


there is no nil on db?


The query looks roughly like:

(d/q '[:find ?eid ?foobar
         :in $ [?e ...]
         [?eid :some/id]
         [?eid :foo ?foo]
         [?eid :bar ?bar]
         [(str ?foo "_" ?bar) ?foo-bar]]
where batch is from a previous query using sample to limit the qty of rows being dealt with to do some retrospective updating


@souenzzo Thanks for that comment re nil db. I found a missing when check in my calling function to check the batch before passing it in. batch was the 2nd argument which I think is the issue here re $__in__2


how can I pass a edn reader for #'? Trying to make this work (edn/read-string {:default (fn [t v] v)} "#'user/hello") but I get No dispatch macro for: '


@mkvlr #' is a clojure special-form. It's not edn. You can use clojure.core/read-string. But it is "not safe"


@souenzzo so there's no way to read that string with edn? I want this for a prepl. Does it mean I have to change it on the side where it's printed?


There is a issue on jira about use #var or something like. you can do

(edn/read-string {:readers {'var resolve}} "#var clojure.core/get")
=> #'clojure.core/get


(binding [*print-dup* true]
  (pr-str #'clojure.core/get))
=> "#=(var clojure.core/get)"
But i think that once it's a prepl, maybe you can use read-string. Once "all data" is trusted.


well this is an untrusted prepl for a hosted notebook…

😅 1

(defmethod print-method clojure.lang.Var
  [x ^Writer writer]
  (.write writer (format "#my/var[%s]" (str (symbol x)))))
=> #object[clojure.lang.MultiFn 0x5bdbb90e "[email protected]"]
=> #my/var[clojure.core/get]
(edn/read-string {:readers {'my/var (comp resolve first)}}
=> #my/var[clojure.core/get]
Not sure if it is a good solution. But kind of work.


cool, thanks! I was trying with print-dup


Is there a way to ensure / specify the order of some dependencies in a classpath (context class path)?


I've come to the conclusion this is the wrong approach and that it is much better (sensible, extensible) to ensure unique paths for 'duplicate' resources...