This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-03
Channels
- # aleph (1)
- # announcements (9)
- # babashka (3)
- # beginners (200)
- # calva (22)
- # cider (74)
- # clojure (97)
- # clojure-dev (43)
- # clojure-europe (15)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-sanfrancisco (2)
- # clojure-uk (103)
- # clojuredesign-podcast (2)
- # clojurescript (45)
- # core-async (5)
- # cursive (13)
- # datomic (42)
- # emacs (20)
- # fulcro (6)
- # graalvm (37)
- # jackdaw (10)
- # leiningen (7)
- # mid-cities-meetup (3)
- # off-topic (2)
- # pathom (1)
- # pedestal (3)
- # re-frame (6)
- # reagent (38)
- # reitit (5)
- # shadow-cljs (117)
- # spacemacs (1)
- # sql (1)
- # tools-deps (17)
- # vim (14)
- # xtdb (18)
How many folks test all the examples in their README files? Do you automate that? Are there any alternatives to midje-readme for that sort of thing?
@U1QQJJK89 Would you use a clojure.test
-compatible tool that could automate README example testing appeal to you?
yes but it would need to test shell command invocation. here I cd into the quickstart directory of the project and run commands: https://github.com/retrogradeorbit/bootleg/blob/master/README.md
Haha... okay, that's an interesting use case... I was talking more about pure Clojure code in the readme, in the context of the project itself, so it would only pay attention to chunks of code wrapped in three back ticks and clojure
🙂
I've used midje-readme
on a couple of projects (and I do not like midje
!) and it seems to be the only game in town and it does have several caveats 😕
selecting the backtick blocks by clojure
annotation would work. shell
blocks could be handled seperately.
True. Not sure the latter is in my scope right now but it's an interesting option to consider.
I've been working on a thing that can turn Clojure code blocks in Markdown and AsciiDoc code blocks interactive: https://github.com/eerohele/useless I've shelved it for the moment, probably mainly because I don't know whether it's actually useful for anyone (hence the name). You could use it to test code blocks in your README, though.
Yeah, the first version is fairly simplistic. I dreamed of some richer approaches overnight so seancorfield/readme
will evolve quite a bit over the next day or two I suspect 🙂
seancorfield/readme {:mvn/version "1.0.12"}
-- https://github.com/seancorfield/readme -- I ended up writing a thing to turn README files into tests 🙂
Anyone tried to use http://pitest.org/ with Clojure
@borkdude hats off to you! I had written my own tiny Clojure-based DSL for generating SVG diagrams as part of the Asciidoctor/Antora pipeline, and as much fun as I was having implementing the various special forms, someone pointed me at sci
and I ripped out my own code and integrated yours, producing a much more feature-filled, yet still safe and usable in a JavaScript pipeline, language. 🔥
there is no =print-method= in the core api page https://clojure.github.io/clojure/clojure.core-api.html
print-method is not included because it's not doc'ed, but it probably should be. it's really more of an spi method than api (for hooking into the print system)
ditto print-dup which is equally as important
things like print-simple and print-ctor, probably not but I'd have to look at it more
Hi all, I have a REST application in clojure and I want to use oauth2 to authorize incomming requests. can you suggest some libraries?
What’s the best way to handle a java.lang.Iterable that blocks forever - (representing a stream of changes from a mongo database)? Obviously need to spawn it in a separate thread but not sure if I should just use doseq
— and how to deal with cancellation…
wdyt of this pattern?
(def q (queue-of-your-choice))
(def enqueuer (future
(while (not (-> Thread/currentThread) .isInterrupted)
(let [v (take-value-from-mongo)]
(put! q v)))))
(comment (future-cancel enqueuer))
(queue-of-your-choice)
could be java blockingqueues, or a core.async chan etc
Idea being, you deal with the mongo iterator in a very delimited part of your codebase, and the rest of the codebase consumes a vanillla queue, with more familiar semantics, and importantly with blocking/timeouts so that production and consumption don't run at disjointed ratesThat’s a good call — and I found out that Iterable can give me an Iterator which has a plain next
call.
doseq seems to be doing the lazy chunking of 32 items at a time, which I don’t want, I want to consume the next time as soon as it’s available.
i need to write a bunch of lines to a file generated from application data ... is there a "nicer" way than opening an io/writer
and chaining calls to (.write w stuff)
with (.write w "\n")
?
Can’t you just use
(binding [*out* w]
(… normal Clojure print, println, et. al. calls …))
Usage: (iterate f x)
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects
And at unpredictable times because of chunking, no?
I don't think it will be called multiple times. But delayed and chunked calls are a possibility.
Looks like iterate
just wraps a call to clojure.lang.Iterate/create
, which is an interesting read https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Iterate.java
it can be invoked multiple times -- the reducible path doesn't cache https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Iterate.java#L65-L75
yeah, the result of iterable can be accessed as a seq and reduced over and those two paths do not share values
doing both is probably uncommon
does clj-http auto decode base64 on the response body?
https://github.com/dakrone/clj-http/search?q=base64&unscoped_q=base64 suggests no
Of course, that's just a suggestion. I could be missing something.
that's weird, because on the browser i receive an encoded body resp, and with clj-http i receive it decoded
In the browser? So cljs-http?
no, i mean, i make the request with Firefox, navigating the page
and using the dev tools i can see it returning a Base64 string as response body
but the same request with same headers made in clj-http returns the same content but it's already decoded
the problem is that in this decoding process it uses the wrong encoding format, and i lose some characters such as ^ ~ `
Are you certain that the server is sending the same Base64 string when you're calling from a Clojure runtime? Any chance there are differences in the request, like Accept headers, etc?
i literally copied the same ones that the browser request is using
i didn't said but, the response is a CSV file
maybe Firefox is doing something and encoding this as base64
Could also be happening in deps of clj-http
Lots of possible places where the requests and/or responses differ.
all of that wouldn't be a problem if i could take this string that i receive on CLJ-HTTP and get back those missing characters ~`
instead i get some
?
characters in place of them, this is ruining my parsing process
could it be that the implicit stringify is using the wrong text encoding?
clj-http add's lot's of headers for us, maybe something is going on there
yes @noisesmith that's what i think, but where is this implicit stringify?
if you use the :as :input-stream
option to clj-http, you'll be able to consume and convert it in whatever way you like
let me look up the actual option...
ok! i'll give it a try
the option is {:as :stream}
- then it's your job to consume the stream, convert, etc. etc.
i'll try to use slurp in it passing the right encoding
there's also {:as :byte-array}
which also won't do any text conversion and might be more convenient
eg. the base64 decoder that comes with java takes a byte-array
assuming this will return the base64
well let's see
found a way much more simple
then it came on the right format
seancorfield/readme {:mvn/version "1.0.12"}
-- https://github.com/seancorfield/readme -- I ended up writing a thing to turn README files into tests 🙂
I have a coworker that wants to learn functional programming concepts but in javascript/typescript language. Has anyone come across a good course or book?
You can have FP concpets in almost any language (higher order functions, expressions vs. statements, referential transparency etc.), but some languages "lend" themselves to it much better than others. For me, the crux of the matter lies in immutability which JS or TS don't have so it'll be much harder... If he wants to learn it on the FE side, he can try Clojurescript/Elm/Purescript etc.
I've convinced him that it is worth learning but can't convince him to pick up a new language
For what it's worth, lots of people in my local dev group love functional programming in JS. I would say it's the most popular language for functional programming in my tiny town
@U5136PEE6 Point him at Grokking Simplicity by Eric Normand. It's a work in progress right now but it uses JS to illustrate the concepts and it's really well thought out.
And speaking of which, Functional JavaScript by Michael Fogus, while kind of outdated, was a very good read
I heard that this is great for functional JavaScript https://github.com/thi-ng/umbrella
i've tried lot's of them, never had success in trying to learn FP concepts with JS
because you can mix paradigms, when i tried, things tend to become a mess and i always got lost in the process
is it possible to write a macro which gets the calling function? I am thinking of using ~(meta &form)
implicit macro var and *file*
. Maybe it is possible to to combine those variables and infer the calling function. Or maybe there is an other way? :thinking_face:
@ghadi I want to make log framework macro that shows tha calling function
You can get the calling function from the stack info, but I think it might add quite a bit of overhead
Java 14 brings an option for "helpful null pointer exceptions" -- how might it affect Clojure? See https://clojureverse.org/t/helpful-nullpointerexception-jvm/5556/3 for an example.
that was my guess when I read about it too
in Java, it is certainly better than the message "null" :)
Yeah. Some of those messages could be greatly improved by small refactorings of the Java code in Clojure's runtime and/or compiler but I'd be suspicious of those changes slowing Clojure down.