This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-03
Channels
- # admin-announcements (2)
- # beginners (18)
- # boot (118)
- # cider (12)
- # cljs-dev (12)
- # cljsrn (24)
- # clojure (142)
- # clojure-art (4)
- # clojure-bangladesh (3)
- # clojure-ireland (1)
- # clojure-italy (7)
- # clojure-norway (4)
- # clojure-poland (207)
- # clojure-russia (101)
- # clojurescript (108)
- # clojurewerkz (2)
- # core-async (6)
- # css (8)
- # data-science (23)
- # datomic (31)
- # devcards (2)
- # emacs (8)
- # funcool (25)
- # hoplon (34)
- # immutant (78)
- # ldnclj (7)
- # lein-figwheel (4)
- # leiningen (6)
- # luminus (35)
- # off-topic (1)
- # om (119)
- # onyx (43)
- # parinfer (29)
- # proton (11)
- # re-frame (25)
- # remote-jobs (1)
- # slack-help (1)
- # spacemacs (3)
- # yada (10)
@codonnell: thanks!
no problem
mattly: fwiw I needed that once and never found a library, just ended up writing a function to generate query params manually
can someone help me with my regex issues? I’m trying to extract out everything within square brackets into capture groups:
"hello" -> (“hello”)
“hello there” -> (“hello there”)
“hello there [foo,bar]” -> (“hello there” “foo” “bar”)
@jethroksy: what do you currently have?
right now I’m just concerning myself with separating the stuff in brackets from the stuff that aren't
yeah, \s+? means one or more whitespace
it sounds like you want everything before [
([^\[]+)\[
though you might not have the [
despite the documentation on lein-migratus, i don’t seem to be able to understand what it does
the only times i’ve gotten it to work is by deleting my old tables, then running $ lein migratus
I am trying to load a bunch of files in a folder while in a jar. I found this: http://stackoverflow.com/questions/11012819/how-can-i-get-a-resource-folder-from-inside-my-jar-file
They do this though:
final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
How to I call getClass() from Clojure? I assume it implicitly hits a class but which one?
Basically i am missing a reference to “this” in Clojure, which is implicit in the above
Anyone here using aleph/manifold in production for web servers? any comments on performance compared to the usual compojure/jetty/ring stack one would get with (for example) Luminus?
@shanekilkelly: you may be interested in #C0702A7SB also
@nha, indeed, meant to mention yada in the post above i’ve been looking at yada/bidi/aleph/manifold recently and would be curious to hear from anyone who has deployed a similar stack in production.
I’m most interested in high-performance and massively concurrent clojure network servers, think the kind of thing Go or Node.js are commonly used for.
what's the fastest way to concatenate 2 vectors ?
What comes to mind for me is (reduce conj v1 v2)
@rm I meant the fastest way performance-wise
@codonnell: (into x y)
would use transients
@rauh: nice, that is a better solution
Does anyone know of a ring middleware to handle a file upload, where the file is in the body of the request itself; i.e. it's not multipart form encoded? I need it to also buffer into a tempfile; or at least not load the body into memory, because it may be several GBs
@rm yes, that's why I'm asking!
@rauh: thanks, that's what I wanted to know
@rauh exactly what I needed to know
@octo221: you can use into
oh, you got it
resolve
for the current ns, or ns-resolve
with the ns as argument
hey @rickmoynihan: by what means is your upload occurring- not through a file button on a web page? file uploads are included in request bodies; the multi-part form encoding is the format of the request body data.
@jonahbenton: it's for an API - not a web form... not actually tried it yet but yeah it looks like ring just puts an inputstream in the :body for you - which is fine
What is ^ symbol in Clojure? Example:
(defn get-elmt [activity elmt]
(str (.getText ^TextView (find-view activity elmt))))
I'm using duct with a reloaded workflow. Everything was working great until I did a windows update and restarted my computer. Now when I attempt to start my system I get an exception
duct.component.handler.Handler cannot be cast to clojure.lang.IFn
i know it's a long shot but does this look familiar to anyone?jjttjj: the full stacktrace will have more information about what line the error occurs on, but somewhere you have an instance of Handler that you are trying to invoke as a function
More of an opinion, but which do you feel is a better signature for an API that calls an underlying Java API with 3 different overloads, each with drastically different behavior (yes, the underlying api is badly designed). Bear in mind that this will be adapted to work on a protocol:
I personally feel the cond is a bit of an anti-pattern in a lot of cases, but there's a few libraries I've found doing similar things to support/prefer passing maps as args
I think it would depend on how drastically different the behavior is
are you talking the difference between a pure function and something with side effects?
they return the same result type, but consume different parts of an iterator
so essentially they filter out results from an iterator
If it were up to me, I wouldn't do that at all, but it isn't my lib
we already have functions in clojure.core that are like a partial application when called with a lower arity
not sure if it’s anything like that
no, I guess not
nope , but looking to clojure.core is always where I start
you said they all have the same return type but do different things with the iterator
yup, that's right
can you think of a single function name that describes all three implementations accurately?
well a comment will suffice and keep it close to the original api if I just use a 3 arity definition on a protocol
if you’re never going to call it with apply or anything like that I would just use differently-named functions
also this may be getting called a few thousand/100k times a second
so I would think using apply would just slow you down considering this is for high performance
also the dispatch for 3-arity is a bit more efficient considering they each call a distinct java overload
just a bit of duplicated conversions in 2 of the arities I think
but 1 extra line of code shared between the 2, no big deal and probably the way to go for performance
yup, will do
on that subject, is there a significant overhead instantiating a collection of records vs maps, assuming the record is just a container, and probably the result set is immediately going to have 1-3 lookups on top-level keys?
assuming you'd be getting back say, anywhere between as little as a few, and as much as a few thousand per collection
Are toplevel do blocks special to the Clojure compiler? It seems to confuse cloverage, and I could see how the compiler just elides them...
I would expect a more compact memory footprint for the records, but maybe other penalties I haven't thought about
hugesandwich: you should measure if you really care. Small maps are the most efficient because of PersistentArrayMap
@ghadi Yeah, planned to for sure, I always try to measure, but thought I'd ask if it's stupid to even waste the time
kind of hard to know because it depends heavily on the data volume of api users
and I can mess with batch sizes to further complicate things
lvh: they are, the compiler treats each expression in a top level do as a top level form
OK, I think I found it: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6001-L6003
I think I’ve asked this before, but can anyone remind me why (#())
evals to ()
?
@chancerussell: (macroexpand '#())
-> (fn* [] ())
That would explain it Thanks @mtkp
is it bad programming to have a lazyseq perform side effects to construct itself as it's read?
hiredman: sorry just scanned the text, that looks ok if i want to materialize the whole result set in memory, or aggregate the whole result set, but there's no reduction in my work, I'm doing db in -> map -> db out
you should read it more carefully then, it is entirely about reducible collections being a better way to represent resources as collections that you don't want to be entirely in memory at once
db out -> map -> db out is reduce
(reduce (fn [db row] (insert db (f row))) db (query db))
the write up is dated, because 1.8 and 1.7 brought new useful reduce and transduce stuff, which you could use to improve in various ways what is in the write up, but what is in the write still works great, and is an improvement over representing resources as seqs
hiredman: nice yah i'm going to start implementing this, i guess i lucked out you had a write-up to my exact question 😉
the only thing the abstraction doesn't necessarily handle gracefully, is the lifecycle of the db out
if i'm reducing db in, I can have coll-reduce easily manage the lifecycle of the db connection
you might want to look at the new clojure.lang.IReduce and IReduceInit interfaces (I think added in 1.8) instead of implementing the CollReduce protocol
transduce lets you provide a reducing function with 3 arities, with which you can do something like
(fn ([] (open-db-connection)) ([conn] (close-db-connection conn)) ([conn value] ...))
hiredman: "When to use Use the reducer form of these operations when: Source data can be generated and held in memory Work to be performed is computation (not I/O or blocking) Number of data items or work to be done is "large""
that reads like the kind of restrictions you would put on the reducers concept of "fold" because of the way it does parallel computation
if you look at http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html (linked from the write up) under the heading "More Opportunity (i.e. Work)" rhickey explicitly called it out as a mechanism for solving "the lazily dangling open resource problem"