Fork me on GitHub
#beginners
<
2021-03-02
>
Thomas Tay02:03:20

I'm looking for a sample repo to setup a pretty straightforward static file web server using Graal as a learning exercise I found this, which seems good, but is httpkit still the way to go for a http server? I saw the project says it's unmaintained by the owner but maintained by community users. https://github.com/yogthos/graal-web-app-example

Scott Starkey13:03:26

Hi there, folks. I’ve been working on Code Academy “katas” like a good beginner, and I came across this bit of irritation: https://www.codewars.com/kata/5ce399e0047a45001c853c2b/train/clojure > Let us consider this example (array written in general format): > ls = [0, 1, 3, 6, 10] > Its following parts: > ls = [0, 1, 3, 6, 10] > ls = [1, 3, 6, 10] > ls = [3, 6, 10] > ls = [6, 10] > ls = [10] > ls = [] > The corresponding sums are (put together in a list): `[20, 20, 19, 16, 10, 0]` So, I whipped up the following bit of code, which I was rather proud of!

(defn parts-sums [ls]
  (if (empty? ls) '(0)
      (cons (reduce + ls) (parts-sums (rest ls)))))
Cue the sad trombone sounds. At the bottom of the exercise it mentions: “Take a look at performance: some lists have thousands of elements.” My solution works for smaller sets and all the test datasets, but does not work on the longer “Attempt” datasets. Grr. Thoughts on optimization?

manutter5113:03:04

What if you reverse the list first?

manutter5113:03:41

Trying to just give vague hints here so as not to give away spoilers. 🙂

Scott Starkey13:03:53

thanks. I will look into it. 🙂

Stuart13:03:13

I'd also look at the function reductions

manutter5113:03:17

Or another question: what’s the most time-consuming part of the problem, and how can you minimize the time you spend doing that?

manutter5113:03:17

That’s a better approach to figuring out optimizations in general.

Stuart13:03:36

e.g.

(reductions + 0 [1 2 3 4 5])
=> (0 1 3 6 10 15)
Think that will help you here.

Scott Starkey13:03:55

Hmmm… I’d never seen or tried to use the function reductions before. One of my attempts was trying to use reduce but that didn’t work.

Stuart13:03:55

It's like reduce, but returns you the intermediate values

manutter5113:03:29

Note that the correct solution to the problem given is The corresponding sums are (put together in a list): [20, 20, 19, 16, 10, 0]

Scott Starkey13:03:03

YESSSSS, reductions! I just looked up that up. That’s exactly what I need here!

Scott Starkey13:03:12

I’d never heard of it before!

manutter5113:03:13

Clojure has a bunch of useful things like that. See also frequencies, which isn’t relevant to this, but it’s also a cool function.

Scott Starkey13:03:01

[heads off and fires up emacs]

❤️ 3
popeye13:03:01

Team, I have service endpoint which has authentication, I am able to get the result in postman, I wanted to integrate same in my application using clojure, Which are the api I can use? I started with composure, But I did not get how to access endpoint via clojure

dharrigan13:03:26

As a client, there are several, for example and are two that immediately come to mind.

3
popeye13:03:26

So we need to use ring in this?

dharrigan13:03:04

No. If I read you correctly, you want to invoke an external 3rd party API that is secured by some type of authentication, in order to retrieve data (most likely JSON)?

popeye14:03:30

Execution error (SunCertPathBuilderException) at sun.security.provider.certpath.SunCertPathBuilder/build (SunCertPathBuilder.java:141). unable to find valid certification path to requested target

robertfw18:03:46

What kind of authentication are you using?

robertfw18:03:42

My guess from the error is that you are using a self-signed certificate?

robertfw18:03:20

@U01J3DB39R6 If you are using clj-http, you should look at the :insecure? or :keystore options. http-kit has the :insecure? option but I'm not sure how it handles :keystore

popeye08:03:00

@UG00LE5TN yeah I used :insecure? to false and it worked for me,

robertfw08:03:20

set to false? I would have expected it to be set to true to allow insecure certs

popeye08:03:46

ya sorry, I rechecked it ..i set it to true

robertfw08:03:15

Groovy. Glad that got you off the ground. Just be wary of that :insecure? setting - it does what it says on the tin, and makes things less secure. Fine for development but if you are putting things into production I'd recommend either getting a properly signed cert, or looking into the :keystore options

pavlosmelissinos15:03:15

So in order to set a custom read timeout in a google analytics api request, I had to write https://developers.google.com/api-client-library/java/google-api-java-client/errors in clojure with java interop. I ended up using reify:

(defn set-http-timeout [request-initializer]
  (reify HttpRequestInitializer
    (initialize [_ http-request]
      (.initialize request-initializer http-request)
      (.setReadTimeout http-request (* 3 60000)))))
However, according to the well-known "https://raw.githubusercontent.com/cemerick/clojure-type-selection-flowchart/master/choosingtypeforms.png?" flowchart, when you want to extend an existing class, you need to use proxy. Is the flowchart outdated or could proxy really have some edge over reify in this particular case?

hiredman15:03:21

That's an interface not a class

picard-facepalm 3
pavlosmelissinos16:03:16

(Yup, it's official, I'm an idiot 😅) Thanks!

Old account16:03:55

Hi, can I ask for some support? I have a Leiningen project that does not work for some reason but I don't know why. https://github.com/audriu/gorilla-rpl-try I run lein gorilla` as shown in this example http://gorilla-repl.org/start.html I just need to find out if this is problem with my setup or I am doing something stupid. The exception is here: https://pastebin.com/9B2QDtrr

Old account16:03:59

The project was created with lein new app name and just added :plugins [[lein-gorilla "0.4.0"]] to project.clj

phoenixjj17:03:39

change reps in plugins section as mentioned in the comment to [org.clojars.benfb/lein-gorilla "0.6.0"]

✔️ 3
Old account17:03:24

thank you so mutch

sb16:03:21

When I publish a Clojure library to Clojars, I see allow just for “org.clojars.baader/*” to submit something, but how could I create eg [baader/library-name “0.1.0"], without org.clojars? Just I don’t understand others.. how could setup this.

hiredman16:03:06

Clojars policies have changed over time

hiredman16:03:31

There were some recent changes to prevent people from using group I'd names that they don't "own" in some sense

seancorfield17:03:54

@sb Both clj-new and depstar will be getting updates this week to "strongly encourage" folks to use group IDs that comply with the new security policy that Clojars is rolling out.

seancorfield17:03:30

If you own (or .net or .org) you should probably use com.baader as your group name (or net.baader or org.baader) so that ownership can be verified. Or com.github.baader if your library lives on GitHub.

👍 6
sb17:03:01

I use Hungarian domain (my company domain), in this case hu.baader ok, btw during this time somebody approved to use baader name (thanks!)

seancorfield17:03:26

hu.baader/library-name would be nice for you to use (and make sure you don't conflict with any other baader out there 🙂 )

👍 3
🍻 3
sb17:03:56

ok 🙂 I can do it. Np for me 🙂

sb17:03:43

works fine, thanks!!

afry19:03:40

Good afternoon everybody, I'm back at it with more livestreaming today. We're starting in about 10 minutes if you'd like to join. Stream link here: https://www.twitch.tv/a_fry_ Per usual, I'm mostly going to be live-coding the development of this app: https://startupinamonth.net/pic-story-pitch/ But first I'm starting with a coding exercise warmup, so if you're new to the language, are trying to learn new techniques, or just curious, then feel free to join for the exercise portion! We're doing this coding challenge from the Eric Normand newsletter today, averaging RGB colors: https://purelyfunctional.tv/issues/purelyfunctional-tv-newsletter-400-is-software-design-worthless/ Hope to see you there :man-bowing:

😮 3
afry22:03:29

If anybody would like to check out my solution, here it is: https://github.com/andyfry01/clojure-coding-challenges/blob/master/src/main/color-averaging.clj You should be able to copy/paste this into any old REPL and just run it. Enjoy!

sova-soars-the-sora19:03:58

is there a way to change the ring anti forgery token error page?

sova-soars-the-sora02:03:07

much appreciated thank you

Todd20:03:45

Watching REPL Driven Development on http://clojure.tv to learn different programming flow with Clojure. Any other suggestions? I’m currently using Cursive since I’m most comfortable there. Any good resources for RDD in Cursive would be awesome!

seancorfield20:03:28

@twcrone I don't know of any that use Cursive (maybe ask in #cursive?). I have a couple of videos on my YouTube channel that show my RDD workflow (with Atom/Chlorine and Cognitect's REBL) https://www.youtube.com/c/SeanCorfield_A and I did a couple of meetup talks/live coding recently with VS Code/Clover and Reveal https://www.youtube.com/watch?v=gIoadGfm5T8 (London: an hour and fifteen) and https://www.youtube.com/watch?v=skEXGSp10Xs&amp;t=837s (Provo: the talk starts 14 minutes in and runs 2 1/2 hours).

seancorfield20:03:23

I love Eric Normand's RDD course on http://PurelyFunctional.tv but that's a subscription service ($49/month).

Todd20:03:04

can’t subscribe anymore…need to pay per video although they are downloadable for free it appears

Todd20:03:12

yes, saw that too

seancorfield20:03:01

I've pinged Eric about the subscription stuff -- he still links to it in his weekly newsletter, saying subscriptions are available. I know he closed them down for a while, then opened them back up.

Todd21:03:11

ok, I seem to remember seeing subscriptions were available recently, then last couple days could not get one.