This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-31
Channels
- # aws (1)
- # beginners (82)
- # boot (7)
- # cider (1)
- # cljs-dev (13)
- # cljsrn (1)
- # clojure (37)
- # clojure-dev (5)
- # clojure-italy (5)
- # clojure-spec (9)
- # clojure-uk (8)
- # clojurescript (110)
- # community-development (6)
- # datomic (1)
- # devcards (1)
- # fulcro (12)
- # lein-figwheel (1)
- # off-topic (34)
- # portkey (24)
- # protorepl (25)
- # re-frame (4)
- # reagent (29)
- # shadow-cljs (8)
- # spacemacs (11)
- # specter (3)
- # unrepl (1)
- # vim (1)
For posterity: I had an old version of the adb (Android Debugging Bridge) that needed updating. Figwheel needs it to do its hot-reloading.
Yay for old state from earlier experiments getting in the way.
Can I use map to iterate over a native js array?
@rdanielo, you can, just keep in mind it returns a lazy seq as normal.
If I'm trying to follow the 12 Factor App (https://12factor.net/config) pattern with environ (https://github.com/weavejester/environ), and I have credentials I'm using for development that can't be public, what is the typical usage? The best I could come up with is a bash script that exports the needed vars, but that doesn't seem far from the config file that 12 Factor is trying to avoid.
Anyone using vscode for Clojure?
@d4hines the usual way for a 12-factor app to get credentials in production relies on something secure and private in the production system exporting those values into the process environment. That can be Heroku’s config
, SSM Parameter Store in AWS, Hashicorp’s Vault, etc.
If you own all the pieces of your production platform then yes, at some point you will have something that does the same thing that bash file does, but you can do it in a secure way that doesn’t leak secrets out of the process environment for your service
(Like a Vault cluster)
To run in dev, you can use the lein
or boot
plugins for environ
and supply the credentials at the command line, rather than keeping them all in a file somewhere.
Can you give me some hints about how credentials from the commandline with lein
works? I'm fairly new to lein. From environ
's readme, it looked like I had to include the credentials in my project.clj, which would get checked into source control, which wouldn't work for me.
It looks like I might be wrong about supplying things directly on the command line with lein
(I am mostly working in Boot projects these days, where you would say e.g. boot envrion -e admin-password=secret
) but I think that the part you’re missing in the docs is this:
> The value of this key can be set in several different ways. The most common way during development is to use a local profiles.clj file in your project directory. This file contained a map that is merged with the standard project.clj file, but can be kept out of version control and reserved for local development options.
So you want to set your keys not in project.clj
but in profiles.clj
, which you can safety .gitignore
Ooooh. I totally missed the profiles.clj part. Thanks a bunch!
@mfiano I do, and the experiecne is far from satisfiying
@rdanielo Yeah, I just decided to try it and I agree that it is very lacking. There's not even a dedicated REPL that you can type into. I'm spoiled by Lisp use with Emacs for many years 🙂
I regret to use emacs. If I'm going to use a editor like that I will go for vim, but having to endensly configure it for every new language I want to try makes me waste so much time that I just gave up
I will say that I also use vim regularly, and it just isn't there for Lisp, Clojure included. Emacs offers a much better experience.
Spacemacs is a great Emacs distribution if you like Vim, and don't want to setup every language. It has sane defaults and plugins already configured for any language.
@mfiano for clojurescript, the best experience for me so far has been cursive, and I’ve tried everything (except vim)
I tried that too. Nothing is as complete or polished as Emacs for Lisp development in my opinion, and I've been doing Lisp for many years.
but that’s beside the point. emacs is just a different ball of wax. I was just thinking that if you want a vscode like experience, cursive will deliver.
No definitely not looking for something as limited as vscode, though I did try Cursive, and despite the bloat and RAM hunger, it is better. However, I wouldn't be able to live without magit anyway. That is hands down the best Git porcelain
I also use Vim occasionally and open Emacs just for Magit support
hey everyone..I am trying to connect to a datomic database and when I run the command:
(def conn (d/connect client {:db-name "hello"}))
I get the following error:
CompilerException clojure.lang.ExceptionInfo: Connection refused #:cognitect.anomalies{:category :cognitect.anomalies/unavailable, :message "Connection refused"}, compiling:(form-init7933263063917191649.clj:1:11)
does anyone know why this could be happening?@mfiano spacemacs looks very appealing, but the fact that I have to learn a completely new set of keyboard shortcuts just for it, without any transfer to any other tool is not appealing to me
You don't, if you are familiar with Vim as you said
It uses Vim keybindings
I'll try it out then
Regarding cursive... I tend to avoid anything JVM baked. Too slow to start up and too resource hungry
I'll try it out then
Yeah, I've started using Spacemacs in the last month or so. I was completely new to Vim and Emacs, so there was a steep curve, but it's paying off. It's still not as nice as my experience with VS Code for JavaScript, but it's getting there, and I'm at least confident I'll never outgrow the tool.
The Clojure layer provides a very easy hotkey for opening up online docs on symbols under point, which has been incredible for learning the language.
Can you give me some hints about how credentials from the commandline with lein
works? I'm fairly new to lein. From environ
's readme, it looked like I had to include the credentials in my project.clj, which would get checked into source control, which wouldn't work for me.
@d4hines What O/S are you running on? On OS X and Linux, you can just say
VARNAME=value lein some args
I'm on Ubuntu, using Emacs/Cider.
I'd have to translate that to cider-jack-in
somehow though.
OK, so you could set them in your shell before you start emacs.
Right, and then just start emacs from that shell. Thanks!
Hi guys! How can I clear atoms before run another test file?
For example: I have a compojure-api with a handler.clj
file and a core.clj
file and when I core_test.clj file, I add some data in a atom that I have, but when I run the handler_test.clj I want a clear atom to start again
(idk if i'm being clear here, but I just want a fresh start for each test file that i run)
you can set the value of an atom to whatever you need with reset!
, ie (reset! your-atom nil)
@d4hines it looks like emacs can alter its environment while running. check out setenv
so you don't have to alter the startup if you don't want to
Yeah, I saw that! I actually put together a elisp script to do just that. I just wanted to confirm that I wasn't missing a super easy way to do it, as I try to avoid writing elisp if possible 😝
Thank you though, @dpsutton
I have an intermediate level proficiency at vanilla JS but I've never gotten into React. Is it recommended to get familiar with React before diving into Om?
simply reading through the React docs is enough, you don't need to have used it before (i haven't)
Can someone help me figure out how to get rid of these 2 warnings when I run lein repl
or boot repl
on Clojure 1.9.0? They don't appear on 1.8.0, and they also don't appear with 1.9.0 on my other PC so I'm stumped:
Edit: they also happen with latest 1.10 alpha release
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: mranderson047.toolsanalyzerjvm.v0v6v9.toolsanalyzer.v0v6v7.clojure.tools.analyzer.utils, being replaced by: #'mranderson047.toolsanalyzerjvm.v0v6v9.toolsanalyzer.v0v6v7.clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: mranderson047.toolsanalyzerjvm.v0v6v9.toolsanalyzer.v0v6v7.clojure.tools.analyzer, being replaced by: #'mranderson047.toolsanalyzerjvm.v0v6v9.toolsanalyzer.v0v6v7.clojure.tools.analyzer.utils/boolean?
nREPL server started on port 36715 on host 127.0.0.1 -
REPL-y 0.3.7, nREPL 0.2.13
Clojure 1.9.0
OpenJDK 64-Bit Server VM 1.8.0_162-b12
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
@mfiano perhaps try putting [org.clojure/tools.analyzer.jvm "0.7.2"]
(the latest) into your deps? might've been fixed
I'll try
@sundarj That didn't help
Removing [refactor-nrepl "2.3.1"]
from my global user profile fixed it, but I have no clue what that prevents me from doing now.
basically it looks like that version of refactor-nrepl
pulls in a version of mranderson
that pulls in a version of tools.analyzer.jvm
that defines a boolean?
function without excluding it first
if you add it back and run lein deps :tree
or boot show
they may tell you what exclusion you need to add
Seems to be the latest version...huh. I wonder why it doesn't occur on my other PC using a version of "LATEST"
i don't see that boolean?
function on the latest version: https://github.com/clojure/tools.analyzer.jvm/blob/e4a36f70f3bb218f0b3e68ec1cdc71150d8cd584/src/main/clojure/clojure/tools/analyzer/jvm/utils.clj
Aye. I just switched to 2.4.0-SNAPSHOT and don't have warnings, so problem solved I guess. Thanks 🙂
I have this issue https://github.com/drapanjanas/re-natal/issues/106
no issue with starting the app on the android simulator and modifying it. It is the repl that gets "stuck" after Prompt will show when Figwheel connects to your application
hi, i’m playing with the spec guide https://clojure.org/guides/spec#_spec_ing_functions for specing the function. I use the exact code in the guide, but i don’t think the spec is doing its job. For example, i can still call function (ranged-rand 10 3)
, i expect the spec would disallow this since start 10 is bigger than 3, anyone know am i doing something wrong here?
Can you share exactly what you tried?
(defn ranged-rand
"Returns random int in range start <= rand < end"
[start end]
(+ start (long (rand (- end start)))))
(s/fdef ranged-rand
:args (s/and (s/cat :start int? :end int?)
#(< (:start %) (:end %)))
:ret int?
:fn (s/and #(>= (:ret %) (-> % :args :start))
#(< (:ret %) (-> % :args :end))))
(ranged-rand 100 10)
exact same as the guideYou need to call instrument
in order to enable spec checking on functions.
user=> (require '[clojure.spec.test.alpha :as st])
nil
user=> (st/instrument `ranged-rand)
[user/ranged-rand]
user=> (ranged-rand 10 3)
ExceptionInfo Call to #'user/ranged-rand did not conform to spec:
val: {:start 10, :end 3} fails at: [:args] predicate: (< (:start %) (:end %))
clojure.core/ex-info (core.clj:4739)
user=>
It's covered a bit further into the guide https://clojure.org/guides/spec#_instrumentation
Instrumentation is likely to be useful at both development time and during testing to discover errors in calling code. It is not recommended to use instrumentation in production due to the overhead involved with checking args specs.
I’m not sure i quiet understand the full implication of this. Does that mean the whole idea of writing a function spec is only for development and test purpose? It’s not recommend to write function spec(fdef) for validation purpose?
@luwh364 Instrumentation causes a runtime overhead so you probably won't want it enabled in production.
Mostly I write specs for data and I do use that in production -- with s/conform
mostly -- but I only use instrumentation during development/testing.
Also, bear in mind that instrumentation checks that calls into your function are correct -- it doesn't check the behavior of the function (what it returns). That sort of checking is intended to be done separately as part of testing, since behavioral testing is done with generative testing.