This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-18
Channels
- # beginners (56)
- # boot (1)
- # cider (96)
- # cljs-dev (148)
- # clojure (60)
- # clojure-austin (11)
- # clojure-france (2)
- # clojure-italy (5)
- # clojure-russia (11)
- # clojure-spec (31)
- # clojure-uk (5)
- # clojurescript (52)
- # community-development (37)
- # cursive (3)
- # data-science (8)
- # datomic (14)
- # devcards (2)
- # emacs (1)
- # fulcro (13)
- # hoplon (1)
- # immutant (2)
- # luminus (3)
- # off-topic (2)
- # onyx (16)
- # parinfer (38)
- # re-frame (8)
- # reagent (5)
- # shadow-cljs (332)
- # spacemacs (5)
- # specter (5)
- # sql (6)
- # vim (52)
What is the difference between (defn ^:private my-fn ...)
and (defn- my-fn ...)
? Both of them can be found in clojure.core
.
For example: https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L7532
@vincent.cantin no difference. Possibly some functions were moved around after the definition of the defn-
macro over time https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L4865
@vincent.cantin It doubles up on the reduced since the reduce
call a few lines down in cat
needs to know if it was stopped by reduced
If so, it needs to return the reduced
object (not the value it holds) since the transduction needs to stop.
Could not transfer artifact lein-ancient:lein-ancient:jar:0.6.10 from/to maven-public .. interesting
i'm looking at the A* implementation in the joy of clojure. I'm trying to understand why the algorithm does not step forwards and backwards between, say, [0 0]
and [0 1]
Does it exist a transducer equivalent of tree-seq
?
I made a transducer version of tree-seq
which seems a lot faster than the original and the improved POC on github.
https://gist.github.com/green-coder/3adf11660b7b0ca83648c5be69de2a3b
Transducers really rocks!
Thank you ^_^
Think i got it. When the algorithm is working on [0 1], it will add [0 0] as a new work item when [0 0] is checked again, the algorithm will look up the neighbors of [0 0], trying to find the cheapest path to get to [0 0]. It will compute a newcost, which will inevitably be higher than the existing cost to get to that position, hence the todo list does not grow. this prevents an infinite loop
Could this be destructured: `(fn [dims] (let [dimensions (js->clj dims :keywordize-keys true) width (:width dimensions) height (:height dimensions)]` I only want to keep width and height.
Hello all. I'm struggling to include :npm-deps {:rmwc "1.2.0"} into my build. It claims to not be able to find react, even when I include cljsjs/react in my dependencies.
Compiling ClojureScript...
ā¢ js/dashboard.js
ā¢ js/devcards.js
events.js:182
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'react' from '<redacted>/node_modules/rmwc/Button'
:npm-deps is still a bit buggy I believe, depending on the library. You include react also with :nmp-deps?
I tried, but then it complains that it cannot find module './ReactInternal'.
All I want is a Material UI library that I can easily use. react-mdl is deprecated, material-ui pulls in it's own react and react-dom (which isn't too bad but I want to avoid it) and rmwc isn't on cljsjs. Any other suggestions?
@reuben.steenekamp Iām just starting to look at material-ui ā and it looks like material-ui-next https://material-ui-next.com - doesnāt pull itās own but uses 16.0. Where did you see material-ui pulls in own react and react-dom?
I mean't from cljsjs From https://github.com/cljsjs/packages/tree/master/material-ui:
cljsjs/material-ui comes with its own cljsjs/react and cljsjs/react-dom.
@reuben.steenekamp one thing to note: shadow-cljs has a mechanism to deal with the fact that many libraries import from cljsjs. it basically shims them so you can install from npm
Cool. Thanks.
@reuben.steenekamp Got it - with shadow-cljs this wouldnāt be an issue.
@reuben.steenekamp if you are going to be importing a lot of javascript libraries iād strongly consider using shadow-cljs, which makes this stuff easier because you just install using npm or yarn. but if you want to get it working using the normal clojure compiler, you will need to import using :foreign-libs
this is how I got react-dnd
to work
:foreign-libs [{:file "resources/lib/ReactDnD.js"
:file-min "lib/ReactDnD.min.js"
:provides ["react-dnd"]}]
before i moved to shadow i just copied the UMD build from the /dist directory of the node_module into my source tree and then pointed the compiler to it using a :foreign-libs like the above
Cool, I hadn't heard about shadow-cljs, will check it out.
Alohaa, another question for Reframe. How do I access a value in the state just once, without subscribing to it? Is this possible or is it totally the wrong approach?
For example I have a list of Users in the State which I want to go through in the frontend, to see if it contains a certain value. I just want to do that once when I press a button for example, without rerendering everything.
can anyone think of a more straight forward way to build up hashmap?
(def board (zipmap (range 1 9) (repeat {:player-id nil})))
as always, there's a way to do it with for
if you prefer (into {} (for [n (range 1 9)] [n {:player-id nil}]))
I have an app that Iām currently storing some state inside of an agent, and I would like to update the data inside of that agent once a day
@lilactown you don't need a library -- one idiom is this:
(import '[java.util.concurrent
TimeUnit
Executors
ScheduledExecutorService])
(defonce threadpool (delay (Executors/newScheduledThreadPool 1)))
(let [a (atom {})]
(.scheduleAtFixedRate ^ScheduledExecutorService @threadpool
#(update-my-atom a)
0 ;; delay
refresh-interval TimeUnit/MINUTES)
;; return the atom
a)
I think the important distinction there is "once per day per process" or "once per day in the world" - scheduled thread pool works great for the former, for the latter you need some inter-process communication
I prefer the scheduled thread pool because it gives you transparency and introspection that a future doesn't
Iām not familiar at all with the java threading/scheduling APIs - so itās going to take me a bit to unpack this š
@lilactown the handy thing is that normal functions are callable - so you can just pass a function of 0 args to be executed
question coming from my naivete w/r/t web development:
I'd like to serve multiple websites from one linux box with one IP address. Ideally, there'd be some Clojure way to do that. Let me know if there is!
I think though I have to set up nginx or apache. What gives me pause is, to configure either of them, I have to specify where .html
files are. I'm using clj-http
and compojure
. I'm not sure how much I have to change my clojure apps to accommodate what I want to do.
Ideally, I could just point nginx to two different java processes for two different URLs. I doubt that's how it works, though!
I made a transducer version of tree-seq
which seems a lot faster than the original and the improved POC on github.
https://gist.github.com/green-coder/3adf11660b7b0ca83648c5be69de2a3b