This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-27
Channels
- # announcements (10)
- # aws (11)
- # beginners (158)
- # calva (8)
- # cider (14)
- # clj-kondo (1)
- # cljsrn (1)
- # clojure (83)
- # clojure-europe (5)
- # clojure-italy (25)
- # clojure-nl (3)
- # clojure-spec (12)
- # clojure-uk (20)
- # clojurescript (72)
- # community-development (18)
- # core-async (4)
- # core-logic (19)
- # cursive (11)
- # datomic (21)
- # duct (6)
- # events (1)
- # figwheel-main (3)
- # fulcro (15)
- # ghostwheel (1)
- # jobs (1)
- # leiningen (16)
- # off-topic (45)
- # onyx (3)
- # pathom (7)
- # perun (1)
- # ring (3)
- # shadow-cljs (48)
- # spacemacs (10)
- # specter (1)
- # sql (24)
- # tools-deps (7)
- # vscode (7)
- # xtdb (14)
Curious results when using reader literals in a vector. This works fine in the repl:
#java/zoned-datetime "2000-01-01T00:00Z"
However, I get an error when I try to place this in a vector and run in the repl:
[#java/zoned-datetime"2000-01-01T00:00Z"]
Execution error at finance.api.db$eval45052/<clinit> (db.clj:115).
No reader function for tag java/zonded-datetime
This also works fine:
[#inst "2018-03-28T10:48:00.000"]
Notice the extra d
in java/zonded-datetime in the error message? I have cleared cache in Cursive and tried this in a clj repl. This is mostly a curiosity that I'm interested in seeing if anyone else has come across.Just to be clear, you also see this in a command-line clj REPL, right? So itโs not a Cursive issue?
Does it make a difference if you have at least one space character before the string?
Your example within a vector above does not have one, but the earlier one not in a vector does.
Oh, yeah, and that error message with a different name is very weird.
I would do a grep over all of your code to see if it contains any occurrences of 'zonded', just in case.
Good suggestion :thumbsup:. I found it. Silly mistake. I had a typo in my print-dup
function which must only be used when serializing sequences ๐
I did some quick REPL experiments with my own data reader function with a tag cljol/uedge
, and it seemed to work at the REPL both inside and outside of a vector, regardless of whether there was a space after the #cljol/uedge
https://clojurians.slack.com/archives/C053AK3F9/p1580096279197800 << not strictly speaking a beginners question; do forgive the x-post. would dearly like a hand sorting this import out
It's Sunday evening in the US so things are a bit quiet in here @benkay ... I'll follow-up in #beginners
I'm working on a bug, but the stack trace is getting erased (optimized?) at some point by the JVM so I just get a "NullPointerException" without a cause or stacktrace. Is there a way to workaround this behavior?
Do you get this exception in a REPL?
First, you can do something like (def e1 *e)
to save the Exception object in the var e1
Then try (.printStackTrace e1)
to see if it is empty that way or not.
If it is, then the default behavior for many JVMs when starting up is to allow it to optimize away the contents of stack traces. Many people always provide a command line option when starting their JVMs to prevent this from occurring.
That option for at least many JVM flavors is: -XX:-OmitStackTraceInFastThrow
With Clojure 1.10.x at least, the default behavior in the REPL is to show just a 1 or 2 line summary when an exception is thrown.
But saving it in a var lets you try other ways to examine its contents. You can also see it in a Clojure datafied way by just evaluating e1
There are various middleware/plugin kinds of things that some people put into Leiningen profiles that modify how stack traces are shown, but Java's .printStackTrace
has a pretty consistent format.
Hmm, looks like I get the same only-1 or 2-line description of an exception in a REPL for Clojure versions back to 1.6.0, so the short summary in the REPL isn't a new thing.
No, that has always been the case. Other repls vary
Other than Cursive, is there a tool that will show me public vars that are defined but not used project-wide?
https://github.com/venantius/yagni and its recently-born cousin https://github.com/stacksideflow/cljs-yagni
Based on the feature list, it can only detect unused private vars (i.e. it's local to a namespace)
@enn clj-kondo does offer this information as part of its analysis export. This is a simple script that just prints them: https://github.com/borkdude/clj-kondo/blob/master/analysis/src/clj_kondo/tools/unused_vars.clj Check out: https://github.com/borkdude/carve which is a tool based on this.
Sure. I get project wide refactors, unused var info, nav, docs, arity checks, completions statically
Hello Friends. Let me ask you somenthing quick: I'm trying to apply a reduce for replace-text in a word document. i want to get a vector with maps such as this
{:variableย "$test$"ย :valueย "thisย isย theย replace"}
; the function that i'm trying to apply.
(.. getRange (replace "$test$" "this is the replace" (new FindReplaceOptions)))
My tought is: how could i get each value of this map at once to apply the necessary changes?
Could anyone help me with some insight?@ramon.rios Something like:
user=> (let [s "$test$"] (reduce (fn [s {:keys [:variable :value]}] (clojure.string/replace s variable value)) s [{:variable "$test$" :value "test-value"}]))
"test-value"
?(defnย fill-template-with-dataย [docxย template-dataย tmp-dir]
ย ย ย (do
ย ย ย ย ย (reduce
ย ย ย ย ย ย (fnย [{:keysย [variableย value]}ย template-data]
ย ย ย ย ย ย ย ย (..ย docxย getRangeย (replaceย variableย valueย (newย FindReplaceOptions))))
ย ย ย ย ย ย template-data)
ย ย ย ย ย (.ย docxย (saveย tmp-dir))))
Did not worked as expected
I think so, let me test that. Thank you @borkdude
https://github.com/venantius/yagni and its recently-born cousin https://github.com/stacksideflow/cljs-yagni
anyone know how to check the tls version of javax mail? we have it enabled but not sure how to see which version it uses
Given a vector like [1 3 5 2] not sorted but with distinct elements, what's a good way to extract a sub vector given a from and to number? For example passing 1,5 I should get [1 3 5]
subvec
Actually sorry they are not numbers they are keywords
The numbers was just to show an easy example
index math is different, but it's the right behaviour
user=> (subvec [1 3 5 2] 0 3)
[1 3 5]
oh - were the args matching elements and not indexes? they were
there's drop-while / take-while
They were matching elements
Yeah I used that for the beginning, I guess I can use it also for the if I conj the second element
I think partition 2 1
idiom helps here
Ah cool I'll try thanks
@andrea.crotti this is weird if the indexes aren't found, but works
(defn inclusive'
[vect a b]
(subvec vect
(.indexOf vect a)
(inc (.lastIndexOf vect b))))
ah cool I was looking for indexOf or similar
it's not wrapped in a core function apparently then
clojure is very opinionated about linear time searching
makes sure it's never the simple thing
yeah performance in this case it's not an issue, the vector will have 10 elements ๐
haha until just now I thought this was the work slack :D ๐
Well I was doing it for my work ๐
A tiny library that might be OSS soon anyway
They are not wrapped. They are mentioned in the list and vectors section of the Clojure cheatsheet: http://jafingerhut.github.io
(take-while (complement #{5}) (drop-while (complement #{1}) [1 3 5 2]))
But the last item will be missing. This will output [1 3].
I have a feeling I am missing a simple trick.
very nice with complement, and yeah I'm just adding it at the end
if you do that, you can get strange results - eg. tacking the thing on the end even though it didn't exist after the start-index at all
this is where (partition 2 1 coll)
is sometimes useful - getting the "peek" of an adjacent element at the end
(then map first or map second to get the real result)
uhm I'm making sure (via assertions) that the elements I look for exist, and they are unique
so I think it's safe in this case
oh, OK then
I replied in the channel.
hi! what is the clojure version of this Java code: TextDocument outputOdt = TextDocument.newTextDocument();
you want (TextDocument/newTextDocument)
- invoke a static method
that import looks wrong as well? should it be (import org.odftoolkit.simple TextDocument)
this version doesn't work - if you split prefix/suffix you need to wrap it in a collection (import (foo.bar Baz))
but I'd only do that if I'm using multiple things from foo.bar
the only difference with import between ns / non-ns is the keywordize of :import, since it's a macro and quotes args already