This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-09
Channels
- # beginners (140)
- # boot (163)
- # cider (43)
- # cljs-dev (50)
- # cljsjs (5)
- # cljsrn (38)
- # clojure (152)
- # clojure-austria (10)
- # clojure-berlin (9)
- # clojure-dev (11)
- # clojure-japan (1)
- # clojure-miami (2)
- # clojure-russia (147)
- # clojure-sg (12)
- # clojurescript (244)
- # code-reviews (3)
- # cursive (104)
- # data-science (5)
- # datavis (15)
- # datomic (35)
- # editors (4)
- # hoplon (1)
- # ldnclj (11)
- # lein-figwheel (14)
- # leiningen (22)
- # off-topic (53)
- # om (373)
- # omnext (2)
- # onyx (67)
- # parinfer (193)
- # re-frame (23)
- # reagent (89)
- # yada (7)
pupeno: here’s an example of doing just that https://github.com/noprompt/ankha/blob/master/project.clj#L44
In clojure, how can I merge 2 n deep maps? I have multiple functions that return maps (that can consist of maps of maps of maps of maps of maps) and want to retrieve one big combined one
https://github.com/clojure/clojure-contrib/commit/19613025d233b5f445b1dd3460c4128f39218741
gonna try that. Thanks @dmitrig01 !
@rantingbob: You can define a shortcut for the REPL, I have mine set to CTRL+ALT+R. It will switch to the repl from wherever you are and open it, if it was minimized before. You get out of it by pressing ESC. This is a default behavior. ESC will switch to the editor window from everywhere else. SHIFT+ESC will switch to the editor and close the active window
(because then the symbols they bind to would have to be namespaced, which could play real havoc and would require a change of clojure's scoping rules)
you can namespace keys
uh destructure namespace keys
So I guess if you have :aggregate/id
and :event/id
then you have to do it the non-shortcut way, but otherwise it's ok?
this is particularly awesome when working with datomic data
Anyone can spot something obviously wrong with this transit handler?
(def ^:private clj-time-writer
(transit/write-handler
(constantly "m")
(fn [v] v)
(fn [v] (time-utils/to-str v))))
(def ^:private clj-time-reader
(transit/read-handler
(fn [v] (time-utils/from-str v))))
then I specify it as {DateTime clj-time-writer
. I've had no problems with JSON repr, but msgpack repr blows up.never had any luck with msgpack
@dnolen might be able to share information on that
I suspect it might be that JSON repr uses the string repr (the second function), while msgpack repr uses the repr (first function), but I couldn't really find any docs on how they should differ.
It's especially confusing how write handlers have two varieties - string and non-string, but read handlers only one.
Yeah, giving it a more sensible repr than identity function helped. But I'm unsure how the read handler should look now - how will it know if it reads the repr or the string repr?
someone here who use the brave book to learn clojure. I have a problem with the last challenge of the do-things chapter
@tcrayford: I've come up with something like this - https://gist.github.com/jaen/027660fbf55bfff6241f - and it works, but I'm unsure if it's relying on implementation details too much or not.
Hi I'm using Flambo (a Clojure DSL for spark) and I'm getting a strange error when running on the cluster: 15/12/09 07:39:32 ERROR yarn.ApplicationMaster: User class threw exception: java.lang.ClassCastException: org.apache.solr.client.solrj.impl.HttpSolrServer cannot be cast to org.apache.solr.client.solrj.SolrServer
The code that I'm running runs fine locally. Could anyone translate what the exception means in this case?
Agreed. But it *works* locally. It only throws this error on a yarn cluster
This is exactly what my confusion is...
yeah. Build from the same lein project.clj
Hmpfh. I didn't use Spark, but maybe it provides it's own solr jar that's incompatible with the version you use
True enough thats possible... let me go dig...
For the people who has developed a backend server that deals with relation databases, which sql abstraction library do you recommend?. I am comparing two approaches, the one from Yesql, in which you have to write queries directly in SQL files, and the one from Korma, which works with a new DSL. I think the later facilitates making changes on the queries (good for the development process), and the former seems much more capable (you have all the power of SQL). Any recommendation on this?. I have to say that my backend will work with just one db engine.
i’ve seen a lot more praise for yesql than i have for korma
korma is also quite old now
There's also a middleground in form of HoneySQL - you have a data structure DSL for building up queries, but it's not a full-blown complex ORM like Korma is.
If you expect your queries to be somehow dynamic it might be a better solution than yesql
Ok. What I don’t like about Yesql (maybe because I don’t know how to properly use it) is that when I want to insert something I need to fill all the defaults/blanks in my code, and I can't rely on the database default values. Inserting seems very unpleasant if sometimes I want to insert a record with 5 columns and the next time with 7 (in the same model/table).
Should I make a constructor to deal with this?, to fill the blanks before inserting them?
;; On the JVM, you can use classes for instance? checks
(s/validate java.lang.String "schema")
;; On JS, you can use prototype functions
(s/validate Element (js/document.getElementById "some-div-id"))
straight from the readme at https://github.com/Prismatic/schema so you can be sure I'm not just making things up.Not saying you were, but it's always nice to have an official confirmation, I might have been relying on something undocumented by doing that.
@rcanepa: I think that's just how it is with yesql - if you want to omit some fields, you have to write another query with those fields omitted.
In general if your queries are not too dynamic yesql will probably work out okay in the long run. If you start noticing you would want to use some form of templating more and more, I suggest trying HoneySQL then.
@jaen: just letting you know I'm doing the advent of code as well https://github.com/bhauman/advent-of-clojure
I like the idea of the sql libs being a dsl which creates lazy lists. I was pleasently surprised I could do (take 10 (map :username (select ...)) with cassaforte, not quite relational sql but close enough.
(Just peeking into the Slack room...)
Haven't been using Clojure much of late, but want to revisit it as a nice side-learning-project.
someone who can help a beginner in the beginners channel with a problem of the brave book ?
@geekyhybrid: which language do you use now then ?
I have worked with C#, Java, Python, HTML/CSS/JS, some Clojure.
I want to do more Clojure - I like that it forces me to think about things differently (different from OOP).
I actually used to be a chemist - and moved over into informatics and lab automation...and picked up programming and dev along the way.
I actually have some well-earned time away from work coming up - so I think I want to use Clojure learning as my unstructured learning project.
i like your avatar @geekyhybrid
Thank you!
Hi everyone, there’s a JNI-heavy library I’ve been using with clojure 1.6 with no issues - and upgrade to 1.7 produced a whole host of linkage errors. Are there any known issues / pitfalls about using 1.7 with JNI-heavy code ?
Which unit testing library is similar to tape from node.js? Has the Clojure community a preferred one?
Oh, the simplicity. No global vars/functions… easy to use and understand. The output format was on TAP so you could you others libraries to consume it and print a “prettier” version.
I saw that clojure.test seems very similar, however, I am not sure if there are better options around.
I’m partial to midje; however, this seems opposed to what you are looking for. Midje is a does-everything library.
The node pattern of avoiding global vars is not so common in Clojure land. What is common is avoiding global mutation. Namespacing prevents collisions.
in default configuration figwheel uses cljs.repl/repl*
to create and run repl, I need to hook into that repl and execute arbitrary commands as if they were typed on the repl command prompt (commands are incoming over network socket from chrome devtools), it looks like :read option is the right way to go, but I need somehow spin default repl-read
on a separate thread and implement my own :read which either gets something from original repl-read
from stdin, or receives a message from the socket, any pointers how to do this? @bhauman?
in other words, I need a side channel, how to enter my own commands into that running repl, while not breaking existing functionality
hello again! wondering if anyone has experience with the clj-kafka lib (https://github.com/pingles/clj-kafka)? having a bit of trouble understanding processing the lazy seq that it returns for consuming msgs and need a quick sanity check
@dmitrig01 thanks for the response! yeah that's how i have it now
(defn consume-msgs
[conf topic msg-handler]
(info "** Consuming msgs, fn: consume-msgs, topic:" topic)
(kf-core/with-resource [c (zk-consumer/consumer conf)]
zk-consumer/shutdown
(doseq [m (zk-consumer/messages c topic)]
(msg-handler m))))
yeah, outside of shutting down the entire program, but based on the kafka docs ""Next, your logic should expect to get an iterator from Kafka that may block if there are no new messages available.", so it should run until
Also, make sure you handle the timeout option when you reach the tip of the stream (I forget what clj-kafka) does about it
"The interesting part here is the while (it.hasNext()) section. Basically this code reads from Kafka until you stop it." - kafka docs
this is the part that i was confused about, bc the doseq does what i need, but i wasn't sure if that was a poor design choice that i basically can't run anything after the doseq
dmitrig01: if you have auto-commit set, and you use a core.async channel, it is easy to commit the message without it being processed.
okay great, thank you @dmitrig01 + @ghadi i will look into converting it to a core.async channel
@bhauman: that does not seem to be what I need, special-fns seem to be caller-defined fns to be available inside repl, no?
I’m not familiar with this repl stuff, maybe I’m missing something here, that massive repl* function starts loop, where it is continuously calling read-eval-print
, which does blocking reading from in stream
I need to hook into that, and provide my own inputs in the loop (to emulate user typing)
the problem is that blocking call, if it blocks in waiting for user input, I cannot hook into it, I have to use multiple threads and do some magic
btw, read-eval-print calls that :read
(eval-read by default) function to do the actual blocking call, so I thought I could reimplement it to use core async channel and that channel would be pushed to by multiple producers
@bhauman: I thought about it a bit, I googled, but didn’t find any good pointers how to do that, this is what I got so far: https://gist.github.com/darwin/e4879f8442f9a60d4f89
@shriphrani I used JNI with both clojure 1.7 and 1.8 with no issues. Maybe your problem lies in JVM version?
@shriphani: I used JNI with both clojure 1.7 and 1.8 with no issues. Maybe your problem lies in JVM version?