This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-24
Channels
- # announcements (11)
- # beginners (72)
- # calva (11)
- # cider (12)
- # clj-kondo (147)
- # clojure (6)
- # clojure-new-zealand (2)
- # clojuredesign-podcast (2)
- # clojurescript (36)
- # cursive (2)
- # datomic (5)
- # emacs (4)
- # fulcro (57)
- # graalvm (104)
- # graphql (2)
- # jobs (1)
- # joker (1)
- # kaocha (3)
- # malli (51)
- # off-topic (2)
- # portkey (1)
- # reagent (18)
- # shadow-cljs (26)
- # spacemacs (7)
- # tools-deps (5)
- # vim (4)
Hi all. What the function can do this?
(fn "ADEF" "BC" 1) ; => "ABCDEF"
first arg soruce string
second substring
third index in source string
I don’t know for (fn “ADEF” “CD” 1) but for (fn “ADEF” “BC” 1) the following function will do:
(defn fn [s c i] (str (subs s 0 i) c (subs s i)))
I made this. More common solution
(defn insert-between [src-val start-idx val]
(let [[before after] (split-at start-idx src-val)]
(concat before val after)))
user=> (insert-between "ADEF" 1 "BC")
(\A \B \C \D \E \F)
hey guys, awesome sunday
me and @mping were inspired by a layerCI article and we started coding PostgreSQL queue relying on NOTIFY
postgres feature.
the code is too small ( https://github.com/clj-lx/clj-pgqueue/blob/protocol-based-queue/src/clj_lx/impl/pgqueue.clj ) 60 lines
could someone give some feedbacks/code-review the code ( it will be open source ) ?
https://github.com/clj-lx/clj-pgqueue/tree/protocol-based-queue
thx in advance
https://github.com/weavejester/crypto-password is what i like to use
Hi, is there an example for a basic rest api with the latest versions of httpkit, composure, ring, json? I'm struggling to find an example on how to start building a rest api using clojure which is fairly recent.
Your best bet might be to start with the sente example project for real-time web comms and slim it down to suit your needs. You can choose HTTP-Kit as a server
@UKEAR38ES feel free to ask me any questions about the videos. httpkit and ring both use the ring approach, so most things will work with either library.
thanks
I was sending plain maps over the wire {:map val} but now i'm sending a vector of maps [{m} {m2} {m3}] but i'm not sure how to digest that on the clojurescript side.
How were you digesting maps before? e.g. via a call to read or read-string, or something else?
(cljs.reader/read-string response) and then cramming the response into an atom
read-string should work fine to read a vector of maps, just as well as it can read a single map.
not sure if that is what you were concerned about -- perhaps you are concerned about how to deal with the difference between a map and a vector of maps after successfully reading it?
Okay, I think the problem is actually on the server side
One way would be to change your application on both sides so that it always sends and receives a vector of maps, if that is reasonable for your application.
If you really want it to sometimes transmit a map, and sometimes a vector of maps, and there is no ambiguity there, you can distinguish those cases on the receiver by a call to map? or vector?
Ah, thank you, that's a great idea...
I think the clientside might not care but the serverside has stopped producing a valid response for the client ;/
I know some people would recommend the "always send a vector of maps" approach first, where you send a vector of one map in every case that now you send a single map.
If the sending of a vector of maps is a bug on one side of your code, and it should only ever send a map, then yeah, fix the bug 🙂
well the serverside gets a result, prints it in the console, i want to send it to the client as a response from a POST, the client prints out null ;x
programming is amazing, incremental rocket construction
how to survive without a repl?
is there a way to print out any special characters i might be missing in the console?
-_- there's a space after the e-mail address
It can be tedious to look through, but if you have any string my-string
, you can look at the sequence of numeric code points of all of its characters using an expression like (map int mystring)
`
If you want to look for non-ASCII characters in a string, you can use filter
on the resulting sequence to remove all character codes in any range you want, that you consider "normal", leaving only the "abnormal" ones
Ah, that's a cool trick
You can also use map-indexed
instead of map
to get the index of each character code, which might be helpful if you want to find out where those characters occur in the original string.
my (return-stuff) function was only printing things out
not actually returning values lol
my brain had an awesome WTF moment there 😃
So the clientside gets a vector of maps over the wire, but only grabs the first map.
Got it now thanks a lot @U0CMVHBL2
forgot to encode as (str) before passing over the wire
Following this announcement https://clojurians.slack.com/archives/C06MAR553/p1574608998245600, I get this error when running the tool:
$ clj -A:graph
Error building classpath. Unknown alias key: :deps
Help, someone?@desm is there a stray key named :deps
in one of the config files? sorry i can't be more specific.
Thanks for trying to help. Is there a way to list the config files that get involved when I run that command?
hmm I wonder. Probably?
You may have to do that first
Thanks sova, looks like I need to make sure I have a newer version of the clj
command.
Not tried it yet though
Yes, you need newer clj
yup, updating to a newer clj did the trick, thanks
oh ok @ghadi, I’ll try that
thanks @ghadi, that helped me get further (to do brew upgrade clojure
)
Anyone ever seen this error before?
$ clj -A:graph
Cannot run program "dot": error=2, No such file or directory
.IOException: Cannot run program "dot": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at dorothy.jvm$render.invokeStatic(jvm.clj:67)
at dorothy.jvm$render.invoke(jvm.clj:38)
at dorothy.jvm$show_BANG_.invokeStatic(jvm.clj:138)
at dorothy.jvm$show_BANG_.doInvoke(jvm.clj:108)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at clojure.tools.deps.graph$make_graph.invokeStatic(graph.clj:107)
at clojure.tools.deps.graph$make_graph.invoke(graph.clj:95)
at clojure.tools.deps.graph$run.invokeStatic(graph.clj:186)
at clojure.tools.deps.graph$run.invoke(graph.clj:160)
at clojure.tools.deps.graph$_main.invokeStatic(graph.clj:205)
at clojure.tools.deps.graph$_main.doInvoke(graph.clj:188)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.main$main_opt.invokeStatic(main.clj:514)
at clojure.main$main_opt.invoke(main.clj:510)
at clojure.main$main.invokeStatic(main.clj:664)
at clojure.main$main.doInvoke(main.clj:616)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:40)
Caused by: .IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 24 more
Dot is definitely part of graphviz, likely installable via brew as well if using a Mac
Definitely. That way when someone does not read the readme, you can link to it :-). Sorry for that comment - I have spent time trying to make install docs complete and there is always some noticeable fraction that miss it anyway.
It is an optional add-on for clj tooling, released yesterday.
Hi all (again 🙂). I have next code
(def myref (ref []))
(defn add-val-to-ref [val]
(dosync
(ref-set (conj @myref val)))
add-val-to-ref calls async by different threads. How can I do all incoming vals be in order of incoming from threads?
T1 (add-val-to-ref 10)
T2 (add-val-to-ref 20)
T1 (add-val-to-ref 30)
T1 (add-val-to-ref 40)
T2 (add-val-to-ref 50)
@myref [10 20 30 40 50]
I may be missing something - what evidence do you have that leads you to believe the results are not in the same order as the calls to add-val-to-ref ?
I solved the problem. Blame frontend.
Cool you solved it .