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
what a great idea! 🙂
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?What if you reverse the list first?
Trying to just give vague hints here so as not to give away spoilers. 🙂
thanks. I will look into it. 🙂
I'd also look at the function reductions
Or another question: what’s the most time-consuming part of the problem, and how can you minimize the time you spend doing that?
That’s a better approach to figuring out optimizations in general.
e.g.
(reductions + 0 [1 2 3 4 5])
=> (0 1 3 6 10 15)
Think that will help you here.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.
It's like reduce, but returns you the intermediate values
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]
YESSSSS, reductions
! I just looked up that up. That’s exactly what I need here!
I’d never heard of it before!
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.
[heads off and fires up emacs]
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
As a client, there are several, for example <https://http-kit.github.io/>
and <https://github.com/dakrone/clj-http>
are two that immediately come to mind.
@robertfrederickwarner yeah I used :insecure? to false and it worked for me,
set to false
? I would have expected it to be set to true
to allow insecure certs
ya sorry, I rechecked it ..i set it to true
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
yes
So we need to use ring in this?
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)?
Execution error (SunCertPathBuilderException) at sun.security.provider.certpath.SunCertPathBuilder/build (SunCertPathBuilder.java:141). unable to find valid certification path to requested target
@dharrigan ^^
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?That's an interface not a class
(Yup, it's official, I'm an idiot 😅) Thanks!
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
The project was created with lein new app name
and just added :plugins [[lein-gorilla "0.4.0"]]
to project.clj
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.
Clojars policies have changed over time
There were some recent changes to prevent people from using group I'd names that they don't "own" in some sense
https://github.com/JonyEpsilon/gorilla-repl/issues/291ou are hitting this issue.
change reps in plugins section as mentioned in the comment to [org.clojars.benfb/lein-gorilla "0.6.0"]
thank you so mutch
@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.
If you own <http://baader.com|baader.com>
(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.
I use Hungarian domain (my company domain), in this case hu.baader ok, btw during this time somebody approved to use baader name (thanks!)
hu.baader/library-name
would be nice for you to use (and make sure you don't conflict with any other baader
out there 🙂 )
ok 🙂 I can do it. Np for me 🙂
works fine, thanks!!
What kind of authentication are you using?
My guess from the error is that you are using a self-signed certificate?
@popeyepwr 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
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:
is there a way to change the ring anti forgery token error page?
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!
@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&t=837s (Provo: the talk starts 14 minutes in and runs 2 1/2 hours).
I love Eric Normand's RDD course on http://PurelyFunctional.tv but that's a subscription service ($49/month).
There's also this from Practicalli: https://practicalli.github.io/clojure/repl-driven-devlopment.html
can’t subscribe anymore…need to pay per video although they are downloadable for free it appears
yes, saw that too
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.
ok, I seem to remember seeing subscriptions were available recently, then last couple days could not get one.
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!