This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (50)
- # boot (27)
- # bristol-clojurians (7)
- # cider (30)
- # clara (1)
- # cljs-dev (130)
- # cljsrn (14)
- # clojure (179)
- # clojure-austin (6)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-spec (19)
- # clojure-uk (54)
- # clojurescript (64)
- # core-async (3)
- # data-science (1)
- # datomic (66)
- # duct (11)
- # emacs (5)
- # figwheel (1)
- # fulcro (26)
- # funcool (7)
- # jobs (1)
- # jvm (6)
- # keechma (5)
- # lein-figwheel (5)
- # luminus (5)
- # lumo (1)
- # off-topic (93)
- # parinfer (37)
- # pedestal (15)
- # protorepl (10)
- # re-frame (42)
- # reagent (12)
- # shadow-cljs (71)
- # spacemacs (3)
- # specter (7)
- # vim (8)
- # yada (9)
Great book for beginners that just talks about software and the development process in general https://www.amazon.com/dp/1977055192/ref=sr_1_1?s=books&ie=UTF8&qid=1518492957&sr=1-1&keywords=software+what+you+actually+need+to+know
Hi everyone, how do you guys usually handle DB migrations? Do you: - Run it from your deployment script - Run it every time the jar is executed - Run it separately as another action (e.g. using REPL manually) - Others
How is your approach on it in terms of clojure @pcbalodi? Do you still use library like
migratus to do it, or do you prefer to do it manually to your database?
Hi, I have a problem with indentation ... When I declare a function, I like to have the docstring next to the function name:
But each time I change the docstring, the line with defn is indented with two spaces. Can I change or disable this behavior ?
(defn path->name "Extract the base name from a file path." [path] (fs/base-name path))
If you are using emacs + clojure-mode there is an option for that - https://github.com/clojure-emacs/clojure-mode#indentation-options
cider is minor-mode for clojure buffers. you major mode still clojure-mode and indentation rules comes from it. So an answer is - you are using clojure-mode + cider
I've tried to put this config in my layer, without success
(define-clojure-indent (defn 2) (defn- 2))
I know this does not follow the community standard, I like to fold my function and keep the docstring visible
oh… but for that you might want to adjust folding rules instead of using non standard indentation
it's mostly for private project, but I will keep that in mind if I release an open source project
@hawari.rahman17 I havent used migratus so I dont know best practices around it. I mostly use
dogfish, its shell based
That's pretty handy, doesn't get tied to any runtime/language. Thank you @pcbalodi.
could you explain me what this does?
(map #(map hash v) (vals (group-by :id (concat coll-a coll-b))))
“what this does” - as written, it blows up as soon as it tries to calculate a single value, because the function passed to map doesn’t accept an argument (I assume the actual code is different and actually accepts an argument)
In my spring java project with some clojure interop, I have some tests that test against an in memory database. My java code uses these properties to connect to the in memory database when testing:
My clojure code retrieves the datasource from the environment like this
datasource: url: jdbc:h2:mem:db username: sa password: driver-class-name: org.h2.Driver schema: classpath:db/sql/schema.sql data: classpath:db/sql/data.sql dbcp2: test-on-borrow: true validation-query: SELECT 1 jpa: database: H2 show-sql: false hibernate: ddl-auto: none database-platform: org.hibernate.dialect.H2Dialect
and connects using
:classname (System/getenv "jdbc_driver_class_name") :subprotocol (System/getenv "subprotocol") :subname (System/getenv "subname") :user (System/getenv "jdbc_username") :password (System/getenv "jdbc_password")
clojure.java.jdbc. My question is, because the tests are in java which calls java which then calls the clojure code, what would I set those environment variables to, so my clojure code will connect to this in memory database on the classpath while testing?
My question really just boils down to this, how would I connect to the datasource(which is an in memory database on the classpath) in my above question with
Also is there a way to catch exceptions thrown in clojure?
@ there shouldn't be any difference. As soon as it's the same process you should be perfectly able to connect to in-memory DB.
You can catch exceptions using
catch - see http://clojuredocs.org/clojure.core/try
You were right, it was the same, would you know if there is a way to set some of the other properties like
when I’m creating the datasource with
schema: classpath:db/sql/schema.sql data: classpath:db/sql/data.sql
clojure.java.jdbc? Or is that something I can just ignore
Hi, do you guys know if there is a list of most often used Java functions etc. in Clojure? Or some concise guide to Java "standard library" ? So that someone with no Java background could leverage the interop?
for starters, we don’t use java functions (in java function is java.util.function.Function which is an API we really don’t need from clojure) - java libraries supply classes which have methods you can use. I learned java as follows: 1) I research “how to do X in clojure” and don’t like any of the answers (if any even exist) 2) I research “how to do X in java” then I translate to clojure using interop clojure interop with java is actually simpler and easier than java for anything that doesn’t require concrete inheritance or numerics https://clojure.org/reference/java_interop
the javadoc format is a little crusty but it’s extremely comprehensive and consistent, which means I can get things done quickly now that I know what to expect from it
for example going from this: https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html#encode(java.lang.String)
(edited to use the correct non-depricated API)
user=> (java.net.URLEncoder/encode "foo;bar$baz" "UTF-8") "foo%3Bbar%24baz"
PS. many people would prefer to pull in a clojure library that “wraps” encoding a URL, despite it being a one liner. That’s an open discussion, perhaps your time as someone who doesn’t want to think about java takes precedence over complexity of your build and size of your jar
hm, I see, makes sense, I was thinking that maybe someone is aware of some resource that could sometimes save you step (1) above
some “java for clojure people” document would be interesting, it doesn’t exist as far as I know
what really helped me was going through that java interop documentation and actually making sure I could take a java class that comes with the vm and do that operation
@prnc here’s another great example of a java interop one liner that eliminates the need for an entire library:
user=> (.encode (java.util.Base64/getEncoder) (.getBytes "hello")) #object["[B" 0x758611de "[[email protected]"] user=> (String. (.decode (java.util.Base64/getDecoder) *1)) "hello"
and you can look up the javadoc for java.util.Base64 to see what precisely it’s doing
yeah, that's super useful to know, I will keep looking if I find anything interesting on this topic will post here, cheers!
hey guys, I’m trying to give a chance to atom ide. how can I see the clojure implementation ? ( like intelliJ CMD + Click )
@oliv If you have a REPL running (necessary for all the fancy Clojure stuff), then it's
ctl-opt-, followed by