This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-26
Channels
- # announcements (4)
- # beginners (160)
- # boot (2)
- # calva (40)
- # cider (41)
- # clara (24)
- # cljdoc (2)
- # cljs-dev (99)
- # clojars (4)
- # clojure (71)
- # clojure-dev (9)
- # clojure-europe (4)
- # clojure-italy (2)
- # clojure-nl (19)
- # clojure-spec (97)
- # clojure-uk (103)
- # clojurescript (57)
- # core-logic (1)
- # cursive (15)
- # data-science (31)
- # datomic (24)
- # duct (1)
- # emacs (39)
- # events (7)
- # figwheel-main (14)
- # fulcro (44)
- # garden (7)
- # jobs (13)
- # juxt (1)
- # leiningen (29)
- # music (2)
- # nyc (4)
- # off-topic (37)
- # pathom (12)
- # re-frame (26)
- # ring (1)
- # ring-swagger (10)
- # shadow-cljs (35)
- # spacemacs (2)
- # specter (4)
- # test-check (67)
Anyone who has experience with http-kit: how do you send "multipart/form-data" parameters? I'm currently working with the discord api and that's what it's asking for, but I can't get it to send properly. I've tried putting the data directly into the :form-params key of the request map but that didn't do it, and I've tried putting the data directly into the :body as well, also no luck.
I think I've figured it out.
@suskeyhose Let me know if you still need assistance with that. We use http-kit
in our test suite to POST images etc into our API for processing.
Oh, thanks! Only issue I'm running into now is actually getting file contents into it. Not sure what's causing problems with it honestly.
hey guys can I get an extra eye please? I have this ns
form failing with spec on clojure 1.10:
(ns af-rematcher.deeplink
(:require [clojure.string :as s]
[cemerick.url :refer [query->map]]
[cheshire.core :as json]
[version-clj.core :as ver]
[com.taoensso/timbre :as timbre]))
generating: clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec. {:clojure.spec.alpha/problems [{:path [], :reason "Extra input",
What am I doing wrong?I have a tree traversal problem: I'm trying to substitute values in a tree according to a substitution map in the tree. for example, if the node [:expr {:x 1} ...]
should substitute all :x
child nodes with 1. here's an example:
(subst [:a [:b [:expr {:x 1} [:d :e [:f :g :x]]]] [:expr {:y 2} [:h :y]]])
=> ([:a [:b [:expr {:x 1} [:d :e [:f :g 1]]]] [:expr {:y 2} [:h 2]]])
I'm aware of clojure.walk but I'm having trouble using it with "memory". any pointers?@wei do you know https://github.com/nathanmarz/specter?
transform
might help.@rodsenra thanks, i was reading https://github.com/nathanmarz/specter/wiki/Using-Specter-Recursively but it'll take a while to get my head around it
Iโm trying to translate this from java to clojure:
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;
but I donโt know how to do the & 0xff
part, anyone point me in the right direction?Hi fellas, this mind-boggling error is consuming me Can't make API call blobstore.CreateEncodedGoogleStorageKey in a thread that is neither the original request thread nor a thread created by ThreadManager
It's happening with me trying to do an interop where the original is
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/" + bucket + "/image.jpeg");
to
(.createGsBlobKey (BlobstoreServiceFactory/getBlobstoreService) "/gs/crowd-hm.appspot.com/users/5644647548321792/profile/0eb6082b-f67d-46b4-ad2c-d2ef2b737ee5.jpg")
@overde sounds like that method whitelists specific threads for the call and you are trying to call it outside the allowed thread
you could send a function (which is a Callable) to be executed in an app-engine thread pool / thread https://cloud.google.com/appengine/docs/standard/java/runtime#threads
I think that would satisfy it (based on a common sense reading of the error message and docs at least)
it wants to impose extra coordination over what you get by default with network calls and threads I guess(?)
> if you want to call App Engine APIs (com.google.appengine.api.*), you must call those APIs from a request thread or from a thread created using the ThreadManager API.
@overde to clarify about the above, if something hands you a Thread you can use -- not quite right...(.run t f)
where f is any clojure function taking no args
so I think the solution is to ask the google ThreadManager for a thread, and pass your 0 arg function to the run method of that thread
the root issue might be that you are in eg. an http server or go block some other context where new threads are created or allocated automatically to call your function
Your explanation was awesome @noisesmith so much thanks!
@overde I need to correct myself - you can pass a function to the Thread
constructor, but you can't pass one to its run
method - so the real fix is different
but I'm sure ThreadManager does have the thing you need
https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/ThreadManager.html#createBackgroundThread-java.lang.Runnable- - this is the method you need, a clojure function of zero args is a Runnable
so it's still straightforward, just not how I initially described it
@noisesmith so i've got to (ThreadManager/createBackgroundThread (BlobstoreServiceFactory/getBlobstoreService))
after the imports
and had com.google.appengine.api.blobstore.BlobstoreServiceImpl cannot be cast to java.lang.Runnable
so what you do is make that call (and ancillary code if any) inside a function
(ThreadManager/createBackgroundThread (fn [] (some-other-step) (BlobstoreServiceFactory/getBlobstoreService)))
where (some-other-step) might not exist, of course
you may also need to explicitly call the Thread's run
method once it has been created
Might be something like this (.run (ThreadManager/createBackgroundThread #(BlobstoreServiceFactory/getBlobstoreService)))
?
right
and you probably don't want that at a top level of the ns (otherwise it runs every time the ns is loaded or compiled)
I was taking a literal read of "after the imports" :D
I find assuming common sense in software discussions is dangerous
weird
oh, you want the .start
method, not .run
- newb error on my part
it's a weird thing about the API that if you call the run method, the thread's code (if any) runs on your thread instead - I have never seen a design where that was useful
but start actually uses the thread object like you'd expect
I've wasted more time than I care to admit accidentally calling .run instead of .start in Java
I'm glad I'm not the only one
To give more context, this is from: https://cloud.google.com/appengine/docs/standard/java/images/#using-image
is it about other methods that need to be on google owned threads, or still the same method?
Came across this trick to avoid loading files at compile time: https://stackoverflow.com/a/31333821
Does that work b/c the def
s are evaluated at compile time and runtime?
yes, that's one work around - the issue is there's no compile time / run time distinction of that sort in clojure - every time your namespace is loaded, whether it's because you are compiling your app or running it, the code inside every def runs (as well as any other top level code)
the cleaner fix is to put things that interact with the "outside world" or stateful objects inside functions, and arrange to call them via your main or other startup code
because clojure allows you to use the full language while compiling - it's a common thing in lisps
there's no "compile only" mode other than putting something inside an fn
and yes, another work around is not using AOT, so that your code is only loaded when running the app (but this still causes problems when eg. linting or running tests, depending what sorts of side effects are in your def)
Same, the snippet here is the same one you see as the first and second line over the link
OK - I think that all the api calls related to using the blob store need to be inside the function you pass to the google thread manager
if you are doing that and still see that sort of error, you might need help from someone who knows app-engine