Fork me on GitHub
#clojure-uk
<
2017-07-13
>
thomas07:07:20

morning šŸ˜¼ mogge

thomas07:07:38

that is a very tough one indeed @agile_geek

thomas07:07:01

would the london role be willing to wait for a few days?

agile_geek08:07:22

@thomas I can just not sign the contact yet and I very much doubt they'd pull the offer, although they want me to start Monday. I need to find out more about the other role.

Rachel Westmacott08:07:18

can you start on Monday AND not sign the contract?

agile_geek08:07:04

One role is Clojure but it's London and it would be one of those "you can't use that library without going thru security checks for 3 months" kind of environments (and I couldn't use my equipment or emacs etc.). The other role is probably Java and hands off anyway...but it's 3 miles away which means I could run into work if I wanted and I'd get to see my kids.

practicalli-johnny10:07:35

I think you should come and work in London, I miss you :)

agile_geek08:07:01

I could start on Monday and then give notice but it looks really bad and I'd probably struggle to get contracts if I did!

glenjamin08:07:25

how long can you live without a job?

glenjamin08:07:12

just tell them you have another job in pipeline that doesnā€™t involve hundreds of miles of travel, worst case they pull the offer, best case you defer a week

agile_geek08:07:12

@glenjamin probably a few more weeks yet

agile_geek08:07:35

That's what I was thinking

yogidevbear09:07:55

That's a tough one. I think the "see my kids" part is what would sway it for me. It's one thing doing a long commute, but still getting to see your family. It's another being unable to see them for 4 nights/mornings every week. Really hard decision.

yogidevbear09:07:15

How old are you children, @agile_geek?

agile_geek09:07:19

@yogidevbear oh, they're grown up but I still like being at home sometimes

yogidevbear09:07:40

I can understand those feelings

jonpither09:07:58

I think @agile_geek is talking about the project I'm on, so I'll stay out of it šŸ™‚

agile_geek09:07:13

@jonpither I think I might be šŸ˜‰

jonpither09:07:15

but I understand the balanced debate you're going through

yogidevbear09:07:19

Hi Jon šŸ‘‹ Okay, guess you have to take the job now Chris šŸ˜‰

yogidevbear09:07:13

I'd be happy to take the London role if you don't want it @agile_geek, but I don't think I'm nearly as seasoned in Clojure šŸ˜‰

maleghast11:07:26

Morning All, even though itā€™s afternoonā€¦

maleghast12:07:41

Anyone used JSONB with Postgres from Clojure..?

maleghast12:07:34

There is a compatibility library kicking around, but it uses a much earlier version of the PostgreSQL JDBC driver than I am using as a dependencyā€¦

jonpither12:07:51

once upon a time I did, but I have forgotten everything about it, doesn't it just work?

Rachel Westmacott12:07:34

Iā€™m using it. It seems to just work.

maleghast12:07:43

It might, I am going to try throwing a map at it instead of politely turning my map into JSON and see what happensā€¦

Rachel Westmacott12:07:30

you might need to extend some protocols to make it ā€˜just workā€™

Rachel Westmacott12:07:36

now I think about it

Rachel Westmacott12:07:49

(ā€œjustā€ is a dangerous word)

Rachel Westmacott12:07:34

something like

(extend-protocol jdbc/ISQLValue
  IPersistentMap
  (sql-value [value]
    (doto (PGobject.)
      (.setType "jsonb")
      (.setValue (json/write-str value :value-fn jsonify)))))

maleghast12:07:39

Iā€™m getting this now: ā€œNo hstore extension installed.ā€

Rachel Westmacott12:07:12

and

(extend-protocol jdbc/IResultSetReadColumn
  PGobject
  (result-set-read-column [pgobj metadata idx]
    (let [type  (.getType pgobj)
          value (.getValue pgobj)]
      (case type
        "jsonb" (json/read-str value :key-fn keyword) ... ))))

Rachel Westmacott12:07:13

with that technique you can provide custom serialisation/deserialisation for any object types

maleghast12:07:29

is json/read-str the equivalent of cheshireā€™s parse-string?

maleghast12:07:53

Also @peterwestmacott ā€œwhereā€ would I make these additions?

Rachel Westmacott12:07:30

in this case json is [clojure.data.json :as json]

Rachel Westmacott12:07:43

but obviously any JSON lib will do

maleghast12:07:51

*nods* I thought so, thatā€™s cool

Rachel Westmacott12:07:06

ā€œwhereā€ - in any namespace that gets loaded before you try to to read to/write from the db

maleghast12:07:43

OK cool, so if I have a little namespace like this:

(ns edge.sentiment.canonical-db
  (:require [yesql.core :refer [defquery defqueries]]))

(def db-spec-ptmeteo
  {:classname "org.postgresql.Driver"
   :subprotocol "postgresql"
   :subname "//localhost:5432/sentiment-canonical"
   :user "oliver"})

(defqueries "sql/sentiment-queries.sql"
  {:connection db-spec-ptmeteo})
that my ā€œcoreā€ namespace requires in, that would be a good venue..?

Rachel Westmacott13:07:34

(oh, also jsonify in my serialisation method is an extensible multimethod for handling random types that might be found in my Clojure maps.)

Rachel Westmacott13:07:17

I guess so. I mean, wherever makes sense in your codebase. As long as the form has been evaluated before you try to use it, you should be fine.

maleghast13:07:46

Lovely, thanks šŸ™‚

Rachel Westmacott13:07:47

They are just top level forms in a ns that gets required elsewhere.

Rachel Westmacott13:07:34

I think there was a blog post about it somewhere that I cribbed that off. A <search engine of choice> search for the protocol names might turn up more info.

maleghast13:07:11

Excellent - I will consult the <search engine of choice> on the subject, as suggested

maleghast13:07:17

@peterwestmacott - After a couple of false starts (that were down to me being dense) I have it working - thanks again, really saved my bacon!

yogidevbear13:07:33

Ministry of Silly Walks

thomas13:07:48

that is very cool indeed @yogidevbear

maleghast15:07:21

Thatā€™s just horrid!

mccraigmccraig15:07:18

(-> session .getCluster .getConfiguration .getQueryOptions .getConsistencyLevel) it's maps four levels deep, but instead of being able to see a map you have to go to the javadoc to figure out the accessor method names

minimal16:07:18

java tries to do lenses, but dies instead

glenjamin16:07:59

not-at-all-random clojure.core function of the day:

glenjamin16:07:30

itā€™s bean

mccraigmccraig16:07:02

oo that's much better for exploration @glenjamin