This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-03
Channels
- # announcements (7)
- # beginners (114)
- # boot (5)
- # calva (25)
- # cider (26)
- # clojure (82)
- # clojure-dev (20)
- # clojure-europe (2)
- # clojure-italy (8)
- # clojure-losangeles (4)
- # clojure-norway (6)
- # clojure-uk (16)
- # clojurescript (21)
- # clojurex (3)
- # core-async (24)
- # cursive (25)
- # datomic (17)
- # emacs (5)
- # events (4)
- # fulcro (9)
- # funcool (1)
- # graalvm (4)
- # hyperfiddle (2)
- # midje (2)
- # mount (2)
- # off-topic (10)
- # pathom (11)
- # pedestal (5)
- # re-frame (36)
- # reagent (15)
- # reitit (3)
- # ring (4)
- # slack-help (2)
- # spacemacs (3)
- # sql (16)
- # tools-deps (5)
i found this here but of course, i still cant get it to work. https://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js
hey guys, I'm new to spec instrumentation
I'm having this error:
:sym ..../position-gen,
:failure #error {
:cause nil
:via
[{:type java.lang.IndexOutOfBoundsException
:message nil
:at [clojure.lang.RT nthFrom "RT.java" 928]}]
for these:
(defn position-gen [len]
(rand-nth (range (dec (or len 50)))))
(s/fdef position-gen
:args (s/cat :len int?)
:ret ::sc/length
:fn #(>= (% :args) (% :ret)))
mine s/fdef as "a too open definition"?
your spec is not restrictive enough to accurately describe the valid inputs
(s/fdef position-gen
:args (s/cat :len pos-int?)
:ret nat-int?
:fn #(>= (% :args) (% :ret)))
isn't restrictive too =<like what if len is -5 ?
user=> (rand-nth (range -5))
Execution error (IndexOutOfBoundsException) at user/eval3 (REPL:1).
ow! thanks!
pos-int? / nat-int?
there's a way to pass a function that
s/fdef
has 0 arguments?thanks
i've not found that
(s/fdef position-gen
:args (s/cat :len pos-int?)
:ret nat-int?
:fn #(>= (% :args) (% :ret)))
isn't restrictive too =<@simon What's in your .lein/profiles.clj
file?
Comment out the :plugins
and :dependencies
lines and see if that fixes your problem.
Yeah, it does. Thanks. Btw, the issue started when I upgraded lein
. Bumping up the deps all works...
Also, does this happen just in a particular project directory, or also when there is no project.clj
file present?
i'm calling an api that returns a collection of results, but the response is paged, which means multiple calls to get the whole dataset. what's a good technique for processing the entire collection?
lazy sequences seems like a trick-gimmick that would work, but lazy-sequences with side effects isn't a good idea
i only want to fetch the pages i need, rather then fetch it all up front and then process it
each record has a timestamp, and i process the records in descending order (by timestamp) until i encounter a record i've already seen (from a previous execution)
So if you had an API call that returned a lazy sequence (I am not yet saying I know that is possible and/or easy to do), you could do a take-while on it?
This actually sounds like one of the specific use cases that core.async was designed for. Create a blocking channel that can hold twice as many records as you get in a single API call, and then, inside a go loop, get a page of data and put it on the channel. If the channel is full, wait for it to have enough room before going to get the next page.
Caveat: I haven’t worked that much with core.async so I may not know all the gotchas, but I’m looking at the docs and it seems like this should be the “right” way to go.
@manutter51 how does the producer know when to stop/exit cause the consumer is finished?
I would put the test for “I’ve seen this one already” inside the loop that makes the actual API calls. Once the “seen” record shows up again, just close the channel. I believe that there’s a way for the publish side of the channel to mark it as closed without losing the data that’s still in the buffer.
I don’t have code for how to do this (and I have to go afk for a bit), but that’s the direction I’d explore.
don't use lazy sequences when you need control over an external source
you probably also don't need core.async (and if you do use it, don't use a go loop for the IO - put that in a thread)
or use pipeline-blocking
but really, I'd probably just use a loop/recur for exercising the api
That’s good for me to know too.
quick java-related question: when i run lein uberjar
for a specific project, it'll produce the same jar file on my machine as it will on another machine, provided we both have the same versions of java, clojure, and lein installed, right?
but there are other factors that may make it unreproducible @nbtheduke
like stray files in the git repo, stale files in the AOT directory (target/classes I believe for lein)
lein plugins / profiles
ah, true
I have an app deployed on a digital ocean box, and it sometimes runs out of space when i run lein uberjar
, so i was thinking of running it locally and then scp
-ing it over, but I don't wanna break things in the mean time if that's not gonna work
@nbtheduke if you can create the uberjar in the same conditions that it's usually created (profiles, versions, clean checkout) then it's probably fine
cool, that's encouraging. I'll try it out! thanks
Hey, I am having issues with lein swank
. My ~/.lein/profiles.clj looks as follows {:user {:plugins [[lein-swank "1.4.5"] ]}}
.
When I use 1.9.0 everything works as expected, but with 1.10 I get Call to clojure.core/ns did not conform to spec.
.
Hi Guys, I have a doubt, what do you using to response in json in pedestal?
@U050ECB92 thanks 😃
I am looking for something like cond->
but not sure if its provided by clojure. Basically I want to test a value/expression for true or false if its true then apply a transformation and pass it to the next test. If its false skip it. Until a final value/expression is reached. In others words, cond->
but with the ability to use the result in the true case of the previous clause in the next condition. Does that make sense?
user=> (doc empty?)
-------------------------
clojure.core/empty?
([coll])
Returns true if coll has no items - same as (not (seq coll)).
Please use the idiom (seq x) rather than (not (empty? x))
@U050ECB92 That was just examples I threw out there for the sake of making an example. But you're right
@UHK8B8STX I guess I could use as->
and make a series if-elses but I was trying to avoid that
Something like this perhaps? https://github.com/worldsingles/commons/blob/master/src/ws/clojure/extensions.clj#L7-L10
@U04V70XH6 Yes, its exactly what I was looking for
Yeah, I use those a lot at work and I see people ask for them fairly regularly, that's why we open sourced that little library.
(cond-> initial-value
(not (empty? initial-value)) (map + initial-value)
(empty? (filter even? <result-of-previous-mapping>)) true)
How can I do something like this in aliases
of CLI Deps? ["trampoline" "run" "-m" "app.server/run-dev"]
I mean running a function other than -main
.
in :main-opts
Hi. I’m trying to get my head around browser vs. server routing, I’m messing things up in my app. I’m using bidi and pushy on the client, and am successfully processing the requested url:
(defn- dispatch-route
[matched-route]
(log/info "Matched route" matched-route)
(let [route (:handler matched-route) ]
(condp = route
:edit-feature (rf/dispatch [:editing-feature
(get-in matched-route :route-params :id) ])
:alexandria-home (do (log/info "In home dispatch") (rf/dispatch [:editing-feature "home"]))
nil)))
In that code, clicking a link with href=“/editfeature/123” works to set the :editing-feature key in the app-db.
I don’t want it to navigate away from the displayed page, I intend to use that key in the app-db to bring up a modal edit dialog.
(compojure/defroutes app
(-> (compojure/routes
(compojure/GET "/" [] (slurp (io/resource "public/index.html"))
)
(route/resources "/")
api/routes )
reload/wrap-reload))
clojure + lein + java11, WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/0x0000000800232040 (file:/Users/idk/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar) to method sun.net.www.protocol.https.HttpsURLConnectionImpl.getServerCertificates()
“Perhaps the best is to provide type hints to the exported types so the call is no longer reflective:”
@ville I suspect the actual reflective access is coming from elsewhere and the message is misleading. Clojure 1.10.1 is tested on JDK11 so it should be fine. What version of Leiningen are you using?
Leiningen 2.9.1 on Java 11.0.3 Java HotSpot(TM) 64-Bit Server VM
it's unclear from the warning whether it's the lein jvm or the project jvm that's causing the issue. If it's the project, add --illegal-access=debug to :jvm-opts, if it's lein, add it to an environment variable LEIN_JVM_OPTS
if you add --illegal-access=debug
you'll get a bit better trace about what is reflecting specifically
right now it points to the clojure.jar itself, because that's where clojure's reflection mechanism lives
If I'm creating a tools.deps based project and want certain folders excluded from the classpath (say my src/migrations
dependencies excluded from a container that only hosts the web or service portion of my app) would it be better to just copy the subfolders when creating the environment, and include the deps in :extra-deps. I've been experimenting with having any non-app related clojure code on top-level folders for example migratus
for my migration code that won't be loaded unless you explicitly call the alias that adds that folder. For people that actually deployed code that has a lot of this type of support code, or multi-enviroment setup, do you care if extra dependencies are even loaded, am I overthinking this?
If it isn't source code, don't put it in src
, use resources
or a folder under that.
If it is source code, and you still want some control, use src/clj
for your Clojure code (and src/migrations
for the migration code) and then use :paths ["src/clj"]
by default and aliases to bring in :extra-paths ["src/migrations"]
as needed.
I like that route
I'm looking for a resource (book chapter, article, tutorial, blog post, video, etc) on interacting with API's through ClojureScript.
@anantpaatra Are you interested in writing ClojureScript that interacts with JavaScript APIs? (In other words, are you interested in JavaScript interop from ClojureScript?)
Exactly 🙂
I'm interested in both actually hehe
Sorry for the ambiguous answer.
There is a draft WIP on JavaScript interop that may ultimately end up on the official site https://github.com/clojure/clojurescript-site/blob/88805681e76a86dcab068ec8b574ed733ebd5f8c/content/reference/javascript-interop-ref.adoc
I’m trying to add [org.apache.wss4j/wss4j "2.2.3" :extension "pom"]
to my lein project, but I am unable to use java classes from that library
I want (import '[org.apache.wss4j.dom.message WSSecHeader])
to work but intellij appears to not find the classes correctly