This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-27
Channels
- # beginners (22)
- # boot (652)
- # boulder-clojurians (1)
- # cider (19)
- # cljs-dev (3)
- # clojure (158)
- # clojure-dev (8)
- # clojure-nl (1)
- # clojure-poland (5)
- # clojure-russia (27)
- # clojure-sg (3)
- # clojure-za (4)
- # clojurescript (44)
- # community-development (2)
- # core-async (17)
- # core-logic (10)
- # css (1)
- # cursive (35)
- # data-science (5)
- # datascript (1)
- # datomic (90)
- # editors-rus (3)
- # events (3)
- # hoplon (90)
- # ldnclj (19)
- # lein-figwheel (2)
- # leiningen (1)
- # om (225)
- # reagent (1)
- # uncomplicate (27)
anybody know if it's possible to reify
or deftype
an interface that has both overloaded methods and void return types? (https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/ssl/X509HostnameVerifier.html)
@danboykis: does type hinting the arguments help? I've had to do that before for proxy
@xeqi: I tried type hinting but it doesn't work
(reify X509HostnameVerifier
(verify ^void [_ ^String h ^javax.net.ssl.SSLSocket s] nil)
(verify ^void [_ ^String h ^java.security.cert.X509Certificate s] nil)
(verify ^void [_ ^String h #^"[Ljava.lang.String;" a "[Ljava.lang.String;" b] nil))
Here's the error: CompilerException java.lang.IllegalArgumentException: Mismatched return type: verify, expected: void, had: java.lang.Object
@danboykis: https://github.com/dakrone/clj-http/blob/master/src/clj_http/conn_mgr.clj#L30
also watch out for the # in #^"[Ljava.lang.String;"
incase that wasn't a copy/paste error
@danboykis: Thanks!
A tip request please: How can I concat a set of large csv files into one. I need rows identified as duplicates removed (i.e. filter (some #{s} (get row 1) ) Each file is has no duplicates, actually, only between the files can duplicate rows appear. The order of the final outputs isn't crucial, but matching a sequential scan of the files would be preferred.
hi all - is there any way to make a project using cljc backwards compatible with Clojure 1.6?
@dnolen thanks for confirming my suspicion. Was looking at using cljc to make core.matrix work with ClojureScript, but I guess it will have to wait until we can drop 1.6 support... maybe after the Clojure 1.8 release
What's currently the most active / wide spread web framework? I used plain ring before but was wondering if there's something better out there
@dvcrn: If you’re looking for something that is batteries included then I would say it is probably https://github.com/pedestal/pedestal
Hi! Question about Loom graphs. I’ve got a collection [:origin A :targets [B C D]]
, and graph takes a collection [node [edges]]
… how do I transform my map to the right data structure? There’s gotta be an elegant way to do this that I’m missing out on.
Here’s an example data structure: https://gist.github.com/LusciousPear/febbd458c4e1e35979de
@dvcrn: I've used liberator a lot http://clojure-liberator.github.io/liberator/
Does anybody know if it’s possible, with yesql to construct queries where you have more than one set of values?
Im trying to download a bunch of iTunes Connect Sales reports quickly so I can assemble an overview of the mobile apps on an iTunes app store account. (Im doing this because Apple doesn't seem to provide and API to just query the list of mobile apps and their properties, like release dates of their versions, etc) It means I need to do a bunch of HTTP GETs in parallel to get it in a few seconds. Serially it would take minutes (for an account with 50+ apps of which many might have 3+ years history). What tools would you recommend to approach this problem, if a, I want to handle errors b, so I can retry downloads c, persist the state of the downloads, so I can pick it up later (and also retry the failed ones later)
I know there is https://github.com/ztellman/manifold/ which would allow me to wire together some download queues, but I suspect the simplest result could be achieved by using core.async
.
d, for later use I would also cache the report files in S3 and/or disk, so to have it close to the CPUs processing it
is there any example which does a similar "mirroring" or some website with adjustable HTTP request parallelism and something like a backing off retry? i would think this is an often solved problem
what im not clear about is where and how can i insert some throttling... like how can i say i want max 50 http request to be active at once
something like eachLimit
from https://github.com/caolan/async#each
> <name>Limit - the same as <name> but runs a maximum of limit async operations at a time
@onetom: this is an async client I help maintain, it has connection limiting: https://github.com/cch1/http.async.client
it's a wrapper around https://github.com/AsyncHttpClient/async-http-client
but in this case the order doesnt matter, however things i put in a core.async chan would be in order, no?
this is a nice lib with multithreaded utilities, especially for doing unordered parallelism https://github.com/TheClimateCorporation/claypoole
i suspect i dont really need threads in this case, since the problem is not CPU but IO bound and separate threads would just increase mem usage, no?
i might even need to slow requests down to make sure im not hitting some per-IP address throttling on iTunes Connect side....
the sales reports im downloading are just few 10s of kilobytes of gzipped tsv which i want to a, pump into Datomic b, backup the original gzip into S3
yeah, I take back the claypoole suggestion, if you use an async client, the callbacks are going to run on their own thread anyway
it's fairly easy to do with core.async, you can use a channel for rate-limiting (it provides request "token" when you can perform one, handles the pauses etc)
if you google core async throttling, rate limiting etc you ll find a few starting points
then if your client has a core.async interface it's should be very quick to put together
or just use a blocking http client and a fixed threadpool (or a client that allows you to specify these things)
@pbostrom: how does https://github.com/cch1/http.async.client compares with http://www.http-kit.org/client.html ?
I would stay away from http-kit (it's barely maintained) and I have no experience with http.async.client
there is aleph which is mentioned together w manifold usually if u need some networking, but iirc it was just interfacing with clj-http?
http.async.client uses a promise-based model. I think http-kit is callback-based. There are also big differences in the underlying libs. http.async.client is based on ning’s async Java client which in turn uses netty.
aleph does not have what I would call an traditional http client -it’s more of an HTTP client tool kit.
also saving a few kbs from what will certainly be a multi mb jar in the end, with a gigantic runtime in the background, sounds a bit useless.
I’ve had overall good experience with http-kit in production but updates are infrequent and the issue tracker is swamped. Once things slow down around work I’m thinking about trying to contribute / fork it.
On that note (active development), I can definitely vouch for the underlying libs behind http.async.client -the ning client is very actively maintained -as is netty. The clojure wrapper itself (the lib @pbostrom and I are maintaining) had been neglected until earlier this summer when we ramped up its support again.
tbh we also had some issues w http-kit. my colleagues said it's better to look for http-kit documentation in some other project's examples (forgot what it was) then its own docs.
But, while it had not been actively maintained, it was rock solid in production for us for years.
mpenet: where is your avatar from? https://avatars2.githubusercontent.com/u/106390?v=3&s=400
anyone have an example application using danielsz/system? im probably just missing something, but i want to see how other folks tackle injecting stub dependencies for unit tests
currently im doing something like (alter-var-root #’system #(assoc % :component stub))
in my test, but im not sure this is the right way
pssst how do I change [:a 1 :b 2]
into {:a 1, :b: 2}
… into {}
isn’t working how I’d expect
BTW, the answer to my question, how do I turn https://gist.github.com/LusciousPear/febbd458c4e1e35979de into a graph? it’s
(graph (apply hash-map (reduce into
(map (juxt :origin :targets) (:edges a-graph)))))
yaknow, when I wrote a SQL Database, I wish I had done the query planner/parser/optimizer in clojure instead of java. prolly woulda saved me 90% LOC 😛
@onetom: you mentioned retrying failures, picking up where they left off. It sounds like hara.event
could be useful there. It's a bit of a paradigm shift to use "events" (a la "conditions" in Common Lisp) instead of exceptions, but it sounds like it addresses your need well. http://docs.caudate.me/hara/hara-event.html
@jeff.terrell: thanks for the pointer. (not directly related, we are using http://docs.caudate.me/adi already, btw
Hmm, I hadn't seen that, looks interesting, thanks!
chouser will be doing a talk about conditions at the Conj btw http://clojure-conj.org/speakers#chouser
Oh, very cool!
I'm writing a macro and I receive a list of arguments, and I need to apply some postprocessing to them (a when
check). What's the right way to do that? I want to not have a loop in resulting code ideally
@jstokes: Not that I've spent much time on this, but to me it sounds you just want to define a test-sytem, along a dev-system or a prod-system, and start it as first thing in your test runner, and destroy at the end.
Is there anything like this in the standard lib? (defn split-by [pred coll] [(filter pred coll) (remove pred coll)])
Alternate implementation: `(fn [pred coll] (let [m (group-by pred coll)] (map m [true false])))`
probably would just do it with a reduction if you want to only traverse the collection once
Naming—as is so often the case—is the trickiest part. I’m not sure it’s quite a split, the way Clojure uses the term. But I’m not sure what I’d call it as partition function.
Rolling with this for now:
(defn pred-partition [pred coll]
(map (group-by pred coll) [true false]))
If anyone has a great idea for a name, I’d appreciate it. Why do you need to wrap group-by
? Is it that you explicitly want the true values first in the resulting sequence?
hello guys, when I create codox documentation, can i specify a lein profile?
mdaines: It doesn’t have to be first, per se. Sample use case: splitting xml nodes into those of a certain tag, and all others. I want both lists. So I’m destructing into two bindings. Something like (let [[links nonlinks] (pred-partition nodes (tag= :link))] ,,,)
.
It feels a little odd to use the boolean as a key, but this works:
(let [{odd false even true} (group-by even? (range 23 43))]
odd)
Haha, was about to paste this:
(let [{odds true evens false} (group-by odd? (take 4 (range)))]
[odds evens])
@camdez: regarding a name, maybe separate-by
? Or maybe bifurcate
?
@asolovyov: not really sure what you're trying to do.
@jeff.terrell: I’m kind of fond of bifurcate
, thanks. But as per discussion with @mdaines, I think I might just roll without.
Destructuring the group-by
has a hint of cognitive overhead, but not enough that I’m yet ready to introduce a new name (/ concept).
Fair enough. :thumbsup:
POCO: Plain old Clojure object
Is there a convenient means of mocking a db instance with monger? The web site states that there’s “unit test support” but I’ve yet to find any documentation that goes further into this.
Is there a version of walk that only operates on the values themselves? I thought specter would have this, but it doesn't, which is a shame.
Take a look at the source for clojure.walk/stringify-keys
— is that along the lines of what you’re trying to do?