Fork me on GitHub

@mario.cordova.862 I was able to add some environment variable from the window you mentioned above. Still didn't solve my issue with profiles.clj but at least Cursive REPL is reading my DB credentials now.

Mario C.00:11:14

You can try catting your .lein-env and see if your environment variable is being built

Mario C.00:11:22

how do you run you app e.g lein with-profile dev,user run?


I run the webserver using lein ring server or lein ring server-headless. REPL: lein repl or via Cursive

Mario C.00:11:10

In the project directory if you run cat .lein-env

Mario C.00:11:20

does your db environment show up? @somedude314


@mario.cordova.862 cat: .lein-env: No such file or directory


lein new compojure hello-world didn't create such file for me.


.lein-env is specific to the environ library

Mario C.01:11:45

How do your project.clj look like? @somedude314


Like this:

(defproject myproject "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]
                 [hiccup "1.0.5"]
                 [garden "1.3.6"]
                 [environ "1.1.0"]
                 [com.layerware/hugsql "0.4.9"]
                 [org.postgresql/postgresql "42.2.2"]]
  :plugins [[lein-ring "0.12.4"]
            [lein-garden "0.3.0"]
            [lein-cljfmt "0.6.1"]]
  :garden {:builds [{
                     :id "screen"
                     :source-paths ["src"]
                     :stylesheet myproject.views/screen
                     ;; Compiler flags passed to `garden.core/css`:
                     :compiler {
                                :output-to "resources/public/css/screen.css"
                                :pretty-print? false}}]}
  :ring {:handler myproject.handler/app}
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})

Mario C.01:11:53

Probably someone more experienced can help you. I have never set up a lein project from the ground up.

Mario C.01:11:59

(defproject hello-world "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]]
  :plugins [[lein-ring "0.12.4"]]
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [environ "1.0.0"]
                        [org.immutant/web "2.1.9"]
                        [ring/ring-mock "0.3.2"]]
         :env {:example "sample"}
         :plugins [[lein-environ "1.1.0"]]
         :ring {:handler hello-world.handler/app}
         :main hello-world.handler}})

Mario C.01:11:45


Mario C.01:11:51

(ns hello-world.handler
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [environ.core :refer [env]]
            [immutant.web.undertow :as undertow]
            [immutant.web :as web]
            [ring.middleware.defaults :refer [wrap-defaults site-defaults]]))

(defroutes app-routes
  (GET "/" [] "Hello World")
  (route/not-found "Not Found"))

(def app
  (wrap-defaults app-routes site-defaults))

(defn -main
  "Entry point for the server"
  [& args]
  (if (env :dev-mode)
    (web/run-dmc app {:host (or (env :host) "localhost")})
    (web/run app (undertow/options {:port 3000}))))

Mario C.01:11:02

then run with lein with-profile dev run

Mario C.01:11:30

To me the most difficult part is project set up tbh


@mario.cordova.862 This semes to be the issue, I will report back after testing. In your example you have :plugins [[lein-environ "1.1.0"]]


@mario.cordova.862 worked, thanks so much!


is there a way to document deftype? I know there wasn't, but I wonder if that's been fixed yet. If not- is there an informal 'standard' on how to do it?


Hi all, I am trying to convert a first simple scraping project to Clojure and was wondering if anybody know what is the best option to run a headless browser w/ Javascript from Clojure? The projects I found are either unmaintained or haven't been updated from more than a year so I was wondering if there are other more active (using Selenium, Splashr, Pupetteer or something else)? Or do clojurist favor Java libraries via interop? Thanks a lot!


I used etaoin some time ago and it's great.


Thanks a lot for the answers!


you can add documentation to the constructor functions

👍 2

user=> (deftype T [])
user=> (alter-meta! #'->T assoc :doc "T doc")
{:arglists ([]), :doc "T doc", :line 1, :column 1, :file "NO_SOURCE_PATH", :name ->T, :ns #object[clojure.lang.Namespace 0x5a85c92 "user"]}
user=> (doc ->T)
  T doc


ah, right, that could do it, good idea!


Do you guys have some good hotkey cheat-sheet to share regarding parens navigation on repl/IDE ?


like for example, i want to go to the end of the expression


instead of doing alt + right arrow, how could i just jump to the last paren?


@mateus.pimentel.w: What program are you using (Cursive, Emacs, Terminal, etc.)?


I use VSCode, and i’m curious to know if the REPL has some built-in hotkeys


( the clj repl )


Pretty sure it would mostly be VSCode specific hotkeys - all the ones I use are either specific to my editor (Cursive) or the environment (Mac, Windows and Linux all have a bit different defaults)


Though both Cursive and Emacs have lots of options for that kind of thing, I haven't looked at what VSCode offers for that


But do you guys have this kind of stuff? Paren navigation hotkeys


Yes - has some info on Cursive, and there are different options on Emacs that are similar


@mateus.pimentel.w you might want to check out, it is available for VSCode!


Aewsome, i found an extension for paredit


I installed parinfer too, i liked it


Beginner question. (let [result []] (conj result 2) (if true result)) How do I retain the value of result I set in the let block?


I think you're trying to treat result as a mutable object. It is not, it is binded to some value in the let binding, and it doesn't change values after that. Every time you reference result in the let, it is still bound to []. If you want to update result to be bound to the new value you need to create a new binding. i.e.

(let [result []]
       result (conj result 2)]
  (if true result))
I find that let bindings are useful when you are using the same value multiple times or if you want to move something complex into a binding for better readability