removed my message for a more relevant channel
This is the create-subscription function:
(defn create-subscription [req]
(prn "request is " (:params req))
(prn "payment method is " (:payment-method-id (:params req)))
(let [customer (cust/create {"email" (:email (:params req))
"payment_method" (:payment-method-id (:params req))
})
subscription (esub/create customer {"items"
[{"price" (:price-id (:params req))}]
"expand" ["latest_invoice.payment_intent"]})]
(prn "subscription is " subscription)
)
(req-res/response "response"))
and the error is in the cust/create
in the docs under create a customer, thereโs a payment_method parameter @dsp
which is what I have as well
I have the following question posted in clj-http: https://clojurians.slack.com/archives/C8860D6BS/p1613018229002500 Your help is much appreciated!
if that's real data you might have a bit of a headache
@dpsutton what do you mean by real data? Itโs key value pairs where values are strings
He means that :basic-auth
string I think...
That auth seems real (although the customer ID seems invalid)
You might want to delete that message @ps although at this point it's probably been archived to the logging site -- not sure if it respects deletes. The Zulip bot does respect deletes so it will at least remove it from there.
The #clj-http channel at least is not logged/archived as far as I can tell so at least it's only in this channel -- and Zulip doesn't copy the body of shared messages. Not sure if logbot does.
@ps You could try :body "customer= cus_IvNWjfw1q2clxS"
in the post request. Itโs equivalent to --data-raw
option in curl IIRC.
Thanks
Hello i am testing a maven project,where Clojure code is also inside the maven. It works fine , but i want to use a class from Clojure code gen-class , and it said it cant find it
in lein, i did :aot but in maven i dont know what to do to find it
normal call clojure from Java works IFn etc , but i want a class
you can use https://github.com/talios/clojure-maven-plugin for that
it hooks into the compile phase to compile clojure code
it does it automatically? or i have to set settings
you'll have to configure your pom to make that happen
thank you i will try it now ๐
the readme has more info
anyone know of a good transducer that kinda sorts? Ideally holds onto the largest N
items by some metric?
and not sorts but just retains the largest values, not necessarily sorted
(transduce (biggest 5 identity) conj [] (range 30)
would build up a collection no more than five at any point in time as it reduced the collection
@dpsutton I think you can look at a transducer like distinct
and then adapt it
good point. thanks @borkdude
you could probably use https://github.com/cgrand/xforms window transducers
yeah i'm not familiar with his excellent library so i was hoping it would ring a bell as something already done with a proper immutable min heap
by which i mean thanks for pointing me towards window
!
lots of other useful things there too
yeah. i've never delved in and its probably time. thanks
I need a TCP client library. I just want to send bytes and receive bytes. Aleph has exactly the kind of interface I'm looking for:
(def client @(aleph.tcp/client {:host host :port port}))
(manifold.stream/put! client (msg->bytes mx))
(bytes->str @(manifold.stream/take! client))
but I'm wondering if there are any lighter weight libraries out there (or even a gist?)https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html
https://docs.oracle.com/javase/tutorial/networking/sockets/index.html
sockets appear to form part of the https://github.com/clj-commons/byte-streams abstraction. Not very familiar with it though
the java socket stuff is pretty easy to use via interop, you don't really need a library for it
on one side you mostly just create a ServerSocket and .accept on it, which gives you a connection, which has an input/output stream on the other, create a new socket and use its input/output stream
pretty basic example: https://www.baeldung.com/a-guide-to-java-sockets
cool I'll give it a shot with sockets. I've used them a bit before but this time I got hung up on some (java) example code using Nio socketchannels and was trying to do it in that way which maybe has a bit more of a learning curve.
that's a couple more steps (but opens some new options)
I'm writing a clj wrapper for https://bitbucket.org/chromiumembedded/cef/ (cef) and am trying to figure out the best way to make it consumable as a library. The cef framework by itself is 80MB compressed and ~220MB uncompressed which seems too large to include in a library jar. Currently, I'm putting everything except the cef framework in the library jar and including a function that will download/extract the framework if it doesn't exist on the local file system. Is there a better way to handle this?
@smith.adriane I think that's a good tradeoff
This will maybe also allow your tool to upgrade CEF itself without upgrading the jar, might add some flexibility.
Or if users already have it, they could maybe set some env variable to indicate where it is
supporting env variables would make a lot of sense. Currently, I only allow the consumer to specify the target dir, but supporting env variables at some point would also be good.
was asking about a biggest-by
transducer earlier but realized i needed a reducing function for this actually. Does anything about this stand out as problematic?
(fn queue-accumulator
([] (PriorityQueue. 30 cmp)) ;; custom comparator
([^PriorityQueue q]
(loop [acc []]
(if-let [x (.poll q)]
(recur (conj acc x))
acc)))
([^PriorityQueue q item]
(if (>= (.size q) threshold)
(let [smallest (.peek q)]
(if (pos? (.compare cmp item smallest)) ;; custom comparator
(doto q
(.poll)
(.offer item))
q))
(doto q
(.offer item)))))
@dpsutton did you find a solution you were happy with for this? ... maybe something like this?
(defn keep-group [f init]
(fn [rf]
(let [g (volatile! init)]
(fn
([]
(rf))
([r]
(rf (reduce rf r @g)))
([r i]
(vswap! g f i)
r)))))
(defn largest-n [n]
#(let [group (conj %1 %2)] (if (< n (count group)) (disj group (first group)) group)))
(comment
(into [] (keep-group (largest-n 5) (sorted-set)) (range 10))
)
I realise it's pretty similar to what you had with the mutable collection ...
yeah. and it doesn't make much sense to do so much accumulation in the transducer. it clogs the whole pipeline until you're done which feels a bit presumptuous of a transducer
also there's no comparisons in yours. so it would just be a huge volatile in a transducer chain
it's in the largest-n
fn ... which limits the number of things in the volatile to n things ... right??
it's doing the comparison by putting the data into a sorted set (which I guess could be a sorted-set-by
... and it's dropping the first one from the set if the count is larger than the n
we give to largest-n
... so there's only 5 things in the volatile ... but in the same way you can't return the first result till you've reached the end when sorting, you can't do that here ... right?
oh i missed that part. i somehow only saw the keep group bit
๐