Fork me on GitHub
#beginners
<
2017-08-13
>
lepistane12:08:34

oke am i doing something wrong?

lepistane12:08:15

ajax.cljs post to server and when i use :body it's #object[java.io.ByteArrayInputStream 0x5aec0e6e java.io.ByteArrayInputStream@5aec0e6e] is that normal ? what do i do now?

lepistane12:08:41

do i need to parse that with transit.clj

lepistane12:08:46

or error is else where?

chrisjd13:08:57

Yeah, you can reasonably expect the body to be an InputStream. The easiest way to get the data out is to just use slurp.

chrisjd13:08:28

(let [body (slurp (:body req))] …)

lepistane13:08:09

so this is normal when using ajax.cljs ?

Drew Verlee13:08:15

Is there a way to use an editor to unpack a the s-expressions back one level? Example: Say i have.. (def foo [x] (+ x 1) and.. (def bar [x] (foo 1)) so if i have my mouse at the * it would unpack the next expression, like so: (def bar [x] *(foo 1)) -> (def bar [x] (+ x 1)) I know there is a “eval and replace” in Cider , i would want a just a “replace”.

athomasoriginal15:08:39

Hey all, just wanted to confirm what is expected in this scenario. You are using boot-reload or figwheel. You load up a simple app where one file as a ns of app.core. You require app.core into another ns. You launch you app and everything works. Now, you want to change your ns from app.core to app-awesome.core. Would this require a full restart of boot-reload or fighweel? Through my experimentation, I found that this is the case. However, I . just want to confirm that this is actually expected and its not my configs.

eggsyntax16:08:04

@drewverlee I think you want cljr-inline-symbol (for me, , r i s). It's been unreliable for me, though, sometimes throws errors in a way I've never tracked down (or really tried TBH).

Drew Verlee17:08:47

Thanks. I’ll take i’ll try that out.

eggsyntax18:08:13

There’s also cider-eval-last-sexp-and-replace, but that does something a bit different — instead of changing (foo 1) to (+ x 1), in your case it would just change it to 2. Not what you wanted, but also sometimes useful 🙂

noisesmith18:08:57

@tkjone figwheel's reloading doesn't handle new files, deleted files, or renamed files.

noisesmith19:08:43

(where effectively, a renamed file is both - you would need to eliminate things defined under the old ns etc.)

eggsyntax19:08:05

@noisesmith I was initially thinking that too, but then I wasn’t confident of it — it seems like a) you wouldn’t usually care if there were things loaded under the old ns, you would just ignore them (in many cases, anyway), and b) it seems like the new ns, assuming cljs, would get built along with everything else in that dir, and then you could just require it as usual. Am I wrong on that? My confidence in the above is extremely low, which is why I didn’t answer.

noisesmith19:08:25

yes you are wrong

eggsyntax19:08:42

Cool, thanks.

noisesmith19:08:44

it's pretty easy to test bymaking a new file

eggsyntax19:08:58

Yeah, I was too lazy to go test it 😉

noisesmith19:08:09

you can even mess it up by deleting the file and recreating it (it's watching file handles, or so it seemed)

eggsyntax19:08:18

Cool, good to know.

rajko20:08:25

Hi, I need a help with using javafx with Clojure. I don't know how to get data from a form to a caller. Can somebody point me in the right direction or maybe knows some resource where I could dig in.Thanks

integralexplorer21:08:42

Newbie: Just learning how to connect to a postgresql database using older examples in tutorials. It appears that jdbc has changed quite a bit since 0.3.0 (now 0.7.0). I am quite confused now with a full day of alternate tutorials, searches, different errors, and reading across both postgres documentation and clojure libraries - jdbc especially. Need expert to verify if I am setting up my dependencies and jdbc correctly. Are these correct? from project.clj: :dependencies [[org.clojure/clojure "1.8.0"] [ring "1.6.2"] [compojure "1.6.0"] [org.clojure/java.jdbc "0.7.0"] [org.postgresql/postgresql "42.1.4"]] from core.clj: ;;; database connection (def db "jdbc:<postgresql://localhost/webdev?user=postgres&password=mypassword%22|postgresql://localhost/webdev?user=postgres&password=mypassword">) When I invoke the webapp I get the following error: ERROR: relation "items" does not exist Position: 63 Which on research appears to mean the table which I am creating in the following code does not exist: (ns webdev.item.model (:require [clojure.java.jdbc :as db])) (defn create-table [db] (db/execute! db ["CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\""]) (db/execute! db ["CREATE TABLE IF NOT EXISTS items (id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), name TEXT NOT NULL, description NOT NULL, checked BOOLEAN NOT NULL DEFAULT FALSE, date_created TIMESTAMPTZ NOT NULL DEFAULT now())"])) which I confirm to be "not created" when looking at pgAdmin. But I think it is getting to the database and looking for the table. But not certain. Can you first verify the items above. I will provide more of the logic later if I need to. Any hints or more current resources I should master here? Thanks

adambard22:08:13

I think your db declaration should be a connection spec, not a string

adambard22:08:43

e.g. (def db {:connection-uri ""})

adambard22:08:47

I've generally used the following before:

(defonce db-spec {:subprotocol "postgresql"
                  :subname (str "//127.0.0.1:5432/" (:database-name env))
                  :classname "org.postgresql.Driver"
                  :user (:database-user env)
                  :password (:database-password env) })

integralexplorer22:08:43

Thanks to you both. I will try both methods and come back here with success status or more questions.