This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-30
Channels
- # aleph (4)
- # beginners (24)
- # boot (15)
- # cider (4)
- # cljs-dev (37)
- # clojure (73)
- # clojure-losangeles (1)
- # clojure-serbia (1)
- # clojure-spec (27)
- # clojurescript (78)
- # core-logic (3)
- # datascript (9)
- # datomic (10)
- # events (1)
- # lein-figwheel (1)
- # lumo (2)
- # off-topic (14)
- # om (6)
- # om-next (1)
- # parinfer (18)
- # pedestal (2)
- # protorepl (4)
- # re-frame (2)
- # reagent (56)
- # specter (6)
- # unrepl (2)
@noisesmith so is there a simple way of turning logging off? so that i wont waste hours of reading and understanding docs
@mjo324_56 from what you wrote, you likely don’t want simple, you want easy 😉
https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/SimpleMadeEasy.md
I don’t see a problem, wrap your whole thing and redirect/filter the output on OS/shell/system level (outside your process)
it's not a point of easy/simple, clj-http is logging crap to stdout, i see no point on configuring it's logging facility since next time some other lib will use a different logging facility
@darwin mother_thread gives good output(my output), but calls thread2 which gives unwanted output
well, there is probably no easy way to do that, as I posted an hour ago, you could “hack” it via System/setOut
, but then you would have to the filtering on your own, because that would capture all java (and clojure) outputs from all threads
I’m pretty sure this is doable, you would need to filter the stream and reject unwanted lines with some regex
for inspiration, you can look here, recently I wrote something similar: https://github.com/cljs-oss/canary/blob/master/runner/src/canary/runner/output.clj#L16
stream would be something you would construct in java land and set into System/setOut
(theory)
i even tried to suppress sysem.out, which also did not work. I think the logging libraries redirect it again,
well, I’m not a java guy, but I can imagine there might be even lower-level layer, which logging library could be using - something like logging into files which happens to be stdout by some lower-level means
I mean writing into something like /dev/stdout
unix-y way, effectively bypassing even System/out
judging from past releases, any idea when 1.9 will be out? right now it is alpha something..
I'm designing some database field column names, and camelCase somehow seems more appropriate than the dash-case
Is there a new api for http://clojuredocs.org? The current one seems to be timing out. I'm guessing it is gone.
@qqq you can convert database column names to dash-case if you want.
(jdbc/query *db* sql {:identifiers to-kebab-case})
i'm using transit with sente, and i noticed there are +
s and -
s in the beginning of the encoded messages, such as +[["~:chsk/ws-ping"]]
. why are they there? it is not appear to be valid json.
ah, i think this is intentional behavior by sente, based on my reading of the source code
@sekao I believe you’re right. Looks like the +
just indicates that the payload contains a callback, and this appears to be above the level of the particular “packer” (read: encoding). https://github.com/ptaoussanis/sente/blob/e3d417334214df3b9f9b0514c8ddd8c71b6d49b0/src/taoensso/sente.cljc#L217-L231
anybody using transit? is there an easy way to customize the precision of floats for the writer? i.e. if I just want to save some on length, round up all floats to 2 decimals only?
What's a quick way of doing checking on a value with an arbitrary function to return a default value. Like the following without the let:
(let [val (expression arg)]
(if (function val) default val))
Basically, if a function returns true, then return nil, otherwise return the original value. So, kinda nil checking.
I suppose that's probably the solution. I just thought there might be something in core that'd do this. The real problem is parsing a float then NaN checking it.
Neither of those is quite right. cond->
doesn’t pass val
to function
, and some->
just bails if the value becomes nil.
Yeah, I'd looked at those, but not quite right.
You don’t really need to jump straight to a macro unless you’re worried about default getting evaluated ahead of time.
I've settled on consecutive entries in a let with the same name.
Cool. But it could be as simple as:
(defn default-if [x pred default]
(if (pred x) default x))
It even reads fairly well in a threading macro:
(-> (+ 2 1)
(default-if even? "even")
(default-if neg? "negative"))
That'd be pretty good. I tend to like to rely on core as must as possible without small helper function like that. Maybe that's just a bad philosophy on my part though.
@U5JUDH2UE I’d say I usually do the same, but I think this can be understood at a glance, which means to me that it’s not going to affect readability negatively by requiring the reader to be familiar with what you’ve introduced.
That's true, and it's arguably more readable than the alternative anyways. Thanks!
Ah, small issue with what I posted above though…if the first default-if
returns a "even"
then it calls neg?
on that and fails.
So you’ll need a macro if you actually want to stack them like that. Anyway, have a good one. 🙂
Thanks, you too. 🙂
Oh, and if you want to do something truly godawful, here’s a way to do it with core:
(condp #(%1 %2) (+ 2 2)
even? "even"
neg? "negative"
identity :>> identity)
🙃@kaosko I think it can’t be too trivial because there are a few SNAFUs around infinity and NaN, but I think this will get you on the right track: https://gist.github.com/camdez/108968382449b7c3a957daecb1aa500a
holy canoli… my java/clojure interop knowledge has some gaping holes. how does one invoke a java api that uses anon inner classes? for example, selenium:
new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
}
1) do you need to provide a return type for a class? provide some sort of complier hint? ExpectedCondition<Type>
2) I know from the clojure guide (and java spec) you can reference anon inner classes as Class$InnerClass, but that’ doesn’t really apply here. how does one construct an anon inner class and provide method implementations?
perhaps I just don’t know enough of the right verbs/nouns in java-land to properly ask dr. google, but I wasn’t able to find muchIn that above example the expectedcondition derives apply
from goog.common.base.Function
… i guess i’m not sure if that means i need to extend an existing base class (proxy) or not (reify)?
@lwhorton <Foo> is a fiction, only the java compiler needs it, it doesn't exist in a true sense in the byte code.
to make an anonymous class, use reify or proxy
*instance of an anonymous class
docs say it's an interface, which means you can use reify, you only need proxy to extend concrete classes