This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-07
Channels
- # admin-announcements (5)
- # aws (2)
- # boot (313)
- # cider (69)
- # cljsfiddle (18)
- # cljsrn (17)
- # clojars (6)
- # clojure (121)
- # clojure-austin (4)
- # clojure-bangladesh (4)
- # clojure-colombia (2)
- # clojure-dusseldorf (17)
- # clojure-japan (1)
- # clojure-russia (65)
- # clojure-sg (4)
- # clojurescript (94)
- # community-development (6)
- # core-matrix (2)
- # cursive (2)
- # data-science (6)
- # datomic (28)
- # hoplon (4)
- # jobs (1)
- # jobs-discuss (1)
- # keechma (15)
- # ldnclj (2)
- # off-topic (6)
- # om (140)
- # om-next (1)
- # onyx (47)
- # parinfer (11)
- # re-frame (13)
- # reagent (4)
- # spacemacs (7)
- # specter (7)
- # yada (18)
When using update-in
, is there an idiomatic way to initialize the intermediate data structures associated with each part of the vector if they’re nil? I know about fnil
, but that will only initialize the final data structure.
For example, when executing (update-in {} [:a :b] conj 5)
, what if I wanted the map containing :b
to be a sorted map instead of a hash map?
I suppose I can just use multiple update-in
s with fnil
to initialize the intermediate data structures
Can someone do me a favor - this function is just recurring forever, and I can't quite see what I've done wrong 😕 can anyone see why this isn't working? https://www.refheap.com/90d3d4687e98bd9e9b367cb0b
I could use a second pair of eyes
@markmandel: use of local rest shadowing the var?
hrmnn... maybe.. lemme try that
https://www.refheap.com/db3f8aff0cce3720c1c79f2c1 < nope. Still just logs "Count: 330" over and over
your (rest points) is always pulling from the param
(Thanks for the help though)
oooh of course it is!
I need to change my destructuring
Thanks. Needed the second pair of eyes
that's better
this might not be the root problem… it seems like the dependencies that my utility library (written in clojure) aren’t visible to the scala application
hmm, not that I’m writing this, might be that I’d have to add clojars resolver to sbt...
there is a pom.xml inside the clojure library that I created, with dependencies listed
to package dependencies of a library that I publish to a local repository (S3) into a uberjar that is
looking at sbt dependencyTree
and it doesn’t show the dependencies that my library has, so most probably sbt cannot get necessary libraries on the classpath
thinking that is there something that sbt dislikes in the pom.xml generated by leiningen...
Are any of the clojurewerkz folks in here? Curious if anyone has a rough eta on when elastisch will have support for ES 2.X? The README states dev will begin after 2.2 release of elastisch, so didn't know if that had started. Thanks!
is it possible to have some methods in a defrecord
be static?
what I wanted to do specifically was call a protocol implementation on the defrecord type
I'm generating records in a macro and I can't just dispatch on the type a priori
I’m using clojure.java.jdbc
to read from a sql server db and for some reason the deployed app doesn’t read unicode characters correctly- has anyone else run into this? here’s the connection map:
{:subprotocol "jtds:sqlserver"
:subname "host:port/db-name"
:user user
:password password
:useUnicode "yes"
:characterEncoding "UTF-8”}
nevermind I don’t think it’s jdbc-related
hi @anmonteiro: can you share more about what problem you're running into?
@jonahbenton: I'm creating records in a macro, and I have them implement a protocol (let's say (defprotocol IFoo (foo [this]))
)
I want to be able to call (foo generated-record)
without instantiating it
atm I'm able to do it by also creating a multimethod implementation that dispatches on the generated record but this feels brittle
Anybody here know of a good example/library for HTTP clients with built in handling of caching (standard HTTP cache headers - etags/last modified)? It seems like I can write middleware to do it for clj-http - but hoping for this prototype I can use something off the shelf.
hmm- why do you need to generate record types if you aren't going to instantiate them? what role do the types play? if the types are just placeholders and are not data containers perhaps just use a keyword taxonomy- which plays well with multimethods- instead?
@jonahbenton: I'm going to instantiate them but I need those methods beforehand
hmm- and what the methods have to do is type specific and is pre-instantiation from a lifecycle perspective?
exactly
my intuition is failing me- can you share what problem is being solved? some kind of type registration? is there a reason it can't be done in the macro?
@fxposter: I don't know the current status of compatibility between tools.namespace and ns-tracker. At the time I wrote the article (2013), ns-tracker depended on an older version of tools.namespace.
I'm sure this has come up, but is there a method in Lein to deploy uberjars to a destination server? Not talking about deploy, but perhaps something with scp.
I have never tried to combine tools.namespace-style reload-on-command with any kind of automatic reload-on-every-request.
hey @nkraft application deployment is usually specific to the infrastructure-model, rather than package-model. There are lein plugins for heroku, aws (elastic beanstalk, pallet), immutant (jboss), and some others. What infrastructure model is your app running on?
@jonahbenton: It's running on local servers, nothing cloudish.
Just trying to save a step: right now I make an uberjar, then scp things around. It would be nice to have some option in lein that I could configure for any server, not just common cloud providers.
Sure, gotcha. So- the short answer is that multi-host application deployment and batch/service lifecycle is not lein's purpose or sweet spot. A tool to look at that is purpose built for these and other use cases and is infrastructure agnostic is Ansible: https://www.ansible.com/
An ansible playbook that scps some uberjars around to a list of hosts and restarts them is about 5 lines
I'm familiar with ansible. It's a good tool, though we use salt for similar things here.
I'm not sure that Lein's sweet spot doesn't include such things. I can use lein to deploy a web application to Heroku, for example, which is really only different from what I'm looking for in url and transport method.
Yet a search on clojars for "scp" comes up empty. Oh, well. I'll keep the current workflow for now.
Yeah- to my eyes the issue is what happens after the scp. Who picks up the uberjar and what do they do with it?
I have a multi module maven project, one module uses java clojure mix, from the container pom, I don't see an option to compile as it complains the inability to aot compile clojure and inability to find java reference (which I have a clojure source with :gen-class), appreciate if anyone can point me to an example multi module java clojure repo
I really wan't going for full automation in deployment. Just need to get it there. System resources pick it up and run it. Lein doesn't need to know about that.
ah, how about lein-shell? https://github.com/hyPiRion/lein-shell
@nkraft: I'd look at boot if you're running into lein limitations. Very easy to just run arbitrary code from boot
bijoy: the clojure maven plugin may compile java and clojure in such an order that the java class isn't available to clojure when it is compiling
@jonahbenton: That's much closer to what I was looking for. Thanks!
bijoy: you might try and crib from https://github.com/clojure/tools.nrepl/blob/master/pom.xml since it has some java and some clojure source
Thanks hiredman, maven-clojure-plugin does decent job for single module, but could not find anything on a multi module setup, was looking out if any thing already exist
I'm having trouble finding a good way to deal with a reflection warning with with-open. I've implemented a few protocols and reified an object using them, one of which has a close method, which calls an underlying Java close. The protocols are not in the same file as the reified object or my test code, so that might be part of the problem. The close itself works fine, but unless I type hint my constructor method with Closeable from Java, it's always putting up a fus about the reflection warning. I could move the close method to just be implemented with Closeable on the reified object, but that also doesn't help. Given it's reified, the type is dynamic and otherwise not needed anywhere else in the code. Am I stuck converting this to deftype if I want to rid myself of with-open reflection warnings? I see a few outstanding Jira tickets related such as: http://dev.clojure.org/jira/browse/CLJ-308
hum, probably ran into this earlier https://github.com/ohnosequences/sbt-s3-resolver/issues/7
@hugesandwich: hmm- you are seeing reflection warnings even with an object that reifies java.io.Closeable?
user=> (set! warn-on-reflection true) true user=> (with-open [a (reify java.io.Closeable (close [this] nil))]) nil
well, better to say this: user=> (with-open [a (reify java.io.Closeable (close [this] (println "closed")))]) closed nil
@bijoy: can you use the lein-maven-plugin https://github.com/abailly/lein-maven-plugin to allow lein to direct the build of the clojure/java submodule in accordance with rules in lein's mixed projects docs? https://github.com/technomancy/leiningen/blob/master/doc/MIXED_PROJECTS.md
@jonahbenton: no, I have implemented a reified object that implements Closeable, and when using it in another namespace in conjunction with (with-open [obj (make-obj]) it happens
I can type hint on the with-open itself to fix the reflection warning, but that is not a good solution
there are actually 2 close functions (from a java api), 1 that takes options as well, so I may want to implement a macro there anyway, in which case i can just wrap this manually or in the case of the 1-arity close, do a with-open with the type hint. Regardless, it's an annoying problem in projects where I globally watch for reflection
I can get a value from a map easily if I have the keyword. Is there an easy way to get a keyword in a map that matches a particular value (assuming all values are unique
Ah, just found map-invert thanks to this stack exchange question http://stackoverflow.com/questions/10612093/reverse-lookup-in-a-map
@stuartsierra: I see… anyway, thanks for the answer.
you're welcome.
@hugesandwich: to keep the type hint confined to definition rather than use, did you try: (defn ^java.io.Closeable make-obj [] (reify ... )))
@jr0cket: if you find yourself doing that often, I recommend getting familiar with clojure.set/index
@jonahbenton: see my previous comment, I did try that and it works, but as I said, it's not so nice, hence why I mentioned the macro.
@jonahbenton: I'd rather not push macros or type hints on people using this api
type hinting the make-some-obj fn as closeable also works, but again is not so good for various reasons
yeah. the implementation doesn't seem to lend any other alternatives. i can imagine a small patch to with-open to try a Closeable cast and fall back on duck typing
I think it needs to be changed per the jira issue
the strange thing is somehow I either must have not caught it or ignored it, but when I had everything in 1 file, I didn't have an issue I think. It was awhile ago though.
actually never mind that, i think I found something in my git history and it does throw a reflection warning, which makes sense. Using reify really exacerbates it.
yeah. the protocol approach is a nice idea, but everybody's code probably has a close function.
I think I'll just write a macro given the 2nd arity for close that the java api exposes and I wrap in my own protocol
thanks for your help
not much help, but interesting problem
I didn't think there was really a solution. It is an interesting problem and ugly things like throwing on closeable seem to be the only solutions right now.
For practice, I'm doing Project Euler puzzles in Clojure and I find I often can't help but using loop/recur
, is this idiomatic in Clojure, or is there usually a better way? Or am I wrong for even thinking loop/recur
is not idiomatic?
an example: https://www.reddit.com/r/Clojure/comments/3ibjfg/new_clojurists_ask_anything/cufthk2
Does anyone have any good opensource examples of reducers and transducers in the wild?
I'm especially interested in examples that use them for I/O sinks... e.g. reduce into this file etc
@weebz: good resource, thank you!