Fork me on GitHub
#clojure
<
2015-08-28
>
michaelr04:08:26

what's with that exception when running an uberjar?

michaelr04:08:27

Caused by: java.lang.ClassNotFoundException: com.stuartsierra.component.Lifecycle

michaelr04:08:54

i got it working in other projects but am getting it again in this one and can't figure what I'm missing this time

zentrope04:08:59

Is it in a dev profile?

zentrope05:08:58

Was just going for low-hanging fruit. Your component dep in the :dev profile rather than up top, etc, etc.

michaelr05:08:27

this is my uberjar section more or less

michaelr05:08:52

i have another 1.7 project which is built mostly the same and I don't get this error there

zentrope05:08:22

Try lein deps :tree and see if the dependency is included?

zentrope05:08:00

You could also try lein with-profile production deps :tree to see if that changes anything. (I think uberjar uses the production profile.)

michaelr05:08:05

it uses the :uberjar profile i think

zentrope05:08:52

Yes, but merges that into the production profile. In other words, the :dev profile is omitted.

michaelr05:08:02

can't get it to work

Pablo Fernandez08:08:51

Does anybody have a recommendation on libraries to make a pool of resources in Clojure? My goal is to have some objects that are slow to create, so I want to re-use them over time, but they are not thread safe, so no two threads should be using one at the same time.

Pablo Fernandez08:08:18

gsnewmark: do you know what’s the semantic of the key when acquiring and releasing objects?

gsnewmark08:08:15

as far as I understand it's just an id for the particular resource (type). For example, in aleph's HTTP client key is a hostname, and all connections to this host are stored under it

Pablo Fernandez08:08:20

Wouldn’t different resource types be different pools anyway?

gsnewmark08:08:44

aleph has one pool for all client connections, but each group of connections for particular host are stored under the different key. I suspect it's easier to specify maximum global number of connections this way, but it's definitely possible to simply create a separate pool for each resource type (and store all objects/resources under the same key). @ztellman can probably explain reasoning behind the key better than I

Pablo Fernandez08:08:50

I just want a single pool, it seems like I would just use one constant key.

ztellman08:08:18

that's fine, I just added the key in case it was needed

Pablo Fernandez08:08:45

Understood. Thanks.

Pablo Fernandez09:08:17

What I’m doing is creating ScriptEngines on a web app to run JavaScript on the server side. They are expensive to create and non-thread-safe. This is why I’m using a pool. But I feel the pool controller is very dependant on the implementation of the web server (whether it’s multithreaded, multi-process, event driven). I went for a fixed controller with a very high maximum, is this the right approach?

Pablo Fernandez09:08:46

@ztellman: I’m trying to understand the stats from the pool. Is the number of workers the number of objects in the pool?

erik_price11:08:21

Is there a version of comp that behaves like some->? (I.e., short-circuits and returns any falsey values.)

erik_price11:08:46

Right now I’ve got

#(some-> %
    zip/node
    :content
    first
    productpage-body?)
and it just looks nicer in my particular case as a comp. (In fact, it was a comp until I realized I was NPE’ing.)

kongeor11:08:56

@erik_price: What's wrong with that approach ? simple_smile

erik_price11:08:24

Well, it’s not the end of the world; it works. But I’ve got a series of predicates that look like this, as arguments to a call to every-pred, and since I’m not closing over any local environment, the anonymous function syntax is a tad misleading. I could just write a function that does something like some-comp but was curious if I was missing anything built-in.

Lambda/Sierra12:08:54

@michaelr: That looks like a problem with AOT-compilation and the way the Uberjar is assembled; possibly related to https://github.com/stuartsierra/component/issues/32

xificurC12:08:24

is datomic free available from some repo? Their page has a zip with all deps

upgradingdave13:08:14

hi all, anyone know of a lein plugin that will process doc/*.md files and create nice html documentation. I’m looking at codox and that looks nice for generating api docs from source code, but I’d also like to include my doc/intro.md in the generated html output as well.

Pablo Fernandez14:08:55

My clojure app running in heroku is throwing out-of-memory errors. Am I correct in assuming that I'm processing more requests than I can simultaneously with the amout of ram that I have?

Pablo Fernandez15:08:02

What would be the Clojure idiom to add key/value pairs to a hashmap only when the value is not nil? I’m constructing a hashmap of configuration and when the environment doesn’t specify a vaule, then it’s nil, but I don’t want an explicit nil, I want no key in the hashmap.

Lambda/Sierra15:08:33

@pupeno: I've done this on occasion (defn assoc-some [m k v] (if (some? v) (assoc m k v) m))

mpenet15:08:16

@pupeno: (reduce-kv (fn [m k v] (if v (assoc m k v) m) ) {:c 3} {:a 1 😛 2 :d nil})

mpenet15:08:41

it should ouput something like {:a 1 😛 2 :c 3}

mpenet15:08:47

damn smileys

Pablo Fernandez15:08:37

mpenet: in clojure you can use anything as keys, even emojis.

pbostrom15:08:07

you can also use into with a transducer: (into {} (filter (fn [[k v]] (some? v))) {:k1 nil :k2 1})

Pablo Fernandez15:08:44

@stuartsierra: that wouldn’t remove the taste of imperative this code has: https://gist.github.com/pupeno/23318a05d4920dcafc51

Pablo Fernandez15:08:15

it looks like a useful function though simple_smile

mpenet15:08:37

or merge and (partial remove (comp nil? val)), but the reduce-kv thing reads better imo

mpenet15:08:20

or cond-> and update-in, etc etc...

mpenet15:08:46

clojure is a bit the anti-python, there are 2mio ways to do the same thing

cfleming15:08:18

I believe that in Clojure, backslashes in regexp literals are not escaped like normal strings are - is that correct?

cfleming15:08:37

However I assume that they are when using re-pattern, since that accepts a normal string?

ragge15:08:54

@cfleming: that is correct, reader docs mention exactly this: "Regex strings do not follow the same escape character rules as strings. Specifically, backslashes in the pattern are treated as themselves (and do not need to be escaped with an additional backslash). For example, (re-pattern "\\s*\\d+") can be written more concisely as #"\s*\d+"."

cfleming15:08:36

@ragge: Thanks, that was what I was looking for, I was having a doc search blank.

ragge15:08:58

@cfleming: didn't mean that as a rtfm, http://clojure.org docs can be hard to navigate ime simple_smile

cfleming15:08:33

@ragge: No problem, I’m quite happy with an RTFM, but yeah - I’d searched for it but hadn’t found it.

malcolmsparks16:08:56

@pupeno: I'm late to the thread, but I use merge with when.

(merge {} (when foo {:foo foo}) (when bar {:bar bar}))
although I'm not sure if it's the most performant way

meow17:08:24

@whacked: @luxbock Not sure if you all are still interested in L-Systems stuff but I think I've figured out a good way to handle parametric and context-sensitive systems. I've got an example where I keep track of the age of items as they go through each iteration of the system. https://github.com/decomplect/ion/blob/master/src/ion/ergo/l_system.cljc

meow17:08:23

I made it very open-ended so pretty much anything can be added as a parameter and so lots of interesting things should be able to be done with these functions.

meow17:08:23

But I have this nagging feeling that I'm not leveraging transducers the way I should be...

Pablo Fernandez18:08:43

http://jarkeeper.com/carouselapps/to-jdbc-uri is claiming my library is depending on the outdated Clojure 1.6.0. Should I depend on 1.7.0 or 1.6.0? the library works with either.

malcolmsparks18:08:22

@pupeno I tend not to depend on any clojure version, but add a clojure dependency to lein's :dev profile so I can boot a repl

malcolmsparks18:08:36

that way your users get to decide

tel19:08:28

Is there a standard way to reference the env in a lein project.clj file?

tel19:08:46

#=(System/getenv x) fails since System isn’t in scope

nikp19:08:33

Weird that system isn't in scope. I use it in the project.clj file in the context of returning database info (e.g. ~(str "jdbc:postgresql:" (System/getenv "DATABASE_URL") ...

nikp19:08:11

perhaps it's in the difference between #= and ~ when it comes to evaluating in project.clj, but I don't fully know

tel19:08:49

maybe! I’ll try ~

tel19:08:17

it looks like the :env/foo-bar-baz symbols might be available everywhere

tel19:08:28

not just in the :repos map

tel19:08:09

oh, or maybe not

tel19:08:59

#=(eval (System/getenv x)) there we go!

troydm20:08:17

is there a clojars statistic somewhere? like which libraries are most downloaded etc

dominicm21:08:31

@troydm: https://libraries.io/clojars has some stats. But they're not great yet(tm)

tel21:08:49

Is c3p0 the current recommended way to do database pooling?

tel21:08:22

the additional notes here seem to say otherwise

tel21:08:29

but the link out is missing?

troydm21:08:09

dominicm: ic, thx

troydm21:08:32

tel: no need to use clojure.jdbc-c3p0

tel21:08:43

gotcha gotcha

serce22:08:09

Does anyone has pdf version of Clojure Data Structures and Algorithms Cookbook book?

tel23:08:44

anyone know why I might be running into SQLException Too many update results were returned on a one statement migratus migration?

juhoteperi23:08:24

@tel: Check HikariCP

tel23:08:57

I’ll try it out

juhoteperi23:08:08

It has a Clojure wrapper also

tel23:08:39

tomekw/hikari-cp, sweet