This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws-lambda (7)
- # beginners (80)
- # boot (134)
- # cider (11)
- # cljs-dev (5)
- # cljsjs (3)
- # cljsrn (19)
- # clojure (144)
- # clojure-austin (2)
- # clojure-berlin (3)
- # clojure-greece (6)
- # clojure-italy (3)
- # clojure-russia (95)
- # clojure-spec (57)
- # clojure-uk (120)
- # clojure-za (2)
- # clojurescript (71)
- # component (1)
- # css (1)
- # cursive (22)
- # datascript (2)
- # datomic (101)
- # dirac (9)
- # docker (3)
- # emacs (10)
- # events (2)
- # immutant (3)
- # leiningen (2)
- # om (63)
- # om-next (1)
- # onyx (6)
- # pedestal (55)
- # portland-or (3)
- # protorepl (2)
- # re-frame (30)
- # reagent (10)
- # ring-swagger (1)
- # rum (31)
- # spacemacs (5)
- # specter (9)
- # untangled (90)
- # yada (2)
Input: a string output: for each character in the string, if it's in [a-zA-Z0-9] leave it as is; otherwise, convert it to _
Hey all, I’m
clj-http is throwing an exception because the site I’m making a request against is returning a bad
MalformedCookieException Invalid 'expires' attribute: session org.apache.http.impl.cookie.BasicExpiresHandler.parse (BasicExpiresHandler.java:63)
I’ve been looking around the web and in the code, and I don’t see any clear way to get clj-http/apache HTTP client to just silently store the malformed cookie value (I only need to make two requests, I don’t care about the cookie expiry date)
(clojure.string/replace "some%url info%%23" #"[^a-zA-Z0-9]" (fn [& rst] "_")) ^^ @williewillus : good suggestion; I think this works; any suggested changes?
user=> (clojure.string/replace "abcABC123$%^" #"[a-zA-Z0-9]" "_") "_________$%^"
@sgrove do you have
:throw-exceptions false in your clj-http call? (edited to remove
? — oops)
I see invalid Expires format warnings from the Apache http client library (interacting with PayPal) but I don’t get exceptions.
this appears to work, so I'm double checking for sanity: is :foo/bar a perfectly keyword? is there anything I should be aware of?
@bfabry: you mean it's perfectly vaild for src/fruits/apple.clj to define a keyword :foo/bar ?
it can be defined wherever, it is the keyword :foo/bar with a namespace of foo and a name of bar, if you were in the namespace foo you could refer to it simply as ::bar and if you were in a namespace that aliased the namespace foo to the name baz you could refer to it as ::baz/bar
but :foo/bar, the fully qualified form, will mean the same thing no matter where you write it :slightly_smiling_face:
you likely understand keywords perfectly well and it's not something to be concerned about, you probably just haven't learned about namespaced keywords yet, which is what happens when you start adding slashes. but yes, src/foo.clj's ::bar == apple.clj's :foo/bar
is there anything more to 'namespaced keywords' other than src/foo.clj's ::blah = :foo/blah from anywhere else?
there's also aliases, so if foo.clj aliases the namespace apple to the name banana then foo.clj's ::banana/bar == :apple/bar
very brief rules of namespaced keywords. https://clojure.org/reference/reader#_literals but there's also been a whole heap of useful syntax for working with them added in clj 1.9 in terms of destructuring. if you're on 1.9 and want to learn more then I'd dive into the spec documentation and the 1.9 alpha release notes. if not then the information on the reader literals page is really all you need to know
Hello. I have a small question about web apps with websockets. For example if you need websockets and decide to go with sente, do you use sente for all you communication of use sente only when it's really applicable (e.g. norifications) and use clj-http (of similar) for everything else? I wonder what may be the drawbacks of going full sente
@nidu: But I could imagine you'd want to use http posts if your service supports a general API, or if you have two separate servers, one for the API, and another for notifications. Maybe depends a bit on your scaling needs?
@zentrope you're right. API is intended to be used only by application (and media is
transit which is not very friendly for public i guess)
@nidu You could also put the actual decision behind a module/namespace facade and just re-implement it if you have to change.
One nice thing about a web socket is that it's persistent, so you just have to auth it once.
@zentrope agree though it sounds like a redundant layer, especially taking into account that sente may work over traditional http with polling as well
I just mean something like comm.cljs, then you have a (create-comm) which returns an opague value, then (comm/send-whatever comm) and (comm/get-other-thing comm).
"comm" itself could be sente stuff, or just an HTTP endpoint, as far as the rest of your code is concerned.
@zentrope agree about that. One issue i found is that one may start to rely on connection lifecycle which complicates code a lot. Yeah, maybe i'm just trying to run away from inherent problems :smile:
You could even create a comm-layer protocol if you wanted to get fancy. ;) Might even facilitate testing.
You make a protocol
(defprotocol MyComm (get-products [...]) (save-login [...])) etc, etc, then implement it using Sente (say).
But for testing, you can re-implement the protocol so that you don't have to have an actual server on the other side.
The .read method returns -1 when there's no more bytes to read, so you could loop until n = -1.
@zentrope oh, you mean clojure protocol. I thought you meant some communication protocol :smile:
I need to make ajax calls from cljs to clj; I am considering tusing cljs-ajax; anyone have comments/sugestions ?
@qqq I try goog.net.XhrIo first which is provided by closure library http://www.closurecheatsheet.com/net
@qqq I also prefer to use goog.net.XhrIo. This is enough if you want simple ajax client.
@gfredericks https://github.com/gfredericks/debug-repl is it possible to use this for web requests instead of only breakpoints inside a repl eval?
a big difficulty is that your repl is not doing anything when you make that request
I guess you'd need the
break! to use a known session, and then have your repl client run inside that session?
1) call a function in your repl that blocks, sitting around watching some global queue waiting for functions to execute
2) make the web request, which hits a high-level middleware that submits the request to that global queue and waits for the response
so you have a middleware that redirects the request to be executed by your repl thread
That's a very easy way to connect them. Does debug-repl not operate within a particular session then?
I'm not sure exactly what you're imagining so can't answer your question directly
but I think you could do what I'm describing without knowing much about how debug-repl works
the only thing you have to know is that
./break! only works if your repl's thread is calling it
That would be great. I'm happy to round it off & such, but you'd likely be quicker at putting it together than I. But if you're short on time, I can give it a go.
@dominicm works on my machine: https://github.com/gfredericks/debug-repl/blob/http-intercept/src/com/gfredericks/debug_repl/http_intercept.clj
@dominicm I added the
can-break? function so that requests don't break when the repl isn't intercepting them; so you'd just have to wrap your
break! calls in that check
I could imagine debug-repl having a
break!? macro or something of that sort so you wouldn't have to worry about it
is there a way to run the same deftest with different test data ? like junit parameterized test
@kevinbheda have used something like this before
Ran 1 test containing 5 assertions. 4 failures, 0 errors.
(deftest equal-to-five-test (dorun (map #(is (= 5 %)) [1 2 3 4 5])))
@lmergen if you don’t mind a quick question about it: my objects don’t have a defined key/id, most of the usage will just be “get me one from the pool”. With dirigiste it seems I need to provide the key but I don’t see a way to get a list of available keys or similar which makes it a bit harder for me to see how I would support my kind of usage...
I think so yes. It might be because of the way that dirigeste is instrumented, and collects data about this pool
In our case, all our objects have ids yes. Don't forget, dirigeste used to be called Lamina's "executor". Which might explain why it's not really suitable for a connection pool. It's meant more as a way of distributing work.
@lmergen may I ask what kind of objects you’re managing? My objects aren’t connections but resources that need to be prepared in order to complete some process. Maybe this is closer to a connection than it is to what dirigiste had in mind
I did not see that yet! You’re right from looking at the tests: https://github.com/ztellman/dirigiste/blob/master/test/dirigiste/pool_test.clj#L41-L42
I think I got confused by the fact that the generator also gets a key. But it seems that that is mostly a means to support some kind of polymorphism for the generator function(?)
one of the projects i want to get at later is a GUI place to edit clojure code, and it could give you suggestions etc. based on the specs of things
this could be nice for like
(if <cond> <then> <else>) if that autofills or is checked when you drag an
if block in
is nice if that comes from inherent-in-the-lang stuff rather than adding some accidental extra description for the editor
@gfredericks I had a play with your implementation, worked mostly well.
unbreak! seemed to not work wthout causing an NPE, but that might be a mistake on my part.
I think you were quick to tie it to http though. This pattern worked inside the handler itself (although, maybe this is why it NPE'd?):
(when-let [e com.gfredericks.debug-repl.http-intercept/the-executor] (e #(com.gfredericks.debug-repl/break!)))
This could probably be part of the core debug-repl namespace with some kind of function which is essentially
http-intercept and break/unbreak always tried to execute within the executor if possible.
@gfredericks just hooked up your middleware, it worked. But I got an NPE if I hadn't already run
intercept-http! in vim
@gfredericks I basically tried to decouple
wrap-http-intercept from being a ring middleware. So it could theoretically work with any block of code (I tend to work on projects with a lot of background tasks for example)
okay so you want to pack all of the work into
break!, which I think makes sense and is certainly easier
if that works then it has nothing to do with http or middleware, and would fit a lot better in the core library
It almost worked, just caused the
unbreak! to NPE for some reason I can't quite figure out why.
Yeah, works fine when the
break! is nested within another layer of function. But it looks like you've figured it out :stuck_out_tongue:
maybe I am doing it wrong, but is there a function like
merge-with that does notify even when there is no key clash?
@dominicm I pushed up a fixed version with a special
break!; I think the biggest improvement would be to figure out how to make it respond to C-c
if you're not capable of doing that normally then this wouldn't be an issue for you :)
I \tear\ cannot. If I do that, my editor is stuck like that. Currently discussing with people how to take advantage of the interruptible eval op, but it's part of a big rewrite of fireplace.
@gfredericks this works really well, already have some bindings set up to quickly insert breakpoints and such. Thanks for this.
@gfredericks completion even works, this is literally going to be a massive productivity boost for me. Can't thank you enough.
@gfredericks My vim completion plugin doesn't, normally. I haven't added contextual awareness yet, it's on the todo. I think your method must but the bindings into "global" scope as far as completion is concerned.