Fork me on GitHub
#beginners
<
2019-10-29
>
nmkip01:10:41

Hi, how do I build a jar? I'm using clojure cli tools

alexmiller01:10:10

you'll need to use a tool like depstar or pack, see https://github.com/clojure/tools.deps.alpha/wiki/Tools for some options

nmkip01:10:00

Thanks 🙂

Shaitan11:10:27

what is the idiomatic way to retry something some number of times on exception?

walterl12:10:11

Perhaps not idiomatic, but I've seen this library being recommended: https://github.com/sunng87/diehard

totomaru11:10:41

Hi, I’d like to download a jpg file using clj-http, but I get 451 error from some specific resource (https://cover.openbd.jp/9784122029576.jpg), from which I can get the jpg file using web browser. Here is my code. Am I missing something?

(require '[clj-http.client :as client])

(client/get "" {:as :byte-array})

Jan K12:10:52

It seems they don't like the clj-http user agent setting. You can use (client/get "" {:headers {"User-Agent" "Mozilla/5.0 (Windows NT 6.1;) Gecko/20100101 Firefox/13.0.1"}})

totomaru12:10:59

@UCPGSBNQ4 It worked! Thanks a lot!

David Rueda12:10:25

Hello guys, I wanted to share a small project I’ve done for parsing RSA private keys (https://github.com/davd33/asn-1-parser)! While it doesn’t parse successfully all key, it successfully parses the one present in the project’s root directory. The code has a lot of side effect handling functions, manipulating a bytebuffer. Could you help me figure out some of the ways I could use to restrain the side effects into the least amount of cose possible?

valerauko12:10:01

is this a study project? why are you reimplementing this yourself?

David Rueda12:10:35

Learn more clojure? Understand ASN.1? I would like to know ways to improve my coding, since I wrote in the beginners channel... If someone wants to help me: thank you in advance !

leonoel19:10:31

@UNDFT2492 it's not the purpose of the beginners channel to help you cheating the hiring process

David Rueda08:10:03

😅 did not want to cheat, but really to improve myself. I found it difficult to find a way to make pure functions with this exercise. Moreover, is getting help from the community cheating? I didn’t know about ASN.1: does that mean I should have abandoned without even learning something? I sent my answers yesterday morning before posting this question. You can verify. But thank you for your public suppositions.

valerauko08:10:46

for learning about it, looking at the relevant bouncy castle libraries may provide a better experience. or buddy, even

David Rueda08:10:36

That’s what I did. My question here wasn’t about ASN.1, rather about the functional approach of my code and how to do better.

Fabian13:10:50

hey, it seems like there are only old versions of clojure and clojurescript on the maven repors (https://repo1.maven.org/maven2/org/clojure/clojurescript/) am i doing something wrong? im trying to install the newst version

alexmiller13:10:11

I think the newest ones are on there?

alexmiller13:10:40

1.10.520 is the newest ClojureScript and that's there

Fabian13:10:42

im always getting Could not find artifact org.clojure:clojure:jar:1.10.520 in central ()

Fabian13:10:04

ah clojure version 1.10.0 works and clojurescript 1.10.520?

Fabian13:10:20

that could be my mistake 🙂

dpsutton13:10:00

clojure has a 1.10.1 release as well

alexmiller14:10:01

^^ that's latest clojure

Sasho14:10:19

Hey, all! 🙂 👋:skin-tone-2: Very often, when one reads the documentation for a function, it says that the function accepts another function as an argument or some map. However, how is one supposed to know what the signature of the input function should be or what the keys of the map are supposed to be. Example: https://cljdoc.org/d/fundingcircle/jackdaw/0.6.9/api/jackdaw.admin#create-topics! > Given an AdminClient and a collection of topic descriptors… So how does one know what keys the topic descriptions should have?

Sasho14:10:55

I mean, of course, without reading the source code.

Sasho14:10:18

Not that I mind reading the source, but I think that such things should be present in the docs, no?

Sasho14:10:43

So, essentially, I guess my question is - is it a question of good/bad documentation or is there something I’m missing?

David Rueda14:10:52

I would say that it should be in the function’s documentation too. Otherwise in the documentation of the library.

Sasho14:10:33

O.K., got it, thank you :+1:

noisesmith17:10:46

I work at Funding Circle, and I alerted the jackdaw team about this question - it might help us improve our docs

cddr17:10:24

TDD seems to be frowned on these days in the clojure community but one of the advantages of TDD (in addition to ensuring that the first user of some function is it's author) is that it provides a ready-made suite of examples of how to use some function. When trying to use a new library, I tend to check the test-suite to see if there are any examples there of the function I'm trying to use. Ideally a library gets to the maturity level of something like clojure.java.jdbc and properly documents all the options but there are a lot of libraries in clojure that aren't yet at that level so it's good to know where to look in the absence of excellent docs.

lambduhhh17:10:43

Howdy folx! So I've been on this channel for a while but mostly just sitting back and learning from afar haha. Today though, today I have a question ! I have a hunch that some of you guys are probably involved in the organization of http://2019.clojure-conj.org/ and so this one goes out to you.... I have some questions regarding qualifying for an opportunity grant (I would also like to attend the Intro workshop). On the website it indicates that it is too late to apply... and well... it is admittedly pretty late to apply (whoops, sorry!) lol but I have to ask bc I would really love to attend... Any chance there are any exceptions to be made for a late application? I believe I would be an excellent candidate as am a LGBTQ, young women, self taught student currently ~2 years in. Scheme and clojure were actually my first programming languages!😯 To find out more about me and my coding style check out my blog https://lambduhh.github.io/

lambduhhh17:10:43

Howdy folx! So I've been on this channel for a while but mostly just sitting back and learning from afar haha. Today though, today I have a question ! I have a hunch that some of you guys are probably involved in the organization of http://2019.clojure-conj.org/ and so this one goes out to you.... I have some questions regarding qualifying for an opportunity grant (I would also like to attend the Intro workshop). On the website it indicates that it is too late to apply... and well... it is admittedly pretty late to apply (whoops, sorry!) lol but I have to ask bc I would really love to attend... Any chance there are any exceptions to be made for a late application? I believe I would be an excellent candidate as am a LGBTQ, young women, self taught student currently ~2 years in. Scheme and clojure were actually my first programming languages!😯 To find out more about me and my coding style check out my blog https://lambduhh.github.io/

chepprey17:10:34

+1 for excellent Slack username

andy.fingerhut18:10:24

I am registered for the Conj, and asked on a Conj-ticket-holders on-line forum of one of the organizers your question, and they responded as follows:

andy.fingerhut18:10:32

"Thanks for asking. The application deadline has already passed for this year. For next year, the link will be posted on the Clojure/conj website and will be announced by via Twitter and other channels. We also send newsletters to the Clojure/conj mailing list, so if someone would like to be added to that, they can email <mailto:[email protected]|[email protected]> with that request. We also update that list every year after conj so that all 1st time attendees get added to the list."

andy.fingerhut18:10:14

I know someone was asking recently if someone wanted to buy their ticket, at a discounted price. Not sure if that would make a difference in your ability to attend.

andy.fingerhut18:10:24

That person looking to sell their ticket is on this Slack as @U8QBZBHGD but they may have already sold it.

Nate Sutton18:10:02

there's a wee bit of a line forming, there are two others waiting to buy. I'll be sure to let you know if that falls through!

lambduhhh18:10:11

thank you folx for responding!

lambduhhh18:10:12

@andy.fingerhut what is this online forum you speak of? may be beneficial for me to join

andy.fingerhut18:10:13

It is one that those registered for the conference are invited to join, before and during the conference. I only asked there because it was easier to find out who one of the organizers was that way. Not open to all, sorry.

andy.fingerhut18:10:18

All the Clojure technical discussions happen elsewhere, like here on Clojurians Slack. That one is mostly about places to go locally in Durham, arranging board game night, etc. for those attending.

lambduhhh18:10:44

Ah, I see. thanks anyway!

Vachi18:10:33

Hi everyone , what is the benefit of binding a partial function to some var

( def some-var (partial some-fn "some-value" ))
vs defining a new function with a closure ?
(defn some-var [another-value] (some-fn "some-value" another-value)) 
with partial binding to a var, we lose the parameter hints from IDE

bfabry18:10:09

there is no benefit, you’re right the 2nd is usually preferable

manutter5118:10:09

@vachichng consider this example:

(def some-arrays
  [[1 2 3]
   [4 5 6]
   [7 8 9 10]])
=> #'user/some-arrays
(->>
 (map (partial clojure.string/join ", ") some-arrays)
 (clojure.string/join "\n")
 (println))
1, 2, 3
4, 5, 6
7, 8, 9, 10
=> nil

manutter5118:10:39

partial is one of those things that’s not necessarily your first pick for a lot of tasks, but in some cases it’s handy.

bfabry18:10:21

imho #() would be clearer there, and I feel it’s pretty much always clearer. but it’s a personal preference

seancorfield18:10:26

I used to be a big fan of partial but I'm leaning more to #() these days.

manutter5118:10:50

tbh I’d probably reach for #() there too, but it was the first example I could think of 😉

alexmiller19:10:35

I don't know if I've ever used partial

alexmiller19:10:27

I take it back! I found evidence that I used it at least once :)

alexmiller19:10:47

looks like I mostly use it in cases where the alternative is #() with %&

lambduhhh19:10:54

ohhhweee well, on the other side.. I'm a pretty big fan of partial :shrug:

lambduhhh20:10:38

(just wanted to represent that partial does have some love here) ... and it's not that I can even necessarily defend exactly why it's just one of the tools that I learned early on and so I'm just pretty familiar with it.

alexmiller20:10:22

nothing wrong with using partial

lambduhhh20:10:17

for example I've found (filter (partial ...) ...) to be pretty useful in the past

lambduhhh20:10:05

this is my meme about partial

lambduhhh20:10:12

I actually like to think of partial as my cool friend greg who actually brought his own beer to the party :shrug: haha just thought you folx might appreciate

Jason Kimmerling22:10:56

I have some questions regarding a sample code in "Clojure for the Brave and True" (def vamp-keys [:name :glitter-index]) (defn str->int [str] (Integer. str)) (def conversions {:name identity :glitter-index str->int}) (defn convert [vamp-key value] ((get conversions vamp-key) value)) (defn mapify "Return a seq of maps like {:name \"Edward Cullen\" :glitter-index 10}" [rows] (map (fn [unmapped-row] (reduce (fn [row-map [vamp-key value]] (assoc row-map vamp-key (convert vamp-key value))) {} (map vector vamp-keys unmapped-row))) rows))

Jason Kimmerling22:10:21

in the reduce section, what order does it resolve?

Jason Kimmerling22:10:58

I am getting a bit confused on the order of resolution, so it is hard for me to understand why they are doing some of the code

andy.fingerhut22:10:20

Not sure what you mean by 'resolve' here, but can take a stab at explaining it.

andy.fingerhut22:10:50

The body of mapify at the 'top level' is (map some-fn rows), where some-fn is most of the code there.

andy.fingerhut22:10:08

That function takes one argument, unmapped-row, which appears to be a sequence of some number of elements, I'm not sure what they typically look like, but when that anonymous fn is called, once per row, first the arguments to reduce are evaluated, then reduce is called.

andy.fingerhut22:10:30

Evaluating (fn [row-map ... creates and returns an anonymous function.

andy.fingerhut22:10:43

Evaluating {} produces an empty map

andy.fingerhut22:10:57

Evaluating (map vector vamp-keys unmapped-row) maps the function vector over both of the sequences vamp-keys and unmapped-row. Given the value of vamp-keys above, that should return something like ([:name unmapped-row-element-1] [:glitter-index unmapped-row-element-2])

andy.fingerhut22:10:16

Then reduce is called with those 3 parameters.

andy.fingerhut22:10:43

Is that anywhere in the neighborhood of what you were asking about?

Jason Kimmerling22:10:17

Yes, I believe so, evaluating the arguments for reduce first makes a good bit of sense, and clarifies it decently. Thanks.

chrisulloa22:10:40

` for code blocks

Jason Kimmerling22:10:29

@christian.gonzalez Ok, thanks

andy.fingerhut22:10:22

In general, all Clojure functions, of which reduce is one, and functions you define with fn or defn are also, when they are called, first all of the arguments are evaluated, then the function is called with those resulting values. That isn't necessarily true of Clojure macros -- it depends upon which macro, since each can define its own behavior in that regard.

Jason Kimmerling23:10:26

@andy.fingerhut thanks, I appreciate the clarifications.