Fork me on GitHub
João Galrito00:09:22

is there a channel for non-clojure programming related questions?


That sounds like a good place to start if there isn't a language-specific or topic-specific channel for your question.

João Galrito01:09:39

Imagining I have a (potentially infinite) lazy seq, how would I go about outputting this seq into a buffer, and when I receive a signal, start processing from the buffer

João Galrito01:09:04

I imagine I'll have two threads, one where I put stuff into the buffer, and another that locks while waiting for the signal then starts processing


How about a control channel? That could be used for start, stop, or whatever kind of signal.

João Galrito11:09:48

I kind of have that to signal the 2nd thread to start processing

João Galrito01:09:13

and reading and writing to an async/chan


(->> bq ; (.jobs) ; (#(.get % project-id job-id)) ; (.execute) ; (.getStatus))) How can I call a method called setLocation which takes a string param on the object returned by line (#(.get % project-id job-id)) In non-threaded form I can achieve it by

(let [jobsobj (.jobs bq)
      getobj (.get jobsobj project-id job-id)
      _ (.setLocation getobj "australia-southeast1")
   (.getStatus (.execute getobj))))


Switch to ->, use doto


(let [some-values [-1 2 -3 4]]
  (->> some-values
       (filter pos?)
       (let [some-values [-5 6 -7 8]])))
;; => (6 8)
That was a bit surprising but it might be pretty handy in certain use cases. Reminds me a bit of hoisting in Javascript. Is there a way to know more about why it works the way it works?


->> is a pure syntactic transform (a macro) so you can always use macroexpand or clojure.walk/macroexpand-all to see what's going on...

user=> (clojure.walk/macroexpand-all '(let [some-values [-1 2 -3 4]]
  (->> some-values
       (filter pos?)
       (let [some-values [-5 6 -7 8]]))))
(let* [some-values [-1 2 -3 4]] (let* [some-values [-5 6 -7 8]] (filter pos? some-values)))

👍 3
Isaiah Jones08:09:15

Hello everyone, I am trying to write a function that is able to call the 'use' function on two parameters but I can't seem to figure out how

Isaiah Jones08:09:23

the function code i have right now is this:

Isaiah Jones08:09:32

(defn foo [a b]
(use a :refer [b]))


use expect a vector if you want to use :refer

(defn foo [a b]
  (use [a :refer [b]]))
but this is a bit strange looking usage of use ) have a look at

Isaiah Jones08:09:23

So then how would I be able to use b inside of that function in this case


(requiring-resolve (symbol (name a) (name b)))


based on example given in one of your messages

Isaiah Jones08:09:14

so that when I call (foo 'project.core 'bar), I am able to refer to the atom named 'bar' located in the project.core namespace inside of this function

Isaiah Jones08:09:05

Anyone know how to fix this issue?


How do I stop a process started with ProcessBuilder? trying to call destroy on it but I end up with

No matching field found: destroy for class java.lang.ProcessBuilder
and when doing
it seems to not have any destroy function.


ProcessBuilder is a builder of processes, it's not the process itself. You will have to get a reference to the started process and call .destroy on it.


excellent, now I got it! thanks @U2FRKM4TW


Hi Clojurians! First post here. Has anyone experience with Luminus? I fail to create a functioning WAR file with lein-uberwar (0.2.1) / Leiningen 2.9.1. WAR gets created but once deployed on a Jetty or Tomcat webapps I get HTTP Status 500: clojure.lang.ArityException: Wrong number of args (1) passed to: mytestapp.handler/app (Notice, I didn't do any coding. It's a fresh luminus templated project with just a WAR option. (new luminus mytestapp +war) I get it perfectly running in dev mode using 'lein run'. Has anyone ecnountered this or has an idea? 1000 Thanks!!!

Pradeep B13:09:47

i used lein uberjar command and was able to run the jar just fine with java -jar <filename.jar>


it's uberwar.


Unless I can deploy a JAR on a Webapp server. (Giving it a try right now.... Thanks)


As expected 'lein uberjar' created an executable. Cannot be deployed as a webapp.


I thought Luminus projects were intended to be just run as an uberjar, starting Jetty internally?


I wouldn't expect an "arbitrary" web project in Clojure to be buildable/usable as a WAR file without additional code being written.


There's a #luminus channel where you might get more detailed answers about that...


@U04V70XH6 Thanks! I'll try that channel. Luminusweb has a +war profile. Doc says "+war adds support of building WAR archives for deployment to servers such as Apache Tomcat". The template code delivers a home page from the get go (lein run). But maybe you're right and there is some additional boot straping neccessary.


yes, you want an uberwar, which will look for servlet class and such and make sure that's aligned with web.xml and all that in the war archive


the uberjar is for running the process standalone, not outside of a container. And that needs it's own main function where the jetty adapter can be started. More like a simple process that starts its own web server


@U01BEC6NUSY Ah, good to know. I'm not very familiar with Luminus' various options. And I have never used WAR deployment with Clojure (in a decade of production usage).


Hi! I'm looking for the best solution to keep strings (sentences, used by my bot) in some configuration file. The idea is that non technical person will modify them or later we'll add new languages. Is there any library designed to help with that? I don't want to reinvent the wheel using json files if not needed.


Thanks, looks like what I'm looking for!


you can create an edn file an put it under resources. and then create your own (simple) function


idk if you have more needs but this solution is easy and straightforward IMHO


Can anyone help me figure out why I can't pick up an alias from my global deps.edn? (transcript attached)


because debug is not in your aliases map

{:aliases {:depstar
            {com.healthfinch/depstar {:git/url ""
                                      :sha "4aa7b35189693feebc7d7e4a180b8af0326c9164"}}}
            {nodisassemble {:mvn/version "0.1.3"}}}}
  {philoskim/debux {:mvn/version "0.7.6"}}}}


oh well that's interesting! indentation fail, I guess


yeah indentation is critical to me. as soon as i reindented it it was clear


Has someone perhaps written a #clojure tools-deps centric tool for auditing all of the OSS licenses in use in the dependency tree?


I’m actually also interested. A Leiningen-based tool would also do.


seems (paid tool) has lein support


Interesting, thanks!


Maybe I’m optimistic, but I guess it shouldn’t be too difficult to build something fairly simple on top of tools.deps.


super simple, just would rather reuse than spend some time building it


Sure, same here.


is a license usually included in the .jar?


then it seems like a pretty simple program to scan for certain files / words on your classpath?


anyone have a recommendation on best visualization library out there - either server side clojure or front-end clojurescript? I'm looking for something relatively simple - data coming from the server as a ledger of date/time and some values, and then want to do some line graphs around that


is Oz too much or are there better options?


Derp, I was thinking Vega Lite was a simplified version of Oz, but it’s the other way around


Best to ask about this sort of thing in #data-science on Zulip: Oz is not simplified Vega/Vega-Lite - it uses them pretty directly. There is Hanami if you want a lib to build something on. It has a means of creating simplified templates for visualizations on top of Vega and Vega-Lite.


Yeah, it’s Vega Lite that’s (obviously) the simpler version of Vega, and Oz that’s a wrapper around Vega/Vega-Lite. I worded my correction badly.


We were looking at Oz/Vega/Vega-Lite for our dataviz stuff, but then the business decided to farm out to Tableau instead of doing it in-house. I was liking what I saw in Oz even though we never built anything in it.


@clypto I'm a happy oz user. It's pretty straightforward. Depending on your needs, also see cljfx and cljplot.


are you sure about cljfx? it's a UI library, not a data visualization library...


although it has charts..


ah cool, I'll give Oz a try


Best to ask about this sort of thing in #data-science on Zulip: Oz is not simplified Vega/Vega-Lite - it uses them pretty directly. There is Hanami if you want a lib to build something on. It has a means of creating simplified templates for visualizations on top of Vega and Vega-Lite.


Should probably mention there is a 'bare bones' example Hanami application as well:


not many people in #xml, so I'll vent here... I've been experimenting with creating xml from code, and it looks just horrible:

(xml/alias-uri 'pom ""
               'xsi "")

      {::xsi/schemaLocation " "
       (keyword "xmlns" "") ""
       :xmlns/xsi ""}
      (xml/element ::pom/modelVersion
Specifying some ns as default requires using unprintable keywords: (keyword "xmlns" "") waaaat


I'm doing exactly this stuff for pom.xml in the tools.deps pom sync code if you want to look at that


sexp api looks better in this regard!


am I missing something?


you can set default ns as an attribute

Istvan Szukacs20:09:40

hi folks, can I do something about project.core$myAwesomeFunction.invokeStatic () it takes up a lot of CPU


that's just the invocation of your function


so your function is taking a lot of cpu. if you open it up, you should learn more about what is doing that

👍 3
Istvan Szukacs20:09:58

You mean just check line by line what it does?

Istvan Szukacs20:09:36

what tool should I use the further analyze this?

Istvan Szukacs20:09:51

seems like VisualVM does not give me everything


those little dropdowns on the right are showing you that the top line, and most of its time is spent in the 2nd line, and if you open, that most of its time is spent in the lines below that etc - if you keep following that trail you can see what's taking most of the time


depending whether visualvm is using sampling or tracing (probably the former), you won't necessarily see everything, but in theory you should see the important stuff


wouldn't it be nice if instead of pom.xml we had pom.edn that could be manipulated as map... :thinking_face: e.g.

{:modelVersion "4.0.0"
 :groupId 'group
 :artifactId 'artifact
 :version "1.0"
 :name "name"
 :dependencies #{{:groupId 'org.clojure
                  :artifactId 'clojure
                  :version "1.10.1"}}
 :repositories #{{:id "clojars"
                  :url ""}}
 :scm {:url "..."
       :tag "..."}}
...and pom.xml could be created as a build step and then discarded after deployment...


pom.edn is serialized data, pom.xml is serialized data


1. pom.edn doesn't have to be a file on disk, it can be created by the build tool on the fly from the deps basis 2. updating a map is so much more reliable than updating an xml


e.g. setting git revision: 1. for map: (assoc-in pom [:scm :tag] git-hash) 2. for xml:


that code handles the strictly more general nature of the xml format, if you make the same assumptions you would need to make to reduce it to a map you could get rid of parts of it, and that code includes the reading and writing to disk, which you map example does not


> that code handles the strictly more general nature of the xml format Well that's the problem, like For loops that complect What with How, reliance on the xml file on disk as a source of truth that is modified by a tool complects What I want (produce desirable pom for deployment from the deps and version) with How to do it (by surgically updating XML in a fragile way because XML is a tool for marking up documents, not data).


reading and writing is 3 lines, everything else is about that xml processing


and that processing is not generic, and every other program does it differently


e.g. deps-deploy has different non-generic code for extracting version from pom.xml


what do you mean by deployment?

Joe Lane21:09:23

Maybe what you want is a database @vlaaad


deployment to clojars


if you don't deploy to maven repo you don't need a pom


I only need pom.xml to deploy to clojars


@lanejo01 not sure about that, what do you mean?

Joe Lane21:09:24

It's not a particularly useful answer for you today, but if you step back and think about manipulating this fragile file from multiple programs, potentially concurrently, etc, etc, you could view the output of a query as the pom artifact. That is one valid representation of some facts, but you could have other representations. What if you have questions about the facts, are you going to iterate over the xml file? Iterate over all xml files in all your projects, etc. A database would allow for better affordances than any other existing tools.


it sounds sort of like what you really object to is the pom file sitting on disk when you don't care about it, so you could just not deploy to maven repos (tools.deps can use git dependencies) or write your own version of deps_deploy with your own version of that sends the pom over the wire without ever writing it to disk


inventing a new serialization format for poms doesn't seem like it gets you anything


maven actually had a project for that kind of thing,


my impression was a lot of initial interest, followed by meh when it didn't seem to get you that much


I wasn't clear enough, sorry — I don't want a new serialization format for poms. Not pom.edn but pom data structure represented as map in a build/deploy process.


part of the work we've been doing to rewrite clj features as functions you invoke is to open up the opportunity to pass it a much greater range of configuration


either via :exec-args in deps and/or by overrides on cli


you're still going to want the pom.xml as a file though to include it in the jar


Of course, but I don't want to have it lying around for more time than built jars are lying around


...because for the build tooling, pom.xml is a mutable place that different tools write to or read from