This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-24
Channels
- # announcements (6)
- # beginners (89)
- # calva (75)
- # cider (37)
- # clj-kondo (1)
- # cljs-dev (19)
- # cljsjs (8)
- # clojars (1)
- # clojure (122)
- # clojure-europe (6)
- # clojure-italy (41)
- # clojure-nl (18)
- # clojure-uk (24)
- # clojurescript (26)
- # cursive (6)
- # data-science (5)
- # datomic (51)
- # emacs (28)
- # fulcro (8)
- # graalvm (13)
- # hoplon (1)
- # immutant (1)
- # jobs (3)
- # joker (1)
- # keechma (43)
- # lambdaisland (1)
- # leiningen (37)
- # midje (1)
- # nrepl (2)
- # off-topic (32)
- # re-frame (3)
- # reagent (24)
- # reitit (5)
- # remote-jobs (1)
- # shadow-cljs (33)
- # sql (7)
- # tools-deps (11)
I am pretty sure that if you exceed the Xmx limit that the JVM will eventually fail a new call, if the process needs that much non-garbage data all at one time.
Hum... I think its because I'm not able to generate distinct fns. It seams this: (repeat 10000 (partial io 10 (rand-str 5000)))
will just generate 10000 times the same fn
It may very well do GC more often than otherwise for some time before that allocation failure occurs.
I tried (repeatedly 10000 #(partial io 10 (rand-str 5)))
but it also seem to generate the same fn
Consider:
(repeat 1000 (rand-int 10))
(repeatedly 1000 #(rand-int 10))
(race condition!)repeat
should return a sequence of the same object in memory, i.e. many references to one object.
The repeatedly
expression above will probably only create one anonymous function object.
user=> (map (fn [[x y]] (identical? x y)) (partition 2 1 (repeatedly 5 #(vector 1 2 3))))
(false false false false)
The anonymous function returning a vector of 3 elements should be creating fresh vectors each time it is called, according to the results of calling identical?
on pairs of them.
This variant does return the same object each time:
user=> (map (fn [[x y]] (identical? x y)) (partition 2 1 (repeatedly 5 (fn [] [1 2 3]))))
(true true true true)
I was surprised to see the fn's sharing the underlying class... the closures just became another parameter (a const, but still)!
Repeatedly is not pointing to the same memory location, just sharing the same base class!
Because you believe that is what your original problematic code may be doing?
You mean, you want a unique fn in order to create a test case that uses more memory, for testing purposes?
;; (repeat 2 (partial str "fn-" (rand-int 1000)))
Class: clojure.lang.Repeat
Contents:
0. clojure.core$partial$fn__5841@4b70e79a
1. clojure.core$partial$fn__5841@4b70e79a
;; (repeatedly 2 #(partial str "fn-" (rand-int 1000)))
Class: clojure.lang.LazySeq
Contents:
0. clojure.core$partial$fn__5841@40a3a985
1. clojure.core$partial$fn__5841@3a46439e
Well, it seems I'm failing to make any of them fail. I was pretty sure that a fixedSizedThreadPool would eventually out of memory if you queued up too many tasks since its queue is unbounded
Could be. You could try sticking a sleep 1 second inside of them.
Using deps.edn, If I don't have a "main" class, how can I run an arbitrary function in my classpath? In my case in my app namespace (not a genclassed namespace) I have two functions, one for "run-server" and "run-dev-server" and I want one alias to run my-ns/run-dev-server
and the other run my-ns/run-server
@theeternalpulse You can use the -e
option to run any Clojure expressions.
I have something like this in my alias :dev-server {:main-opts ["-e" "(
clj -e "((requiring-resolve '
You need to require the ns before you can use it.
ok got it workign with :dev-server {:main-opts ["-e" "(require,'[
@theeternalpulse Are you not on Clojure 1.10?
What I suggested above will work on Clojure 1.10.
let me update my deps, i'm using RELEASE
(but wonāt work on earlier versions)
"RELEASE"
should bring in 1.10.1 at this point.
I htought resolving-require was your way of saying to use the require statement š
requiring-resolve
is a core function.
let me see what's going on
:dev-server {:main-opts ["-e" "((requiring-resolve,'))"]}
to match what youāre actually trying to do.ah, earlier you wrote resolving-require
The nice thing about requiring-resolve
is that a) itās all-in-one b) itās thread safe. Oh, sorry, was typing on the small screen.
Will edit that. Fixed.
very nice works like a charm
glad I watched your deps video or the commas would have got me
The āCorfield Commaā? š
in the future will it accept regular edn?
,
is whitespace ā even in EDN I believe?
At some point I expect a fix will be figured out. Itās a hard problem. You should see what you have to do on Windowsā¦ :shocked_face_with_exploding_head:
Found the cmd-invoking-powershell example ā¦
powershell -command 'clj -Sdeps "{:deps {viebel/klipse-repl {:mvn/version """"0.2.3""""}}}" -m klipse-repl.main'
it's not too bad, since I can just make a task function
Ah, yeah, here we go āCommas ,
are also considered whitespaceā ā https://github.com/edn-format/edn#general-considerations
So it is regular EDN already š
true, I guess I meant something that could be parsed inline wiht edn so you can do :dev-server {:main-opts ["-e" '((requiring-resolve '
no biggie, just curious
iād like to build a website. is there any battery-included framework so I can reduce the development time?
I'm kind of busy with something as a pet project. The idea is to run the app locally, you can log in, upload photo's, create documents. And it can spit html in such a way it integrates nicely with Netlify. It's mostly on hold now because it's using spec a lot, also to generate the HTML/js. So want spec 2 to stabilize before going further.
there are a few
depends a bit on what you want, do you want to do a single page app, and therefore want a way to build APIs, or do you want a html-spitting webserver š
Iāve seen this being recommended: https://github.com/coast-framework/coast, but I donāt think that provides an admin, its also of the āhtmlā-spitting kind (although you are free to not do that)
Theres also this: https://github.com/juxt/edge
@i Clojure really isn't about "battery-included framework" websites. I don't think Coast or Edge will be close to what you're looking for -- but that's not Clojure's strength TBH.
There are some fairly comprehensive templates tho'...
There's no CMS systems in Clojure, as far as I know.
ah yeah, I was instantly reminded of django when you asked
Luminus might be the closest, in terms of templates. Uses Selmer by default (inspired by Django). Still not anything close to a CMS tho'.
I would not expect to find such pre-built components in the Clojure world.
http://www.hyperfiddle.net/ might be another option
If I wanted a CMS for a site, I'd go with Wordpress/Django/Joomla/etc as a packaged solution. I see no point in building such a thing myself...
hello guys, how do I convert curl -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST '
to the clj-http library (client/post "
?
you can write the params as the body
or using form-params
, check: https://github.com/dakrone/clj-http#post
I tried it like this
(client/post "
but I got
Execution error (ExceptionInfo) at slingshot.support/stack-trace (support.clj:201).clj-http: status 400
the problem is, that it's influx inline protocol, every comma count, and the timestamp at the end aswell. So I would need to send this in string, is this possible?
yes, this is right, I forgot my timestamp from the first example. But anyway, is it possible to send my request in a string form, without using a map?
looking at the examples it looks like doing what you did is correct https://github.com/dakrone/clj-http/blob/70df5add2a565a87d2ac79b39e90f777999babc0/examples/logging-apache-requests.clj#L22
the 400 seems to suggest an error sent by the server, rather than stemming from the client. I'd suggest you print out the request from the server and compare the request from curl vs the one from clj-http. As a tip you can add :throw-entire-message? true
to the options map of the request to see if the response had more of a message for that 400
Thank you very much, tavistock saw my real problem, I mistyped the url... so amateur mistake. (http/post "
this was the good solution, thank you very much.
Hey is there a standard nomenclature for the function that gets passed into reduce? 'Aggregator' doesn't seem quite right.
it's usually called a reducing function :)
Thanks.
In the greater functional world I hear "reducer" a lot. ĀÆ\(ć)/ĀÆ
in clojure, reducers are a specific thing https://clojure.org/reference/reducers
Neato, thanks! ^_^
both clojure.core/reduce and the clojure.core.reducers are about doing the thing general fp calls "reducers", but inevitably we have more specific concrete details beyond what that implies in the theory world
Actually 'aggregator' seems to me like a better description of what a reducing function does, but it's good to know the standard terminology.
I thought the accumulator was the value that's returned by reduce
Just so
if we were to be pedants about grammar, it's surely the accumulated object, not the thing performing the accumulation
Yeah, but isn't there part of a CPU called the accumulator? My sense is that it's a call-back to that.
yeah - it's a historical name