This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-18
Channels
- # boot (42)
- # cider (26)
- # cljs-dev (6)
- # cljsrn (6)
- # clojure (119)
- # clojure-berlin (3)
- # clojure-dev (2)
- # clojure-nl (1)
- # clojure-russia (38)
- # clojure-spec (1)
- # clojurescript (44)
- # component (3)
- # cursive (1)
- # data-science (2)
- # datomic (19)
- # dirac (60)
- # emacs (12)
- # figwheel (2)
- # hoplon (13)
- # iot (4)
- # keechma (2)
- # klipse (38)
- # leiningen (5)
- # luminus (1)
- # lumo (1)
- # off-topic (6)
- # om (2)
- # om-next (4)
- # onyx (21)
- # perun (79)
- # reagent (32)
- # untangled (39)
- # vim (36)
- # yada (1)
@hiredman thank you! I'll have a go. I don't have much experience with clojure, let alone with interop but this seems like a good chance to try that out š
I thought http://socket.io was superseded by websockets?
as far as I can tell it's some protocol defined on top of ws. Something like ws being just a dump duplex pipe and http://socket.io defining the stanzas and other concept on top of it. I didn't spend much time on it but I'm trying to connect to one of those from clj
http://socket.io as protocol van gover over different transports, websockets are, I think the preferred one now, the clients and servers support falling back to long polling if websockets don't work
(which it will these days in all modern browsers)
with clojure.spec, is there a way to more āhuman-readableā a nested spec?
(s/def ::my-domain-entity (s/keys :req-un [:a ...])
(s/def :a (s/keys :req-un [:c ā¦ ]))
(s/def :c number?)
My complaint is that it becomes hard(er) to read a spec if it has any sort of nested maps or any deep structureā¦ because you are chasing keys up and down a file
Rather than something like schema which would allow
(m/defschema my-entity {:a {:c sc/number}}
and ignoring all the other wins of clojure.spec, this one feature of schema is niceI search have one repository https://github.com/halgari/clojure-py-redux, but i donāt know how to work it.
May be Jython https://github.com/rplevy/clojure-python is good answer.
not now which channel is correct for this question.
how can I do on duplicate key update
in mysql with clojure.java.jdbc/insert-multi!
.
@andrea By chance I just used the java library for socket io to connect to some service using that. you can find the code here, its not really much therefore pretty easy to do: https://bitbucket.org/snippets/sveri/geK8y#snippet.clj-33
Not sure if I can describe my problem well, but Iām kinda stuck, so Iāll give it a try. I have a hobby project where I followed the instructions on http://www.luminusweb.net/docs/websockets.md and got it working. But now I want to use it for a game, and I need to know which user is connected with witch websocket. As a solution I thought I would add a unique key to the connect! on-close and on-receive functions, but because itās a macro I dontāt know how to get this done. What I use know is evaluated in the macro, causing the key to be always the same (and being some weird object).
this is my current function going wrong: (defn ws-handler [request] (with-channel request channel (let [key (unique-key)] (connect! channel key) (on-close channel (partial disconnect! key)) (on-receive channel #(handle-message % key)))))
(defn ws-handler [request] (with-channel request channel (set-unique-key) (connect! channel @unique-key) (on-close channel (partial disconnect! @unique-key)) (on-receive channel #(handle-message % @unique-key))))
works, but it might be that two connection come in almost at the same time, and than '@unique-keyā could already have a new value. I would rather have a let within them
Iām still wondering for a good answer, probably I need to prevent the let from being evaluated in the macro I think
@andrea I almost suspected that. I am into the game for a few days now. Not much bots, so, it would be great if more could join š
I played it quite a bit, and I thought a bot for it was a good candidate to practice some clojure, so sure š
I use this: https://github.com/aysylu/loom for pathfinding. One of the nice things about it is, you can put maps directly into it, as keys and values, makes pathfinding very easy š
Apparently the macro had nothing to do with it, it was some other problem, so the original syntax works fine, every cannection now get an unique ker :1, :2 etc. and all functions always get the same
general question about locally installing a library (not really experienced with this):
I forked a library (https://github.com/weavejester/clj-aws-s3/ ), and made some tweaks. Then I upped the version in project.clj and did lein install
.
When I run lein repl
inside the library project, I see things working. But when I use it in my application, I get NoClassDefFoundError at runtime for the Java imports the library uses
should I install it in a different way locally? What am I missing? Or should it work like this?
(I get this error: [{:type java.lang.NoClassDefFoundError :message "Could not initialize class com.amazonaws.ClientConfiguration" :at [aws.sdk.s3$s3_client_STAR_ invokeStatic "s3.clj" 52]}])
@kah0ona this should probably go to #leiningen - you can also paste the output of lein deps :tree
there
@kah0ona the deps on master for clj-aws-s3 are really, really old... that might be something to do with your problem
but then it should work if i just do a lein install and then include it in my application right?
but wouldn't it crash than as well if I would use it from the repl inside the library project itself?
there's also amazonica.aws.s3, which may be more up to date
it is, @pesterhazy - I use that
also you could do a lot worse than using the amazon java libraries using java interop
that too... but amazonica's docs are pretty good for a quick result - also if jar size matters, there's instructions on the readme for excluding all the aws sdk deps and then selectively including just what you want, with the example being s3
amazon as a company runs on java, which ensures that aws's java libraries are always as good or better than their peers
i.e. needs
[com.amazonaws/aws-java-sdk-core "1.10.49"]
[com.amazonaws/aws-java-sdk-s3 "1.10.49"]
I reckon adding that core lib might also fix your problem with the clj-aws-s3 deps, not sure why it works at the repl but maybe you have extra deps on your repl via your user profile or something
I started to play with clojure.spec, and I like what I see, but boy those namespaced keywords are a pain to de/serialize. Forget JSON, and monger just drops the namespace because internally it uses clojure.core/name
. Has the community gained wisdom on that topic?
As far I can tell, I'll have to pre-process the keys with pr-str
and post-process them with clojure.edn/read-string
. Any other ideas?
@danielsz Well if you really want to retain all your datatypes, I'd suggest starting with Transit instead of JSON. For large objects Transit can even be faster than JSON due to internal caching and the like.
Aside from that, I assume you've seen :req-un
in s/keys
? That looks for un-qualified keywords, and was pretty much added because of JSON like data structures.
hi, anyone using yesql here? I'm having a problem connecting to the postgresql database, it prompts an error:
...
Caused by: java.sql.SQLException: No suitable driver found for jdbc:
...
Here's the offending code:
(def db-spec {:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname "//localhost:5432/testdb"
:user "testuser"
:password "testpass"})
(defquery users-by-country "../resources/sql/queries.sql"
{:connection db-spec})
I have no Java background unfortunately.https://bitbucket.org/KgOfHedgehogs/game-of-life/src/6ecdc43f764b694b8face52f63e6be594bb72074/src/life/colors.clj?at=master&fileviewer=file-view-default#colors.clj-27 ā that's were it is defined
@kgofhedgehogs So you can drop them š
and never mind that it's also wrong sometimes
(many things are IPersistentVector that aren't PersistentVector)
@ejelome It seems like you need the dependency for postgres: [org.postgresql/postgresql "9.4.1212"]
Hi! Is Enlive considered "done", or "dead"? Is there something that's currently maintained? https://github.com/cgrand/enlive
different lib, same question: what about Incanter? There is a recent reddit thread asking whether it's still en vogue or dead. The github repo doesn't look too promising AFAICT ...
@tbaldridge Oh, thank you! I actually hadn't seen :req-un
. I really just started looking at spec
. That's really good to know. Now whether I really want to retain my datatypes, don't we all š
@tbaldridge I mean, when you have a domain model enriched with specs, u want to retain it and leverage it to the maximum, right? You want to keep it intact when it travels in and out of the application boundaries. When you store domain entities in a database, for example. Isn't that the intention as well?
@tbaldridge Many interface libraries are unable to cope with the namespaced keywords. Monger, for example.
Yeah those libraries should be considered broken, imo. But I know that's rather drastic
@tbaldridge Right, no I get that. It's reasonable to say that some libraries are not yet prepared for clojure.spec
.
So yeah req-un is fine if you have no control over the situation, otherwise I try to keep true keyword support as a hard requirement of my deps
@tbaldridge Gotcha. Awesome.
Rest APIs are another case where you often have no control over the shape of the data
@tbaldridge Right. Hence the coercion mechanism in spec
, right? Are people using it to restore namespaces to keys?
No, most things I've seen just use req-un
Maybe I'm misunderstanding the problem
@tbaldridge No, I think you nailed it. I guess I'm in the market for a persistence store that can take care of my spec'ed darlings and handle serialization for me.
Which seems to be a pattern anyway. Everytime I start a project, I look at the persistence solutions out there. I feel blessed with the Clojure ecosystem because most things have "perfect" solutions, but this is one area where I keep on looking.
Is there anyway to get case
to work with two or more syntax-quoted symbols?
(case `foo/a `foo/a 1 `bar/b 2)
;=> Duplicate case test constant '(quote quote)ā
adambros: From the docs: The test-constants are not evaluated. They must be compile-time literals, and need not be quoted.
sorry my example might not have been the best, let me edit it
Itās more a convenience really, but I canāt use aliases to namespace more than one symbol
om.next mutate, iām just not wanting to use a multimethod
does different actions depending on the symbol
just symbols
namespaced and i would like to use an alias
im simply curious about case
, i think i have alternatives i can use
I saw someone mentioned Loom earlier. It's very cool. I built a stream process orchestrator and simulator with it
Does anyone know how to deal with environment vars with respect to a postgres DB? Iām working with a luminus application and Iām stuck
mruzekw: I like this library: https://github.com/weavejester/environ
+1, I use that. You can also make it play nice with Component, but I donno if people use that anymore (I have mixed feelings on it)
I like so so like cprop
as you can use either env vars or system properties