This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-16
Channels
- # beginners (48)
- # cider (21)
- # clara (6)
- # cljdoc (3)
- # cljs-dev (11)
- # cljsrn (5)
- # clojure (30)
- # clojure-canada (1)
- # clojure-dusseldorf (2)
- # clojure-italy (10)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-russia (8)
- # clojure-spain (18)
- # clojure-uk (39)
- # clojurescript (84)
- # core-async (17)
- # cursive (22)
- # data-science (27)
- # datomic (27)
- # docker (3)
- # editors (5)
- # emacs (2)
- # figwheel-main (18)
- # fulcro (54)
- # hoplon (3)
- # hyperfiddle (2)
- # immutant (4)
- # jobs (1)
- # jobs-discuss (1)
- # lein-figwheel (7)
- # leiningen (3)
- # lumo (1)
- # onyx (5)
- # re-frame (64)
- # reagent (5)
- # reitit (7)
- # ring-swagger (6)
- # shadow-cljs (118)
- # specter (23)
- # tools-deps (38)
Anyone knows if the following plugin somehow works with emacs/cider? https://github.com/AvisoNovate/pretty
That library alters the stacktrace printing functions. It doesn't integrate with your editor. It'll behave the same in a Cider REPL. The Cider Error display is already pretty good, though.
@dottedmag i have made something like that from component: https://github.com/onyx-platform/onyx/blob/f4cdff5b7202b1deefcd890e291ba45f9739f76a/src/onyx/test_helper.clj#L137-L148
Did anyone used https://github.com/Factual/geo? What is the difference between region and polygon? How to compute if points is in polygon or not?
@troglotit when you talk about geographic features then you would use the notion of region. When you talk about the actual implementation, then its a polygon. You can use geo.poly/region-contains?
for point in polygon computations.
how geofeatures differ from their implementation? hmm, but yeah, I found this https://desktop.arcgis.com/en/arcmap/10.3/tools/coverage-toolbox/overlapping-polygons-in-a-coverage-regions.htm But I’m not sure if what they meaning is common meaning.
subset?
is implemented using every?
(defn subset?
"Is set1 a subset of set2?"
[set1 set2]
(and (<= (count set1) (count set2))
(every? #(contains? set2 %) set1)))
I'm looking for a good way to define some functionality contract - similar to a protocol, but not dependent on types. For example, I might have a contract by which my program interacts with a db with functions like query-data, transform-1, transform-2, store-data, etc. Normally I'd use a protocol for something like this, but mongo and sql connections are both maps (containing mongo and sql types as values), not distinct values Furthermore, I'd love to be able to have multiple mongo implementations (same type) and be able to def db-implementation to be one or the other. Is there a good way to approach this without having to define a bunch of my own "wrapper" types and construct one to bind to db-implementation so defprotocols can discern between them?
Would multimethods work @jmromrell?
I could use a multimethod for each function in the contract, but it loses the benefit of a protocol where it fully encapsulates the definition and implementation of each contract in one place
When I see a protocol, it's obvious what the contract is. When I see a bunch of multimethods scattered around a large namespace, it's a lot harder to read and less clear how to extend the contract with a new complete implementation
e.g. are you serializing the file object which is basically just the path of the file without contents, or do you want to save the contents of the file?
the first is kind of crazy, but could be something you want for some reason, but I am going to proceed with assuming you want the second
almost certainly it only makes sense to get some kind of value of the contents of the file out when decoding
(you don't want decoding to somehow write the contents to a tmp file and then return a file object pointing to that tmp file)
so I would suggest the first step in encoding to be a similar process, get some kind of value of the contents of the file
I’m trying to avoid reading the file into memory, so I was hoping I could use nippy/freeze-to-out
in combination with maybe a
to get an inputstream of the serialized file contents
I’m trying to extend slurp
to an additional class (jGit ObjectLoader) but I’m struggling to make it work:
(extend ObjectLoader$SmallObject
io/IOFactory
(assoc io/default-streams-impl
:make-input-stream (fn [x opts] (println "Opening stream") (.openStream x))
:make-reader #'io/inputstream->reader))
I would think that this should at least print “Opening stream” when calling slurp
on a SmallObject
instance but instead I get an exception from input-stream->reader
that SmallObject
can’t be coerced to InputStream
Also let me know if this is a bad idea 😄
(extend ObjectLoader$SmallObject
io/IOFactory
(assoc io/default-streams-impl
:make-input-stream (fn [x opts] (println "Opening stream") (.openStream x))
:make-reader (fn [x opts] (io/reader (.openStream x)))))
this worksAlright, I somehow assumed make-input-stream
is also used by `make-reader in some way but it seems like it’s not?
(extend ObjectLoader
io/IOFactory
(assoc io/default-streams-impl
:make-input-stream (fn [x opts] (.openStream x))
:make-reader (fn [x opts] (io/reader (.openStream x)))))
Guess this does the job.As far as I remember, you cannot extend Java classes with Java interfaces. Only with protocols. (I assume io/IOFactory is an interface; if it's a protocol, then something else is a problem).
@U086AG324 it’s a protocol and the snippet above did the trick… I was confused because I - for some reason - assumed make-reader
would internally use make-input-stream