This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-25
Channels
- # aws (1)
- # bangalore-clj (1)
- # beginners (15)
- # boot (4)
- # clara (7)
- # cljs-dev (7)
- # cljs-experience (3)
- # cljsrn (1)
- # clojure (143)
- # clojure-austin (2)
- # clojure-germany (1)
- # clojure-italy (11)
- # clojure-serbia (11)
- # clojure-spec (96)
- # clojure-uk (20)
- # clojurescript (70)
- # community-development (58)
- # cursive (14)
- # data-science (1)
- # datomic (45)
- # events (2)
- # fulcro (19)
- # jobs (5)
- # jobs-rus (2)
- # off-topic (40)
- # om (24)
- # onyx (3)
- # parinfer (52)
- # pedestal (6)
- # protorepl (38)
- # re-frame (15)
- # reagent (11)
- # ring-swagger (5)
- # specter (37)
- # sql (3)
- # unrepl (3)
- # vim (1)
yes and no
the latter could easily be yes if people stopped using with-redefs actually (and it isn't hard to stop using with-redefs and make a new runner that goes in parallel)
I guess the output as you go would be tricky maybe...
I thought with-redef was thread safe? Or is it just that it restores the original def when leaving its scope?
with-redef effects all threads, and you can avoid it by making code that isolates pushes side effects to the edges and takes other parts of the app as an explicit argument so that "mocking" simply consists of passing a different function in
eg. component makes it very easy to write your system this way
I like lisp () for everything except for math notation. Is there a nice way to embed a math DSL in lisp notation, or are the two mutually exclusive ?
@qqq I've seen several examples of infix
macros that accept "normal" math DSLs and convert them to prefix notation
I thought there was one in Joy of Clojure but I just searched it and didn't find it.
Clojure in Action 2nd Ed has one...
...but it's overly simplistic.
Did you mean the one in Clojure for the Brave and True? https://www.braveclojure.com/writing-macros/
@qqq it might be an interesting project to see if you could create a math dsl using tagged literals. https://stackoverflow.com/questions/20677055/define-my-own-reader-macro-in-clojure
Took me a bit to get my head round it, but once I did I find it clearer and easier to work with than the normal notation
hmm, so the idea is that as long as my 'math dsl' also happens to be a syntacticaly valid sexp, I can just convert it from infix to prefix via . a macro? the limitation to this approacy is that instead of writing x+y I would have to write x + y right? basically sprinkle in many spaces to make it all separate into the right symbols
What is your experience about profiling Clojure app on production. I mean solutions like https://sentry.io for logs but to answer how much memory, CPU etc. it use. I was very excited about https://stackify.com/retrace/ because of good marketing articles, but on the end in my experience when i sent to it logs and got “success” no logs appear in panel. I was trying and trying… so in my opinion this tool is not enough mature at that moment. Can you recommend something?
*i need something free/cheap for small hobby project and the best if i don’t have to host it myself, but on the end i can 🙂
@kwladyka https://newrelic.com/java try this one, really good like a monitoring service and also they can do stress tests for java-based applications
I’m using only newrelic and it is more than enough for me) if i remember something i will update this thread
How can I forget) There is another service - https://www.datadoghq.com/
i am trying to understand why datadog has integration with new relic. Why? I want to understand which tool is for me, but this make me even more confuse.
now i use http://sentry.io for logs and alerts, today i started search solution to know how much memory and CPU app needs and soon i will do metric about how long operations take
datadog is more generic service for collecting and visualizing data from different places. One of this places can be NewRelic. It makes migration from NewRelic to Datadog much more simpler. Both of them can cover use cases that you just described but requires different integration strategies in you code. But as long as you are using http://sentry.io (which has an integration with datadog) I can recommend to check datadog first. For your case you should install, configure and start datadog agent on your servers (information about CPU, memory, IO and network traffic will be collected without any additional steps). For the second part you should check for the library that can send events to datadog servers directly from your code and follow the guides about integration on code level.
If I wanted a version of postwalk
that treats maps as a discrete element rather than a set of key-value pairs is there any better way than creating my own version of walk
with a clause like (map? form) (outer form)
that seems to work fine and, other than the minor duplication & variation of a couple of library functions, not be a lot of hassle
@sandbags postwalk
calls the function for the maps also, so just check inside the fn if the value is a map
@juhoteperi my experience is that it uses map
to walk the map and so i get a call to the function for each keypair, as a vector, which is indistinguishable from any other vector
@sandbags It calls the fn with both
Check (clojure.walk/postwalk (fn [v] (println v) v) {:a 1 :b 2})
Right but i don't want it calling the function with vectors of keypairs from inside maps
Oh right. Yes, kw pairs are indistunguishable from vectors.
Bit confused by some behaviour I'm seeing for sorted-map-by
with maps w/ namedspaced keywords
namespaced keywords are sorted lexicographically on their namespaces, then on the names
@bronsa In 1.9 alphas, there seems to be a bug:
boot.user=> (sorted-map-by (fn [k1 k2] (doto (compare k1 k2) (prn k1 k2))) :db/ident :foo :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db/index true :db/unique :db.unique/value)
13 :db/valueType :db/ident
-6 :db/cardinality :db/ident
10 :db/index :db/ident
-13 :db/index :db/valueType
12 :db/unique :db/index
-1 :db/unique :db/valueType
6 :ident :cardinality
6 :index :cardinality
10 :index :ident
12 :unique :ident
12 :unique :index
13 :valueType :ident
13 :valueType :index
1 :valueType :unique
#:db{:cardinality :db.cardinality/one, :ident :foo, :index true, :unique :db.unique/value, :valueType :db.type/string}
This behaviour is different from 1.8:
boot.user=> (sorted-map-by (fn [k1 k2] (doto (compare k1 k2) (prn k1 k2))) :db/ident :foo :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db/index true :db/unique :db.unique/value)
13 :db/valueType :db/ident
-6 :db/cardinality :db/ident
10 :db/index :db/ident
-13 :db/index :db/valueType
12 :db/unique :db/index
-1 :db/unique :db/valueType
{:db/cardinality :db.cardinality/one, :db/ident :foo, :db/index true, :db/unique :db.unique/value, :db/valueType :db.type/string}
user=> (def a (sorted-map-by (fn [x y] (println x y) (compare x y)) :a/b 1 :a/c 2 :a/d 3))
:a/c :a/b
:a/d :a/b
:a/d :a/c
#'user/a
user=> a
:c :b
:d :b
:d :c
#:a{:b 1, :c 2, :d 3}
@bronsa Took me a minute to get my head round what you were saying there. I get it now, thanks!
Anyone have any experience using clojure to stream video files w/ http? preferably with ranges and stuff taken into account as to not force the browser to download the whole video
@sandbags you can walk data structures with more precise semantics and performance much greater than postwalk
with specter. Here's a path that replicates postwalk
:
(def walker
(recursive-path [afn] p
(cond-path (pred afn) STAY
coll? [ALL p]
)))
and here's one which for maps only walks the values:
(def walker2
(recursive-path [afn] p
(cond-path (pred afn) STAY
map? [MAP-VALS p]
coll? [ALL p]
)))
to do something like increment all numbers, it would just be (transform (walker2 number?) inc data)
to get a vector of all numbers, it's (select (walker2 number?) data)
@alice - Haven't done anything with Clojure for that, but I know a lot of HTTP streaming (including Netflix) is done with the "DASH" protocol. https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP
Hi guys! not clojure specific request but community one i'd appreciate it if you participated in vote https://www.reddit.com/r/Clojure/comments/6vxqro/lets_settle_this_vote_slack_vs_other_platforms/ So many complaints and useless posts i wanna do something about it and a lot of people want something to be done. Lets vote and see how we all stand on the topic and consider our options 🙂 thank you
I dunno, as much as I prefer irc, I find this sort of thing ridiculous. A vote presupposes some kind of body able to move with a single purpose. Which the "Clojure Community" is not. The clojure slack wasn't created because of a vote, it wasn't created by rich or anyone in clojure/core (as far as I know). It was created by some guy, and then people joined. In effect people have already voted.
of course, in variably these polls are put up by people who prefer whatever isn't being used at the moment
"oh, we aren't using the tool me and my friends prefer, so the will of the people is being flouted, we need a vote"
having used slack day to day at work I find it incredibly frustrating, but that's mainly because I'm expected to rely on it despite the massive noise for actual pertinent information. Also no one uses threads at work -_-
but for information gathering I think it's fine, though forums make it more visible to people that tend to answer more than ask
@nathanmarz thanks, yes, I had forgotten about specter even though I have played with it a little and think its a good thing.
i confess i don't follow your examples or how i'd translate to my use-case but probably i should go back and read the Specter docs again
Anyone care to offer advice on using Kafka? In particular with the Streams API
A general reminder -- to @lepistane and anyone else who cares about which communication platform is used -- that discussion belongs in #community-development (and has been happening there, on and off, for close to two years).
@sandbags yea recursive paths are more advanced usage but easy once you learn the concepts
happy to walk you through it in #specter
When I try to call this in repl (.sleep (Thread/currentThread) 2000) O've got an error : IllegalArgumentException No matching method found: sleep for class java.lang.Thread clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:53) After read java api about Thread I was found that there are 2 sleep method to call First one with one long argument and second with long and int arguments. When I try to cast to long I get same effect:
what should i do to call in clojure this one in java : Thread.currentThread().sleep(2000)
How does Thread/sleep
work differently than Thread.currentThread().sleep()
? It looks like they both sleep on the current thread.
no need for currentThread
, since javadoc for sleep
says: Causes the currently executing thread to sleep
said another way, it makes little sense for a thread other than the currently executing thread to sleep
which is quite stupid in this case. otherThread.sleep(2000) would still cause the current thread to sleep.
i have this in book exemple .. and i thougt why i can't do this in clojure if i can in java (even it's a stupid idea to use it)
@borjarus Yeah, you have to act like the Java compiler, which statically knows the type of Thread.currentThread()
. Another way to think about this in Java is that this won’t work:
Object t = Thread.currentThread();
t.sleep(1000);
while this is OK, IIRC:
((Thread) null).sleep(1000);
In other words, the Java compiler is just employing static type information, which you can do in Clojure via (Thread/sleep 1000)
Has anyone here used java.text.MessageFormat.format()
in their Clojure apps instead of clojure.core/format
, which calls String.format()
?
I'm doing a lot of physical-units structural-engineeringy stuff at the moment. Does anyone know of something for clj/cljs like Python's Pint (http://pint.readthedocs.io) to get some guardrails up around dimensional calculations?
(looked at clojure-toolbox and frinj / minderbinder don't quite seem to be in the same space).
best case it could work with Javelin and subsume a whole host of crazy brute-force Excel work.
Calling the following code works when entered in the REPL but when compiled and required into the repl it fails. Any idea why?
(defn parse-file [file-name]
(-> file-name io/resource io/file xml/parse zip/xml-zip))
which is to say, io/file will, unfortunately, let you do it some times, but given the way resources work you should never expect it to work
a resource is something you load from the classpath, which essentially means some kind of static data you distribute with your code
I thought io/resource
was the correct thing to use because I am using :resource-paths ["resources"]
if you intend to deal with arbitrary files on the classpath, you can't use io/resource
ok cool. the parse-file call is really only for testing (usage will have xml passed to it as a string)
the reason it isn't working for you isn't the compiling, it is the jaring, once you are running out of a jar, a resource is just a stream of bits read from that jar, no file on the file system
ah, yeah, not string, was it bytestring or something? (I had it working that way earlier but for testing purposes it was easier to have it read a file)
cool. thanks a ton for pointing out the issue with file btw. was thoroughly confused at the gap between repl-entered behavior and ‘require’d behavior.
yeah, the whole resource thing presupposes some knowledge of jar files and classloaders, which clojure docs tend to studiously avoid talking about
I’ve used clojure for some stuff before, but I haven’t used Java for anything so a lot of times I run into issues when the underlying java concepts get unearthed.
you get the function itself, which likely has a name hiding in it
(in the printed repr that is) - but it’s messy and it’s an implementation detail
the function you get can be just about anything, I wouldn't count on getting anything from it
in fact, I am pretty sure the function it is passed in some anonymous closure created inside clojure.test that actually calls test-var which eventually calls your test
Hi! Question: what is the easiest way to write a clojure library (with lein) that I can re-use in other projects? I read some stuff about creating a private Maven repo but surely there is an easier way?
@hmaurer You can just do lein install
and it'll build the lib and put it in your local Maven cache on that machine. Is that sufficient?
(i.e., do you only need the lib on your own machine?)
@seancorfield mmh that might be enough for local dev, but for deployments I might need the CI server to have access to my lib
I could have it clone the lib and run lein install
before running lein uberjar
though
If you have a CI server (in-house?) then it's not a stretch to stand up Archiva or something similar for an in-house Maven repo and deploy to that. Or an S3 bucket if you have access to AWS (S3 Wagon is a reasonable deploy/repo option I've heard).
s3-wagon-private would be perfect if it didn’t print stack traces when somebody queries for an artifact that isn’t in the repo
it still behaves properly, but the stack trace printing is super annoying
Submit a PR? 🙂
oh I tried fixing it, and I couldn't figure out what was going on in that code at all
it's weird dependency injected java inheritance stuff
@seancorfield @noisesmith thanks; s3 wagon looks neat, I’ll try it out
@seancorfield unrelated question: I seem to remember you use ProtoREPL?
@hmaurer Yes, I do use #protorepl !
my workaround for the s3-wagon-private stack trace issue is to override :repositories
so that the s3 wagon is the last one checked, otherwise you get spammy stack trace printouts for every artifact that isn’t yours
@noisesmith why are those stack traces such a big deal?
It's like 30 lines of noise, looking like an error, for every individual dep. Many thousands of lines with a fresh m2, and no actual erroneous condition.