Fork me on GitHub
#clojure
<
2016-04-15
>
keeth04:04:02

@ckarlsen: aleph I think

Alex Miller (Clojure team)05:04:30

@mrg sorry about that! we do have an errata listed on it (https://pragprog.com/titles/vmclojeco/errata) for the next edition

razum2um10:04:57

is there any library which extracts table definitions form pg/mysql/sqlit into a datastructure?

mrg10:04:48

Thanks @alexmiller! I already added it there!

vincentdm12:04:32

Quick question: I'm building an AWS-Lambda based project, but since Lambda doesn't provide ENV vars, i want to bake them into my uberjar (the password are encrypted before baking and decrypted in Lambda). I have found the Environ plugin to manage env variables, but I cannot find a way to bake env vars into the JAR.

vincentdm12:04:11

So does anyone know how I can include env vars (flags) in my build so that they are available to the code running in the uberjar?

vincentdm12:04:20

(I'm using Leiningen)

borkdude13:04:47

@vincentdm: you can put them in .lein-env if you use leiningen

vincentdm13:04:29

Aah ok. I thought those were the ones that would be available locally. I must have misread the docs. Thanks!

borkdude13:04:27

@vincentdm: you can put the environment variables in your project.clj, lein environ then spits them out to .lein-env

borkdude13:04:44

@vincentdm: and using profiles you can then differ between dev or prod, etc

vincentdm13:04:43

Smart! I'll do it that way. Thanks for pointing me in the right direction!

borkdude13:04:43

@vincentdm: you have to add the leiningen plugin, just read the docs of lein environ

vincentdm13:04:48

yeah I did... but I interpreted it as if the .lein-env was for overriding the env vars of the machine the code is running on.

jstaffans13:04:14

Another way is to pull a config file from S3

vincentdm13:04:20

@jstaffans: I know, but since cold Lanbda's are already quite slow, I'm reluctant to add yet another request.

vincentdm13:04:39

I'm currently planning to decrypt the baked-in secrets using KMS on the Lambda's first run, and cache them in the /tmp folder

vincentdm13:04:30

(I know I can also do that with the secrets I fetch from S3, but I like it better if my JAR contains everything I need)

jstaffans13:04:11

have you measured the impact of one request to S3? I’d assume it would be plenty fast

vincentdm13:04:19

No I must confess I didn't...

jstaffans13:04:06

However, I understand if you don’t want to bloat your JAR with more of the AWS SDK just to get a config file..

vincentdm13:04:08

yeah, and the idea of managing the bucket permissions, making sure each env fetches the right keys from it... I prefer containing it all in the jar. But I'm aware of danger of premature optimization...

lwhorton13:04:01

i’m a little lost trying to wrap a macro function into an app-specific function that is called with default parameters.. how do you do this in clojure? e.g.

(app-http “GET” {:args …})

(defn app-http [url & args]
  (ajax/GET url args)) <— this is a macro from another lib

lwhorton13:04:50

my specific use-case is I want an app http library that wraps particular invocations to GET/POST/DELETE with various interceptors … for auth, cache, jwt, etc.

lwhorton13:04:16

but I don’t want to litter my codebase with (ajax/GET “/api” {:interceptors [a b c d]})

darwin14:04:44

@lwhorton: I think this will depend on how ajax/GET macro is written, if it expects explicit map during compile time, then you will have to write a macro to do that

darwin14:04:51

I’m afraid

darwin14:04:09

can you point us to that ajax/GET source code?

abtv14:04:26

Does anybody know a good tutorial or just rules on naming namespaces? For example, I have such namespaces as loader, processor and saver. They look pretty bad, especially processor, because it means nothing. Is it a good idea to give more specific names? Say, tweets-loader, tweets-processor. Actual code is here: https://github.com/abtv/tech-radar/tree/master/src/clj/tech_radar/services

clomat14:04:15

Hello everyone, I am about to start on a fairly complex full-stack project and am considering Clojure/ClojureScript for it - what is the up-to-date 2016 approach to building a complex Clojure back-end? Is it ring + roll your own or is there a well-maintained set of libraries/framework?

borkdude15:04:38

@clomat: http://www.luminusweb.net gives an overview of libraries you can use together

borkdude15:04:02

@clomat: the alternative to 'roll your own ring' is Pedestal

lwhorton15:04:58

nested macros are a pain

akiva15:04:52

@abtv, sub-namespaces might help you out here: services.twitter.loader and services.twitter.processor.

akiva15:04:08

Or consider combining them into one namespace. services.twitter.

darwin15:04:10

@lwhorton: just skimmed the sources and it seems the ajax/GET is a normal method (generated by a macro for some reason)

darwin15:04:28

so I don’t think you should have a problem applying args to that method

darwin15:04:32

in your code, you probably wanted to write (apply ajax/GET url args)

lwhorton15:04:28

o? it looked to me like the call to get was doing a macro-rewrite to lower-level (http {:method “GET” :args …}), ill take a closer look

clomat15:04:04

@borkdude Thanks! Also how would you say the split between Backend(Clojure) vs Frontend(CLJS) is in the community, ie which one would you say is more active, if you know?

lwhorton15:04:34

ugh i need to do more reading on macros.

darwin15:04:34

a side note: to me it is not obvious why that must be a macro, a plain function for generating that function would work just fine IMO, also using symbols like this does not serve any purpose, just a noise IMO https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/macros.clj#L4

lwhorton15:04:47

I’m pretty new to clojure so i have a hard time evaluating the quality of a library. It seems to be the only cljs-compatible one with interceptors, though.

lwhorton15:04:57

I did find a workaround per the suggestion. I like to avoid globals such as their implementation of a global atom default-interceptors, though.

lwhorton15:04:14

My thought was just wrapping everything get/post/put etc with default-interceptors or method-specific interceptors.

lwhorton15:04:26

seems thats just counter to the way the library is designed, though.

twashing16:04:59

Have people compared Spectre to Jai? What differences / tradeoffs does each library make? https://github.com/nathanmarz/specter https://github.com/zcaudate/jai

lwhorton16:04:45

is there an idiomatic if thing then thing else otherthing short of (if (:key thing) (:key thing) (otherthing)) (to avoid repetitiveness)?

loganmhb16:04:12

@lwhorton: (or thing otherthing)

loganmhb16:04:58

(lein-kibit suggests this, iirc)

lwhorton16:04:16

hah, thanks - so simple (should go back to my nand-gate school days)

yatesj916:04:11

if i want to search a vector of maps and return that single map if found, is this the best way of doing it? '(into {} (map #(if (= 1 (:vlan %)) %) vlan-data))))' assuming i have two or more maps in a vector with a key of :vlan.

yatesj916:04:02

(into {} (map #(if (= 1 (:vlan %)) %) vlan-data))))

slipset16:04:23

Wouldn't keep be what you're looking for?

yatesj916:04:18

I'll give that a try, thanks.

cupello17:04:11

Does anyone have a good example of docjure in use?

cupello17:04:21

Hi everyone!

fasiha17:04:08

Is the code block at https://github.com/clojure/core.async/wiki/Go-Block-Best-Practices#general-advice beginning with (defn http-call missing something? The block's last line (load-urls urls) calls a 2-arity function with a single argument?

zentrope17:04:38

Is it possible to “extend-protocol” with a multi-arity protocol? (extend-protocol proto recordType (foo [_ a] …) (for [_ a b] …))?

zentrope17:04:02

I keep getting a wrong-number-of-args message, for some reason.

zentrope17:04:33

When I make my record directly implement that protocol, it works.

zentrope17:04:03

Okay: (foo ([ a] …) ([ a b] …)) works, as extrapolated from the extend function.

lewix18:04:02

nodejs vs clojure vs nodejs vs clojure vs nodejs....ahhhhhhh make up your mind @lewix

arrdem18:04:27

Node if it's brain dead simple web crud and you'll probably throw it away otherwise Clojure

lewix18:04:25

from this day forward I decided that i'm not gonna look at other languages..//it's distracting to look and wonder about other tech @arrdem hehe

lewix18:04:56

it's like women (don't take it the wrong way, I say it respectfully)

zentrope18:04:19

Sometimes you want to do one thing, then another, then another, and node makes that so … problematic.

pbostrom18:04:33

the answer is clearly ClojureScript on nodejs

lewix19:04:45

do people actually do that? @pbostrom

arrdem19:04:59

Yeah that's been throw around quite a lot actually.

pbostrom19:04:11

I've been doing it for AWS lambda

lewix19:04:34

clojurescript on node.js hmm

lewix19:04:45

@pbostrom: does it work seamlessly?

lewix19:04:19

@pbostrom: and why did you favor it over the jvm

pbostrom19:04:31

yeah, I haven't run into any issue so far; I am not a node expert or anything but it works fine, the only tricky thing is that everything is async and runs on the event loop, I wasn't used to that at first

pbostrom19:04:05

I just started playing with AWS lambda, I didn't want to deal with JVM start up time for that

lewix19:04:27

@pbostrom: async shouldn't be a problem with clojure laziness ?

pbostrom19:04:50

core.async channels help, for example every call in the AWS node SDK takes a callback which returns the result, so if you are making several calls you could end up in callback hell or have to pass around some global atom; channels let you avoid that

pbostrom19:04:10

laziness does not really come into play much (in terms of handling async callbacks)

georgek19:04:58

Heya, does anybody know how to go about reading the meta-data from an mp4 file/image file?

cupello19:04:52

Hi, which library should I use for connecting with Oracle DB?

akiva19:04:51

@lucelios, never had to do it myself but a quick search turned up https://github.com/funcool/clojure.jdbc.

base69820:04:57

I use that ^ I would not use Korma. Apparently there is also HugSQL, which I haven't personally used

donaldball20:04:30

I tend to use honeysql+clojure.java.jdbc

cupello20:04:35

Thanks very much!

nkraft20:04:38

@donaldball: That's the combo I use too. Or just clojure.java.jdbc. I have mixed feelings about piling one DSL on top of another.

yatesj920:04:51

If you need connection pooling I've used BoneCP, it works well. http://www.jolbox.com/

nkraft20:04:48

BoneCP is good. We use HikariCP, which was a huge improvement on C3PO.

yatesj920:04:27

I'll check that one out, see what's different

borkdude21:04:54

yesql + clojure.java.jdbc is what I have done in the past, but I heard there was some other library like yesql but better, don't remember the name