This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-15
Channels
- # announcements (20)
- # babashka (281)
- # beginners (13)
- # biff (8)
- # calva (20)
- # cider (5)
- # clj-commons (1)
- # clojure (46)
- # clojure-boston (1)
- # clojure-europe (6)
- # clojure-losangeles (24)
- # clojuredesign-podcast (3)
- # clojurescript (12)
- # datomic (1)
- # events (1)
- # fulcro (12)
- # guix (2)
- # honeysql (1)
- # integrant (1)
- # introduce-yourself (1)
- # rdf (16)
- # reagent (3)
- # reitit (14)
- # releases (3)
- # sci (28)
- # shadow-cljs (122)
- # specter (1)
- # tools-deps (10)
- # xtdb (6)
I'm curious if anyone knows about a tool to automatically merge .clj and .cljs files into a .cljc file?
Hmm... any pointers why this might happen?
user=> (spit "/tmp/rec.clj" (with-out-str (clojure.pprint/pprint (macroexpand-1 '(defrecord Rec [])))))
nil
user=> (load-file "/tmp/rec.clj")
Syntax error (VerifyError) compiling . at (/tmp/rec.clj:41:4).
Bad type on operand stack
Well if you have a repro, please file an ask question
This worked:
user=> (spit "/tmp/rec.clj" (with-out-str (binding [*print-meta* true] (clojure.pprint/pprint (macroexpand-1 '(defrecord Rec []))))))
nil
user=> (load-file "/tmp/rec.clj")
user.Rec
A VerifyError should almost always be considered a bug in the compiler
My use case for the above: I want something like defrecord (in SCI) but with more implementation data on that. I could use metadata (which I'm doing right now) but sometimes people use with-meta
on the record and it wipes the implementation data. So I thought, maybe I could use the code generated by defrecord
and add a few fields of my own...
So in general terms: I want to create a record that has some fields that should not show up in the ILookup nor in the metadata of the record, basically a hybrid between defrecord
and deftype
I guess I could also try to add those fields to the ext-map and override print-method or so to not print those, but it does feel more like metadata than anything else
I'm trying to add a field _sci_meta
to the above output.
This yields:
Syntax error (ClassFormatError) compiling deftype* at (/tmp/rec.clj:5:2).
Duplicate method name "<init>" with signature "(Ljava.lang.Object;Ljava.lang.Object;Ljava.lang.Object;)V" in class file compile__stub/user/Rec
I updated all the constructor calls, but I'm not sure where the constructor itself is being generated
it's in the compiler, so not sure you're going to be able to do that
I don't understand: I'm basically doing the same as defrecord
which emits code that runs deftype*
- is there some magic Compiler stuff going on besides that?
Can do that. Can also copy emit-defrecord
, that might be less error prone than editing what it generates
there's a special temporary stub class that gets generated under deftype* (note the compile__stub there) - that's all in the Compiler
ok, so the emit-defrecord stuff isn't that generalizable as there is special support for it in the Compiler only for a specific set of cases?
it's not intended as public api so maybe not as general as you would like
yeah I get that :)
I copied emit-defrecord to emit-defrecord2 and added a field __sci_meta
(and to every place which removes those built-in field names to separate them from user fields)
user=> (eval (emit-defrecord2 'Foo 'Foo '[] nil nil {}))
Syntax error (ClassFormatError) compiling deftype* at (REPL:1:1).
Duplicate method name "<init>" with signature "(Ljava.lang.Object;Ljava.lang.Object;Ljava.lang.Object;)V" in class file compile__stub/user/Foo
so there's probably an assumption in the Compiler about the amount of of built-in fields or so. No problem, this was just me exploring if this was a feasible option.
Same issue with sci_meta
and scimeta
.
Here's the code I tried:
https://gist.github.com/borkdude/19ac04ea0b2ef9d6643ba3de6817de57
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L8019
I'm going to need something else than metadata anyways, since different types are not equal and the type info is currently stored in the metadata which does not affect equivalence...
But storing the type info in a field in the record itself affects into
etc: this info is preserved... So a tweaked defrecord
is probably the way forward - even if I cannot add fields of my own (I still don't fully get why that isn't possible), I can tweak the protocol/interface methods a bit to make it work.
Does anyone have any experience receiving emails with any sort of clojure/java/node api? I'm in a bit of a cursed integration testing scenario and I don't see another way out
What are you trying to do exactly? You can use something like Sendgrid's Parse Webhook to expose a web service that receives emails https://docs.sendgrid.com/for-developers/parsing-email/setting-up-the-inbound-parse-webhook If you're looking for a queryable local SMTP server that you can use in integration tests you can try https://github.com/mailhog/MailHog
> What are you trying to do exactly? I'm trying to navigate an email based auth mechanism. So i want to run a machine and get the emails and parse out the needed info
Sounds like setting up a web service + the Sendgrid parse webhook would give you that - then you receive http callbacks to your endpoint with all of the email info (envelope, various content types etc)
How do I fix this error? Looks like cheshire is finding it difficult to convert "class http://java.net.URL" to JSON. Thanks for any hint. [{:type com.fasterxml.jackson.core.JsonGenerationException :message "Cannot JSON encode object of class: class java.net.URL: https://xxxxxxxx.s3.us-west-2.amazonaws.com/xxxxxxxxxxxxxxxx" :at [cheshire.generate$generate invokeStatic "generate.clj" 155]}]
You need to add an encoder for java.net.URL
: http://dakrone.github.io/cheshire/cheshire.custom.html#var-add-encoder
Thank you so much. It really helped/worked. What I did is (:require
[cheshire.core :refer :all]
[cheshire.generate :as cheshire-gen]
....)
Then added this line
(cheshire-gen/add-encoder java.net.URL cheshire-gen/encode-str)
Thanks a bunch.what's the current state of the art for streaming web servers? I know of manifold + aleph. is that still the best bet?
what kind of streaming? • media (audio/video) • long polling • web sockets • large files
mainly I'm interested in sending chunked HTTP responses, e.g. https://www.mariokandut.com/how-to-stream-to-an-http-response-in-node-js/
I thought that was available for most web servers. Are you already using a particular web server or are you trying to pick one with at least this capability?
Yea. I would be surprised if you couldn't do chunked responses with jetty. There's some examples for teh ring-jetty-adapter, https://github.com/ring-clojure/ring/blob/master/ring-jetty-adapter/test/ring/adapter/test/jetty.clj
Pedestal has interesting options involving clojure.core.async: http://pedestal.io/reference/streaming