This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-20
Channels
- # announcements (42)
- # babashka (70)
- # beginners (152)
- # chlorine-clover (19)
- # cider (14)
- # clj-kondo (23)
- # clojars (15)
- # clojure (86)
- # clojure-denmark (1)
- # clojure-dev (5)
- # clojure-europe (57)
- # clojure-france (145)
- # clojure-hungary (2)
- # clojure-italy (5)
- # clojure-nl (7)
- # clojure-spec (35)
- # clojure-sweden (2)
- # clojure-uk (58)
- # clojurebridge (1)
- # clojured (1)
- # clojurescript (50)
- # core-typed (9)
- # cursive (10)
- # data-science (11)
- # datascript (4)
- # datomic (25)
- # emacs (8)
- # fulcro (49)
- # graalvm (7)
- # graphql (6)
- # joker (1)
- # juxt (2)
- # kaocha (1)
- # off-topic (22)
- # other-lisps (1)
- # pathom (20)
- # re-frame (3)
- # reagent (11)
- # reitit (2)
- # remote-jobs (1)
- # shadow-cljs (44)
- # spacemacs (2)
- # sql (17)
- # tree-sitter (2)
- # vim (8)
- # vrac (2)
When using clojure -Spom, is there a way to specify the version number generated for the project? It seems to be a constant of '0.1.0'.
Looks like you can only get 0.1.0 (at least for now): https://github.com/clojure/tools.deps.alpha/blob/11cba8fd05372ab51bea3771307721546a3ea6c0/src/main/clojure/clojure/tools/deps/alpha/gen/pom.clj#L73-L77
The whole idea is that if there is a pom, it updates in place. Just change it to whatever you want.
Otherwise there would need to be 100 flags for every piece of data
It only updates dependencies, repostories, and source paths
@tstout In case it's helpful for the next project you create, if you use clj-new
to create a (library) project, it generates a pom.xml
that is "complete" and you can specify the initial version to use (and other things) via command-line arguments when you create the project: https://github.com/seancorfield/clj-new#the-generated-pomxml-file
clojure -A:new lib tstout/myapp -e version=1.0.0 -e developer="Mr Stout"
Produces
<groupId>tstout</groupId>
<artifactId>myapp</artifactId>
<version>1.0.0</version>
<name>myapp</name>
...
<developers>
<developer>
<name>Mr Stout</name>
</developer>
</developers>
Thanks for the responses. My use case is invoking clojure -Spom and then depstar in a Dockerfile so that the manifest in the uberjar will have a version. My employer has a standard such that all services have an /about endpoint which responds with various useful bits of info, including the build version. I am attempting to get the build version from the uberjar manifest in order to properly respond to the /about request at runtime using the functionality of java.util.jar.Manifest. Perhaps there is an easier path to supply this information to the docker image.
@tstout What I tend to do in such situations is to have the version in a file that is both part of the application itself and also used to build the application, so it would require some process to read the version file, modify the pom.xml
, and then invoke depstar
to build the uberjar.
At work, we specifically bake in a git-related version: we use last tag + commits + SHA which we get with git describe --tags
and our wrapper around invoking depstar
runs that commands and then writes the value to the pom.xml
and also to an EDN file in the resources
of the app -- and then runs depstar
.
That way our apps can report their actual "build" version easily.
https://github.com/funcool/buddy-auth/blob/ec454fecd3a84746c8e7b9e3af942cb1a692fdbd/profiles.clj#L21
why in this file the profile :session-example is specified as a list instead of a map as in this line: https://github.com/funcool/buddy-auth/blob/ec454fecd3a84746c8e7b9e3af942cb1a692fdbd/profiles.clj#L16
Just wanted to share this for those (like me) who have to deal with protobuf from clojure, as it might be handy: https://gist.github.com/hkupty/783a89820fdc10d9a525cdf7cd2abac2 The one thing though I'd like is to avoid the runtime reflection, but I guess (from what I rad from protobuf's docs) that's probably not possible if class is not known beforehand...
@i that's a composite profile https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md#composite-profiles
How do I get access to the ring request object inside a Compojure API handler. My handler looks like this:
(GET "/me" []
:summary "Get current User object"
(user-handler))
Inside the user-handler function definition I want access to the Ring request object, so that I can read the user object from the session details. Thanks!
“request” is available in endpoint definitions via the request var, you can define your method as follows
(GET "/me" request (user-handler request))
How would I go about sorting by dates in different directions? for example - sorting by :start-time ascending and :end-time descending (using java-time). The solution I have right now is:
(compare [(:start-time thing-1) (:end-time thing-2)]
[(:start-time thing-2) (:end-time thing-1)])
How do I set jvm-opts for a deps.edn project where it runs without using -O argument? I am using Calva so I can set a jackInEnv. However I want it to work for any environment.
Do deps.edn projects know to read the project-specific .jvmopts file, maybe?
but you can wrap clj executable into your own script wich will try to detect local .jvmopts file or will use any other logic to get jvm options and run clj/clojure
binary with a set of -J%java opt%
arguments
Also: Calva has a setting named jackInEnv
that can be used for setting JVM options. (EDIT: And now I read the OP more carefully... never mind me...)
placing wrapper into preject-related bin directory should work for everyone
but I agree that this feature could be implemented in clojure executable. It will be handy in many cases
Am I missing something?
{:deps {......}
:aliases {:dev
{:jvm-opts ["-Djdk.attach.allowAttachSelf"]}}}
I’m looking for use this library https://github.com/clojure-goes-fast/clj-memory-meter. But also was wanting to experiment with heap size
Suddenly started working. Didn’t change anything lol
does anyone know of a good library for accessing google docs, specifically google sheets? I'd love to find something like docjure
I suppose what might be nice is something that hits the JSON http directly rather than wrapping the java, but idk
I have been using the Java SDK and it works well (`com.google.apis/google-api-services-sheets`)
@U963A21SL cool. thx for the recommendation
I want to write a parser for a simple text file format that's read line-by-line, so the parser really only has to parse a line and then put the data into datascript. The two main options I see for parsing are instaparse and using clojure.spec's conform
to parse, which is the better option?
For parsing, use instaparse
. Spec is not intended to be used for parsing.
instaparse is nice to get something quickly, but if you need to process loads of data, you might get into performance issues. spec is not designed to work with text, although you can get it working. don't expect superb performance. hand-rolling a parser is imo the best way long term
@nihilazo to see what I mean, check out this advent of code puzzle which I solved using 4 different parsers, including instaparse and spec: https://github.com/borkdude/aoc2017/blob/0f5bce5e496d65d0e53a8983e71ea3462aa0569c/src/day16.clj#L241-L244
what I'm parsing is a very simple text file format (that's also changable to make parsing easier, if I need to) so writing my own parser using string tools wouldn't be too difficult
also, I'm storing a bunch of data (basically, a file name and the tags assocated with it, that I then filter by tags) and I'm thinking of using datascript to keep this data during runtime, but there might tens or hundreds of thousands of files. I don't want to use a database server, but is datascript up to that task or not?
@nihilazo There is a #graalvm channel. Also check out https://github.com/lread/clj-graal-docs and https://github.com/lread/clj-graal-docs/blob/master/doc/external-resources.md#projects for examples.
@nihilazo fwiw I'm using transit in clj-kondo (also a CLI compiled with graalvm) to do a database-like thing for storing arities, etc. about clojure functions
@nihilazo Another idea: you can write a script with babashka (fast startup while still having access to much of the JVM Clojure ecosystem) and access a sqlite database by shelling out: https://github.com/borkdude/babashka/blob/master/examples/sqlite.clj
I'll try using datahike first, it seems like about what I need, and then I'll try sqlite if that doesn't work out
I was going to write this in rust, but I decided to stick with what I was familiar with (this is for a tool that me and maybe 4 other people might use, so it's not a massive deal)
@nihilazo This just got announced: https://github.com/wandersoncferreira/mamulengo in #announcements. Might also be interesting for you.
Hello Clojurians, I'm having a problems getting access to a zero-token through a POST so that I can use it in my buffer to perform an authentication request. Now the URL here's the link ; following along a video 'Microservices with CLojure'. I'm lost on how to use this site to create a way to well, access to a zero-token through a POST so that I can use it in my buffer to perform an authentication request. Here is the relevant functions that calls the outdated api: (defn auth0-token []
(let [ret
(client/post ""
{:debug false
:content-type :json
:form-params {:client_id (System/getenv "AUTH0_CLIENT_ID")
:client_secret (System/getenv "AUTH0_SECRET")
:grant_type "client_credentials"}})]
(json/parse-string (ret :body))))
Can someone help me with this? Thank you in advance 🙂@guillermoithier Please don't cross-post the same question here as #beginners -- just be patient and wait for someone to respond.
maybe the browser already has what you need (if that's your target)? https://www.w3schools.com/xml/xml_parser.asp
any tips on how to solve this reflection warning? > Reflection warning, /blabla/notification/ports/emailer.clj:79:7 - call to method withToAddresses on com.amazonaws.services.simpleemail.model.Destination can't be resolved (argument types: clojure.lang.IPersistentVector). the code that generates it:
(defn- ^Destination notification->destination
[{::spec.notification/keys [^String destination]}]
(-> (Destination.)
(.withToAddresses [destination])))
and the method signature:
com.amazonaws.services.simpleemail.model.Destination/withToAddresses
[this java.util.Collection]
[this java.lang.String[]]
I tried annotating it with everything already :man-facepalming:aha! nvm. I was trying to annotate the vector but TIL that it doesn't work. annotating a symbol and passing it to the method works
I really like the thought process behind datafy/nav
but I'm having trouble understanding the intuition behind the v
argument of nav
(i.e.,
(nav coll k v)
(nav coll k)
I would understand, but I don't really understand the v
. Is it just usually omitted in most case and it's just there if you need it?To put it another way, if I already have the value v
, what do I need nav
for?
@goomba (nav coll k v)
returns v
in a lot of cases.
But it is a consistent API for navigating from "data" to "things".
For example, in next.jdbc
(and the experimental datafy
/`nav` support in clojure.java.jdbc
), if you (nav row :foo_id 42)
it will fetch the row from table foo
that corresponds to id = 42
-- so it needs both k
and v
.
ahh that makes sense
(there's an optional schema behind next.jdbc
that lets you override the default conventions)
And in many cases, you'd end up calling (nav data nil v)
because there's no index/key association for the v
part of data
(such as a sequence)
Aha. So if there's no index/key association, we'd use nil
for k
. I would've thought v
would be nil but I wasn't thinking about it in terms of index == value
I was thinking in terms of (get coll k)
. That's an excellent explanation @seancorfield, much appreciated
For others here thinking about datafy
/`nav`, maybe this chapter of the next.jdbc
docs helps https://cljdoc.org/d/seancorfield/next.jdbc/1.0.13/doc/datafy-nav-and-schema