Fork me on GitHub
#clojure
<
2017-12-01
>
scaturr02:12:43

does anyone have experience with ssl on heroku?

scaturr02:12:51

i have an api running on immutant

scaturr02:12:36

apparently its stupid easy lol

scaturr02:12:38

¯\(ツ)

dadair05:12:03

hello! I'm confused about project dependencies when linking to clojure from another JVM language; I've articled my problem/question fully here: https://stackoverflow.com/questions/47586889/handling-clojure-project-dependencies-when-dynamically-linking-to-clojure-runtim. If anyone could help that would be greatly appreciated 😄

eMko06:12:01

@dadair I have similar setup for two projects. I have Clojure code compiled as überjar, intended to be used as a library from Java (and some Java classes calling the Clojure code - :gen-class won't create javadoc for classes/methods and my colleagues would be upset 🙂 ). I ended up with embedding nREPL in the project. I copied code from this library: https://github.com/jarohen/embed-nrepl . From Java code I call the Clojure method to start repl during application start. Then I can connect to that from emacs.

seancorfield06:12:37

I'll second that. For a long time -- as we introduced Clojure into our stack -- we used the "Java API" to call Clojure from our legacy application and we started a REPL server inside that code which we could connect to from Emacs or the command line and have our regular fast-feedback Clojure workflow.

qqq06:12:52

so to use clojure in a legacy codebase with coworkers who don't want to use java, you are: 1. compiling *.clj iknto uberjar 2. when the uberjar is called from java, firing up a nrepl 3. so now you have a clojure repl into your legacy java app (that still "starts from java") ?

seancorfield06:12:00

One thing I'll observe is that we deliberately did not create an uberjar and deploy things that way -- we decided to deploy as source and put the src folder on the classpath of the legacy application (along with any Clojure libraries we needed). This meant we could modify source if needed and require :reload to pick up changes (I'll say that we rarely do this now, but it was common when we first started embedding Clojure).

seancorfield06:12:13

The progression for us was that we started using Clojure as a small, isolated "library language" for low-level stuff and it gradually expanded until it became our primary language. Now we do all new development in Clojure and our legacy systems are shrinking as we replace functionality with pure Clojure microservices and applications.

val_waeselynck10:12:51

What is the best way to type hint an Object[] array in Clojure? I've seen this method #^"[Ljava.lang.Object;" here (http://disq.us/p/1buoakl), but I'm not sure it's officially supported.

rauh10:12:11

@val_waeselynck Check out to-array source.

leonoel12:12:41

@val_waeselynck ^objects works as well

val_waeselynck12:12:19

@U088T6UDC thx! weird that it's not in the official docs

Alex Miller (Clojure team)13:12:40

That will not work on vars by the way, only in signatures

borkdude14:12:40

What’s the rationale behind nthrest? Noticed it for the first time today. What about (drop n ...) wrapped in doall if you need it strict?

mfikes15:12:19

Interestingly, they both seem to have a recur pattern that is eagerly done to consume the beginning of the sequence.

borkdude15:12:54

so the difference is nthrest skips n immediately and drop only when the sequence is consumed

mfikes15:12:59

nthrest is eager initially, while drop staves off the initial eagerness

borkdude15:12:56

hmm yeah, so (doall (drop ...)) would consume everything in the dots too, while nthrest leaves that to the consumer of the seq

mfikes15:12:59

You do have an interesting question regarding rationale, especially given that nthrest wasn't added until 1.3

borkdude15:12:31

maybe (drop ...) caused an issue in the impl of partition?

mfikes15:12:40

@borkdude If you are curious as to my rationale for using nthrest: It was simply that I had used rest (instead of (drop 1 ...), so when I needed to revise the code to drop more items, I reached for nthrest without thinking about it too deeply. I certainly wasn't thinking about laziness, whether to employ transducers, or any such deeper analysis.

borkdude15:12:35

Yeah, when I saw your code I started thinking about transducers. It lends itself well for it. But whatever, that’s not better or worse, just different and maybe overthinking a puzzle 🙂

mfikes15:12:25

FWIW, I think your final solution using drop is the cleanest, easiest to read, especially given that the revised code needed to drop more than 1 item.

mfikes15:12:17

There is also an argument that some functions are a bit esoteric (and perhaps should be avoided). drop is used 50 times more frequently than nthrestin the data in http://www.lispcast.com/100-most-used-clojure-expressions My favorite example Var in that category is when-first. It is hard to justify using when-first given that it never became part of the "idiom".

borkdude15:12:43

Never heard about it

borkdude15:12:56

nthrest is also not used in the rest of the clojure codebase

mfikes15:12:04

Indeed, that's the problem with using Vars like that. It is like using a "dictionary word" in conversation, where the other participants in the conversation get stuck on what you just said.

mfikes15:12:43

Not good for readily understandable code. 🙂

borkdude15:12:44

Maybe that’s the problem with Specter too.

borkdude15:12:14

Or Clojure. 😛

borkdude15:12:16

Ah, @alexmiller replied: it’s probably about holding the head

Alex Miller (Clojure team)16:12:33

or simply avoiding calling first on anything for cases where that realizes things

mbertheau15:12:29

How would I write this more concisely? (let [d {:a [{:b 1 :deleteme "foo"}]} f #(dissoc % :deleteme)] (update-in d [:a] #(mapv f %)))

ghadi15:12:14

update is now in core for updating when the path [:a] only has one segment.

ghadi15:12:25

your code seems fine to me

borkdude15:12:24

Seems fine to me too with update.

waffletower22:12:06

If you are directly indexing :a you might not mind numerically indexing its array using medley's dissoc-in:

waffletower22:12:11

(let [d {:a [{:b 1 :deleteme "foo"}]}]
  (dissoc-in d [:a 0 :deleteme]))

waffletower22:12:51

But if you have more than one element in :a I would just inline the lambda instead and use update as bork suggests:

(let [d {:a [{:b 1 :deleteme "foo"}]}]
  (update d :a (fn [m] (mapv #(dissoc % :deleteme) m))))

nathanmarz15:12:59

@mbertheau with specter: (setval [:a ALL :deleteme] NONE data)

laujensen16:12:46

Anyone here familiar with a javalib which compresses animated gifs, similiar to what Guetzli does to jpgs?

laujensen16:12:39

(clojure libs are valid too, but we're more of a wrapping kinda people)

ghadi16:12:20

probably anything you find would be a wrapper.

ghadi16:12:55

I don't know of anything, but if there is a C library that does what you need, it's straightforward to wrap C, and pretty pleasant using JNR-FFI

ghadi16:12:07

you don't have to write any C glue manually

kwladyka17:12:30

What do you do in clojure spec to generate sample (gen/sample (s/gen ::foo)) with unique value like code. Do you make own function for code generation or is some simpler way?

Alex Miller (Clojure team)17:12:47

you can use s/with-gen to supply a custom generator when you define a spec

Alex Miller (Clojure team)17:12:10

or supply an override generator function when a spec is used in places like s/exercise, stest/instrument, etc

kwladyka17:12:51

yes, i was thinking about s/with-gen. Not sure what you mean by override generator. Probably i don’t know about something 🙂

Alex Miller (Clojure team)17:12:57

functions like s/exercise take a map of spec name to generator functions that can be used to override the generator for a spec just in the context of that call

kwladyka17:12:47

oh i see some things changed in the doc from last time when i saw it, thx

Alex Miller (Clojure team)17:12:59

clojure
user=> (s/def ::i int?)
:user/i
user=> (s/exercise ::i)
([0 0] [-1 -1] [1 1] [-1 -1] [-6 -6] [-6 -6] [-4 -4] [2 2] [-2 -2] [-56 -56])
user=> (s/exercise ::i 10 {::i (fn [] (s/gen #{5 10}))})
([5 5] [5 5] [10 10] [5 5] [5 5] [10 10] [10 10] [5 5] [5 5] [5 5])

Alex Miller (Clojure team)17:12:16

the docs have been out of date for a very long time but I refreshed them last week

Ryan Radomski20:12:38

In Stuart Halloway's talk Simplicity Ain't easy, at the end he mentioned that there is some interesting discussion about design foundations other than simplicity. I can't seem to find any more information on it. Does anybody know of any discussion on that?

Alex Miller (Clojure team)21:12:44

@radomski the three ones from Rich and Stu are power, focus, and simplicity

Alex Miller (Clojure team)21:12:39

I think Stu has done talks on two of those (see also https://www.youtube.com/watch?v=KZ8u_sWT9Ls )

Alex Miller (Clojure team)21:12:38

Maybe some day he will complete the trilogy and then we can get into the prequels

noisesmith21:12:22

just wait, he’ll use CGI to add realistic concrete inheritence when he re-releases the original