This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-27
Channels
- # announcements (2)
- # aws (17)
- # babashka (13)
- # beginners (84)
- # calva (46)
- # chlorine-clover (40)
- # cider (19)
- # clojure (27)
- # clojure-australia (1)
- # clojure-europe (84)
- # clojure-nl (2)
- # clojure-uk (49)
- # clojurescript (65)
- # core-async (6)
- # cryogen (1)
- # cursive (11)
- # datomic (13)
- # etaoin (3)
- # jackdaw (5)
- # jobs (2)
- # kaocha (34)
- # minimallist (6)
- # off-topic (17)
- # pathom (2)
- # pedestal (11)
- # re-frame (8)
- # reagent (5)
- # rewrite-clj (19)
- # shadow-cljs (30)
Hi! π About MongoDB. Does anyone here know how the monger library (via the mongodb java driver) converts the internal JSON data structures to and from Clojure data types?
Documentation says: "Monger does not try to offer object/document mapping functionality. With Monger, you work with native Clojure and Java data structures like maps, vectors, strings, dates and so on"
@marcus.akre This is the code that does all the conversion in Monger: https://github.com/michaelklishin/monger/blob/master/src/clojure/monger/conversion.clj
hello, is there an easy way to get the formatted time elapsed since a given date (for example: "5days ago") in clojure?
Searching for clojure humanize
got me to https://github.com/trhura/clojure-humanize#datetime
this uses clj-time and I was told to use java-time now
datetimes in Java-land are a nightmare..
@U01CVNTDF34 have a look at tick - it uses Java-time and you can use it in both clj and cljs https://github.com/juxt/tick
looks interesting, don't know why I went past it, thanks
it doesn't seem to support humanizing a time "ago" (i.e: "5 days ago")
but it's definitely more complete than java-time
Oh @U01CVNTDF34 I'm sorry I completely missed the point of your initial message. Try this https://duckling.wit.ai/
actually I replaced my code with and it's much better already
that duckling lib looks awesome
I never saw it before!
I'm trying to see if it can handle the reverse (a duration to a humanized representation)
mmh it doesn't seem to do that, and it has been deprecated in favor of an haskell version from facebook π
@U01CVNTDF34 sorry I can't help much. I don't think it would be too hard to implement one, though. And at the end you can publish that as a lib π
Just a quick tip (as a user) - I personally don't like when apps do that. I even have JS tweaks to replace the "... ago" on github. So please remember some people might not want that "feature". So I'd add that as an configurable option.
I use it for knowing how long ago an app was deployed, and my users are my employees so it's fine ^^
Hello, i have to develop web app with clojure (API) + vue.js. Is there any framework that nearly equal to express.js? Are Ring + http-kit recommended? I haven't completely read about them yet. The project is relatively small only crud stuffs and user administration.
Clojure tends to prefer composing libraries over using frameworks. compojure-api
is probably a good place to start looking if you want to build an API. Pretty much all the web libraries in Clojure are based on Ring. The default adapter is the built-in Jetty web server and that's a good, solid choice for production usage.
@raefaldhiamartya We have used both Jetty and http-kit at work. They're pretty much interchangeable although http-kit claims to be faster -- but most monitoring/observability solutions out there work much better with Jetty (we ended up switching from http-kit to Jetty because we use New Relic and it doesn't work very well with http-kit).
@raefaldhiamartya You can also take inspiration here http://www.todobackend.com/ There is 4 Clojure implementations including a recent one I did with the Ring Reitit stack.
Syntax error compiling at (/tmp/form-init9098034618826095313.clj:1:73).
No namespace: devbots.bots.vacation
ls -l src/devbots/bots/vacation.clj
-rw-rw-r-- 1 stefan stefan 1538 Nov 27 18:15 src/devbots/bots/vacation.clj
head src/devbots/bots/vacation.clj
(ns devbots.bots.vacation
(:require [devbots.events :as events]
[devbots.github :as github]
[devbots.macros :as macros]
[java-time :as jt]))
(ns devbots.dispatcher
(:require [taoensso.timbre :as timbre :refer [info]]
[taoensso.carmine :as car :refer [wcar]]
[taoensso.carmine.message-queue :as mq]
[clojure.core.cache.wrapped :as cache]
[devbots.events :as events]
[devbots.util :as util]
[devbots.bots.vacation :as vacation]
[devbots.bots.lock-issue :as lock-issue]
[devbots.bots.lock-pull-request :as lock-pull-request]
[devbots.bots.needs-triage :as needs-triage]
[devbots.bots.needs-review :as needs-review]))
OMG ... I had a test/devbots/bots/vacation.clj
which I just renamed to vacation_test.clj
(it did have the right devbots.bots.vacation-test
namespace though
(rubber-duck debugging: figuring out the solution, just by explaining it to someone else)
I hear ya! Although I have a team mate, we've always worked remotely, so we're both almost "lone coders" π
Kotlin is nice. Better than Java or Scala π
Some of my roles have involved more management or more architecture than actual coding -- that's when my OSS projects get a lot more attention! When work is heavy coding, my OSS projects take a back seat. I just have to code to stay sane π
@marcus.akre This is the code that does all the conversion in Monger: https://github.com/michaelklishin/monger/blob/master/src/clojure/monger/conversion.clj
Clojure tends to prefer composing libraries over using frameworks. compojure-api
is probably a good place to start looking if you want to build an API. Pretty much all the web libraries in Clojure are based on Ring. The default adapter is the built-in Jetty web server and that's a good, solid choice for production usage.
Thanks @seancorfield! I will look into the code. π
for the "time ago" thing, I ended up (painfully) writing this
@st3fan After a lot of back and forth at work, we ended up settling on clojure.tools.logging
and log4j2 (and setting the JVM option -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory
(and using the log4j2 adapters to pipe all the other logging libs through it)
;; use log4j 2.x:
org.apache.logging.log4j/log4j-api {:mvn/version "2.13.3"}
;; bridge into log4j:
org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.13.3"}
org.apache.logging.log4j/log4j-jcl {:mvn/version "2.13.3"}
org.apache.logging.log4j/log4j-jul {:mvn/version "2.13.3"}
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.13.3"}
Right now I see Jetty and my own logging end up in different formats in the console ..
Yup, another reason to bridge all logging into one place.
This sounds like something I should pour at least an hour into to understand and get right
is Clojure considered a really expressive language? meaning... can represent almost any algorithm or idea.
yes and what the foundational clojure forms cannot express well you can build with macros and functions
Can someone help me understand why this throws an error?
((fn [start stop]
(loop [start start
stop stop]
(if (start >= stop)
start
(recur (inc start)
stop)))) 1 4)
no worries, earliet today i typed something like (defun something [] (return 123)) π
I suppose I also need to understand how to read clojure error messages better - couldn't tell what error my line was on. So i thought the issue was with recur
I defined:
(ns minimal.spec
(:require
[clojure.spec.alpha :as s]))
(s/def ::my-spec ...)
and in the main file:
(ns minimal.core
(:require
[clojure.spec.alpha :as s]
[minimal.spec :as spec]))
(s/conform :spec/my-spec ...)
but I get
unable to resolve spec: :spec/judgement
what's going on?@meditans You need ::spec/judgement
so the alias is auto-resolved.
(you have a single :
instead of a double ::
)
thanks @seancorfield (I can't wait to see your talk on the repl btw). But why do I need to autoresolve that? isn't :spec/judgement
equivalent to :minimal.spec/judgement
given my import? I was under the impression (maybe wrong) that ::
added the current module
No. :foo/bar
is always just :foo/bar
. But ::foo/bar
will expand an alias foo
into its namespace.
In the same way that ::bar
expands to :current.namespace/bar
I see, so without the ::
there's no namespace substitution! Thanks! Where can I find the complete semantic of ::
?
I was just looking on http://clojure.org for that... I suspect it might be in the Reader section...
https://clojure.org/guides/weird_characters#autoresolved_keys (and the following section about namespace map syntax) touch on it -- but don't really show aliases being expanded...
Oh, they do give an example further down in the namspace map syntax section!
@raefaldhiamartya You can also take inspiration here http://www.todobackend.com/ There is 4 Clojure implementations including a recent one I did with the Ring Reitit stack.