Fork me on GitHub
#beginners
<
2018-06-17
>
fmn03:06:36

In datomic, how do you query all non-schema data?

sova-soars-the-sora17:06:41

What do you mean? I didn't know you could ask for data that didn't have a shape defined in the schema.

mg18:06:35

I believe the question was querying against entities that are not attribute entities. If that’s the case you could do something like this to return all non-attribute entity ids:

(d/q '[:find [?eid ...]
       :where
       [?eid _ _]
       (not [?eid :db/valueType _])]
     db)

fmn13:06:15

Yep. I'm trying to query all eid that doesn't have :db/ident or :db/valueType. Unfortunately the given solution throws with "insufficient bindings". I ended up querying all eid who has :db/ident, get all eid with datoms, get the difference with set/difference and then finally I can feed it to pull-many

pooboy05:06:05

How to use cryptography with clojure ?

Philip Hale07:06:23

What kind of crypto / for what?

pooboy08:06:43

I know java only a bit

pooboy08:06:50

Is that going to be a problem ?

pooboy08:06:58

In my pursuit of clojure

gklijs08:06:14

Not really a problem, at some points like when doing Java interop, or when you want to run something in production, you might to increase your Java knowledge.

👍 4
valerauko10:06:28

I'm trying to validate a user registration submission using specs. It comes in a map that has a bunch of keys, including :pass and :pass-confirm. How would I check if the values at these two keys are equal?

valerauko10:06:13

Just had to ask and I found the solution:

(s/def ::user-reg #(= (::pass %) (::pass-confirm %)))

4
Denis G10:06:37

What would be the smart way of doing circular list in clojure. Assuming that I want to iterate in a circular way on a sequence. Don’t know if using lazy-seq together with concat is smart (my solution). Any ideas?

(defn circular-list
  [coll]
  (lazy-seq (concat coll (circular-list coll))))

ghadi11:06:36

@denisgrebennicov there is a built-in named cycle

4
bringe15:06:04

I'm struggling with how to test code in a namespace that has two public functions and then a few private functions used by the public ones. From what I've seen in my searching there are two options. 1) You test the private functions by referring directly to the function's var, like (#'some-ns/some-private-function). 2) You make the private functions public so they can be easily tested. Or am I missing something?

bringe15:06:43

In the Joy of Clojure though I've seen separating the implementation (private functions) of a namespace into a separate namespace and making them public, so perhaps that's the idiomatic route. :thinking_face:

Alex Miller (Clojure team)15:06:59

All of those are fine

👍 4
jherrlin18:06:58

Hey, I wanna run lein figwheel devcards and then connect Cider to that REPL. But I am not smart enought to work it out. When running lein figwheel devcards from a shell I get a REPL and can run stuff like (js/alert "Hey") and that will be sent to my browser. Now I wanna connect Cider to that REPL. I am using M-x cider-connect-clojurescript, entering localhost and the port 7002 and I get a REPL in the user namespace. But from here I cant do (js/alert "Hey"), I get a exception `CompilerException java.lang.RuntimeException: No such namespace: js`. And when inside a .cljs buffer and trying to send stuff to the REPL I get an error saying: "`cider-eval-defun-at-point` needs a ClojureScript REPL". What am I missing? The lein template I am using: https://github.com/reagent-project/reagent-template generated with: lein new reagent unitime +test +devcards +cider +sass.

haywood18:06:43

when you boot up figwheel does it give you an nrepl port?

jherrlin18:06:04

Yes it does: Figwheel: Starting nREPL server on port: 7002

haywood18:06:22

use the cider connect command to connect to that

haywood18:06:29

that will give you a clojure repl, not a clojurescript repl

haywood18:06:46

from here there should be a function to connect to a clojurescript repl

haywood18:06:03

with shadow, in emacs I run (shadow/nrepl-select :my-build)

haywood18:06:34

(checking that template out)

jherrlin18:06:41

Okey, when i connect using M-x cider-connect-clojurescript and the run M-x cider-connection-browser it understands that it is a ClojureScript REPL

haywood18:06:00

oh gotcha, but it's just not working right?

haywood18:06:10

I haven't used those commands to boot a cljs repl

jherrlin18:06:27

Yes, my Cider REPL not working like the REPL i have in the shell

jherrlin18:06:02

Are there any other way to do what i want?

jherrlin18:06:41

I run Figwheel and Devcards, and use Cider 🙂

haywood18:06:34

I would try a more manual approach

haywood18:06:40

run lein repl from your project

haywood18:06:51

connect to that nrepl from emacs

haywood18:06:56

and then in emacs run

haywood18:06:05

(use 'figwheel-sidecar.repl-api)

haywood18:06:13

(start-figwheel!)

haywood18:06:38

and then once that compiles, start the cljs-repl by running (cljs-repl)

haywood18:06:55

after that if you refresh the browser where the js is being served

haywood18:06:07

you should be able to eval (js/alert "sup")

haywood18:06:46

if this works for you, you can create a user.clj and have the repl load that file to make it easier to repeat those steps each time

jherrlin19:06:57

@U0TU3SMNC nice, this steps works fine for me. I get Figwheel to run and the Cider REPL is working just fine 🙂 Thx!

haywood19:06:25

whoa sick, I helped someone. go and be great!

❤️ 4
haywood19:06:06

check debux out, it's got functions that print to the javascript console when you've got a brepl up and running. it's pretty game changing

jherrlin18:06:55

working on it...

haywood18:06:45

@jherrlin have you checked shadow out?

haywood18:06:58

I have had a lot more luck with that, it's pretty incredible

haywood18:06:45

I recently created a small minimal project to reproduce an issue I was having (but ended up not being an issue) https://github.com/haywoood/deb

jherrlin19:06:13

ill look into that later on 🙂

haywood19:06:01

but with that I can connect cider to a browser repl, and a browser repl that runs my unit / integration tests against the browser

jherrlin19:06:33

The next step now would be to get Devcards to work to

sova-soars-the-sora17:06:41

What do you mean? I didn't know you could ask for data that didn't have a shape defined in the schema.

mg18:06:35

I believe the question was querying against entities that are not attribute entities. If that’s the case you could do something like this to return all non-attribute entity ids:

(d/q '[:find [?eid ...]
       :where
       [?eid _ _]
       (not [?eid :db/valueType _])]
     db)

fmn13:06:15

Yep. I'm trying to query all eid that doesn't have :db/ident or :db/valueType. Unfortunately the given solution throws with "insufficient bindings". I ended up querying all eid who has :db/ident, get all eid with datoms, get the difference with set/difference and then finally I can feed it to pull-many