This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-02
Channels
- # announcements (1)
- # asami (89)
- # aws (10)
- # babashka (41)
- # beginners (71)
- # calva (25)
- # cider (3)
- # clj-kondo (65)
- # cljdoc (15)
- # cljs-dev (3)
- # cljsrn (8)
- # clojure (56)
- # clojure-europe (44)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-uk (48)
- # clojured (7)
- # clojurescript (17)
- # conjure (6)
- # cursive (3)
- # datomic (9)
- # emacs (11)
- # events (3)
- # fulcro (3)
- # helix (3)
- # honeysql (7)
- # hugsql (6)
- # introduce-yourself (2)
- # jobs (2)
- # kaocha (4)
- # luminus (1)
- # nrepl (2)
- # off-topic (10)
- # pathom (7)
- # philosophy (3)
- # polylith (27)
- # reagent (18)
- # reitit (3)
- # remote-jobs (7)
- # reveal (3)
- # shadow-cljs (9)
- # slack-help (5)
- # tools-deps (9)
- # vim (48)
FAIL in (defspec-failure) (file.clj:10)
expected: {:result true}
actual: {:shrunk {:total-nodes-visited 1, :depth 0, :pass? false, :result false, :result-data nil, :time-shrinking-ms 0, :smallest [-1]}, :failed-after-ms 2, :num-tests 2, :seed 1622595497912, :fail [-1], :result false, :result-data nil, :failing-size 1, :pass? false, :test-var "defspec-failure"}
FAIL in (deftest-failure) (file.clj:8)
expected: (= 1 2)
actual: (not (= 1 2))
there's a lot more context that would be helpful.I believe your only chance would be to transfer that context into the test results xml file somehow? How is the test failure represented in that?
Maybe this is a repeat question... I am a newbie and I have just stumbled upon spec in Clojure. I was wondering if spec can somehow be used to replicate regular expressions? e.g. say we have a sentence pattern like "Sam is a good boy"... We want the sentence to be parsed by an expression parser to extract words like this: "<name> is a <adjective> boy". We can do this in regular expression. I was just wondering if somebody has tried this using spec?
I just joined this channel... do you need me to repost my question here? I am sorry I didn't follow...
It is not designed for that but for something simple patterns it is generally possible https://blog.michielborkent.nl/2017/10/10/parsing-a-circuit-with-clojure-spec/
This is really interesting... many thanks, I'll look it up!!
@U1192DAP3 you may also want to look into regal: https://github.com/lambdaisland/regal
wow this is really cool reefersleep!! Many thanks!
@U0AQ3HP9U: thanks again for the link to lambdaisland/regal!! I started looking thru the example code. This tries to show how to match a pattern which equates 2 word symbols with "=" sign. I am pasting it here again... (def r [:cat
`[:+ [:class [\a \z]]]`
`"="`
`[:+ [:not \=]]])` . When we execute (regal/regex r)
we get #"[a-z]+=[^=]+"
as the pattern. How do we make a regal schema to create #"([a-z]+)=([^=]+)"
instead? Any ideas? Eventually I'd like to run a command like (re-seq #"([a-z]+)=([^=]+)" "foo=bar")
and get (["foo=bar" "foo" "bar"])
for output...
I solved it myself... I need to use the :capture
keyword!! @U0AQ3HP9U: this is really awesome tool!! Many thanks indeed!!
@U022LK3L4JJ great that it fits your use case! By the way, if you are not strictly wanting to do regex parsing, I know that @U4P4NREBY is working on a wrapper for a Java lib that can identify things like adjectives and nouns in sentences, if I remember correctly.
oh yeah that'll be great as well... I am interested in both regular parsing which is a bit more readable/manageable and language parsing... This is great help!! Many Thanks!
I am using https://github.com/flatland/clojure-protobuf library for serialization and it strips all the default values/fields not provided while sending it over the wire(which is understandable) but also when deserializing at client side, it doesn’t add those default values or missing fields(with default values) back. I checked https://github.com/golang/protobuf golang library which returns those default values. Does anyone have idea why this library doesn’t return default values?
Is there a way to create a sorted-map that is sorted by the values?
Not easily, it seems: https://stackoverflow.com/questions/1528632/how-do-you-use-sorted-map-by-to-sort-a-map-by-value/3252266
I'll find a different way to do what I want.
Hooray
I am running an sh
job for side effects and I want to be notified when it finishes. However, if it the execution throws an error it never does finish:
user> (future (sh "non-existant-command-fails")) ;; never finishes
How do I get around this problem?This does not work either:
(future (try (sh "non-existant-command-fails") (catch Exception ex {:error ex})))
what does work mean?
@(future (try (/ 1 0) (catch Exception _e {:it :threw})))
returns {:it :threw}
.
Not working: it never finishes. But the above (with @) is blocking. I'd like to dispatch a job and then be notified when it finishes.
When I do:
(def f (future (try (sh "non-existant-command-fails") (catch Exception ex {:error ex}))))
It returns fine for me. Looking at f
I get:
#object[clojure.core$future_call$reify__8477 0x652ce654 {:status :ready, :val {:error #error { ......}}}
If I don’t use def
and instead deref immediately, it returns instantly with the IOExceptionThe above works, but if I add a callback function (just println in the below example) the callback is never used:
(def f (future (try (sh "non-existant-command-fails") (println "hoi") (catch Exception ex {:error ex}))))
That is how I was hoping to be notified of the job being finished (or having errored)
I see the reason why, I just wonder how to get around it 🙂
Ah, I'll try 🙏
Anyone know any good time zone conversion libraries?
Depends what you mean by that — for Clojure, I’d just use Java Time directly for most time/date stuff.
Anyone using Datadog APM with Clojure? Or even more in particular ... using Clojure + open telemetry with Datadog APM?
There was just another APM question last week, how about creating a channel about the topic?
Just saw, there is #observability
We use Datadog APM and report to it via opentacing Java lib. Yeah, I’m getting some déjà vu here.
@U083D6HK9 what was your experience with stack traces?
we have a few apps setup and it is working fine, but 500 error responses just show ERR_CODE_2
rather than the stacktrace. A java based app using the same otel gateway has stacktraces visible, so wondering where the issue lies.
Have a ticket open with DD on it
Is this expected behavior?
> (Math/abs 30359687764)
30359687764
> (#(Math/abs %) 30359687764)
294916692
> (#(Math/abs ^long %) 30359687764)
30359687764
> ((fn [x] (Math/abs x)) 30359687764)
294916692
>> ((fn [x] (Math/abs ^long x)) 30359687764)
30359687764
I think this may already be logged (has to do with the coercion/casting path for primitive long vs object Long) but please ask these kinds of things on https://ask.clojure.org
there are several questions there that seem like the same thing already
https://ask.clojure.org/index.php/1908/wrong-numeric-result-from-math-abs-on-java-8
https://ask.clojure.org/index.php/3312/truncation-downcasting-primitive-reflection-overloaded
:thumbsup:
if you start asking a question on ask.clojure btw, it will suggest similar existing questions
Just noticed that it seems like those questions and tickets refer to Java 1.8. My above results are on Java 11
doesn't matter
nothing in this area has changed since Java 1.0 afaik :)
maybe there have been changes in how Clojure reflection worked against Java that would be relevant, dunno