beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
eunmin 2020-11-26T05:29:46.431500Z

Hi~! Is there a utility that I can get(or assoc) all values in nested map with vector?

(def data
  {:a [{:b {:c [{:d 1}]}}
       {:b {:c [{:d 2}]}}]})

;; It's ok
(get-in data [:a 0 :b :c 0])
=> {:d 1}

;; Like this?
(get-all data [:a :* :b :c :*])
=> [{:d 1} {:d 2}]

;; Like this?
(assoc-all data [:a :* :b :c :* :e] 3)
=> {:a [{:b {:c [{:d 1
               :e 3}]}}
        {:b {:c [{:d 2
               :e 3}]}}]}

2020-11-27T03:29:17.458100Z

Im curious what the real situation is. Both libs mentioned will help. But always suspect there is a database issue at play when I see questions like this.

phronmophobic 2020-11-26T06:01:24.432200Z

specter can do that https://github.com/redplanetlabs/specter

šŸ‘ 2
2020-11-26T06:46:55.435400Z

Has anyone here used etaoin to print a pdf of a web page? Webdriver spec has the command. There are examples here for c# and Java: https://stackoverflow.com/questions/47387776/chromedriver-print-to-pdf-after-page-load#48405542 , but when I look in the code for etaoin I donā€™t see it implemented. Are there other clojure options?

Ben Sless 2020-11-26T06:50:20.435600Z

Also https://github.com/noprompt/meander

2020-11-26T10:29:14.437400Z

Is there a way with transit-clj to serialize sorted-maps?

gon 2020-11-26T11:24:40.438Z

sure, you have to provide your encoding/decoding handlers

gon 2020-11-26T11:26:39.438400Z

take a look at https://www.cognitect.com/blog/2015/9/10/extending-transit

2020-11-26T14:38:59.445100Z

IThanks a lot @gon!

2020-11-26T14:40:09.446400Z

I have a question about multimethods: if a method is defined in two different namespace wit the dispatch value, and they are both loaded into a new namespace, which one will take precedence?

2020-11-26T14:41:06.447200Z

I tried in Clojure and it appeared to me that it was the namespace which was imported last (which somehow made sense), but then I tested in ClojureScript and the order was not relevant.

2020-11-26T14:41:21.447500Z

I am asking because I need to overwrite one of the dispatch function.

st3fan 2020-11-26T16:59:16.451Z

I've turned this week off into Clojure Hack Week

st3fan 2020-11-26T18:11:51.451400Z

I guess most people are šŸ¦ƒ šŸ„§

Pablo 2020-11-26T22:45:43.454700Z

Hello everyone, Could you please help me with a jdbc function call? I have this:

(jdbc/execute! db/*db*
  ["update request
    set timestamp = ?
    where id = ?
    returning *"
 "2020-11-26T15:37:45.13-06:00"
 621])
But Iā€™m getting this error:
Execution error (PSQLException) at org.postgresql.core.v3.QueryExecutorImpl/receiveErrorResponse (QueryExecutorImpl.java:2477).
ERROR: column "timestamp" is of type timestamp with time zone but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
  Position: 61
I understand that "2020-11-26T15:37:45.13-06:00" is the standard date format (ISO-8601), but I donā€™t know why itā€™s not working. Thanks!

Pablo 2020-11-26T22:53:32.454900Z

On psql this works fine:

update solicitudes.solicitud
set modificaciĆ³n_horario = '2020-11-26T15:37:45.13-06:00'
where solicitud_id = 621
returning *

Bob B 2020-11-26T23:24:39.455100Z

it seems like you might need to pass a timestamp instance instead of a string - <https://stackoverflow.com/questions/9305541/clojure-jdbc-postgresql-i-am-trying-to-update-a-timestamp-value-in-postgresql-f>