Fork me on GitHub
#clojure
<
2018-09-07
>
yqrashawn06:09:54

hi, is there anybody use conch and graalvm together before?

yqrashawn06:09:40

i wrote a commad line tool and compiled it with graal, it works fine when run with java -jar, but the compiled file throw a ClassNotFoundException: java.lang.ProcessBuilder error.

benzap13:09:03

I had the same issue, I believe it's a problem with reflection. Did you try this with the release candidate 6 of GraalVM?

noisesmith15:09:19

also, if you are moderately skilled with interop, it's easier to use ProcessBuilder / Process directly rather than conch; this would also be easier than fixing conch so it works with graalvm

👍 1
noisesmith15:09:01

well, maybe I should say "if you are trying to do anything interesting with process IO and moderately skilled with interop"

noisesmith15:09:22

conch does make some people's tasks simpler, just not the ones I've needed

deliciousowl06:09:01

I'm trying to draw time series data onto a static image file, is there an aesthetically pleasing graphing lib out there by any chance?

andrea.crotti08:09:44

is there a way to pretty print Json while writing it to a file?

andrea.crotti08:09:56

the only way I found is

(spit output-file
          (with-out-str (json/pprint new-json-obj)))

andrea.crotti08:09:06

which actually works but seems a bit of a weird way

andrea.crotti08:09:47

I wonder why there is no format in the json API

roklenarcic09:09:42

Where can I report bugs in clojure core?

roklenarcic09:09:58

I mean this is a bug right? (proxy [URLClassLoader] [(make-array URL 0) ^ClassLoader (.getContextClassLoader (Thread/currentThread))]) emits reflection warning

roklenarcic09:09:15

there's no reason why there is a reflection warning there

andrea.crotti09:09:17

@just_crashed I'm using clojure.data.json not chesire

jcr09:09:45

@andrea.crotti so you're looking for a way to customize the pretty printer? data.json uses clojure.pprint under the hood, see http://clojuredocs.org/clojure.pprint if you want to dig inside. If you just want to print it to a file directly (without the intermediate string), see http://clojure.java.io/writer + (binding [*out* (writer ...)] pprint here)

andrea.crotti10:09:44

no I was jus tasking if there was a better way to do what I did with

(spit output-file
          (with-out-str (json/pprint new-json-obj)))

andrea.crotti10:09:06

if it just uses the core pprint maybe I can simply use the pprint/format instead

jcr10:09:38

As I've said, (binding [*out* (writer output-file)] (json/pprint new-json-obj)) would be a better way of doing it (no intermediate string)

jcr10:09:13

Is that what you were asking or did I misunderstood you?

andrea.crotti14:09:54

well it .just seems silly to go through out entirely

andrea.crotti14:09:08

since there should be a format function that returns another string surely

andrea.crotti14:09:38

so ideally something like (spit output-file (json/format new-json-obj)) would be what I would have liked more

andrea.crotti14:09:53

but not a big deal

jcr17:09:03

if you need to return a string, with-out-str is totally fine (but if all you do with that string is to spit it in a file, you don't need that string at all)

jcr17:09:09

cheshire has a specific function that writes an object to a string, but data.json takes a more minimalistic approach to the api; can't blame them for that! :)

jcr09:09:08

@roklenarcic maybe it's because of some proxy magic? I have no idea to be honest.

roklenarcic10:09:25

@just_crashed I tried signing up for that clojure dev confluence, but it doesn't recognize my password and I just signed up prior, no confirmation email either... oh well... app still works despite the warning

h.elmougy10:09:04

what is the easiest way to replace all "-" with "_" in a complex nested json structure?

schmee10:09:21

I recommend asking in #specter 🙂

jcr10:09:48

there was a library specifically for that, can't remember the name

jcr10:09:52

something about camels

schmee10:09:25

with Specter I think it would be something like (transform (walker string?) #(str/replace % #"-" "_") your-json)

👍 1
danielneal10:09:03

is the thing about camels 😄 🐫

danielneal10:09:15

(json/read-str "{\"firstName\":\"John\",\"lastName\":\"Smith\"}" :key-fn ->kebab-case-keyword)

jcr10:09:59

yep, that's the one :)

jdbell11:09:57

Hello. Playing with Datomic. I have a query using pull that does what I want, but the results use the #: namespace map syntax. Is there a way to get the results with fully expanded attribute names? So, {:equipmentType/typeName "Crane"} instead of #:equipmentType{:typeName "Crane"} Edit: hey, I found it! It was just REPL formatting. I did (set! print-namespace-maps false) in my REPL.

joel13:09:13

Can anyone explain to me why the first version of the code, while handling files sequentially works while the second versions hangs because after the report channel is filled (I set it with a buffer size of 10), all my threads are parked and nothing happens anymore in process-object? I am missing something

mavbozo13:09:31

@joelmarty2 are there any processes taking something from reports channel?

joel13:09:55

there is, but it is never triggered

joel13:09:26

everything stops after 10 items are taken from s3objects

joel13:09:12

i guess the process consuming the reports is blocked since all threads are parked ?

mavbozo13:09:51

so, in the first version, the consumer successfully takes reports?

mavbozo13:09:02

@joelmarty2 i tried your code with just processing integer and it works fine

joel14:09:07

the process-object function is blocking and may take a while to execute (something like 10s)

mavbozo14:09:49

@joelmarty2 i put (Thread/sleep 10000) inside the process-object and still works

joel14:09:13

one difference I see is that you buffered the s3objects channel, which is not my case but it doesn't make any difference

mavbozo14:09:24

if the process-object does blocking IO, then it's better to use pipeline-blocking instead of go-block.

joel14:09:44

i've looked into that but I am not sure my process-object function could be seen as a transducer, I don't know enough about transducers. the process function reads the s3 object line by line, parses it and makes some transforms and then writes the structures to a redis instance

joel14:09:16

the output is a report of what happened in between

mavbozo14:09:18

so let's play around with it, you can create a transducer from your process-object function by simply (map process-object)

mavbozo14:09:30

(a!/pipeline-blocking 1 results (map process-object) s3objects)

joel14:09:37

I'll try that

joel14:09:56

looks like it's working, thanks a lot @mavbozo

mavbozo14:09:01

@joelmarty2 no problem, i'm sorry I can't help you find the problem with using go-block for your process. I still don't fully understand the go block

joel14:09:17

don't sweat it @mavbozo,I won't look further into it, I inherited this overly-complicated app and I don't plan to spend much more time on it, your solution works and using a library function is much more reliable that what I could have done

JH15:09:21

As a community, has a standard been established for naming spec definitions?

isaac15:09:41

how to use clj cli compile java code? I have some java code in classpath

noisesmith16:09:41

that's out of scope, clj is not a build tool

noisesmith16:09:02

you can write some other code that compiles your java and uses clj; maybe someone has implemented that already

alexmiller16:09:55

if you really want to, you could write a clojure program that used the JavaCompiler api to compile java :)

alexmiller16:09:32

that is, clj is a program runner. the java compiler is a program.

lwhorton16:09:57

what’s the clojure mechanism for something like:

(attempt (a) (b) (c))
which throws if a, b and c throw, but not if one passes?

lwhorton16:09:43

smells kind of like an error monad i guess

noisesmith16:09:43

I'd probably try (assert (some #(try (%) true (Catch Exception _)) [a b c]))

noisesmith16:09:53

or something vaguely like it

dominicm16:09:13

@isaac If you wanted an example of using the Java compile API, I use it in pack.

noisesmith16:09:58

@lwhorton you could look at the source of as->, and replace the let machinery it uses with and/`try/catch`

noisesmith16:09:25

(if you prefer a form based rather than fn based solution)

lwhorton16:09:27

oh, that’s a good idea :thumbsup:

noisesmith16:09:49

actually, I just checked the source of some-> and that is very similar, and probably an even better starting example

noisesmith16:09:45

of course your difference from both is you don't need the let bindings, as you aren't propagating data from one step to the next

lwhorton16:09:05

its neat that this can be done without introducing a large dependency (was about to go looking for error monad libs)

noisesmith16:09:24

not only that, but the hand rolled macro will be relatively small and you can be reasonably confident there aren't huge gotchas - clojure is kind of special that way

lwhorton17:09:36

i love it. i work in elixir probably 40% of my time now and i miss clojure 100% of that time.

isaac16:09:31

where I can found the example @dominicm

emccue16:09:58

is there a way to make an interface that "extends" another interface without gen-class?

emccue17:09:21

im just messing around, this isnt that important

rplevy18:09:16

More or less on-topic: I always thought it was common sense to use OracleJDK in prod, does anyone know why Heroku nudges users (Clojure and JVM generally) to OpenJDK?

zentrope18:09:42

I think Oracle changed licensing such that commercial use is quite onerous.

hiredman18:09:35

no, they just changed their support model (which when was the last time you used jvm support?), and oracle has a bad image, so when they change things it is attributed to them wanting to do something shady (which I entirely believe), which begets any even worse image, which causes people to want to get away from them

scriptor18:09:34

doesn’t “jvm support” include releasing bug fixes and security patches, not just customer support?

rplevy19:09:32

Another twist (something I didn't know until recently) is that it's Oracle that maintains OpenJDK too

seancorfield19:09:57

@rplevy It looks like maybe Red Hat will step up to become the primary avenue of support for OpenJDK...

seancorfield19:09:31

(and this discussion probably belongs in #java since it isn't really about Clojure -- which is not affected by Oracle's decisions 🙂 )

👍 1
rplevy19:09:39

I just learned that Oracle is going to charge for support and updates for JDK 1.8 (minimum for Clojure 1.10) starting in January (I think that's what @hiredman was referring to actually)

andrea.crotti19:09:41

does anyone have a good strategy to squash database migrations together?

andrea.crotti19:09:44

I'm using migratus now so I just write the migrations as SQL, I guess I could - migrate everything - get the actual SQL schema from the database - create a new squashed migration with that schema, just a bit sad to lose all the comments and things like that though

Christian Johansen20:09:27

does anyone have a working example of server-sent events with ring 1.16? I’m hitting a brick wall

Jon Walch20:09:47

What’s the best way to check that a map only has certain specified keys in clojure.spec.alpha? I tried following https://groups.google.com/forum/#!topic/clojure/fti0eJdPQJ8 So for example I have

(s/def ::message (s/merge (s/keys :req-un [::value])
                                            (s/map-of #{:value} any?)))
If I comment out the s/map-of call, stest/check works fine. If I uncomment it, I get ExceptionInfo Couldn't satisfy such-that predicate after 100 tries. clojure.core/ex-info (core.clj:4739) Regardless of map-of being commented out or not, (gen/generate (s/gen ::message)) works every time. Does anyone have any insight?

seancorfield20:09:47

@jon324 What are you calling stest/check on? What does that function look like?

seancorfield20:09:02

(does s/merge actually allow a spec that isn't just s/keys?)

Jon Walch20:09:46

changing them all to s/and instead of s/merge was the trick

seancorfield20:09:51

First off, that's two years old so it may well be out of date by now.

seancorfield20:09:38

Second, Alistair doesn't explain why he changed it to s/merge, nor did anyone follow-up to ask about the difference... which also makes me think no one tested the two versions fully.

seancorfield20:09:15

s/merge's docs just say "map-validating specs" and gives s/keys as an example, but I don't think I've ever seen s/merge used with anything other than s/keys specs...

seancorfield20:09:30

So, yeah, s/and makes more sense to me here.

seancorfield20:09:51

(btw, there's a #clojure-spec channel, in case you need to deep dive on it)

Jon Walch20:09:27

Thanks so much!

olleromo21:09:34

Just started looking at juxt/edge and I’m wondering how it deals with externs?

seancorfield21:09:16

There's a #juxt channel in case you don't get any answers here (smaller channel might be more likely to see/help sometimes).

olleromo21:09:38

great, thanx 😊

bringe21:09:20

Do library owners normally sign their release artifacts with gpg when deploying to clojars? I recently released my first library, but it look me several hours to figure out how to sign the release artifacts with gpg. I develop on windows, but eventually used linux just to get gpg to work, and even still it took me a while. Now I'm trying to release another version, and I'm having issues with gpg again. gpg: signing failed: Permission denied

bringe21:09:43

I know I can skip the signing, but is this a bad idea? I don't want to go that route, but these issues are driving me crazy

andy.fingerhut21:09:05

@brandon.ringe Do you use Leiningen for deploying to Clojars, or some other method? I've followed the Leiningen instructions for deploying, and while they were not a quick 5-minute read, they have worked.

andy.fingerhut21:09:23

From a Mac OS system, so Unix-like, not from Windows.

andy.fingerhut21:09:46

I am no gpg expert, so a cookbook approach is what I was looking for.

bringe21:09:20

@andy.fingerhut Yes, I have read through them several times looking for something I may have missed. But I haven't tried storing my credentials yet, so maybe I need to do that.

bringe21:09:52

I'm guessing it might be trying to use my key, seeing no credentials file, and just denying me, instead of prompting for credentials.

dpsutton21:09:31

i've run into issues with gpg v1 vs v2. For some reason v1 keeps getting reinstalled from my package manager but v2 is the one that brings up a system wide prompt. Check gpg --version. I symlink gpg2 to gpg and mv gpg version 1 to gpg_old

👍 1
andy.fingerhut22:09:59

I am trying out tools.trace on a project where there are Clojure protocols, and there are deftype types that implement those protocols, and also extend-type forms that cause those protocols to be implemented for built-in JDK classes. When I try tools.trace's trace-ns on the namespace, or trace-var on the name of one of the protocol methods, I see traces of calls to the methods defined with extend-type on the built-in JDK class, but I do not see any messages about the calls to that protocol method on the Clojure deftype. Does this sound like a limitation of tools.trace's capabilities that would be difficult to change?

andy.fingerhut22:09:45

A related question would be - if you wanted to trace such calls, is there a method other than using tools.trace, and inserting debug println calls, that you use?