is there a channel for non-clojure programming related questions?
#off-topic ?
That sounds like a good place to start if there isn't a language-specific or topic-specific channel for your question.
Alright
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
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
I kind of have that to signal the 2nd thread to start processing
and reading and writing to an async/chan
with a buffer
How about a control channel? That could be used for start, stop, or whatever kind of signal.
That description isn't specific enough for me to say. If you want to partially process a sequence, it would matter for recommendations what the logical predicate is to stop and whether you want that processing to return a value or perform a side effect
you can always split a sequence by index with the combo of take and drop
(->> 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?found via https://twitter.com/VincentCantin/status/1308611926310576128
->>
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)))
user=>
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
the function code i have right now is this:
(defn foo [a b]
(use a :refer [b]))
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
Anyone know how to fix this issue?
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 https://clojuredocs.org/clojure.core/requiring-resolveSo 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
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
(clojure.pprint/pprint
(clojure.reflect/reflect
process))
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 @p-himik
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!!!
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.
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.
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
{:extra-deps
{com.healthfinch/depstar {:git/url "<https://github.com/healthfinch/depstar.git>"
:sha "4aa7b35189693feebc7d7e4a180b8af0326c9164"}}}
:disasm
{:extra-deps
{nodisassemble {:mvn/version "0.1.3"}}}}
:debug
{:extra-deps
{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?
Thank you!
I’m actually also interested. A Leiningen-based tool would also do.
seems https://www.versioneye.com/ (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.
https://github.com/clojure/tools.deps.alpha/wiki/Tools got me excited briefly
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?
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...
@seancorfield 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
@bastilla 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).
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
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
I enjoyed using Oz, really nice to use. I did the following with Oz https://practicalli.github.io/blog/posts/visualising-uk-covid19-data-with-oz/ https://practicalli.github.io/blog/posts/a-deeper-understanding-of-oz-data-visualization/
Should probably mention there is a 'bare bones' example Hanami application as well: https://github.com/jsa-aerial/bbhanami
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 "<http://maven.apache.org/POM/4.0.0>"
'xsi "<http://www.w3.org/2001/XMLSchema-instance>")
(println
(xml/indent-str
(xml/element
::pom/project
{::xsi/schemaLocation "<http://maven.apache.org/POM/4.0.0> <http://maven.apache.org/xsd/maven-4.0.0.xsd>"
(keyword "xmlns" "") "<http://maven.apache.org/POM/4.0.0>"
:xmlns/xsi "<http://www.w3.org/2001/XMLSchema-instance>"}
(xml/element ::pom/modelVersion
{}
"4.0.0"))))
Specifying some ns as default requires using unprintable keywords: (keyword "xmlns" "")
waaaatam I missing something?
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.
you can set default ns as an attribute
hi folks, can I do something about project.core$myAwesomeFunction.invokeStatic () it takes up a lot of CPU
I'm doing exactly this stuff for pom.xml in the tools.deps pom sync code if you want to look at that
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
thanks!
sexp api looks better in this regard!
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 "<https://repo.clojars.org>"}}
: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
You mean just check line by line what it does?
what tool should I use the further analyze this?
seems like VisualVM does not give me everything
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: https://github.com/cljfx/cljfx/blob/master/build/version.clj
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 https://github.com/slipset/deps-deploy/blob/master/src/deps_deploy/deps_deploy.clj#L13-L49
what do you mean by deployment?
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?
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 https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/deps/alpha/gen/pom.clj that sends the pom over the wire without ever writing it to disk
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.
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, https://github.com/takari/polyglot-maven
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
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