Fork me on GitHub

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


I always like the idea of running migrations as a seperate action.


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:

(defn path->name "Extract the base name from a file path."
  [path] (fs/base-name path))
But each time I change the docstring, the line with defn is indented with two spaces. Can I change or disable this behavior ?


If you are using emacs + clojure-mode there is an option for that -


I'm using CIDER with spacemacs, does CIDER use some features from clojure-mode ?


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

  (defn 2)
  (defn- 2))


try this (set clojure-docstring-fill-prefix-width 0)


it works ! Thanks, you save me from a lot of frustration @delaguardo


you are welcome)


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)


both coll-a and coll-b are vectors of hashes


what is v?


@schmee v is probably a vector


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:

    url: jdbc:h2:mem:db
    username: sa
    driver-class-name: org.h2.Driver
    schema: classpath:db/sql/schema.sql
    data: classpath:db/sql/data.sql
      test-on-borrow: true
      validation-query: SELECT 1
    database: H2
    show-sql: false
      ddl-auto: none
    database-platform: org.hibernate.dialect.H2Dialect
My clojure code retrieves the datasource from the environment like this
: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")
and connects using 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?


@U8SKQTWEM 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 try with catch - see


You were right, it was the same, would you know if there is a way to set some of the other properties like

schema: classpath:db/sql/schema.sql
    data: classpath:db/sql/data.sql
when I’m creating the datasource with 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


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


to this:

user=> ( "foo;bar$baz" "UTF-8")
(edited to use the correct non-depricated API)


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


that would be great, google search is hijacked by "clojure for java devs" 😉


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


that plus needing to do things that were documented for java but not clojure


cool, I will look through the Java interop reference, thanks!


@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 "[B@758611de"]
user=> (String. (.decode (java.util.Base64/getDecoder) *1))


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 )


any package to “go to implementation” ?


@oliv If you have a REPL running (necessary for all the fancy Clojure stuff), then it's ctl-opt-, followed by o


(there's a #protorepl channel that will probably be helpful BTW)


oh, thank you


jump to talk there