Fork me on GitHub
#clojure
<
2017-06-24
>
weavejester01:06:05

Does anyone happen to know of any decent OAuth2 client libraries? There’s a lot around, but all the ones I’ve found are weirdly designed 😕

royalaid04:06:18

weavejester: The best I could find was clj-oauth

jgeraert07:06:45

yada seem to have implemented something themselves https://github.com/juxt/yada/blob/master/ext/oauth2/src/yada/oauth.clj. Maybe its time we see a new repository appearing under your github account 😉

qqq04:06:44

in clojure/match, can I do [x & ys] // x matches first elem of vector, ys matches rest or do I have to do ([x & ys] :seq) ?

clj.max15:06:48

Hey friends

clj.max15:06:08

Anyone have a good way to split a vector (of CLI args in my case) into pairs?

clj.max15:06:55

I have e.g. -m 4 -y 2016 and want to end up with [["-m" 4] ["-y" 2016]] or maybe a map

alice15:06:43

I believe you may be looking for zip

alice15:06:55

Alternatively, (partition 2 ["-m" "4" "-y" "2016"]) => (("-m" "4") ("-y" "2016"))

clj.max15:06:22

hm tbh I don't get what zippers do from reading the docs lol

clj.max15:06:30

feels dumb

alice15:06:52

I've not used zip in Clojure at this point, but in my experience zip functions pair 2 values together

clj.max15:06:32

ah like zipmap?

alice15:06:45

But I think it's more often something like '(1 2 3) '(4 5 6) => (1 4) (2 5) (3 6)

clj.max15:06:02

oh yea I remember that one. I think that's the reverse operation. let me try the partition.

clj.max15:06:56

your partition example does exactly what I want

clj.max15:06:58

thanks 🙂

noisesmith15:06:33

clojure has "zippers" which are an abstraction for navigating complex nested structures, and zipmap which creates a hash-map out of a collection of keys and a collection of values

phill15:06:12

zippers are for driving a turtle around a nested structure, optionally editing it along the way. so for example xml-zip gives you a zipper that can walk through the data structure returned by clojure.xml/parse. you can go next-next-next, or at any node you can ask what are all the parent/ancestor nodes, etc.

clj.max15:06:46

I see. That sounds way more complex than my program 🙂

clj.max15:06:51

One day 😉

phill15:06:52

ok. don't forget clojure.tools.cli.

clj.max15:06:35

Thanks, I'll check it out. This is more to teach myself a few things anyway, and it seems like partitioning a vector sounds like a useful thing to know.

madstap16:06:06

The zip function found in other langs isn't in clojure. You just use map.

anicholslcsw17:06:30

Is this a good place for a total noob to learn or should i check elsewhere?

noisesmith17:06:49

@anicholslcsw there's a #beginners channel

yannvahalewyn19:06:12

Hey guys, trying to setup a connection pool with c3p0. It seems to have trouble connecting to the production database using ssl (heroku, needs sslmode=require). I’ve tried

(.setJdbcUrl my-datasource (format "jdbc:%s:%s?sslmode=require" (:subprotocol dbspec) (:subname dbspec)))
and
(.setProperties my-datasource
                (doto (java.util.Properties.)
                  [...]
                  (.setProperty "sslmode" "require")))
C3p0 doesn’t seem to pick this up, I keep getting SQLException: Connections could not be acquired from the underlying database!. Getting a connection for the db-url string with the sslmode query-params does indeed work. Has anyone else experienced this?

yannvahalewyn19:06:25

where my-datasource an instance is of om.mchange.v2.c3p0.ComboPooledDataSource

yannvahalewyn19:06:48

Update: just tried with apache’s DBCP2, and that seems to pick the sslmode just fine. Is there an issue with c3p0 I’m not aware of?

mikeb19:06:26

You might also try HikariCP for pooling, it's rock solid. https://github.com/brettwooldridge/HikariCP

yannvahalewyn20:06:31

Thanks @mikeb. Already looked at it, looks great indeed 🙂