This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-20
Channels
- # aleph (4)
- # beginners (47)
- # boot (22)
- # cider (7)
- # clara (1)
- # cljs-dev (8)
- # cljsrn (21)
- # clojure (180)
- # clojure-argentina (13)
- # clojure-gamedev (1)
- # clojure-italy (5)
- # clojure-poland (4)
- # clojure-russia (17)
- # clojure-spec (19)
- # clojure-uk (33)
- # clojurescript (107)
- # cursive (61)
- # data-science (1)
- # datomic (7)
- # emacs (69)
- # euroclojure (1)
- # graphql (1)
- # hoplon (11)
- # immutant (43)
- # jobs (1)
- # leiningen (3)
- # off-topic (5)
- # om (10)
- # onyx (2)
- # parinfer (52)
- # pedestal (11)
- # re-frame (31)
- # reagent (23)
- # ring-swagger (3)
- # schema (2)
- # specter (7)
- # unrepl (9)
But it does crop up again eventually as I'm reloading different files. I'll see if I can narrow it down.
you are reloading the file where the protocols without reloading the file where the record defined, or you are reloading the file where the protocols are defined and trying to call the new (because of the reload) protocol on a instance of the record type that had the old protocol extended to it
But I don't understand why that's happening. The only file I ever require directly from cljs-ajax is ajax.core
, as far as I know.
and core is importing the record class directly instead of using the constructor fns
The docs for cljs-ajax really make it sound like it should work in both, and it almost did, except for this reloading issue. At any rate, I switched to using clj-http on the server and it's all working now. It just means I can't share the code between the client and server the way I wanted.
does anybody uses eastwood
together with clojure.spec
. It is becomming really annoying that eastwood complains about the spec macros even though I cannot do anything about it. Or can I?
@kurt-o-sys no, from what I understand it is about the macro expansion of the specs:
src/service/routing/spec.clj:40:17: suspicious-expression: and called with 1 args. (and x) always returns x. Perhaps there are misplaced parentheses?
src/service/routing/spec.clj:44:22: suspicious-expression: and called with 1 args. (and x) always returns x. Perhaps there are misplaced parentheses?
src/service/routing/spec.clj:38:20: constant-test: Test expression is always logical true or always logical false: 2 in form (if or__5058__auto__ or__5058__auto__ (clojure.core/or 0))
src/service/routing/spec.clj:38:20: constant-test: Test expression is always logical true or always logical false: nil in form (if nil (clojure.core/inc nil) 2)
src/service/routing/spec.clj:38:20: constant-test: Test expression is always logical true or always logical false: nil in form (if or__5058__auto__ or__5058__auto__ (clojure.core/or
Well, I guess eastwood is not clojure.spec compliant yet. You may add an issue to https://github.com/jonase/eastwood/issues ?
similar issues seem to exist already: https://github.com/jonase/eastwood/issues/207
jumm I was hoping to be wrong. The question is rather is eastwood at fault or clojure.spec? because those expanded expressions do look suspicious
this might be a dumb question - it likely is - but what is the best way to define a spec in clojure.spec
for an argument that is a function of arity 1?
Something that could be used to spec a function like take!
from core.async
:
(defprotocol ReadPort
(take! [port fn1-handler] "derefable val if taken, nil if take was enqueued"))
How could I combine two images?
What's the pattern in Integrant/Component REPL development to pick up an edited configuration file on reset? Do you make it a component in the system? I'm building my system object according to the config so I can't do that.
@yonatanel I tend to read the config file each time and merge the result into my system map. Using Aero to read the EDN file I then do something like this: (merge-with merge system config)
.
With a component like this:
(defrecord Datomic [uri]
component/Lifecycle
;; ...
)
And a config file like this:
{:datomic {:uri "datomic:"}}
Looks like Integrant will reload your config from this: https://github.com/weavejester/integrant#configurations
@jcf Integrant config is the equivalent to Component's system, so it won't just re-read my external config file.
Yeah, from a quick look at the Integrant README, there is no explicit system map in Integrant.
If you've got a config
somewhere as per the README, and reloading is done via clojure.tools.namespace, I'd expect changes to the file to show up.
(def config
(ig/read-string (slurp "config.edn")))
How can I add java dependencies to my clojure project?
@danielgrosse same way you add clojure dependencies. the project.clj dependencies list is just maven artifacts
okay.
@yonatanel you might want to look at Integrant-REPL
Does anyone know of a fuzzy finder lib for Clojure? By fuzzy finding I mean that you can, for example, search for "msd" and it would match, and give a high score to, "my/secret/dir", because the letters appear at word boundaries.
Hi @weavejester, I was wondering if i could ask you a #duct related question?
@oskarkv http://yomguithereal.github.io/clj-fuzzy/clojure.html (and there's also a Java lib: https://github.com/tdebatty/java-string-similarity )
@kurt-o-sys Does that do what I want? All the examples look weird, e.g. (dice "healed" "sealed") => 0.8
@oskarkv oh, I must have misunderstood you. But it looks pretty easy to make it work as you expect: extract the letters at word boundaries and match it against one of the fuzzy string algorithms
so, the only thing to do for you would be: convert my/secret/dir
to msd
, right?
@kurt-o-sys I want some more features, like "msod" would not match "my/secret/dir" but it would match "my/awesome/dir"
oh... that's different, right đ
So, you've written it in less than 3 hours, right? Nice đ
I wonder if you could rip off elisp from one of the emacs helpers that does that and convert it
Ops, that last one should not have a score of 3 đ I added it manually and did it wrong. đ
got it. đ
Anyone have a pointer to a small-to-medium-size, open source codebase that uses clojure.spec
in the ways that it is typically used?
I expect to have one next week đ. Well, it still needs some work, but the current state is: https://gitlab.com/kurtosys/lib/factoidic/
https://gitlab.com/kurtosys/lib/factoidic/blob/master/factoidic/src/clj/factoidic/config.clj - spec for config (will be lib boundary, that's why it's in a separate namespace; other specs might not be in a separate namespace).
I use it for: 1. lib boundary validation 2. generative testing 3. instrumentation during debugging
right, that's one of the reasons why I keep it quiet and it's still in SNAPSHOT
. I have to add more specs, testing and some benchmarking.
is there a good clojure library for very simple GIS/map data visualization? or am I better off using something like Om with clojurescript?
may not fit your requirements, but https://github.com/wiseman/leaflet-gorilla could be relevant
Okay @weavejester, right now i'm trying to integrate buddy
's authentication middleware with ataraxy
and duct
, and looking at the ataraxy module docs, it says that for finer control i should use duct.router/ataraxy
instead of duct.module/ataraxy
. I was wondering if there was a way to add other middleware using the module
instead of router
?
@arundilipan you can use both. Use the module to create the routes, then add the middleware to the router key.
@weavejester, oh what would that look like? Would duct.module/ataraxy
and duct.router
be keys in the edn file?
Hi, how do I write a response directly in http-kit? I'm building a tunneling proxy and need the very first response to be exactly "HTTP/1.1 200 Connection established\r\n\r\n",
but it seems http-kit renders that as a body, even if I do something like {:status "HTTP/1.1 200 Connection established"}
sounds like what you want is to supply a :headers map? but I thought :status would automatically be lifted into the headers
@noisesmith Oddly, it's not a header, it's a status-line
in the HTTP spec
oh, OK - I donât know how to override that via ring (assuming if youâre handing it a hash-map like that youâre using it via ring)
sounds like youâd be better off using a TCP library rather than an http library if you want to specify that kind of thing by hand?
I might be wrong
Ya, I'm not sure it's possible with ring. I'd rather not have to use a TCP library, as I don't want to have to glue reqeusts and responses together. But you're right. I may just fork httpkit/ring and kludge something in there
thereâs also aleph which has an http server but also supports using tcp sockets in the same lib
iâd hazard a guess it would be more flexible
iâm surprised something is depending on that specific reason phrase and forcing you to not use âOKâ đż
@bradford also - thinking outside the box for a minute - itâs probably a good idea to reverse-proxy any jvm webserver behind nginx anyway, and I bet thereâs a four line snippet to rewrite your status lines via nginx
a quick web search reveals a lot of "why would you ever want to do that? lol" by library authors in general
@noisesmith That's interesting. Hm...
looks like it could be for using http CONNECT
requests?
possible terrible kluges include ârun server sockets through netcat / sed shell pipelineâ
I'm not saying anyone in clojure-land would ever give that response, just seeing it in general for searching "set status-line http" đ
(donât actually do that)
https://textslashplain.com/2015/11/19/understanding-connect-tunnels/ seems relevant
@arundilipan Something like:
{:duct.module/ataraxy {"/" ^:foo [:index]}
:duct.router/ataraxy {:middleware {:foo #ig/ref :foo.middleware/auth}}}
specifically: > Upon receiving such a request, the proxy is expected to establish a TCP/IP connection to the requested hostname and port and signal its success by returning a HTTP/200 response indicating that the requested connection was made:
HTTP/1.1 200 Connection Established
Connection: close
Come to think of it, I think middleware of :foo
assumes a key of :project.middleware/foo
already.
@weavejester so if i wanted to use a 3rd-party middleware i'd replace :foo.middleware/auth
with <3rd party ns>.wrap-auth
?
@chrisbroome ahhh thanks!
@arundilipan Youâd need to create an init-key
method for it. Say your project name is âfooâ. What I tend to do is have a foo.middleware
namespace where I dump all the init-keys for middleware.
(ns foo.middleware
(:require [integrant.core :as ig]
[buddy.middleware.auth :refer [wrap-auth]])
(defmethod ig/init-key ::auth [_ options]
#(wrap-auth % options))
And then in my config:
{:duct.module/ataraxy {"/" [:index], "/private ^:auth [:private]}}
yeah lol
@weavejester ahh thanks, i'll give it a try!
httpkit also forces you to add headers, tsk tsk.
if (!headers.containsKey("Server")) {
headers.put("Server", "http-kit");
}
if (!headers.containsKey("Date")) {
headers.put("Date", DateFormatter.getDate());
}
I have a java.nio.HeapByteBuffer which I feed into this function
(defn- decode-UTF-8 [^ByteBuffer buf]
(.toString (.decode StandardCharsets/UTF_8 buf)))
still I'm getting plenty of barbage,
this is the return value before being applied the function decode-UTF-8
#object[java.nio.HeapByteBuffer 0x40b43b15 "java.nio.HeapByteBuffer[pos=0 lim=28 cap=32768]"]
and for the same object, after the application
/g_new,iii
Is there any possible way to trim this garbage away from the given information of pos, lim and cap?(defn- decode-UTF-8 [^ByteBuffer buf]
(.toString (.decode StandardCharsets/UTF_8 (.slice buf))))
didnt do it, may be something more extreme here going on
#object[java.nio.HeapByteBuffer 0x1f6ad41a "java.nio.HeapByteBuffer[pos=0 lim=252 cap=32768]"]
/d_recv,b�SCgfovertone.studio.fx/fx-freeverb?�33???buswet-dry room-size dampeningControlInFreeVerb
BinaryOpUGen��
ReplaceOut
some esetoric charset here in play, this is a buffer from clj-osc.I love how clj-time.core/today
's docstring says "LocalDate objects do not deal with timezones at all.", but it doesn't mention that the function is sensitive to the current timezone.
I don't think programmers have a good vocabulary for discussing time[-zones]
My apologies if this is a FAQ, I did try searching here and in the Google Group⌠but Iâm just curious, does anyone have a sense for when Clojure 1.9.0 might start making its way to beta and then final releases? Iâm not stressed about it or anything, really Iâm just curious. Thanks!
solved my shit above, someone from the past made osc message decoder that I could just use directly. This is what happens when I program without a beer.
@aviflax I get the impression sometime later this year. The hold-up is because 1.9 will include its own dependency management.
dependency management?
@gfredericks There was a talk about it at EuroClojure a few hours ago. Because spec is now its own package, the idea is that Clojure needs to be able to download dependencies without requiring an additional build tool like Leiningen or Boot.
oh man
So Clojure will get a clj
script that will use a deps.edn
file to retrieve packages and construct a classpath. The classpath will be cached so that the shell script can use it directly the next time its called.
It looks pretty nice.
so it's definitely user-facing then? the next question is how that composes with lein/boot
and where do you get the script from
Thanks @weavejester !
And thanks so much for all the excellent libraries and tools that you share with the community!
@gfredericks Script will be packaged up in brew, apt, etc. I believe itâs a script around a Java jar for performance, IIRC.
Lein and Boot probably wonât be affected at first, since itâs a separate system
But I can see a build tool being made thatâs effectively just a bunch of clj
aliases.
@aviflax Youâre welcome
please tell me deps.edn
uses the [org.clojure/clojure "0.9.0"]
syntax at least
@gfredericks Nope, itâs more like: org.clojure/clojure {:source :mvn, :version "0.9.0"}
So itâs a map of symbols to maps.
But the idea is that itâs not necessarily limited to Maven
e.g., npm?
Yeah, or raw Github for example. Funny you should mention npm, since ClojureScript is getting the ability to use that directly.
via deps.edn
or something different?
Via a compiler option I believe
I imagine that itâll converge with Clojure
Advantage is that npm packages can be pulled into Google Closure, so you donât need externs
As well as being convenient.
computers are complicated
:thinking_face: probably naĂŻve, but when you first mentioned dependencies I thought of Rich Hickeyâs talk last year (?) about maybe radically changing how we manage dependencies⌠IIRC to boil it down reductively, to track dependencies at the function level rather than the âlibraryâ level, and to never change the contract of any given function⌠pretty compelling stuff!
https://www.youtube.com/watch?v=oyLBGkS5ICk for those who have not seen it
It doesnât go that far, yet, since itâs just for classpaths and only supports Maven currently.
But I get the impression it could go that way in future.
And it has the advantage of not using Mavenâs dependency resolution algorithm.
I donât know the details of why thatâs compelling, but moving away from Maven sounds positive to me
so transitive deps are all entered manually?
@gfredericks No, itâl resolve transitive dependencies, but I believe it all has to be unambiguous otherwise itâll complain.
Presumably if the Maven artifacts lead to conflicts itâll require that you resolve the dep explicitly.
Rather than the Maven resolution of just going with the âclosestâ dependency.
Same thing I heard with the cljs npm deps. They want the deps to be unambiguous and not subject to change.
Which I can get behind.
No support for specifying ranges, Iâm pretty sure.
Thereâs support for overriding deps, though, IIRC.
And (eventually) for excluding transitive deps, but the syntax for that is pending a talk with Rich
Take what Iâm saying with a grain of salt, until the EuroClojure videos comes out đ
Since Iâm a secondary source, and itâs late
That's Alex Miller's talk today?
Looking forward to the video ... hopefully tomorrow? đ
Yep, Alexâs talk was on the clj
script, deps.edn
thing.
Iâm kinda thinking about a build.edn
nowâŚ
Or a tasks.edn
, either in the project root, or included in the resources path.
We use deps.edn
for regular coordinates today and load them from various subprojects and concatenate them (and then update them from a list of "pinned" versions in a versions.properties
file) as part of our dynamic Boot-based dependency analysis.