Fork me on GitHub
#beginners
<
2019-11-27
>
Mario C.01:11:50

Is it possible to prevent C3P0 from retrying after a specific failure such as login failure but retry as normal for anything else?

Oli Sturm14:11:56

Where can I find useful instructions to install Clojure on Fedora Linux (or any Linux)? The details in "getting started" (https://clojure.org/guides/getting_started) are outdated, the installer can't be downloaded, there's no link anywhere to the current version...

andy.fingerhut14:11:05

Which step on that page failed for you? The curl command, or something later?

Oli Sturm14:11:38

The curl command - "no such file or directory"

Edward Hughes14:11:02

You'll need to use your package manager to install curl

Oli Sturm14:11:30

Hm, I have curl...

Oli Sturm14:11:38

So you're saying that URL should definitely work?

Edward Hughes14:11:45

Yeap, just ran it myself.

Oli Sturm14:11:39

Okay, my apologies for the hassle - I just confirmed that the URL works on a different machine. Problem between the ears... or rather somewhere in my system setup.

Edward Hughes14:11:17

Ah yes, our eternal nemesis, convoluted state.

andy.fingerhut14:11:37

Well, a network with no state often doesn't behave as we wish, either 🙂

Edward Hughes14:11:20

The key is managing it, which is why we're all here 😀

JoshLemer15:11:00

Quite often in talks, Rich Hickey will use the term “concretion”, for instance “product types are not data abstractions, they are data concretions”. So far as I can tell he has coined the term, was wondering if anyone knows precisely what he means by it? If I had to guess, from the way he uses it, he seems to mean “concretion” as something like “a pattern in our programming practice where we over-commit to a particular representation or data structure, which is then very hard to change because everything comes to be coupled to exactly that specific representation” But I would be eager to hear others’ interpretations as well, cheers!

👍 4
Adrian Smith15:11:01

Imagine a map of: Authors -> Blogs -> Comments essentially you have a tree that also stores data, it's now hard to reconfigure to: Comments -> Authors -> Blogs even though you "have the data" a tree is an opinion on the way the data should be stored that is hard to change or a "concretion" imo

JoshLemer15:11:27

ok that’s a good one thanks

alexmiller16:11:26

I think you're attributing more negative connotation to it than intended (with "over-commit").

alexmiller16:11:59

Rich did not invent this word, it existed. :) I believe he uses it to mean "combining multiple things into one".

alexmiller16:11:13

and an example would be in Java to make a concrete User class that combines a bunch of attributes about a user. But different parts of your code may need a different set of attributes, so you make a SystemUser class. You've got two concretions with overlapping attributes. Clojure (and where we're going with spec) is to create looser aggregations in maps and attach the semantics to the attributes, not to particular combinations of those attributes.

💯 4
adityaathalye17:11:50

As I understand it, "concretion" occurs when orthogonal things are combined into a thing that cannot then be recombined as generally as the constituent parts. e.g. structure + state + behaviour in the case of java-style classes and objects obj1 + obj2 = obj3, but f(obj1) cannot work on obj2 or obj3; nor is the notional "+" commutative in obj1 and obj2 as compared with: tree1 + tree2 = tree2 + tree1 = tree3, and where any f(tree) would work on any of the trees

Steven Lombardi10:12:28

+1 for how Alex worded it

Steven Lombardi10:12:24

We still write Java, although I'm working to get Clojure adopted. It can be easy to get too focused on writing a premature abstraction. I'll usually tell my team to punt on abstracting until you have enough "concretions" (3 - 4 use cases, possible implementations, etc) to better inform your abstraction.

FiVo16:11:34

I was wondering if there has been any work in the direction of hotloading liberaries/projects from a git repo? I know that there is https://github.com/cemerick/pomegranate, but that goes through maven/clojars.

alexmiller16:11:57

Clojure clj can use git deps

alexmiller16:11:19

the add-lib branch has a speculative feature for hotloading deps (including git deps)

alexmiller16:11:17

of tools.deps.alpha

FiVo17:11:00

Any specific reason that lein projects are excluded?

alexmiller17:11:54

Yes, it’s not easy to retrieve lein deps as the project.clj is often evaluated, and/or modified by profiles

alexmiller17:11:32

I am quite hesitant to pull in leiningen as a dependency of tools.deps in order to do that evaluation

alexmiller18:11:54

But this is an unresolved question

FiVo16:12:42

When do you think this feature is ready? Can one somehow help?

FiVo16:12:03

My main goal is to do some analysis with tools.analyzer.jvm on Clojure source code. I have two options. The git route vs the maven/clojars route. In the first I would add the dependencies with something like your add-lib in the second I would use the clojars api together with pomegranate. I would prefer the git route, as it's a lot easier to figure out forks, number of stars, git features and also more code. Do you have any thoughts on this? Or maybe some idea how to best go about?

alexmiller16:11:59

it's a little challenging to use that right now but we're looking at how to bring that into mainline

👍 4
Aleks Abla19:11:50

hey everyone, hope all is well -- I am trying to send a CSV file in an HTTP response. Is there something like

(api.util/respond-*CSV* (str (java.time.LocalDateTime/now)))

Aleks Abla19:11:10

this my routing

#{["/v1/search/clock" :get
     (conj interceptors/common-interceptors clock) :route-name :clock]

noisesmith19:11:45

from what I've seen people use libs for parsing csvs but just use string formatting to make them

Aleks Abla19:11:40

I am good on the file itself, but I am not sure how to send a CSV file in an HTTP response. I can download the CSV to my local machine, but would like to have it appear as a download

noisesmith19:11:47

oh, so what you want is to set the Content-Type header, and use a proper response map

noisesmith19:11:53

that's what drives the browser behavior

Aleks Abla19:11:25

ok awesome!! yea i was recommended to set content-type header, but was not sure what that meant or how to do it! thanks a lot, enjoy the holidays! 🙂

noisesmith19:11:55

clojure.data.csv does have functions for writing though https://github.com/clojure/data.csv/blob/master/src/main/clojure/clojure/data/csv.clj - it should be trivial to integrate that into a helper for handling requests

alexmiller19:11:49

And it is better to use the csv functions when writing csv or you won't get proper escaping / multi-line value handling

8
didibus19:11:51

Funny thing is, I've had to do my own csv parsing often, due to a lot of csv out there being not proper csv 😝

alexmiller20:11:16

well that is true :)

alexmiller20:11:29

be the csv you want to see in the world

😄 20
Aleks Abla21:11:36

hey, wanted to check back in with the 'HTTP response as a CSV file problem' -- I read the ring.util.response documentation, and went ahead to specify the response in my data-pull event (seen below). It does not seem to be working, and would love to get some help. @noisesmith @alexmiller

Aleks Abla21:11:53

(reg-event-fx
 ::data-pull
 (fn [{keys [:db]}]
   {:http-xhrio {:method :get
                 :uri ""
                 :format (ajax/json-request-format)
                 :response-format (content-type "csv")
                 :on-success [::data-pull-success]
                 :on-failure [::data-pull-failure]}
    }))

noisesmith21:11:54

you should be setting the content type on the server side, this looks like cljs client code?

Aleks Abla21:11:34

thanks for clarifying!

Aleks Abla22:11:17

so essentially having this instead, with report-0 being a predefined body

Aleks Abla22:11:24

(defn report [request]
  (response/content-type report-0 "csv"))

noisesmith22:11:30

response/content-type is a middleware, it takes a function and returns a new augmented function, usually you'd wrap your existing handler function with it

noisesmith22:11:05

using middleware inside handling functions is pretty much never the right thing

Aleks Abla22:11:38

would it help if i then use 'report' and pass is as an endpoint through an interceptor, as seen below

Aleks Abla22:11:47

["/v1/search/report" :get
     (conj interceptors/common-interceptors report) :route-name :report]

Aleks Abla22:11:22

im really sorry if these questions seem silly -- i am doing a clojure software internship, and have very little CS background 😕

noisesmith22:11:47

1. content-type doesn't exist as far as I know, it's called wrap-content-type 2. wrap-content-type takes a function and returns a function

noisesmith22:11:05

it's not an interceptor, it's a function following a specific pattern

noisesmith22:11:41

there is a content-type-response function, but it's simpler to use wrap-content-type instead

noisesmith22:11:10

maybe a simpler way to put it: if f is a handler function that works with ring, (wrap-content-type f "csv") returns a new function, that does exactly what f does, but also sets csv in the content type header

Aleks Abla22:11:55

oh wooow!! thank you so much for clarifying that.. I think that makes more sense

Aleks Abla22:11:37

so I could essentially use (wrap-content-type) and then for f, pass it the function the returns my data, after which the header becomes csv

Aleks Abla22:11:25

i hope one day i'll be able to help some one with their questions! thanks!

noisesmith22:11:29

this might help?

(ins)user=> (defn wrap-intro [f] (fn [x] (str "my name is: " (f x))))
#'user/wrap-intro
(ins)user=> (defn foo [x] (str x ", esquire"))
#'user/foo
(ins)user=> (foo "theodor s. preston")
"theodor s. preston, esquire"
(ins)user=> (def intro-foo (wrap-intro foo))
#'user/intro-foo
(ins)user=> (intro-foo "theodor s. preston")
"my name is: theodor s. preston, esquire"
the wrap-intro function is written the same way most ring wrapper middlewares are

🌟 4
noisesmith22:11:16

except they end up modifying a response map instead of string concat of course

Aleks Abla22:11:36

yep! thanks a lot! ❤️