This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-20
Channels
- # admin-announcements (1)
- # announcements (9)
- # aws (11)
- # babashka (33)
- # beginners (125)
- # calva (20)
- # cider (18)
- # clj-kondo (7)
- # cljs-dev (73)
- # clojure (72)
- # clojure-europe (18)
- # clojure-italy (13)
- # clojure-nl (13)
- # clojure-uk (9)
- # clojurescript (22)
- # core-async (7)
- # cursive (1)
- # data-science (25)
- # datomic (22)
- # duct (32)
- # emacs (13)
- # graalvm (5)
- # hoplon (16)
- # juxt (6)
- # kaocha (8)
- # leiningen (3)
- # malli (11)
- # meander (12)
- # off-topic (18)
- # pathom (109)
- # pedestal (5)
- # rdf (10)
- # reagent (1)
- # reitit (12)
- # shadow-cljs (27)
- # spacemacs (5)
- # sql (9)
- # tools-deps (7)
Does anyone know of a complete parser for the https://www.ietf.org/rfc/rfc3339.txt date format? There are so many caveats to the format and all the examples I've found online seem to fail.
I got pretty close with "yyyy-MM-dd'T'HH:mm:ss[.SSS]ZZZZZ"
pattern + parseBest but rfc3339 includes leap seconds which means seconds can go to 60 and causes it to fail 😞
Leap seconds are only valid at certain times, the end of June or December, have you been testing your parsering with date times where leap seconds are valid?
Execution error (DateTimeException) at java.time.temporal.ValueRange/checkValidIntValue (ValueRange.java:330).
Invalid value for SecondOfMinute (valid values 0 - 59): 60
Hmm https://stackoverflow.com/questions/55304194/java-instant-parse-on-date-java-8/55310635#55310635
I think this works!
(.withResolverStyle
(DateTimeFormatter/ofPattern "yyyy-MM-dd'T'HH:mm:ss[.SSS]ZZZZZ")
ResolverStyle/LENIENT)
For those interested, this is the final code that seems to work with all my examples
(def rfc-3339-formatter
(.withResolverStyle
(DateTimeFormatter/ofPattern "yyyy-MM-dd'T'HH:mm:ss[.SSS]ZZZZZ")
ResolverStyle/LENIENT))
(defn parse-rfc-3339-to-instant
[date-string]
(-> (LocalDateTime/parse date-string rfc-3339-formatter)
(.atZone (ZoneId/of "UTC"))
(.toInstant)))
I'm trying to use cheshire
to create a JSON lines dataset. I wrote a working function that I am reasonably happy with.
(defn write-jsonl
[rows writer]
(doseq [row rows]
(ch/generate-stream row writer {:escape-non-ascii true})
(.write writer "\n")))
Does anybody know if there is a cleaner way to get the newline rather than a separate call to .write
? Perhaps a cheshire option that I can't find in the docs?Hi, I am looking at spec-ing some code and I wanted to make a set extensible; (s/def ::type #{:local-file :s3})
such that in another file, I could add on another type e.g. :sftp
Hello everyone! Just trying my luck here: has anybody successfully enabled OS X clojure build via Travis CI/CD? Seems like they only support linux and win out of the box... Edit: made it work if anyone is interested - just needed to add leiningen into addons: seems quite simple, so I am not sure why Travis states: "Clojure builds are not available on the macOS environment."
language: clojure
matrix:
include:
- os: osx
jdk: openjdk11
addons:
homebrew:
packages:
- leiningen
update: true
I have a project which has a deps.edn dependency to a private http://github.com repo, Clojure deps is failing to pull the dependency with:
Cloning: [email protected]:grzm/psycho-roll.git
Error building classpath. [email protected]:grzm/private-repo.git: invalid privatekey: [[email protected]
org.eclipse.jgit.api.errors.TransportException: [email protected]:grzm/private-repo.git: invalid privatekey: [[email protected]
Seems like it’s an issue with my SSH keys, but I’m a bit puzzled as I can clone this same dependency from http://github.com from the command line with git clone
without any problem, and the necessary keys show up when using ssh-add -l
. Hints on what I might be doing wrong?I have a vector of one or two map elements [{:x 'x} {:y y}]
and I would like to create a replica of those two maps and append them to an accumulator vector. I primarily iterate to each one of them and append it to the acc-vector such as (map #(swap! acc-vector conj (do-something %)) original-vector)
. Is there an actual function for this? if not then I keep this approach
great recommendation
Because we are talking about this, I am using async and I use map. Should I use run!
instead for the following example?
(defn upsert-legs!
[legs]
(let [leg-chan (chan 1024)
match-chan (chan 1024)
upsert-chan (chan 1024)]
(onto-chan leg-chan legs)
(pipeline-blocking 16 match-chan (map match-leg) leg-chan)
(pipeline-blocking 16 upsert-chan (map upsert-leg!) match-chan)))
makes sense
hey folks, i get this reflection error when trying to call static method like this: (Cls/foo ...), any way i can unconfuse reflection machinery to see that it's Cls being called, not xyz.core$eval6024? Cls is gen-classed in another namespace if that matters
I’m writing a simple transpiler, in first step I parse original source into clojure datastructures and then in second step I take that data and emit output text. The problem is that my data is a deeply nested structure containing lazy sequences (produced by map, etc.) and when the structure is realized during emit I might get some errors/exceptions. And for that I would need some context info to print meaningful error messages. I didn’t want to pass context explicitely down through all the calls. I wanted to use something like binding
to set some context at the top level and use it later when I hit exceptional state. Any ideas how to do that?
currently I opted in forcing recursive realization of the datastructure (using doall
) at some well defined points and with dynamic binding
to set current context info, but that has some issues
What is a way to read transit from stdin while only relying on core or standard Java features?
$ echo "{:a 1}" | jet --to transit | ./bb '(transit/read (transit/reader ... :json))'
yay, that worked!
$ echo "{:a 1}" | jet --to transit | ./bb '(transit/read (transit/reader System/in :json))'
{:a 1}
here is how you detect, that something was passed on stdin: https://github.com/xsc/lein-ancient/commit/9c973ce589f09c1ef026a92d112e5ad74911e881#diff-49011372f9f79f94fddac7b48e625774R170-R171
anyone have a good reference handy for a macro that is a def
-function-like? Ie parsing dosctring and arities
Spec is a great use case for this! I do that in my defn-spec library https://github.com/Provisdom/defn-spec/blob/f0dd33d9b16674a2f1209a19f02ccb9eb2ca037f/src/defn_spec/core.cljc#L35
not sure what you need, but if you're looking for code that parses an expression like defn does, it might be good at the code for defn
a combination of clojure.core and cljs.core actually. sometimes I find the code in cljs.core a little bit clearer
If you import the relevant Java class (e.g., ExpectedFooClass
), you can provide a hint to your function call: (CIs/foo ^ExpectedFooClass foo)
Alternatively, if foo
is being passed in as an argument, you can provide the hint there:
(defn foo-wrapper [^ExpectedFooClass foo]
(CIs/foo foo))
the problem is somehow in Cls/foo itself. it's static method inherited from ClsSuper/foo and it's looking up the caller stack to make sure Cls extends ClsSuper but somehow fails that check. clojure uses invokeStatic to call Cls/foo and that makes it not be in the stacktrace somehow? i don't know..
at com.almasb.fxgl.app.GameApplication.launch(GameApplication.java:62) at xyz$eval6024.invokeStatic(form-init1514362494284450037.clj:19) supposedly there should be a line with Cls.launch in between here, right?
I strongly suspect that if the lib relies on implementation details of how java implements inheritance and superclass method invocation, the simplest and least error prone thing is to write a java stub that invokes clojure functions in all its method bodies
each method would use clojure.java.api.Clojure to look up an ns and call a function https://clojure.org/reference/java_interop#_calling_clojure_from_java
or just write it all in java if that's easier
just in case anybody else stumbles across this, the problem was in implicit assumption that caller of .launch is a class that extends a certain super, which it is not if .launch is invoked directly from clojure code
If you’re looking for UI-building tools, these are the two I’m aware of : https://github.com/fulcrologic/fulcro-native, https://github.com/drapanjanas/re-natal
(both based on React Native)
I’d assume very. But I’m assuming desktop java clojure involves a lot of imperative code. Do you use a particular library or framework for desktop java/clojure UI dev?
there’s a whole other React Native toolchain you use, along with the ClojureScript toolchain
that being said, it’s pretty useful to know. you can currently build UIs for windows, macOS, iOS and Android with React Native, and it gets more feature complete and advanced as time goes on
fundamentally, getting clojure to run on android is difficult; there are differences between mainstream JVMs and the android runtime. and the Clojure startup time is a big UX problem on smaller devices
If you only worked with Java, adjusting to JavaScript as host might require some learning. That being said React Native + shadow.cljs is becoming really nice app-development platform. Resulting applications also work quite nice, and there’s more and more useful bridges to native code. The biggest problem, probably, is that you’re gonna have to read documentations and issues of JavaScript tools, you might not be familiar with