Fork me on GitHub
#clojure
<
2019-06-01
>
currentoor00:06:32

Using the build in clojure cli is there a way to make it download all the deps? The equivalent of lein deps?

johnj01:06:35

just running clojure alone will download the deps declared in deps.edn

ghadi01:06:33

that will start a repl

ghadi01:06:46

if you don't want that run clojure -Spath > /dev/null

currentoor01:06:26

@U050ECB92 what does -Spath do?

ghadi02:06:49

computes the classpath

👍 4
lvh00:06:24

with the clojure/deps.edn ecosystem, is there a good reason to stuff a project with multiple components (let's say server/client binary) that don't make sense separately but are developed mostly in tandem in 1 deps.edn file or multiple?

lvh00:06:53

I ask because i've currently done that with leiningen and hit a whole bunch of long-standing profile-related bugs

dominicm06:06:01

@lvh in JUXT/edge we use separate deps.edn files, and then use :local/root to pull them together.

dominicm06:06:58

On client projects (this hasn't been demo'd too much) we have designed extensive setups where the configs are factored out to make it easier to pull applications together this way.

haochenx09:06:50

i’m using http-kit to write a simple API server. does anyone know how to add SSL support to it directly with Clojure? by directly I mean without using an external reverse proxy (like nginx) or SSL terminator. Internal ones (i.e. inside the JVM where I could control with Clojure) are perfect

haochenx09:06:39

the reason i’d like to have control over the SSL part is because the API server is a test server for a custom SSL client on MCU, and we want to be able to generate new SSL certificate and have multiple SSL sockets listening with different certificates (for testing successful cases and unsuccessful cases)

jumar09:06:22

This still sounds like a perfectly doable thing with nginx or other proxy: https://stackoverflow.com/a/38054382/1184752

haochenx09:06:20

yeah sure i’m using a configuration like that for the production server but this is for the testing server and would like direct control over ssl configuration (including certificate generation) directly from the Clojure codebase

haochenx09:06:20

i’ll try jetty for now but if anyone has better suggestion it would be great

orestis13:06:42

The pedestal codebase might have some ready-made code you can either use directly or copy-paste

👍 4
haochenx13:06:31

for anyone who’s curious, i finished the exploring and got a working piece so far by using - Bouncy Castle to generate a keypair and a self-signed certificate - a KeyStore instance of type “pkcs12” to hold the certificate + private key - Jetty with a ServerConnection configured with a SslConnectionFactory and a HttpConnectionFactory to finally get a running server

haochenx13:06:07

not sure who else is interested but i may post a gist after cleaning the code a little bit another day

👍 8
haochenx13:06:31

for anyone who’s curious, i finished the exploring and got a working piece so far by using - Bouncy Castle to generate a keypair and a self-signed certificate - a KeyStore instance of type “pkcs12” to hold the certificate + private key - Jetty with a ServerConnection configured with a SslConnectionFactory and a HttpConnectionFactory to finally get a running server

kulminaator14:06:25

where do you host your stuff ?

haochenx05:06:09

locally, for testing purpose

kulminaator15:06:54

if on amazon i would recommend using alb or elb instead of doing the ssl stuff yourself ... yes it costs a little extra but is well worth the money

haochenx05:06:27

yeah, for another project i’m doing exactly the same--using elb for ssl termination--yet this stuff is for developing and testing the “hardware” part of a solution (an MCU controlled gateway-ish thing that connects an input device to the application server running in the cloud)

haochenx05:06:34

so finally the production server will be hosted behind elb as planned now, but i was trying to make the local server and want more flexibility on certificates for testing purpose

valerauko15:06:33

even locally, an nginx reverse proxy can alleviate lots of that pain

👍 4
dottedmag15:06:43

Could you have a look, is this solution good enough, or am I misusing protocols this way? The problem: I have a code that reads/writes things to a serial port. There are places in program where a number of reads/writes is expected to be finished by a specific deadline (protocol description contains phrases like "if the whole data frame was not received within 1500ms, application should stop receiving it and return to idle state.") I have tried to weave the operation deadline through reading/parsing routines (the data frame cannot be read in one operation, as it contains embedded lengths), but it was awkward. At the end I bound a deadline to a port object. (edited: moved read-byte out of interface)

abdullahibra15:06:57

how can i embed values into xml files in clojure?

abdullahibra15:06:09

something like erb in ruby for example

abdullahibra15:06:50

if someone interested too 🙂

yuhan18:06:38

Are #, % and & valid characters in a Clojure(script) symbol? I couldn't find an official language spec, and the rules given in https://clojure.org/reference/reader seem overly restrictive

yuhan18:06:09

Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, ', ?, <, > and = (other characters may be allowed eventually).

andy.fingerhut18:06:08

The rules given at http://clojure.org are what is explicitly supported. The implementation does not prevent you from using other characters, but using some of those other characters can cause some use cases to break

andy.fingerhut18:06:27

If you are looking for an implementation of (symbol "some string") or (keyword "some string") that throws an exception if you give it a character that is outside of a particular set of characters, you will have to write it yourself or find it in some third party library.

yuhan18:06:20

Does that mean that using e.g. a#b$c as a variable name could potentially be broken in a future release of Clojure?

andy.fingerhut18:06:31

I am not the decision maker on what changes in future releases of Clojure, so can't authoritatively answer such a question, but I can say that the Clojure maintainers do a great job at maintaining backwards compatibility, and rarely make changes that break such things. They know that because the implementation allows other characters, that many people take advantage of htat.

andy.fingerhut18:06:30

But for example if you find that using such a variable name causes, say, printing your code or data to a file, then reading it back, to break, then if you are using characters outside of the allowed set, and that is the reason it is breaking, you will likely not get a lot of people rushing to change Clojure to make that work.

andy.fingerhut18:06:19

For example, if you use a space in a symbol or keyword, that will break the ability to print code/data and read it back and be equal to the original.

yuhan18:06:36

that makes sense, spaces are definitely off-limits

andy.fingerhut18:06:48

There is a Clojure JIRA issue that suggests some kinds of actions in this area -- I am forgetting whether it was only adding more documentation for Clojure, or adding a function that would check whether a proposed string was a supported symbol/keyword

andy.fingerhut18:06:25

Semicolons would be another thing that might be a bit grey in terms of print-read round-tripping. Probably many others.

didibus18:06:36

You can easily extend printing and reading though. I've added support for spaced namespaces and symbols in some use cases where it was convenient

yuhan18:06:45

I was wondering because clojure-mode in Emacs highlighted a variable name foo#bar wrongly, and I couldn't find out if it was an actual bug or according to spec

didibus18:06:52

And it can round-trip if you need it serialized

didibus18:06:24

I don't think I've ever seen a breakage related to what are valid symbols and namespaces. Like no version of Clojure ever broke that.

didibus18:06:45

So I'd say, it it works, you're probably good to go

andy.fingerhut18:06:48

But if you go to significant lengths, e.g. days and days of work, trying to get color highlighting "working" (whatever that means to you) for arbitrary sequences of characters, you may go mad. 🙂

yuhan18:06:35

thanks for the clarifications! 🙂

dominicm20:06:43

Is it possible to use tools.reader to read a form as a string? Preserving whitespace. I'm guessing there might be some trick with the pushback reader, but not sure.

Alex Miller (Clojure team)22:06:24

Yes, also in the Clojure reader

❤️ 4
lvh23:06:20

I'm running: clj -A:cli:client -m aot some-args the client alias has both an :extra-deps and a :main-opts. I was expecting the main-opts on the command line to override those from the alias, but instead the main-opts from :client are used. Is there an order to specify them in that fixes that, or is this why -R/-C exist?

Alex Miller (Clojure team)23:06:24

This is a known issue, but using R and C should be a workaround

Alex Miller (Clojure team)23:06:55

A will always be applied last right now

lvh23:06:20

ah, gotcha -- thanks 🙂