This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-25
Channels
- # aleph (2)
- # announcements (7)
- # babashka (6)
- # beginners (53)
- # calva (17)
- # cider (5)
- # clj-kondo (137)
- # cljs-dev (19)
- # cljsrn (14)
- # clojure (74)
- # clojure-conj (9)
- # clojure-europe (13)
- # clojure-houston (1)
- # clojure-italy (16)
- # clojure-nl (21)
- # clojure-spec (3)
- # clojure-uk (9)
- # clojuredesign-podcast (24)
- # clojurescript (85)
- # cursive (11)
- # datomic (28)
- # duct (3)
- # emacs (6)
- # figwheel-main (1)
- # fulcro (68)
- # graalvm (19)
- # graphql (3)
- # joker (32)
- # kaocha (10)
- # lambdaisland (1)
- # malli (50)
- # off-topic (13)
- # other-languages (7)
- # pathom (2)
- # pedestal (14)
- # re-frame (53)
- # reitit (8)
- # shadow-cljs (57)
- # specter (2)
Would anyone be willing to help me understand some clojure code in here: - https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/server.clj I'm specifically unfamiliar with
(def ^:dynamic *session* nil)
and how it relates to what is going on in
(defn- accept-connection
"Start accept function, to be invoked on a client thread, given:
conn - client socket
name - server name
client-id - client identifier
in - in stream
out - out stream
err - err stream
accept - accept fn symbol to invoke
args - to pass to accept-fn"
[^Socket conn name client-id in out err accept args]
(try
(binding [*in* in
*out* out
*err* err
*session* {:server name :client client-id}]
(with-lock lock
(alter-var-root #'servers assoc-in [name :sessions client-id] {}))
(require (symbol (namespace accept)))
(let [accept-fn (resolve accept)]
(apply accept-fn args)))
(catch SocketException _disconnect)
(finally
(with-lock lock
(alter-var-root #'servers update-in [name :sessions] dissoc client-id))
(.close conn))))
I'm specifically trying to understand what the dynamic does and how it interacts with (binding
I want to make a small 3D thing with WebGL and ClojureScript. But then I would like to show it on a website using JavaScript (preferably "inside" on one of the existing pages). I don't know many details yet, nor much about web development. But I would like to know, is there a way to achieve this? And what is this way called?
Hi juri, yes it is totally possible. ClojureScript compiles to Javascript, so your code will definitely run in an existing web page.
How do I do it? Do I include the compiled Javascript in my html, and have the code use a div with an id of my chosing? Is it that simple? (I've not yet understood how to even deploy a clojurescript website. Seems I need a server, seems like the resources/public folder isn't enough. Would this server be an obstacle to the above approach?)
Is it that simple? Yes, it can be. Yes you need a server. I would suggest trying shadow-cljs for your tooling.
This might help get you running quickly: https://github.com/shadow-cljs/quickstart-browser
I'm trying to remember the order of the arguments in the core functions. As a general rule of thumb, is it correct to expect higher-order functions to have their "most significant" arg in second+ place (for example you would usually use ->> for map and reduce) and functions that operate on data to have their "most significant" arg in first place (-> with assoc, get, etc)
from https://clojure.org/guides/threading_macros#thread-last: > By convention, core functions that operate on sequences expect the sequence as their last argument. Accordingly, pipelines containing map, filter, remove, reduce, into, etc usually call for the ->> macro. > > Core functions that operate on data structures, on the other hand, expect the value they work on as their first argument. These include assoc, update, dissoc, get and their -in variants. Pipelines that transform maps using these functions often require the -> macro.

Hello 🤙, I'm trying to use font-awesome from webjars in luminus, and getting a mime-type conflict:
The resource from "" was blocked due to MIME type ("text/html") mismatch (X-Content-Type-Options: nosniff).
When linking the style with
{% style "/assets/font-awesome/web-fonts-with-css/css/fontawewsome-all.min.css" %}
I think that the crux of it is these two wrappers
(wrap-content-type
(wrap-webjars (constantly nil))
As suggested by https://github.com/weavejester/ring-webjars/issues/4
I should be able to use wrap-content-type to wrap to add the right mime type to the style.
However trying
(wrap-content-type
(wrap-webjars (constantly nil))
{:mime-types {"css" "text/css"}})
(based on the documentation https://github.com/ring-clojure/ring/wiki/Content-Types)
Didn't do anything..
Any idea what can I do?Thank you, I've switched to another way of importing it, but will probably try it later to find out :)
https://codepen.io/apexcharts/pen/xYqyYm I want to use this chart in my cljs app there is a line ApexCharts(document.querySelector("#chart"), options);
is there a way to pass hiccup element to this function instead of using document.querySelector("#chart")
how do I get a single char into a set? (set \a)
fails, as set
expects a collection. (into #{} \a)
also fails, both are trying to use a char as a sequence. seems ugly to go through (set (str \a))
to get there. (and for my larger problem, can’t just do #{\a}
). My real issue is I want a function to accept a collection of chars or a single char, and I dislike switching on type.
you could use (hash-set \a)
or (conj #{} \a)
but I might actually recommend that you set your defn up to take varargs, which will make a seq regardless, then you can use set
(defn foo [& cs] (set cs))
or my even better advice would be to not take both char and coll of char as valid args and just stick with coll-only. it complicates the logic on both sides of that interface and every time I've done this, I ended up regretting it later.
thanks @alexmiller , your gut sounds right. I’m just playing around in a toy project and I’m overly worried with my own sense of beauty.
How to write a project so that I can run a REPL against a working instance of it and play with data?
add an nrepl server to your system https://nrepl.org/nrepl/0.6.0/usage/server.html
here’s a good primer on how to structure your program for live development: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
Hi I don't now if this is the right channel to ask this question 😅
I'm pretty new to clojure and java in general, I'm trying to do lein run
in this project (https://github.com/snoe/clojure-lsp) but I keep getting this error, any help?
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
java has this (seldom used) feature where you can sign jars, and the signature is included as part of the contents of the jar, so if you blindly combine jars to build a new jar, you can end up with a signature from one of the jars and of course doesn't match the combined jar
herm, actually, no, it is a failure of the signature mechanism, but it doesn't look like the kind of failure you get when combining jars
it looks like the project has moved to deps.edn and clj over lein, but has some code to include the deps.edn deps in the project.clj, my guess is that code isn't properly handling some exclusion you need, so you are ending up with two copies of TextDocumentIdentifier
clojure_lsp.handlers$eval10214$loading__6434__auto____10215.invoke(handlers.clj:1)
clojure_lsp in that stacktrace seems weird
Thanks a lot for the quick answer, as far I can see the project.clj
loads the dependencies from deps.edn
like this:
(def +deps+ (-> "deps.edn" slurp edn/read-string))
So the dependencies are only in one place, but maybe deps.edn
is loaded implicitly by Clojure :thinking_face: , and that is maybe causing the issue?deps.edn is not loaded implicitly by Clojure (or explicitly)
Ok thanks for the reply
the maintainer runs its on java 12 and i run it on java 8 without those issues sorry
@dpsutton I just tried with Java 8 and It works the problem comes from Java 12 I don't know why. At least it works now, thanks for the tip
And now I tried again with Java 12 and it works 😱, I think it is because everything it is compile now so when I do lein run
it only runs the Jar
So yeah lein clean
it does not work any more, then Java 8 lein run
it works then Java 12 lein run
it works
yes that is correct, I need to compile it
first with Java 8
This is all the events