This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-28
Channels
- # announcements (6)
- # beginners (89)
- # boot (1)
- # calva (1)
- # cider (24)
- # cljsrn (19)
- # clojars (2)
- # clojure (102)
- # clojure-europe (2)
- # clojure-italy (9)
- # clojure-nl (1)
- # clojure-spec (6)
- # clojure-uk (56)
- # clojurescript (29)
- # code-reviews (14)
- # cursive (5)
- # data-science (1)
- # datomic (44)
- # duct (1)
- # emacs (10)
- # figwheel-main (5)
- # fulcro (8)
- # graphql (10)
- # hoplon (1)
- # leiningen (7)
- # overtone (17)
- # pathom (8)
- # re-frame (13)
- # slack-help (3)
- # spacemacs (22)
- # sql (2)
- # vim (3)
Is there an existing option in CIDER (Emacs) that will auto-switch namespace in the REPL to match the current clojure mode buffer?
So that if I am in foo.clj, and I change to bar.clj, the REPL will automatically (in-ns 'whatever-project.bar)
I do not know, but wanted to point out that if no one here has an answer for you, there are #emacs and #cider channels that may be more target-rich environments for asking.
I've been toying with ideas for what custom FS I could build in FUSE after writing a simple RESTful API + FUSE integration in Clojure to serve dog pics. To actually make a real integration that provides value, I'm wondering if something that combined (dir *ns*)
type output (but mapped doc
across each) and stored the results in a directory structure, with file names being the function/variable names and the VFS file contents being the doc string would provide any value to clojure users
Then tree based FS navigators (like ranger) or Emacs dired would let users very quickly cycle through files (filtering off ones they do vs do not want) and see the result of some doc
Getting ready to announce the release of https://github.com/jayzawrotny/book-report tomorrow. Any sour notes stick out in my tiny, quiet symphony?
the “Which prints:” section shows different text printing than the code above that staged it would suggest. Probably just changed it a few times and something got out of sync.
Would also be nice to have some guidance on expected workflow. Are you expecting others to create workbooks and distribute them?
Or looks like this is more of a scratch pad for the person doing the learning to come back and reference? sorry maybe misread the intent originally
in that case probably what you have makes sense. they can organize it however they like and use whatever workflow
Good point, I’ll try to clarify that in the explanation. Though it definitely could work as a repo people can clone to learn how an API works or learn a specific topic. I haven’t really thought of that use case.
what library are you guys using for http-calls? I am currently using https://github.com/dakrone/clj-http but I am having issues with setting custom SSL-contexts.
Got it working by using keystore parameters.
I had a pkcs12 file, only had to set the parameters
keystore, keystore-pass and keystore-type
.Afternoon!
what's the idiomatic way to build a vector in Clojure?
Basically, I have a hash-map and I want to build a formatted string depending upon specific keys
I was going to just create a vector and then string/join the final output but now that I think about it, maybe that entire approach is wrong
depends on what you are trying to accomplish, maybe give us an example of input and output?
I'm looking for a way to relativize two paths like this:
(= "../basics/route-syntax"
(wanted-function
"/d/metosin/reitit/0.2.10-alpha1/doc/http/pedestal"
"/d/metosin/reitit/0.2.10-alpha1/doc/basics/route-syntax"))
I briefly played with nio.path's relativize
but it did return too many ..
jumpsWell, input would be a 'bookmark' which is an SSH connection:
{ :name "My super important production server", :alias "prodserv", :tags [ "foo", "bar" ], :address "my.host.internal", :user "james" }
And i'm just basically trying to format the output based on different fields, eg.
[1] james@prodserv (My super important production server)
or if some fields were missing, it may just be
[1] prodserv
Normally, I'd just have some conditionals and append to a list the merge the list
or something along those lines
But now I'd have to have a load of embedded logic such as if key :name then prepend :name value @
in pseudocode
Should I just have smaller functions that return a blank string if the value is missing, and use (format)
to merge them all into a single output string? Or is that equally as bad?
I’d say functions are always idiomatic in Clojure 🙂 one function, which might be handy in your case is fnil
and there might be others https://clojure.org/api/cheatsheet
Clojure is built around manipulating data structures and we have a lot of built-in functions to do just that
you could also merge a map with defaults with the actual map to get the default values for some missing keys
thanks for your help
Does somebody understand why this returns a path with two ../../
segments?
(let [->path #(Paths/get % (make-array String 0))
s1 "/d/metosin/reitit/0.2.10-alpha1/doc/http/pedestal"
s2 "/d/metosin/reitit/0.2.10-alpha1/doc/basics/route-syntax"]
(.relativize (->path s1) (->path s2)))
#object[sun.nio.fs.UnixPath 0x3bbb24a4 "../../basics/route-syntax"]
Shouldn't this be just ../basics/route-syntax
?
hmm, I’m not sure about the exact semantics, but seems to be consistent with the docs here https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#relativize(java.nio.file.Path)
in this repo https://github.com/Raynes/lein-findfn it’s written: > Distributed under the Eclipse Public License, the same as Clojure. But Clojure is not distributed under EPL, but Apache?
What’s the preferred license in the Clojure community? Same as Clojure? I chose MIT for some projects, but I’m not really an expert on these things
>>> * Clojure * Copyright (c) Rich Hickey. All rights reserved. * The use and distribution terms for this software are covered by the * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) * which can be found in the file epl-v10.html at the root of this distribution. * By using this software in any fashion, you are agreeing to be bound by * the terms of this license. * You must not remove this notice, or any other, from this software.
Clojure and contribs (and many open source Clojure projects) use EPL, but Apache is common as well
Is it possible to extend protocol for object?
(defprotocol Taggable
(tags [x] "returns list of tags"))
(def config {:option-1 "One"
:option-2 "Two"})
(extend-type clojure.lang.PersistentArrayMap
Taggable
(tags [me] {:tag (get me :option-1 "None")}))
(defn print-tags [taggable]
(prn {:tags (tags taggable)}))
(defn taggable-config [config]
(reify Taggable
(tags [_] {:tag (get config :option-2 "None")})))
(def adorned-config (taggable-config config))
;; config behaves as both Map and Taggable
(print-tags config)
(prn (keys config))
;; adorned-config behaves only as Taggable
(print-tags adorned-config)
(prn (keys adorned-config))
What I want to achieve is something like:
(extend-object config
Taggable
(tags [me] {:tag (get me :option-1 "None")}))
So only specific object would have implementation of certain protocols?
in Clojure 1.10, for protocols that explicitly allow it, you can supply a protocol implementation as metadata on a particular object - is that what you’re looking for?
Thanks! I’ll give it a try. The project I am working on is still on 1.9 tough…
you would need to set :extend-via-metadata true
on the Taggable protocol
then adorn your config object with metadata that has the impl
(def adorned-config (with-meta config {`tags (fn [me] {:tag (get me :option-1 "None")})}))
Thanks, it works!
I'm trying to make something that would make a test like this pass: (is (= {a 23 } (let [b 23] (mymacro [a b]))
(defmacro ->map
"(->map a b) ;;=> {:a a :b b}"
[& symbols]
(assert (every? symbol? symbols))
`(hash-map
~@(interleave (map keyword symbols) symbols)))
So I've been trying to selectively unquote parts of this binding vector, or to look them up in &env, but I can't get either to work
Hello guys, I am working on a reservation system with mongoDB. I use monger for handling it from clojure. Unfortunately arrayFilters doesn't work, is this a problem on my side, or monger doesn't work? https://github.com/michaelklishin/monger/issues/181
I've offered a possible solution in that GitHub issue. I haven't actually used Monger so that's just my reading of the source code.
I’m not sure what your macro is supposed to do. name a value and return a map of names and values?
otherwise i can only do (wisp-compile (+ 37 x))
which results in 37 + x
(that part works already)
(defn compile-+ [& args]
(str/join " + " args))
(defmacro eval* [body env]
(let [evaled (mapv #(or (get env %) %) body)]
`(compile-+ ~@(rest evaled))))
(defmacro wisp-compile [bindings body]
`(let ~bindings
(eval* ~body ~&env)))
(wisp-compile [x 5] (+ 37 x)) ;;=> "37 + 5"
@mrg I'm assuming that you have a function somewhere which takes something like '(+ x 37)
and returns "x + 37"
.
What you need here is a macro which will walk over the code it is given and if the key is in &env, it should be set to x
, otherwise 'x
?
You will run into difficulty if you want to support nested macros in certain cases, but overall you might be okay.
Let's say I have a parent hiccup form that references a child hiccup form, how would I evaluate the nested hiccup form?
(defn child []
[:p "hello world"])
(defn parent []
[:div
[child]])
; [:div [#function[slm.components.input/child]]] --> what I get when I evaluate `parent`
; [:div [:p "hello world"]] --> desired outcome of evaluating `parent`
@mrg I think your best bet here is core.unify, having played with it some in the REPL.
Trying to auto-detect which variables are available based on &env is tricky, because it excludes all the def
and require
in the namespace.
@jacobhaag17 call child like the function that it is
That's what I was thinking, however I am concerned with deeply nested hiccup forms and child hiccup forms that require arguments.
(defn child [value]
[:p value])
(defn parent []
[:div
[child "hello world"]])
((first (second (parent))) (second (second (parent)))) ; doesn't seem like a very good solution
;; [:p "hello world"]
hm I just deployed my (Luminus-based, but I suspect this is not important here) server app and it's worked fine locally but now that I'm running a production build, I see java.lang.NoClassDefFoundError: Could not initialize class org.apache.batik.bridge.DefaultFontFamilyResolver
. I suspect this is classpath-related (I haven't really dealt with JVM in aaages). I'm using lein uberjar
to build this.. do I need to somehow tell lein about batik?