#clojure logs

2015-06-09

03:20jonathanjhow does putting a .jar on a classpath work?
03:20jonathanji guess if i want to address something contained in the jar i have to use syntax like: something.jar/path/to/thing?
03:21jonathanjpath/to/thing doesn't get merged into the classpath as though it were just a directory, i assume
03:22jonathanjso using Joplin, i want to call joplin/migrate-db but i need to specify a path to my migrator scripts, i'm not quite sure how to construct a path that is valid when run with `lein run` and `java -jar uberjar.jar`, any ideas?
03:32oddcullyjonathanj: according to the GH page it will pick up resources (from classpath)
03:33jonathanjoddcully: hrm, my migrators are in ./joplin/sql/... and joplin is in my :source-paths vec
03:34jonathanjoddcully: i don't think those are then considered resources, are they?
03:35oddcullyyou might want to check, where it ends up in your target/uberjar
03:36oddcullyi am only familiar with the java side of things here (not leiningen)
03:37oddcullyif they end up in the jar's root joplin/sql/... i would expect them to be accessible
03:41jonathanjso the path on disk is something like: my_project/joplin/sql/file.clj
03:41jonathanjuh
03:41jonathanji think it's actually something like: my_project/joplin/migrators/sql/file.clj
03:41jonathanjin the uberjar they end up looking like: migrators/sql/file.clj
03:42jonathanjbut if i give the path "migrators/sql" to migrate-db then it complains about not being able to find any migrators when run as an uberjar
05:34kungiWhat is the current state of the art for using component in conjunction with compojure? I would like to reach around a DB connection as parameter to my routes for example.
05:35justin_smithkungi: def* macros are annoying to use with component, though I guess you could put all your defroutes inside your start method
05:35justin_smithis there a non-macro version of them?
05:35kungijustin_smith: there is (route) for that.
05:36justin_smithcool, so yeah, it would make sense to use that inside your start method
05:36justin_smithand bind your routes to the returned component
05:37kungijustin_smith: So you advise just building a "routes component"
05:37justin_smithkungi: thats how I do it (though not with compojure), I also start the http server in the same component
05:37justin_smithbecause the http server would be a very small component otherwise, and the separation gains nothing
05:38kungijustin_smith: I do that as well in another project but I think that code can get out of hand pretty fast and become a bit ugly.
05:38kungijustin_smith: I just found this idea: https://stackoverflow.com/questions/19776462/passing-state-as-parameter-to-a-ring-handler
05:38kungijustin_smith: Use a middleware to inject the app state int the request
05:38justin_smithI make a function that takes the db connections, and other stateful resources, and returns the properly wrapped routed
05:38justin_smith*routes
05:40justin_smithkungi: that makes sense if the http server is the apex of your app I guess
05:40kungijustin_smith: It is in my case.
05:40justin_smithkungi: the second option in the top answer is pretty close to what I do
05:42justin_smithkungi: the difference is that the http server is inside a component, so that I can cycle the whole app state - that version doesn't leave a top level of the component in global state to stop / restart
05:44justin_smithwith the component at the top level, I retain control of the system, with the component created inside the app definition, my only option is to redef, or hope that only shutting down the http server is sufficient and nothing else is really stateful...
05:45kungijustin_smith: makes sense. I will wrap my routes in a function which get's the state.
06:31kungijustin_smith: I have to nag you again :-)
06:31kungijustin_smith: I created a function app-routes which takes the db and returns a bunch of routes.
06:32kungijustin_smith: And I created a JettyServer component
06:32kungi(component/using
06:32kungi (map->JettyServer {:options {:port 3333}
06:32kungi :routes-fn #'core/app-routes})
06:32kungi [:db])
06:32kungiWhen using my component like this the app-routes don't get updated when I reset my application.
06:43wombawombaI'm having some issues defining a macro.. how do I fix this? https://gist.github.com/aeriksson/072546aafcaee64c6db6
06:44hanzo215Can i get help on wireless settings for my thomson router
06:44kungi hanzo215 I think you are in the wrong channel. THis one is about clojure and clojure development.
06:44hanzo215oh snap, my bad :)
06:45kungiwombawomba: have a look at the expansion.
06:45kungiwombawomba: id expands to your-ns/id
06:46kungiwombawomba: That is why you can't use it as a parameter
06:46kungiwombawomba: you might want to use a gensym. That would be id#
07:30wombawombakungi: thanks!
07:38Kneiva(inc kungi)
07:38lazybot⇒ 3
07:57crockethttps://groups.google.com/forum/#!topic/clojure/PTy89Y0WDkk
07:58crocketWhich project do I best contribute if-let-all to?
09:23c-qjv0xfihttp://pastebin.com/ccmnjBhf
09:24c-qjv0xfiIs there any blaringly obvious reason this would keep throwing "Assert failed: unused keys in regular expression map
09:24c-qjv0xfiThe URL I'm trying is /foo/bar/ABCD/1234/
09:26pbxc-qjv0xfi, what code is doing the assert?
09:27pbxthe POST function i assume, but in any case that's where i think you'd need to look
09:48afhammadIs it possible to pass config data to a library via the host app project.clj?
09:54schmirafhammad: https://github.com/weavejester/environ may help
09:56afhammadschmir: thanks was just looking at that. What is the best approach to set a single config setting (i.e url) to be used by a test lib, instead of passing it into each function call
09:56afhammadschmir: thanks was just looking at that. What is the best approach to set a single config setting (i.e url) to be used by a test lib, instead of passing it into each function call, environ seems overkill
10:27wasamasahmm, are there any specific idioms on the re-* functions?
10:28wasamasaI've only seen re-seq used heavily, probably because it's the shortest one for code golfing
10:28justin_smith,(apropos "^re-")
10:28clojurebot()
10:29wasamasalol
10:29justin_smith,(apropos "^re-.*")
10:29clojurebot()
10:29justin_smith,(apropos #"^re-.*")
10:29clojurebot(clojure.core/re-find clojure.core/re-groups clojure.core/re-matcher clojure.core/re-matches clojure.core/re-pattern ...)
10:29justin_smithfinally!
10:29dnolenBronsa: hrm trying to read cljs.analyzer, it looks cljs.tools.reader dropped alias-map how are namespaced keywords supposed to get resolved?
10:29justin_smithwasamasa: anyway, they all do distinct things, use the one that concisely does the operation you require?
10:29Duke-wasamasa: Joy of Clojure recommends only using re-seq
10:30wasamasaDuke-: does it name any specific reason for that?
10:30Duke-yes, the other functions expose some mutable stuff I think
10:30Duke-and re-seq wraps everything nicely
10:31wasamasahmk
10:32justin_smith,(clojure.string/join " " (map name (apropos #"^re-")))
10:32clojurebot"re-find re-groups re-matcher re-matches re-pattern re-seq re-quote-replacement"
10:33Bronsadnolen: oh, uhm. currently there's no support for ::foo at all but I guess with alias-map we could support at least ::foo/bar
10:33justin_smithout of those, re-pattern, re-matcher, re-quote-replacement and re-groups are of a different category altogether
10:34dnolenBronsa: yeah w/o that can't really read any of the ClojureScript .cljc files
10:34justin_smithwhich leaves re-find if you want the first match, re-matches if you want a boolean, and re-seq if you want a lazy-seq of matches
10:36wasamasabut isn't re-matches on the whole string and re-find only on substrings?
10:37justin_smithwasamasa: actuall yeah, you're right
10:37dnolenBronsa: it needs more thought but I think I will add `*ns*` dyn-var just to support the bootstrapping use case. Will just be a bound to a map. Also `ns-aliases` will be present.
10:38Bronsadnolen: that would be nice. if we could also have a ns-interns we could support all of the auto-qualifying features
10:40Bronsaactually we'd need ns-interns and ns-map
10:40Bronsadnolen: could just be a set of symbols, no need for a map sym->Var like in clojure
10:41Bronsain the meantime I'm re-adding alias-map and ::foo/bar support
10:42dnolenBronsa: yeah I don't know about that set of symbol, anything that requires adding a whole bunch of runtime information is undesirable.
10:43dnolenwould have to add a bunch of runtime bookkeeping.
10:43dnolenBronsa: as I suggested earlier all this information is already present in the JS environment.
10:43dnolenI think all you need is a table of namespaces identifying which paths in the global environment represent namespaces
10:44dnolenresolve, ns-interns can all use this
10:45Bronsadnolen: couldn't cljs.core/ns-map just perform the necessary reflective calls into the js env rather than using a runtime map then?
10:46dnolenBronsa: you mean to add `ns-map`? `ns-map` isn't a thing right now.
10:46dnolenreflecting on the js env isn't going to work
10:46Bronsadnolen: yeah, to add it
10:46dnolenyou'd have to walk a bunch of things that don't matter
10:47dnolenthink browser
10:47dnolenlike a complete walk
10:47dnolenyou need a table of paths that represent namespaces
10:47dnolenthen no walking, except to collect vars
10:47Bronsaah, gotcha
10:48dnolenBronsa: k I think I have a simple plan. Will ping you when it's in place :)
10:49Bronsacool thanks
10:50stainis there a trick to forward a future to a promise without starting another future?
10:50stain(and not block)
10:54justin_smithstain: what does "forward a future to a promise" mean?
10:54justin_smithstain: you may be thinking of a definition of future and/or promise that doesn't match clojure on the jvm
10:55justin_smith,(future? (promise))
10:55clojurebotfalse
10:55stainjustin_smith: I've made a (future) that depends on incoming (promise) -- and then I want to the result of that future to be delivered to other (promises)
10:56stainso perhaps I can make my future simply do (deref (deref that-promise)) or something silly
10:56stainI won't know inside the future body where to deliver it to
10:56justin_smithstain: oh, you are delivering a future to a promise?
10:56stainright
10:56stainthey are kind of chained together
10:56stainwell, they should be
10:57stainhttps://github.com/stain/flowing-clj/blob/master/src/flowing/core.clj#L14
10:57stainnow I have to implement the linking
10:57justin_smithwait, you shouldn't be able to apply fn
10:57justin_smithoh, never mind, macro
10:57justin_smithsilly me
10:58stainyeah, so it will deref inside the future
10:58stainand not block outside
10:58stainhttps://github.com/stain/flowing-clj/blob/master/test/flowing/core_test.clj if you are interested
11:00justin_smithstain: so what is the functionality being implemented here?
11:00stainjustin_smith: see the test
11:00stainyou define a series of steps
11:01stainthen wire them together to provide the parameters from other steps (or outside values)
11:01justin_smithI saw the test and lack the imagination to see a situation where I would want to do that
11:01stainit's to have easier flexibility about the wiring
11:01stainin scientific data analysis for instance
11:01justin_smithoh, so the kind of thing prismatic/plumbing does?
11:02justin_smithor maybe that was prismatic/graph
11:02justin_smithor both
11:02stainI think so
11:02stainbut I'm trying to stay close to the computational model of Apache Taverna, as I will plug this in as an alternative workflow engine
11:03stainthanks for the links
11:04justin_smithn/p, I hope that provides some help, because at this point I really don't understand enough about what your code is trying to do to provide much input - maybe someone else could grok it though
11:07stainjustin_smith: thanks for your help :)
11:08stainshould be easier if I wrote some documentation
11:09stainI added a deref-deep function
11:09stainso then I can do
11:09stain(defn deref-deep [ref]
11:09stain (loop [ref]
11:09stain (if (not (ref? ref)) ref
11:09stainsorry
11:09stainthen I can do (deliver (:a step) (future "double-ref!"))
11:09justin_smithstain: the future returns the promise?
11:10kungiCan someone please have a look at this gist and help me find out what I am doing wrong: https://gist.github.com/Kungi/beaed8b0bea16beb8ce6 When I change my routes in routes.clj and (reset) the whole system the routes don't change. Somewhere must be a reference to the old routes.
11:10stainjustin_smith: no, I deliver the future to the promise
11:10stainand then inside the future I call (deref) twice, if needed
11:10justin_smithnever mind, that still wouldn't work - if the future returned a promise you could do (deliver (:a step) @(future ...))
11:11stainbut then the delivery would block
11:11justin_smithoh, the promise is the first val, never mind
11:11stainand I would need another future
11:35kaffeeboehnchenI remember a site where one could learn clojure interacitvly with ranking and stuff. I just dont remember the url. Any ideas? :D
11:35wink4clojure?
11:35clojurebot4clojure is the place to go for Clojure exercises
11:35kaffeeboehnchenah yeah, thanks
11:42ShayanjmI need to split my application into two components, a "generator" component (generates a huge vector that needs to be fed to workers), and a "worker" component (does stuff with the data it's fed)
11:43ShayanjmHow do I go about building two different jars when I run lein uberjar?
11:43dstocktonShayanjm: split them into separate projects perhaps
11:44Shayanjmdstockton: since they're so tightly coupled, i'd love to be able to build them both in one go
11:44justin_smithShayanjm: another option is one uberjar - you can choose when invoking a jar which class is run as main
11:44Shayanjmjustin_smith: I considered that, but my hesitation is that the jar loads a lot of stuff as of right now
11:44dstocktonhttp://stackoverflow.com/questions/19334454/create-multiple-uberjars-in-leiningen
11:45Shayanjmwhich would introduce some non-trivial overhead for worker spin-up time
11:45justin_smithso for one case you run java -cp my.jar clojure.main -m my.core1, in another you could run java -cp my.jar clojure.main -m my.core2
11:45justin_smithShayanjm: oh, OK
11:45schmirShayanjm: https://github.com/zcaudate/lein-repack
11:46Shayanjmlooking schmir
11:46Shayanjmoh interesting
11:46justin_smithShayanjm: so in order to not include all the deps, you would have different :dependency vector per uberjar profile?
11:46Shayanjmjustin_smith: Yeah preferably
11:47justin_smitherr, I mean :dependencies of course
11:47ShayanjmI saw something about using profiles and building via lein with-profile x1:x2:x3 uberjar
11:47Shayanjmbut i didn't see anything about splitting the deps
11:58justin_smithShayanjm: what about separate project.cljs in one repo with overlapped :source-paths as apropriate?
11:59Shayanjmjustin_smith: that sounds interesting. Anywhere I can read about proper :source-path use?
11:59Shayanjmi'm not even seeing it in my currently project.clj
11:59justin_smithShayanjm: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L278
12:00Shayanjmthanks justin_smith
12:00ShayanjmOh wow
12:00Shayanjmi didn't even know this existed
12:00Shayanjmthis is excellent
12:01weiShayanjm: you could also try looking into boot, it offers more flexibility with “non-standard” builds
12:01Shayanjmhow do you select the different project.clj's in a single repo justin_smith?
12:01Shayanjmi.e: how do I tell lein which project.clj i'm looking at?
12:01Shayanjmwei: will definitely look into it. Boot is just another build tool, right?
12:01weiyup
12:02justin_smithShayanjm: my approach would be to have subdirectories with the different project.clj files, and use "../src" etc. in the source-paths
12:02ShayanjmGotcha that makes sense
12:03justin_smithShayanjm: bonus, each one would have its own target dir isolated from the others
12:03Shayanjmthat sounds like an ideal situation actually
12:03justin_smiththe negative is managing multiple project files, but that may not be so bad depending
12:03winkI'd also never thought of this. brilliant :P
12:03ShayanjmFor the most part, the project files will be set-and-forget
12:04Shayanjmdistributed computing is hard to architect locally :\
12:04ShayanjmI guess most people don't do hacky distributed computing with Clojure. Seems like most of the literature floating around is all about hadoop/spark integrations
12:05justin_smithShayanjm: I assume you have looked at sorenmacbeth 's stuff like flambo and marcellene?
12:05justin_smith*marceline
12:05Shayanjmjustin_smith: Yeah I did. I watched his talk too
12:05winkis there even non-hacky distributed anything? anywhere?
12:05ShayanjmAwesome stuff
12:05Shayanjmthe issue is that we're primarily a python shop
12:06Shayanjmso our current distribution pipeline is python-based, so I'll have to write the hypervisor in python
12:06justin_smithwink: bitcoin?
12:06justin_smithdunno, maybe that's hacky
12:06justin_smiththe Internet
12:06winkjustin_smith: hm, it's eventually consistent, but definitely not fast :P
12:06Shayanjmwhich makes deploying a bit of a weird thing since it's a non-JVM tool, I'll have to spin everything up and handle everything pretty much manually
12:07winkI'm just sayin, for a majority (I think) of people real distributed stuff is just too hard
12:07Shayanjmso I don't know how people 'usually' architect their distributed projects
12:07Shayanjmwink: Yeah, most people don't need distribution
12:07winkit makes going from solving a problem a day.. to thinlking for 2 weeks
12:07Shayanjmbut for those that do, they usually just jump on the hadoop bandwagon
12:07winkthinking isn't bad... but it's really opening a different can of worms
12:08winkmonoliths can be so nice to work with :)
12:08Shayanjmlol, the current code base is hella monolithic
12:08Shayanjmhttps://github.com/ableeng/hexpacker
12:09ShayanjmBut doing 1m queries on a single box is suicide
13:42irctcwould anyone be willing to look at my code on codereview and give me some feedback? I'm worried everything I'm doing is not idiomatic.
13:42irctchttp://codereview.stackexchange.com/questions/93051/structure-of-parser-in-clojure
13:44irctc(I once looked at some python code that doubled every item in a list using a while loop and i+=1, which is SO NOT pythonic. Just worried I might be making some similar errors with my first foray into clojure)
13:54hyPiRionirctc: One would generally prefer keywords over symbols, and vectors over lists. So it's more common to see something that looks like {:shared [[:record-type 2] [:entering-firm 4] ...] :1A [[:filler 9] [:poss-dupe 1] ...]}
13:56pandeirousing ring-defaults' wrap-defaults, shouldn't setting {:session nil} within a response map delete browser cookies as well?
13:58irctchyPiRion: and then have a second hash map linking the keys to the functions? The need for that extra dictionary was what prevented me from using keywords or plain strings in the first place.
14:01hyPiRionirctc: I've only skimmed the source, but if the symbols are there for evaling stuff, then yes, definitely. It's very uncommon to use eval in the first place (although it's warranted in some cases)
14:04bensuirctc, ask if you have any questions on the feedback.
14:09amalloyirctc: i agree with hyPiRion. it wasn't totally clear to me until i was already done writing up my review why all your names were funky and what you're using eval for, but hyPiRion's suggestion is the right one to get rid of that nonsense, and make explicit the implicit mappings you're currently using
14:11eraserhdgfredericks: AFAICT, there's no way to conditionally call a generator. Is that right? If not, I'm missing something super-obvious.
14:14gfrederickseraserhd: depends on what the condition is; bind could do that
14:14gfredericksif you describe the use case better I could tell if that's the best approach
14:14eraserhdI mean, I could call (gen/vector conditional-generator (if (= other-generated-name some-value) 1 0))
14:15eraserhdI'm generating events (maps). The event types are keywords (generated using gen/elements). I then generate the other fields, some are only present in some maps.
14:15amalloyeraserhd: so you need bind, indeed
14:16amalloyor, well, maybe you can use fmap
14:16eraserhdfmap always generates. I realized that I forgot what bind actually does, so I'm looking it up.
14:17amalloy(gen/vector (bind conditional-generator (fn [the-map] (if (make-whatever? the-map) (make-whatever the-map) the-map))))
14:17amalloyor, well, i guess that is missing some returns. i am just slapping together stuff that is not very helpful. listen to gfredericks
14:20gfrederickseraserhd: if you used fmap it'd probably be that you're generating all possible fields, then use fmap to remove the ones that don't apply to the event type
14:20gfrederickswhich could be more elegant if your event types have overlapping fields
14:21gfredericksanother option is instead of gen/elements use gen/one-of and have a generator for each event type, that generates the full map for that type
14:21eraserhdThat actually sounds pretty nice.
14:23gfredericks~test.check actually sounds pretty nice
14:23clojurebotIt's greek to me.
14:24gfredericks~test.check |actually sounds| pretty nice
14:24clojurebotRoger.
14:25eraserhdI've noticed that my cases seem exponential. This kind of makes sense. E.g. 25 cases take 25 seconds, 30 take 35, I've never seen 125 complete. This is probably not a way to resolve :)
14:27gfrederickswell
14:27gfredericksthat kind of means you've set up your generators so they can't tolerate a size up to 125
14:28gfrederickswhich you can handle three ways
14:28gfredericksA) it doesn't matter I'll just only run my tests with n=30
14:28gfredericksB) I want to be able to run with more test cases so I'll cap the size at the generator level
14:29gfredericksC) I'll figure out how to rewrite the generators at a lower level so they don't get too big
14:29gfredericksD) does defspec have an option for max-size? maybe it could
14:29gfredericksE) that's four ways, or 3.5 maybe, but not 3
14:31gfredericksversion 0.8.0-alpha3 has a new gen/generate function that can make it easy to explore how large things get at different sizes
14:32hyPiRiongfredericks: D is a suggestion I've put up on jira
14:33gfrederickswill probably tackle that while re-vamping the API for the quick-check function
14:33justin_smithgfredericks: a funny number problem http://www.ericharshbarger.org/dice/go_first_dice.html
14:34hyPiRionyeah, http://dev.clojure.org/jira/browse/TCHECK-10 it is
14:35gfredericksjustin_smith: sweet
14:35gfrederickshyPiRion: yeah I expect some way to pass arbitrary args to quick-check should be included
14:40Shayanjmjustin_smith: do I need to have a :gen-class for both namespaces I intend to generate jars for?
14:41ShayanjmI don't think I've fully grok'd what gen-class actually does...
14:41justin_smithShayanjm: if you use java -cp my.jar clojure.main -m my-ns.core you don't need :gen-class at all
14:42justin_smithShayanjm: it creates a class that a java process knows how to invoke, usually used in order to have an invokable main method
14:42Shayanjmgotcha
14:42Shayanjmso if I have :gen-class in there I don't need to specify an entrypoint when I execute my jar?
14:42Shayanjmi.e: namespace.gen and namespace.work become gen.jar and work.jar
14:42Shayanjmeach have their own -main's
14:43ShayanjmI've just been doing java -jar my.jar to execute (my namespace.core is being split to namespace.gen & namespace.work. namespace.core currently has :gen-class)
14:43justin_smithShayanjm: well, that route involves setting your :main-ns and having :gen-class and setting up your :aot field in project.clj
14:43Shayanjmthat sounds dirty
14:44ShayanjmI'll just kill the :gen-class's. Will that fuck anything up re: uberjaring?
14:44ShayanjmI think I'm still using the boilerplate uberjar setup in my project.clj
14:44justin_smithShayanjm: only that you'll need a command line arg specifying the main ns for clojure to invoke
14:44Shayanjmkk
14:45justin_smithwhich is a small hassle in my experience, compared to the complexity an otherwise unneeded gen-class can create
14:45ShayanjmTrue that
15:11tahmidHello! I need some help with immutant 2
15:11tahmidI am handling webscoket request
15:11tahmidImmutant provides nice callbacks like :on-message :on-open and :on-close
15:12tahmidBut what should I do If I want to send a message to a websocket without those callbacks
15:12tahmidI mean arbitrarily , without any event happening
15:15gwstahmid: if you don't get help here, you may have a better shot asking in #immutant
15:16justin_smithtahmid: with sente it's just a question of having a handle to send-fn and having the unique ID of the client you wish to send to
15:16justin_smithtahmid: and you can use sente with immutant
15:16justin_smithhttps://github.com/ptaoussanis/sente
15:17tahmidI looked at sente, it seemed a bit daunting
15:17tahmidI will give it a try
15:17justin_smithtahmid: it's not that bad in my experience. The key is that you need to hook up its handler functions to your http server, and then when you initialize it it will provide you with the send-fn that will send to a client
15:19tahmidjustin_smith: I am storinng the channels that I get from ring request in a vector.
15:19justin_smithoh, if you already have that you can use those, right?
15:21SeyleriusCan keywords have a colon in them, later in the keyword? Like ":Foo:bar" and "Foo:baz"?
15:21tahmidjustin_smith: printing the vector that contains the channels giving me this [#object[org.projectodd.wunderboss.web.async.websocket.UndertowWebsocketChannel 0x79aa8b3d org.projectodd.wunderboss.web.async.websocket.UndertowWebsocketChannel@79aa8b3d] #object[org.projectodd.wunderboss.web.async.websocket.UndertowWebsocketChannel 0x67435a65 org.projectodd.wunderboss.web.async.websocket.UndertowWebsocketChannel@67435a65]]
15:22Seyleriustahmid: Dude, paste that shit somewhere.
15:22tahmidSorry
15:22Seyleriussprunge.us or ix.io is a good idea.
15:23amalloyif it's just a single long message it's not a big deal, really. the problem is when people paste 15 lines as 15 separate short messages
15:24Seyleriusamalloy: Fair point.
15:25SeyleriusHmm... Quick and dirty way to invert a map of sets? I need a map where the keys are the items from the sets, and the values are sets of which keys contained the key.
15:26amalloySeylerius: https://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L234 ?
15:26SeyleriusBasically, I need to turn {:Foo #{:Bar :Baz} :Flib #{:Bar :Box}} into {:Bar #{:Foo :Flib} :Baz #{:Foo} :Box #{:Flib}}
15:26SeyleriusTaking a look at that now, thanks amalloy.
15:27amalloyif you wanted to use it without pulling in useful, you could remove the code that supports {x 1 y #{2}}
15:28amalloyat which point it's just (apply merge-with into {} (for [[k vs] m, v vs] {v #{k}}))
15:28amalloy,(let [m '{:Foo #{:Bar :Baz} :Flib #{:Bar :Box}}] (apply merge-with into {} (for [[k vs] m, v vs] {v #{k}})))
15:28clojurebot{:Baz #{:Foo}, :Bar #{:Flib :Foo}, :Box #{:Flib}}
15:29H4nsif i have a lazy seq bound to a variable and then traverse it while still keeping a reference to the head, will that cause the whole sequence to be realized? or can i safely keep a reference to the head and traverse it two times?
15:29justin_smith,(into {} (for [[k vs] {:a #{1 3 5} :b #{7 9}}, v vs] [v #{k}]))
15:29clojurebot{1 #{:a}, 3 #{:a}, 5 #{:a}, 7 #{:b}, 9 #{:b}}
15:30justin_smith^ my golf of that
15:30amalloyjustin_smith: a totally incorrect golf...?
15:30justin_smithincorrect?
15:30amalloytry it on the input originally requested
15:31justin_smithamalloy: oh, I missed a constraint, OK
15:31amalloyH4ns: you will realize it all
15:32Seyleriusamalloy: That's great, just tried it.
15:32SeyleriusWorks perfectly.
15:32Seylerius(inc amalloy)
15:32lazybot⇒ 277
15:32H4nsamalloy: ok, i kind of suspected that without really understanding why
15:33justin_smithH4ns: the locals-clearing or gc cannot reclaim memory when you have a handle to it, the head of the list counts as a handle to the rest after it
15:35H4nsjustin_smith: ok - so i basically want to avoid binding large lazy sequences to variables.
15:35justin_smithH4ns: right, or make sure those variables go out of scope
15:35H4nsjustin_smith: thanks!
15:36justin_smitheg. (let [nums (range)] (foo nums)) is fine as long as foo does not return nums as part of its result
15:36justin_smithbecause locals-clearing knows that nums can't escape otherwise
15:39m1dnight_https://www.refheap.com/102345 <- can anyone give me *any* clue where to start looking? A stackoverflow
15:40m1dnight_but I dont get an origin from within my own code.. :<
15:41justin_smithstack overflow while printing a sequential, makes me wonder if there are recursive concat calls somewhere?
15:42m1dnight_oh there are
15:42justin_smithor a collection that contains itself...
15:42m1dnight_oh
15:42m1dnight_!
15:42m1dnight_that gave it away
15:42m1dnight_i think
15:42m1dnight_to the debugcopter
15:42m1dnight_justin_smith++
15:42m1dnight_(inc justin_smith)
15:42lazybot⇒ 262
15:42m1dnight_okay :p
15:43justin_smith(inc palindromes)
15:43lazybot⇒ 2
15:43Shayanjmjustin_smith: I'm blanking on this project.clj. Just sorta divorced the gen/worker stuff from the existing core
15:44Shayanjmnow need to rewrite the project.clj's for both gen & worker
15:44Shayanjmunsure how overlapping :source-path's help with dependency isolation?
15:44justin_smithShayanjm: well, of course they wouldn't overlap entirely
15:44justin_smithfor that to help
15:45justin_smithbut if you can't isolate like that, then you don't gain anything by having separate uberjars either
15:45ShayanjmMaybe i'm unclear on :source-path itself. In all examples I see it points to src/clojure - so I'm assuming it's just pointing to clojure itself?
15:45Shayanjmerr, src/main/clojure or something
15:45justin_smithShayanjm: the default binding is "src" which is the directory under which we have our clojure src
15:45Shayanjmgotcha
15:45Shayanjmahhhhh
15:46justin_smithand src/main/clojure as the second entry
15:46Shayanjmokay that makes way more sense
15:46justin_smithso you might hav something like src/common/ src/app1 src/app2
15:46justin_smithwhatever makes sense for your case
15:46ShayanjmRight, perfect. And in each project.clj I can define separate deps
15:46justin_smiththough do take a moment to verify it wouldn't be simpler to just have two totally independent repos
15:46justin_smithShayanjm: right
15:47Shayanjmso in order to uberjar, i'd have to cd into the subdirectory which has each project.clj and lein uberjar?
15:47justin_smithright
15:47ShayanjmOkay great, just making sure I'm not overlooking some lein magic
15:47m1dnight_justin_smith: indeed. I had a an atom that contained itself
15:48justin_smithm1dnight_: yeah, that would do it
15:48m1dnight_by luck I printed some variable and its enormous :>
15:48gfredericks,(let [a (atom nil)] (reset! a a))
15:48clojurebot#object[clojure.lang.Atom 0x3460a511 {:status :ready, :val #object[clojure.lang.Atom 0x3460a511 {:status :ready, :val #object[clojure.lang.Atom 0x3460a511 {:status :ready, :val #object[clojure.lang.Atom 0x3460a511 {:status :ready, :val #object[clojure.lang.Atom 0x3460a511 {:status :ready, :val #object[clojure.lang.Atom 0x3460a511 {:status :ready, :val #object[clojure.lang.Atom 0x3460a511 {:status ...
15:48Bronsait's not as fun anymore :<
15:48justin_smithm1dnight_: my preferred way to deal with this sort of thing is an adjacency-list representation - it allows arbitrary cycles in the data without any recursion in the structure itself
15:49justin_smithat the cost of one layer of indirection
15:50justin_smithm1dnight_: because, of course, sometimes your data really is a graph and not a tree
16:01oddcullygiven, that vim-fireplace calls piggieback like this (cemerick.piggieback/cljs-repl'.arg.'); is there any vile trickery to write `arg` that only `arg` gets executed?
16:04m1dnight_I think im closing in
16:05m1dnight_but I have a question, if I have macros that expand a single line (the macro call) to say, 10 lines, do the line numbers in stacktraces and such match the actual lines, or the expanded lines?
16:05m1dnight_Im guessing the latter?
16:10justin_smithm1dnight_: I recall various bugs regarding this line numbering behavior
16:13m1dnight_Well, I have pinpointed (some what) the problem; I print a message (map) and that contains a cycle somewhere
16:13clojurebotExcuse me?
16:14justin_smithm1dnight_: right, my suggestion was that an adjacency-list representation allows arbitrary
16:14justin_smith"nesting" in a flat one level structure
16:15justin_smithor if the nesting isn't needed, just not having it is a simple fix too :)
16:18m1dnight_Well, I predicted this issue, and I wrapped the entire concat in a (set ..) but that doesnt seem to fix it
16:18m1dnight_so Im guessing I dont have the exact cause yet.
16:42zotwhen using prismatic schema, is there a way to concisely say, (s/either #{Foo} [Foo] '(Foo)) to cover the basic grounds for all things seqable?
16:44anthgurzot: what about pred? http://prismatic.github.io/schema/schema.core.html#var-pred
16:45zotthat's what i was just writing up as the more verbose alternative. wondered if i missed some other better idea...
16:46m1dnight_I'm trying to debug my project with IntelliJ/Cursive but I get the error: "Exception in thread "main" java.lang.ClassNotFoundException: actransors.stm.RetryEx"
16:46m1dnight_That is a custom exception I implemented and has genclass, but it works fine in leiningen.
16:47m1dnight_Im not running the project as lein in intellij btw. I just put (-main) in my core.clj file and then "run core"
16:47justin_smithm1dnight_: are you requiring the namespace inside cursive that would create that class?
16:47m1dnight_Yes, I am
16:48m1dnight_And also importing it
16:48m1dnight_https://www.refheap.com/102355
16:51m1dnight_Its odd that it works fine in leiningen though.
16:53canweriotnowAnybody up for a slightly insane question about string/json parsing?
16:53amalloy~anyone
16:53clojurebotanyone is anybody
16:53justin_smithcanweriotnow: in general, just go ahead and ask
16:53amalloyargh
16:54canweriotnowlol clojurebot
16:54amalloyi wish i knew how he was inferring that so i could remove it
16:55canweriotnowSo, I'm looking at core.match, prismatic schema, doing a prewalk... too mnay options. I have some insane json, thus: https://gist.github.com/canweriotnow/56f737784db1d2bd293f
16:56canweriotnowMy issue is that I have keys like "[question(n)]" for each n (question number).
16:56justin_smithcanweriotnow: what are you trying to do with this json?
16:56canweriotnowI need to correlate the question numbers (among other things) from this response data to the questions themselves, for which I have id's.
16:57justin_smithsounds like a json parse (I like cheshire) plus a map-kv, plus a regex and a group-by
16:57justin_smithsomething like that
16:58canweriotnowWhat I'd like is to restructure into a map like {:question {:4 "Drifter"}} instead of the flat "[question(4)]":"Drifter"
16:58justin_smithyeah, that's where the group-by comes in
16:58justin_smithbut before that you need to do some parsing with regex
16:58justin_smithand :4 won't work
16:58justin_smithbut 4 will
16:59canweriotnowThe best I've done to make it usable is to give cheshire a keyfn that strips the \W chars, so I get :question4 "Drifter"
16:59justin_smithcanweriotnow: that's where map-kv comes in - you can call a function on the keys to transform them
16:59canweriotnowSo you think maybe multiple capture groups to grab (question) and (4) and then use group-by?
16:59justin_smithright
17:00canweriotnowOh! I forgot map-kv!
17:00justin_smithand probably some update-in in a reduce
17:00justin_smithcanweriotnow: sorry, not map-kv, I meant reduce-kv
17:00canweriotnowjustin_smith: right, gotcha
17:01canweriotnowjustin_smith: This gives me a great place to start, thanks so much.
17:04justin_smith,(reduce-kv (fn [m k v] (let [[_ a b] (re-matches #"([a-z]*)([0-9]*)" k)] (assoc-in m [a b] v))) {} {"abc12" :a "abc13" :b "abd42" :c}) ; canweriotnow
17:04clojurebot{"abc" {"12" :a, "13" :b}, "abd" {"42" :c}}
17:04justin_smithclojure is an excellent language for this sort of insanity
17:05m1dnight_Can one force clojure to print an atom in a particular way?
17:06m1dnight_Im trying to debug using print statements but the datastructure is just way too massive to pick it out by hand
17:06justin_smithm1dnight_: my preferred technique is to bind the thing, then use (-> ...) plus the up-arrow keys to drill down into it
17:06justin_smith(in the repl of course)
17:12cflemingm1dnight_: WRT your gen-class issue, you need to tell Cursive to compile your namespace, under Settings->Build etc->Compiler->Clojure
17:19canweriotnowjustin_smith: that's perfect. Clojure is excellent for many kinds of insanity :)
17:59justin_smithfrom our friends at circleci (built in clojure / cljs) - this blog post is hilarious http://blog.circleci.com/its-the-future/
18:00jarjar_primewhich profile does "lein release" load?
18:01m1dnight_cfleming: thanks. that was what I was looking for.
18:01m1dnight_(inc cfleming)
18:01lazybot⇒ 16
18:01m1dnight_btw justin_smith fwiw, I found the error. Im using code from my professor and he simply creates circular maps. he just never prints them and that way it works..
18:02m1dnight_so I see a nice PR coming up :>
18:02m1dnight_after my thesis
18:03jarjar_primeuberjar has its own profile
18:04justin_smithm1dnight_: ahh - so I stand by my initial proposal, that with clojure you are better off using an adjacency list rather than a circular map
18:08m1dnight_Im not clear exactly on what you mean by that. Ive googled a bit and isn't a map an adjacency list?
18:09devth_,(= false)
18:09justin_smithan adjacency list can be represented by a pair of maps
18:09clojurebottrue
18:09devth_,(= nil)
18:09clojurebottrue
18:09devth_what's the deal w/ that
18:09justin_smith,(= Double/NaN)
18:09clojurebottrue
18:10m1dnight_reflexivity devth
18:10m1dnight_no wait
18:10m1dnight_well, that X is equal to X
18:11m1dnight_yes, reflexivity
18:11justin_smithm1dnight_: the idea with an adjacency list is that all the keys (in both maps) are your nodes. One map is nodes to values, the other is nodes to edges, each node having edges being a set of keys for nodes you have outgoing connections to
18:11justin_smithm1dnight_: not quite because of Double/NaN, but kind of
18:11devththere must be a use? why is = even defined for a single arg?
18:11justin_smithdevth: because we like to use apply to call a function on all the elements of a list as the args
18:11justin_smith,(apply = ())
18:11clojurebot#error {\n :cause "Wrong number of args (0) passed to: core/="\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: core/="\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 399]\n [clojure.lang.AFn applyToHelper "AFn.java" 152]\n [clojure.lang.Rest...
18:12justin_smith,(apply = '(Double/NaN))
18:12clojurebottrue
18:12justin_smithit's not fully consistent, but it at least has a flimsy rationale
18:12devthi see.
18:12justin_smith,(apply = [1 1])
18:12clojurebottrue
18:12justin_smith,(apply = [1 2])
18:12clojurebotfalse
18:16m1dnight_doesnt (=) make sense that it errors?
18:16jarjar_prime(inc clojurebot)
18:16lazybot⇒ 53
18:16m1dnight_,(=)
18:16jarjar_prime:-D
18:16clojurebot#error {\n :cause "Wrong number of args (0) passed to: core/="\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: core/="\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 399]\n [sandbox$eval193 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler...
18:17m1dnight_,(+)
18:17clojurebot0
18:17justin_smithm1dnight_: more sense than (= Double/NaN) not being an error (or at least false)
18:17m1dnight_oh, odd
18:17justin_smith,(*)
18:17clojurebot1
18:17jarjar_primem1dnight_: what does , mean?
18:17m1dnight_well, thats needed for reducing and such I assume
18:17justin_smith,(= Double/NaN)
18:17clojurebottrue
18:17m1dnight_jarjar_prime: you type ,<sexp> to evaluate it
18:17justin_smith,(= Double/NaN Double/NaN)
18:17clojurebotfalse
18:18m1dnight_because a double is a reference type so thats normal too
18:18justin_smithm1dnight_: read it again
18:18justin_smithit's not equal to itself, that's the spec
18:18m1dnight_oh
18:19justin_smithbut = is short-circuited to always return true if it has one arg
18:20Bronsajustin_smith: how could it behave in any differnt way?
18:20Bronsathere's no way to make (= x) return false IFF x is NaN
18:20BronsaI think?
18:21Bronsano nevermind, there's Double/isNaN
18:21justin_smithBronsa: it's more of a silly thing to me, it's very unlikely to lead to bugs
18:22Bronsajustin_smith: I've lost my sleep because of sillier things
18:22justin_smithI'm sorry to hear that
18:22andyf_Bronsa: So, a JIRA ticket and patch are forthcoming, then? :-)
18:22clojurebotGabh mo leithscéal?
18:22Bronsaandyf_: that's justin_smith's pet peeve, not mine :P
18:22andyf_(completely, 100% joking there)
18:30Bronsadnolen: do you have a way to make hudson run the cljs tests on the core.match/core.logic port?
18:30dnolenBronsa: nope, need to sort that out with puredanger at some point
18:30dnolenlikely via Node.js or something
18:31Bronsaok
18:31dnolenNashorn still seems too unstable to depend on
18:32justin_smithfeeling a bit better about my own cljs test automation woes right now...
18:38puredangerWe should probably use docker coreos etcd and kubernetes right dnolen
18:38dnolenlol
18:42jarjar_primethere doesn't seem to be a way to specify a profile for :release-tasks huh?
18:42jarjar_prime["deploy"] gets called with no profile set it seems
18:45jarjar_primeseems some projects are getting around it by using uberjars
18:45jarjar_primebut I am trying to avoid sending a fat jar to artifactory
18:48jarjar_prime"lein with-profile docker deploy" works
18:48jarjar_primebut "lein with-profile docker release" doesn't
18:49jarjar_primeis there another profile that release uses?
18:49justin_smithjarjar_prime: I'm not sure about this stuff, but one thing that might help is "with profile +foo" which adds the profile, rather than replacing
18:51jarjar_primejustin_smith: thanks, but it appears release is stripping that away too :(
18:55stainjustin_smith: https://github.com/stain/flowing-clj -- perhaps easier to explain now that it works :)
19:04stainTEttinger2: I did the workflow thing we discussed yesterday, have a look at https://github.com/stain/flowing-clj -- pretty basic so far (can only run the workflow once!)
19:04stainalso it can be changed from push to pull by replacing "future" with "delay".. I'll probably make that an option somewhere
19:06hiredmanstain: have you seen prismatics stuff for this?
19:07hiredmanhttps://github.com/Prismatic/plumbing#graph-the-functional-swiss-army-knife
19:08stainhiredman: yes, I looked at it earlier
19:09stainbut I wanted to finish mine first before trying it
19:18stainhiredman: what is smooth with the prismatic graph is how it has autowiring of the parameters
19:20stainbut it seems ironically to not have a good way to do the plumbing independently
19:29hiredmanstain: I would take plumbing and extend it with component's dependency system then
19:30hiredmane.g. avoid the dsl macros and use a sort of environment map of names to functions and a dependency map of functions to arguments
19:44stainhiredman: yeah, that sounds like a doable approach as well.. a bit different style, though
21:10lvhIs there anything obviously wrong with these compojure routes? I'm getting 404s, which leads me to believe that resources is taking precendence: https://gist.github.com/lvh/af3a2825d7647345437b
21:21xulferLooks okay to me
21:22justin_smithlvh: have you tried restarting your server since the definition?
21:23lvhjustin_smith: ah; good idea :) figwheel has spoiled me!
21:23justin_smithif restarting fixes it, try passing #'app to your http server as the handler instead of app
21:25lvhjustin_smith: yep! thanks :)
21:25lvhjustin_smith: wait, ring knows how to deref stuff?
21:47justin_smithlvh: ##(#'+ 1 1) ; vars deref when invoked
21:47lazybot⇒ 2
21:50justin_smithlvh: the difference ends up being, of course, if the server is using your var, it will see any new definitions, not so if it is using a function