Fork me on GitHub
#beginners
<
2018-03-31
>
austin02108:03:47

For posterity: I had an old version of the adb (Android Debugging Bridge) that needed updating. Figwheel needs it to do its hot-reloading.

austin02108:03:26

Yay for old state from earlier experiments getting in the way.

rdanielo11:03:25

Can I use map to iterate over a native js array?

d4hines16:03:21

@rdanielo, you can, just keep in mind it returns a lazy seq as normal.

d4hines16:03:38

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.

mfiano16:03:30

Anyone using vscode for Clojure?

chris_johnson17:03:11

@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.

chris_johnson17:03:26

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

chris_johnson17:03:39

(Like a Vault cluster)

chris_johnson17:03:33

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.

d4hines18:03:27

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.

chris_johnson01:04:17

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:

chris_johnson01:04:34

> 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.

chris_johnson01:04:58

So you want to set your keys not in project.clj but in profiles.clj, which you can safety .gitignore

d4hines17:04:26

Ooooh. I totally missed the profiles.clj part. Thanks a bunch!

rdanielo17:03:37

@mfiano I do, and the experiecne is far from satisfiying

mfiano17:03:54

@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 🙂

rdanielo17:03:55

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

mfiano17:03:51

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.

mfiano17:03:55

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.

lee.justin.m17:03:03

@mfiano for clojurescript, the best experience for me so far has been cursive, and I’ve tried everything (except vim)

lee.justin.m17:03:16

i think atom + clojure + protorepl should work well

lee.justin.m17:03:28

but protorepl is not really there for cljs

mfiano17:03:33

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.

lee.justin.m17:03:11

i used emacs for 10 years and i don’t miss it 🙂

lee.justin.m17:03:32

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.

mfiano17:03:24

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

mfiano17:03:50

I also use Vim occasionally and open Emacs just for Magit support

brnbraga9517:03:43

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?

rdanielo17:03:54

@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

mfiano18:03:16

You don't, if you are familiar with Vim as you said

mfiano18:03:23

It uses Vim keybindings

rdanielo18:03:46

I'll try it out then

rdanielo18:03:34

Regarding cursive... I tend to avoid anything JVM baked. Too slow to start up and too resource hungry

d4hines18:03:53

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.

d4hines18:03:07

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.

seancorfield19:03:55

@d4hines What O/S are you running on? On OS X and Linux, you can just say

VARNAME=value lein some args

d4hines19:03:42

I'm on Ubuntu, using Emacs/Cider.

d4hines19:03:03

I'd have to translate that to cider-jack-in somehow though.

seancorfield19:03:09

OK, so you could set them in your shell before you start emacs.

d4hines19:03:35

Right, and then just start emacs from that shell. Thanks!

max.forasteiro19:03:23

Hi guys! How can I clear atoms before run another test file?

max.forasteiro19:03:44

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

max.forasteiro19:03:43

(idk if i'm being clear here, but I just want a fresh start for each test file that i run)

schmee19:03:47

you can set the value of an atom to whatever you need with reset!, ie (reset! your-atom nil)

dpsutton20:03:41

@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

d4hines20:03:30

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 😝

d4hines20:03:39

Thank you though, @dpsutton

nikoszp20:03:22

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?

sundarj21:03:33

simply reading through the React docs is enough, you don't need to have used it before (i haven't)

sundarj21:03:46

though i would recommend Fulcro instead of Om (it's Om-inspired)

ferzco21:03:06

How do I change Clojure version in Light Table, it's showing 1.5.1

mfiano21:03:46

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

sundarj21:03:44

@mfiano perhaps try putting [org.clojure/tools.analyzer.jvm "0.7.2"] (the latest) into your deps? might've been fixed

mfiano21:03:42

@sundarj That didn't help

mfiano21:03:54

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.

sundarj21:03:29

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

sundarj21:03:40

if you add it back and run lein deps :tree or boot show they may tell you what exclusion you need to add

mfiano21:03:40

Seems to be the latest version...huh. I wonder why it doesn't occur on my other PC using a version of "LATEST"

mfiano21:03:57

Aye. I just switched to 2.4.0-SNAPSHOT and don't have warnings, so problem solved I guess. Thanks 🙂

sundarj21:03:06

ah, sweet. no problem!

clojurians55821:03:43

hello, can anybody help me with an issue with re-natal ?

clojurians55821:03:51

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

clojurians55822:03:12

solved my problem. I had to run re-natal use-android-device avd.

luwh36422:03:56

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?

seancorfield22:03:57

Can you share exactly what you tried?

luwh36422:03:44

(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 guide

luwh36422:03:31

i would expect the ranged-rand now throw something with wrong argument, wouldn’t it?

seancorfield23:03:00

You need to call instrument in order to enable spec checking on functions.

seancorfield23:03:18

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=> 

luwh36423:03:17

oh, thanks!

luwh36423:03:38

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?

seancorfield23:03:17

@luwh364 Instrumentation causes a runtime overhead so you probably won't want it enabled in production.

seancorfield23:03:25

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.

seancorfield23:03:54

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.