This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-22
Channels
- # 100-days-of-code (1)
- # adventofcode (21)
- # announcements (2)
- # beginners (44)
- # calva (1)
- # cider (2)
- # cljdoc (16)
- # cljs-dev (70)
- # cljsrn (29)
- # clojure (66)
- # clojure-austria (1)
- # clojure-europe (4)
- # clojure-finland (1)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-nl (3)
- # clojure-uk (127)
- # clojurescript (30)
- # core-typed (3)
- # cursive (34)
- # data-science (2)
- # datomic (16)
- # duct (17)
- # editors (1)
- # emacs (4)
- # figwheel-main (4)
- # fulcro (40)
- # hoplon (2)
- # instaparse (5)
- # kaocha (4)
- # leiningen (1)
- # luminus (4)
- # nrepl (46)
- # off-topic (5)
- # onyx (2)
- # other-languages (55)
- # parinfer (3)
- # protorepl (4)
- # re-frame (33)
- # reagent (6)
- # reitit (13)
- # ring-swagger (5)
- # shadow-cljs (26)
- # spacemacs (4)
- # sql (8)
- # testing (27)
- # tools-deps (21)
- # yada (1)
@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.
You can try catting your .lein-env
and see if your environment variable is being built
I run the webserver using lein ring server
or lein ring server-headless
. REPL: lein repl
or via Cursive
does your db environment show up? @somedude314
@mario.cordova.862 cat: .lein-env: No such file or directory
.lein-env
is specific to the environ
library
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}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"]]}})
Probably someone more experienced can help you. I have never set up a lein project from the ground up.
(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"]]
:profiles
{: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}})
(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}))))
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}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"]]}})
@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!
There is Sparkledriver: https://github.com/jackrusher/sparkledriver and Etaoin: https://github.com/igrishaev/etaoin both are maintained
@mseddon Looks there isn't. (deftype ^{:doc "abc"} my-type [my-field]) is OK. (clojure.repl/doc my-type) gives CompilerException java.lang.RuntimeException: Expecting var, but my-type is mapped to class clj_genetic_01.neural_net.my-type, compiling:(C:\Users\madera\AppData\Local\Temp\form-init7285806055912380243.clj:1:1) (meta my-type) gives => nil. If you look at https://clojure.org/reference/metadata, you can see that metadata are supported for symbols and collections. Deftype creates a plain-old-java-class.
user=> (deftype T [])
user.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)
-------------------------
user/->T
([])
T doc
nil
Do you guys have some good hotkey cheat-sheet to share regarding parens navigation on repl/IDE ?
@mateus.pimentel.w: What program are you using (Cursive, Emacs, Terminal, etc.)?
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
Yes - https://cursive-ide.com/userguide/paredit.html has some info on Cursive, and there are different options on Emacs that are similar
@mateus.pimentel.w you might want to check out https://shaunlebron.github.io/parinfer/, it is available for VSCode!
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