This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-30
Channels
- # announcements (1)
- # beginners (94)
- # calva (12)
- # cider (5)
- # cljdoc (4)
- # cljs-dev (4)
- # clojure (170)
- # clojure-austin (2)
- # clojure-dev (45)
- # clojure-germany (53)
- # clojure-italy (20)
- # clojure-nl (6)
- # clojure-spec (25)
- # clojure-uk (242)
- # clojurescript (161)
- # cursive (16)
- # data-science (3)
- # datomic (20)
- # defnpodcast (6)
- # emacs (40)
- # events (1)
- # fulcro (80)
- # funcool (46)
- # jobs (1)
- # leiningen (23)
- # liberator (2)
- # lumo (43)
- # mount (3)
- # off-topic (21)
- # onyx (1)
- # pedestal (15)
- # re-frame (23)
- # reitit (4)
- # schema (1)
- # sfcljs (1)
- # shadow-cljs (167)
- # spacemacs (1)
- # tools-deps (21)
- # yada (2)
What is the best way to deal with updating a deeply nested parsed XML structure? More specifically I need to find specific elements and attributes through a few nested layers.
XPath for finding specific elements from an XML document, XSLT for transforming one. If you're willing to venture outside Clojure, that is. 🙂
I tried using zippers, but it feels really clunky to run the checks at every level. Is there a better way?
Sounds like a nice use case for https://github.com/nathanmarz/specter
A thank you, does it support updating a deeply nested elements as well as querying?
Yes, it supports updating with transform
Ah thank you so much. It seems much easier than the zipper madness I was dealing with.
Sure thing. There's also a #specter channel here on slack.
Anyone else seeing Travis CI builds failing for Clojure projects at the moment?
Could not transfer artifact org.clojure:data.json:jar:0.2.6 from/to central ( ): Access denied to: , ReasonPhrase:Forbidden.
Nothing will transfer from Maven (but Clojars is fine). Leiningen 2.8.1 (the default choice right now it seems).looks related: https://github.com/diffblue/cbmc/pull/2863
Thank-you! Yes, jobs seem to be running properly now. Interesting.
Not sure if it's related, but my Gitlab CI build also failed about 20 minutes ago with undefined method 'force_encoding' for nil:NilClass
, but I retried and seems fine now
@seancorfield same problem
basically something like (map-indexed (fn [idx a b c] ...) coll-a coll-b coll-c)
would be the use
Hi all, Is there a channel where clojure blog posts and articles get shared?
@sneakypeet yes, #news-and-articles, don’t know how active it is though
:thumbsup:
Does this docstring have a typo in it? https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/test-vars > test-vars > function > Usage: (test-vars vars) > Groups vars by their namespace and runs test-vars on them with appropriate fixtures applied. It references itself (`test-vars`). I assume it should read "and runs test-var on them".
I got a problem with tools.namespace.reload/refresh
trying to load a namespace that isn't referenced in my source anymore
The namespace has been removed. Anyone know how to debug it?
Some kind of caching? If you’re using lein, you could try lein clean
; if you’re using IntelliJ/Cursive, you could try File -> Invalidate Caches / Restart.
using clj
from commandline
There it is - A cljc namespace was left in my target folder
Aha! 🙂
Clojurice starter app uses JDBC with Postgres. You may find the code instructive: https://github.com/jarcane/clojurice
java.sql.BatchUpdateException: Batch entry 0 CREATE TABLE users (data text) was aborted. Call getNextException to see the cause., compiling:(my_app/handler.clj:53:1) clojure.lang.Compiler$CompilerException: java.sql.BatchUpdateException: Batch entry 0 CREATE TABLE users (data text) was aborted. Call getNextException to see the cause., compiling:(my_app/handler.clj:53:1)
This is line 53: (j/db-do-commands "<postgresql://user:pass@localhost:5432/dbname>" (j/create-table-ddl :users [[:data :text]]))
surround that with a try ..catch
and see if the next exception (as the error indicates you to use) provides more information:
(try
<your code here>
(catch Exception e (.getNextException e)))
Here is my code: (try (j/db-do-commands "<postgresql://user:pass@localhost:5444/dbname>" (j/create-table-ddl :asdf [[:data :text]])) (j/insert! "<postgresql://user:pass@localhost:5444/dbname>" :asdf {:data "Hello World"}) (catch Exception e (.getNextException e)))
The page loads. I see no exception. The table asdf is made, but it has no Hello World row.
Sweet! I got the Hello World to write by separating the second statement and surrounding it with its own try catch
My guess to what is wrong is that you keep re-running the application, which will re-run the create-table-ddl
command, which will throw an exception since the table already exists. (if you aren’t clearing the SQL database between restarts)
Surrounding things with try .. catch
doesn’t magically make these things work, it’s just allowing you to get around the issue that you are trying to create a table that already exists. Surrounding the insert with its own try .. catch
probably does nothing, since I’m assuming the data
column has no constraints that could cause an exception to be thrown.
I am making an ajax call and successfully getting {:data "Hello World"}{:data "Hello World"}{:data "Hello World"}{:data "Hello World"}{:data "Hello World"}{:data "Hello World"} back from the database. Problem is I can only see it in my network tab. I can't seem to alert it or write it to a div.
Here's my attempt: (defn ajax-input [id] [:input {:id id :on-change #(js/alert (.-value (.send goog.net.XhrIo "/database"))) } ] ) It gives undefined.
hi everyone. this is not a clojure question but I don’t really know where else to ask 😕 I’m trying to use mysql database that lives in docker, with my application
@neural.works.com There are a couple of tools listed on the wiki for the tools.deps
repo...
is there a good tool for having the repl show stack traces in reverse order? with the message at the bottom too?
nine years scrolling up to see the top of the stack trace was fine, but sometime soon I'll have been doing it for ten years, and that's too many
I don't know of one, but it sounds like a perfect feature creep for your seventy-one project
only works on stack traces with seventy-one elements
@gfredericks are you using emacs with cider? I thought it broke up the exceptions in a way that made it a bit more sane
it might actually -- I just realized it's the clojure.test output I'm dealing with, so I probably need something that customizes that
Maybe aviso does what you want? Search for word "reverse" on this page: https://ioavisopretty.readthedocs.io/en/latest/exceptions.html
yeah that looks good; thanks
the stractrace.raw readme conveniently links to other projects that manipulate stacktraces
we use some timbre logging and boot at work, both of which do some stracktrace munging, I think maybe using aviso, so stracetrace.raw has been very helpful to me
it doesn't seem like the problems he lists aren't solvable
I mean I guess if you don't control the library and can't change it quickly then you practically can't solve it
maybe, I dunno, I just have yet to see a library that doesn't at least sometimes get in the way
it has been a bit, but I think with aviso it is usually a problem with eliding the frame I am interested in
(try (fancy-thing e) (catch Throwable _ (do-what-stu's-thing-does e)))
yeah I don't want any frames elided
Hi! newbie quick question: if a function returns "clojure.lang.LazySeq@3c72489" and I know it's a hash map, how can I "extract" the content?
that is the kind of not super useful thing you get back from the .toString method on a lazy seq
I am suggesting those as ways to inspect the data to see what you actually have, because you don't know what you have
Maybe your precious map is an element of the lazy sequence?
Unless the double quotes you show mean the function returns a string, in which case you have a string, not a LazySeq or a map
you think you got a map, you actually got a lazy seq, so you may need to do some debugging of your function, and it might be useful to look at the contents of the lazy seq that is returned when doing that
hmmm, I'm using: (db/create-question! question) if I run it in the repl I got {:id 67}
Maybe that function is executing a Clojure sequence-returning function like map
on your map, and returning a lazy sequence?
e.g. (map identity {:a 1 :b 2})
=> ([:a 1] [:b 2])
(type (map identity {:a 1 :b 2})) => clojure.lang.LazySeq
but If I run it inside a (doseq [question questions] , (db/create-question!) returns a lazyseq
When you run (db/create-question! question) in the REPL, do you know whether it is returning a map, or printing a map? If code prints something to the out stream, it can be a little confusing to distinguish the stuff being printed from the return value.
so you don't mean you are calling something that contains the doseq and it is returning a lazy-seq, you mean you are getting a lazy-seq when you call create-question! in the doseq?
I don't know what (db/create-question! question) does internally, but perhaps depending upon its argument, or some state in the database/etc., it returns different types?
the code you pasted will only ever evaluate to nil, because doseq by definition evaluates to nil
sorry my mistake, the function that I'm interested is (db/create-question! question)
I think he means that the (log/info ... (pr-str last-id)) call is showing LazySeq... as the return value from pr-str ?
I have the dumbest problem, and I'm probably overlooking something, but when using clj-http
it doesn't encode spaces in query params correctly
If I specify a query-param of A B
it encodes it as A+B
instead of A%20B
has anyone else had this problem?
hm...
I was getting ready to type that but I couldn’t find a good reference to back it up with.
thanks
Hey, I'm using gitlab CI with clojure and trying to cache my .m2 like so https://gitlab.com/gitlab-org/gitlab-ci-yml/blob/master/Maven.gitlab-ci.yml#L30
are you sure you want .m2/repository
instead of ~/.m2/repository
?
@noisesmith I'll use whatever works. It's just for CI anyway
but you likely aren't using maven
you need to make sure your build tool is told where the maven cache is
eg. CI might only provide MAVEN_OPTS to maven, so nothing happens if you don't invoke maven(?)
I'm talking about the program that is being invoked (eg. lein or boot)
does CI hand your MAVEN_OPTS to your build tool? if not, you probably need to adjust that
clojure with deps.edn doesn't call mvn (the maven command), but it does use the same cache and some of the same java libraries
I'm skimming through https://clojure.org/reference/deps_and_cli and can't really find anything
the key thing is that the config that tells the maven libs where to put the cache needs to be supplied to the tool actually fetching the deps
my hunch is use -J to pass the same -D that would be passed to mvn
-Jopt Pass opt through in java_opts, ex: -J-Xmx512m
so it would be -J$MAVEN_OPTS
in the invocation
or you could define a CLJ_JVM_OPTS that works similarly but includes the -J before each one
and use it the same way the example does on mvn
calls
you can set the location of the Maven repository in your deps.edn
like {:deps ..., :mvn/local-repo "/home/.m2/repository"}
won’t work in an alias
you could pass it on command line with -Sdeps '{:mvn/local-repo "/home/.m2/repository"}'
$HOME/.m2/repository is the default local repo though so not sure whether you’re helping
relative dirs should work too, assuming you can control current directory
you could set HOME\