Fork me on GitHub
#beginners
<
2021-01-23
>
raspasov10:01:40

In Datomic’s pull syntax, is there a way to (pull ?e [*]) but exclude a specific key, say :db/id or a number of keys?

raspasov10:01:58

(yes, I can transform the data recursively after I receive it, but wondering if there’s a nicer way)

roelof10:01:28

Why do I get here that the home-handler is unused where there is one

(defn home-handler
  [request]
  (let [page (extract-page-number request)]
    (future (memo-display-data (inc page))
    (-> (memo-display-data page)
        (display/generate-html page)))))

(defroutes app
  (GET "/" home-handler)
  (route/resources "/")
  (GET "/favicon.ico" [] ""))

roelof11:01:35

and what can be the reason for this error message : HTTP ERROR 500 java.lang.NullPointerException: Response map is nil URI:/ STATUS:500 MESSAGE:java.lang.NullPointerException: Response map is nil SERVLET:- CAUSED BY:java.lang.NullPointerException: Response map is nil Caused by:

java.lang.NullPointerException: Response map is nil
	at ring.util.servlet$update_servlet_response.invokeStatic(servlet.clj:100)
	at ring.util.servlet$update_servlet_response.invoke(servlet.clj:91)
	at ring.util.servlet$update_servlet_response.invokeStatic(servlet.clj:95)
	at ring.util.servlet$update_servlet_response.invoke(servlet.clj:91)
	at ring.adapter.jetty$proxy_handler$fn__7287.invoke(jetty.clj:28)
	at ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:501)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
	at java.base/java.lang.Thread.run(Thread.java:834)
Code so far : https://github.com/RoelofWobben/paintings

DG16:01:14

Seems like :keys destructuring only works for let and not for fn arguments, is that correct? Seems like I cannot have a (map (fn [{:keys...} args])

rakyi16:01:03

(map (fn [{:keys [k]}] (inc k)) [{:k 1} {:k 2}])
(2 3)

DG16:01:30

Looks like I did something wrong. What if I also wanted the original map? (map (fn [{:keys [k]} m] ..)

DG16:01:57

I think that's where I got it wrong

rakyi16:01:42

(map (fn [{:keys [k] :as m}] (assoc m :a (inc k))) [{:k 1} {:k 2}])
({:k 1, :a 2} {:k 2, :a 3})
recommend checking the docs 🙂 https://clojure.org/guides/destructuring

DG16:01:10

Thanks @U751SU53R , I actually checked the docs but I missed the :as part (which isn't needed for let

lassemaatta17:01:02

can you clarify what you mean by "isn't needed for let"? e.g. (let [{:keys [a b] :as m} (invoke-some-fn)] ..body)

roelof18:01:40

oke, I got a project work with hiccup What is now a good way to learn to do the front-end with reagant or re-frame ?

Malik Kennedy19:01:26

One cool thing I've found with hiccup / reagent is that hiccup form can generate other times of XML like SVG. https://github.com/Aeyk/clojure-scratchpad/blob/master/opus_flammagramma.svg Was generated with hiccup code, for instance

roelof19:01:58

??? I want to learn how I can convert some hiccup to re-frame

Mno19:01:10

re-frame has a bunch of other moving parts, since it has a philosophy on memory management and such. I recommend starting a simple project from scratch before trying to port this one. (don’t worry your knowledge of hiccup will help you quite a bit because reagent and re-frame also use a version of it) I’d probably recommend reagent first then maybe try re-frame. and this site is highly recommended for getting a quick overview with a bunch of examples: https://reagent-project.github.io/

Mno19:01:38

Once you get a good grasp of how the template is set up and runs maybe you can try adapting your previous one to work with reagent as well. This might be very fast if you’ve used react before and understand the underlying concepts, otherwise it might take a bit of getting used to.

roelof19:01:39

then I have a big problem. I have no xp in react or friends

Mno20:01:49

not a big problem, it’ll just take a bit longer to understand why they do certain things.

Mno20:01:15

You’ll be fine!

Joe20:01:36

Eric Normand has some good videos on the basics of reframe and reagent. Jacek Schae has free and paid courses for both reagent and reframe, building an application starting from the ground up. Both assume no knowledge of react.

6
roelof20:01:48

yep, I have seen the free course on reframe

Joe20:01:26

As mentioned earlier in the thread, you probably want to do reagent before reframe, since the latter is used on top of the former.

roelof20:01:33

wil do the next few days

👍 3
roelof20:01:01

and maybe reagent is all I need and maybe not

roelof20:01:24

can I better use npm or yarn ?

Joe23:01:52

I use npm with no issues. I’m not familiar with yarn so couldn’t say if it’s better.