Fork me on GitHub
#clojure
<
2018-11-22
>
john00:11:04

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

john00:11:53

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

john00:11:27

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

bmaddy05:11:15

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?

pradyumna06:11:01

@bmaddy here is what i would do..

petterik06:11:31

@bmaddy Here's another one:

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

tomerweller08:11:05

is there a best practice for syntax quoting without fully qualified namespaces? (similar to this: https://stackoverflow.com/questions/13758555/why-is-clojure-adding-namespace-qualifiers-to-names-inside-a-backquote) The options that I see are ~' (unquote/quote) every symbol or use a library that provides such a macro but isn't maintained (https://github.com/brandonbloom/backtick). Am I missing anything? (aside from writing my own macro)

schmee08:11:40

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?

tomerweller08:11:47

@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

schmee08:11:02

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

schmee08:11:15

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)

masztal09:11:40

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

jumar09:11:06

@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.

jumar09:11:42

I used buddy's compact message signing for a similar purpose in the past: https://funcool.github.io/buddy-sign/latest/#compact

jumar09:11:59

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.

masztal09:11:23

ok, thanks for a good approach

octahedrion10:11:08

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 ?

weavejester11:11:11

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

borkdude11:11:28

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

weavejester11:11:46

I figured I might need to do something like that 🙂

eval202011:11:43

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

eval202011:11:33

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

mitchelkuijpers12:11:31

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 clojure.tools.logging 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(Compiler.java:7010)                                                                                                                                          
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(Compiler.java:6773)                                                                                                                                              [INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyzeSeq(Compiler.java:6991)           
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(Compiler.java:6773)                          
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.access$300(Compiler.java:38)                                                                                                                                             [INFO] [talledLocalContainer]   at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:595)
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyzeSeq(Compiler.java:7003)                                                                                                                                           [INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(Compiler.java:6773)                                                                                                                                             
[INFO] [talledLocalContainer]   at clojure.lang.Compiler.analyze(Compiler.java:6729)                                                                                                                                              [INFO] .......
We are using com.theoryinpractise/clojure.osgi is there anyone who has any knowledge about this?

mitchelkuijpers15:11:58

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

RobinVdB12:11:13

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,...

ajay12:11:33

I am a Clojure newbee. Have read about GraalVm for speeding up command line apps. https://clojureverse.org/t/why-is-graalvm-so-fast/2079/4 No personal experience though.

RobinVdB12:11:00

I'll look into it, thank you

mseddon12:11:59

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

borkdude13:11:47

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

❤️ 1
idiomancy14:11:13

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.

6
🦃 1
taylor14:11:59

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

❤️ 1
👍 2
jumar21:11:13

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

👏 1
kommen15:11:02

using tagged-literal as shown here http://insideclojure.org/2018/06/21/tagged-literal/, 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

schmee15:11:45

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

kommen15:11:43

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.

shawwn15:11:00

what’s the win?

shawwn15:11:08

so much complexity for so little gain..

bmaddy15:11:59

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

lboliveira18:11:11

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

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

chrisulloa18:11:19

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

souenzzo19:11:12

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

bronsa19:11:32

old syntax for ^Key

👍 1
yogidevbear20:11:22

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

souenzzo20:11:19

@yogidevbear it's a #datomic query?

yogidevbear20:11:35

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

souenzzo20:11:34

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

yogidevbear20:11:22

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

yogidevbear20:11:50

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

souenzzo20:11:32

there is no nil on db?

yogidevbear20:11:15

The query looks roughly like:

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

yogidevbear20:11:56

@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

mkvlr20:11:28

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: '

souenzzo20:11:58

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

mkvlr20:11:28

@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?

souenzzo20:11:45

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

souenzzo20:11:12

(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.

mkvlr20:11:08

well this is an untrusted prepl for a hosted notebook…

😅 1
souenzzo20:11:43

(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]"]
#'get
=> #my/var[clojure.core/get]
(edn/read-string {:readers {'my/var (comp resolve first)}}
                 "#my/var[clojure.core/get]")
=> #my/var[clojure.core/get]
Not sure if it is a good solution. But kind of work.

mkvlr20:11:23

cool, thanks! I was trying with print-dup

jsa-aerial21:11:46

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

jsa-aerial22:11:34

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...