Fork me on GitHub
#beginners
<
2021-06-23
>
zackteo03:06:20

Is there a sample ring + compojure server I can look at? :o

seancorfield03:06:10

Something like this @zackteo? https://github.com/seancorfield/usermanager-example/ That's a bit more than just Ring + Compojure but it's a small working app with a DB.

zackteo03:06:18

That works! Probably a bit more complicated compared to what I need but should be okay

seancorfield03:06:16

Feel free to DM me if you have any Qs about it.

seancorfield03:06:22

Or ask them here.

zackteo06:06:09

Having some difficulty in understanding what I need to do to get a POST working and how to go about checking it. Should I be writing my response as json with clojure.jata.json/write-str

seancorfield16:06:34

I don't understand what you're asking here, sorry.

borkdude09:06:47

@zackteo If you need something even more basic, you can omit compojure completely and build your own router as demonstrated here: https://github.com/kloimhardt/babashka-scittle-guestbook

Michael Stokley15:06:33

does this function already exist? does it have a conventional name?

(defn f
  [g]
  (fn [x] (g x) x))
g side effects

delaguardo15:06:23

looks like doto

👍 2
🙏 2
Michael Stokley15:06:17

nice, this is it

arielalexi18:06:36

Hey everyone, I have a problem with require one my files to another ont in the same project. this is how the project looks like :

.
├──src\c\g
      └── do_lib
           ├──views
      	      └── home.clj
           └── assets.clj 
the ns of assets.clj is: (ns c.g.do-lib.assets) I want to require the assets file in the home file so I did: (:require [c.g.do-lib.assets :as assets]) when I try to eval the home ns I'm getting a syntax error Class Not Found Exception then windows path of home.clj file directory on my computer then c.g.do-lib.assets. other requires that been imported don't make a problem. what did I miss ? thank you :)

dpsutton19:06:35

how is assets.clj a child of home.clj?

arielalexi19:06:51

by mistake - things change here - let me change it back

dpsutton19:06:10

typo? c.g.do-lib.assets vs cO.g.do-lib.assets?

dpsutton19:06:30

hard to tell which is a typo in slack and which might be a typo in your source. c.g vs co.g

dpsutton19:06:39

can you post the full error message?

myguidingstar19:06:07

what's the ns did you put in home.clj? from the dir tree it should be (ns c.g.do-lib.views.home)

arielalexi19:06:46

Syntax error (ClassNotFoundException) compiling at (c:\Users\..\my-pro\src\c\g\do_lib\views\home.cljc:0:0). c.g.do_lib.assets

arielalexi19:06:59

the ns I used for home.clj is (ns c.g.do-lib.views.home)

ghadi19:06:44

the directory do-lib needs to be do_lib

dpsutton19:06:04

(c:\Users\..\my-pro\src\c\g\do_lib\views\home.cljc:0:0) it seems to be

ghadi19:06:21

just double check that namespaces have dashes, and the corresponding files/dirs have underscores

ghadi19:06:34

It's a common stumbling point

dpsutton19:06:19

ah, good point. in your tree output it is with a hyphen and in the copied error it has an underscore. These copy paste mistakes can make diagnosing issues quite difficult

arielalexi19:06:56

the tree output shold look like the directory exactly?

arielalexi19:06:59

in the directory name it is do_lib but I changed it in the namespace to be do-lib.

myguidingstar19:06:57

so the dir name is already do_lib before ghadi's suggestion?

myguidingstar19:06:50

maybe you haven't saved the file after changing the namespace?

myguidingstar19:06:45

hmm, have you tried to eval the home.clj file directly?

arielalexi19:06:32

@myguidingstar - reopening and eval the file solved it. thank you all for the help 🙂

👏 2
Drew Verlee19:06:58

In the clojure core function sort-by

([keyfn ^java.util.Comparator comp coll]
   (sort (fn [x y] (. comp (compare (keyfn x) (keyfn y)))) coll))
I'm not sure i understand the use of the dot here. I understand it to be related to java interopt. Is this a case of Member access ? e.g (.instanceMember instance args)* (.instanceMember Classname args)*

phronmophobic19:06:31

It's this one: `(. instance-expr (method-symbol args))`*

ghadi19:06:39

(.doThing obj a b c) == (. obj (doThing a b c)) == in Java: obj.doThing(a, b, c)

👆 2
Drew Verlee19:06:06

ah ok, so comp here isn't clojures.core/comp. that was causing me some confusion

Drew Verlee19:06:25

I was looking past the params