This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-28
Channels
- # announcements (4)
- # aws (2)
- # babashka (56)
- # beginners (43)
- # calva (70)
- # clj-kondo (25)
- # cljs-dev (29)
- # clojure (103)
- # clojure-dev (9)
- # clojure-europe (55)
- # clojure-gamedev (8)
- # clojure-nl (5)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojured (1)
- # clojurescript (56)
- # copenhagen-clojurians (1)
- # core-async (2)
- # cursive (16)
- # datomic (5)
- # deps-new (18)
- # emacs (9)
- # events (3)
- # fulcro (45)
- # graphql (2)
- # gratitude (2)
- # kaocha (6)
- # lambdaisland (8)
- # lsp (72)
- # meander (41)
- # missionary (5)
- # nextjournal (52)
- # off-topic (2)
- # pathom (12)
- # pedestal (2)
- # practicalli (1)
- # re-frame (6)
- # reitit (5)
- # releases (1)
- # reveal (1)
- # specter (3)
- # sql (4)
- # tools-deps (22)
- # vim (8)
- # wasm (1)
- # xtdb (22)
I saw the compojure wiki In Middleware chapter.
(defn wrap-current-user [handler database]
(fn [request]
(let [user-id (-> request :session :user-id)
user (get-user-by-id database user-id]
(handler (assoc request :user user)))))
To solve this problem, we can use wrap-routes:
(-> (context "/user" {:keys [user]}
(GET "/current" ...)
(POST "/current" ...))
(wrap-routes wrap-current-user))
the wrap-current-user has two parameters that handler and database. the wrap-current-user function is called by wrap-routes, the 'database' argument is how to pass to the wrap-current-userWhat's the different between `::keyword` and `:keyword`?
(re-frame/reg-event-db
::initialize-db
(fn [_ _]
db/default-db))
vs
(re-frame/reg-event-db
:initialize-db
(fn [_ _]
db/default-db))
I'd try it like Alex suggests but :keyword
is an un-namespace keyword whereas ::keyword
is shorthand for :current-namespace/keyword
P.S. the `::` shorthand is useful for referencing keywords that are namespaced in a namespace you require into your current namespace. For example,
(ns my-current-ns
(require [my.longer.nested.other-ns :as other]))
(def foo [m x]
(assoc m ::other/key-from-other x))
In the example above ::other/key-from-other
expands to :my.longer.nested.other-ns/key-from-other
This is called auto-resolved keywords https://clojure.org/guides/weird_characters#autoresolved_keys
Try it at your repl
I am trying to add space before capital letters in string like this "HelloWorld, ThankYou"
in clojurescript by using clojure.string/replace "HelloWorld, ThankYou" #"(\p{Ll})(\p{Lu})" "$1 $2"
but it is not working.
I don’t usually use POSIX character classes, but from looking at the docs (https://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html), I get the impression you have to spell them out, e.g. \p{Lower}
etc.
Thanks, the lower one worked, and what to do if I want to reverse it like remove space?
I would just use either a literal space or the \s
whitespace wildcard.
(let [s "This line has too many spaces."]
(clojure.string/replace s #" +" " "))
=> "This line has too many spaces."
or
(let [s "This line has too many spaces."]
(clojure.string/replace s #"\s+" " "))
=> "This line has too many spaces."
Sorry, not space if I have an underscore between, and I need to replace it with space "TT_Hello_World, CC_Thank_You"
but only need to replace combination of [a-z][_][A-Z]
Sure, just use literal underscore.
(let [line "TT_Hello_World, CC_Thank_You"]
(clojure.string/replace line #"([a-z])_([A-Z])" "$1 $2"))
=> "TT_Hello World, CC_Thank You"
(clojure.string/replace "HelloWorld, ThankYou"
#"(\p{Lower})(\p{Upper})" "$1 $2")
=> "Hello World, Thank You"
Personally I’d just use #"([a-z])([A-Z])"
May I ask if tools.build will be published on maven/Clojure at some points?? Because of corporate policy we can’t pull deps from GitHub/gitlab?
Does your company not allow open-source software to be used?
I can’t pull any repository from GitHub.
It is a bit incoherent since I could pull any docker images from docker hub and some others. So I could probably pull an image where Clojure Tools is included and search for the jar xD
Better be safe than sorry, I work in a old industry with life threatening consequences on data leaks.
@neo2551 https://ask.clojure.org/index.php/11433/will-tools-build-be-released-as-a-jar
Thanks :)
You could build it yourself too :)
It would bring me outside of my comfort zone :)
I guess I have been spoiled by tools.deps and everyone's work for too long :)
It's just jarring the source dir :)
I guess you'd need a pom too, but it's a few lines of tools.build :)
I guess depstar would also work xD.
Thanks a lot for all your work, if you make a Clojure Survey this year, you could ask if people want to have a official tools to be published in Clojure/maven if this is okay to have everything on GitHub xD (my corporate me would tell it makes things easier to have code in Clojure xD).
I will probably get around to doing it, have just been waiting to see if demand
☝️:skin-tone-2: Yeah, I'd be surprised if a company that doesn't allow you to download software from GitHub would allow you to use a deprecated and archived open source project?
does the jar include the repo information? If not there’s no way to catch that with an automated policy right?