#clojure logs

2015-12-19

01:12lambda-11235leiningen isn't recognizing my test.check dependency.
01:22lambda-11235Nevermind, now it's working. For no apparent reason.
02:57slesterhey, is there a way to stop a window opened by clojure from immediately closing at the end of a program? I wanna look at a visualization but it just turns off
02:57slestercloses immediately :(
03:26felixnanyone familiar with clojure.core.logic.fd? I want to see if a list a is smaller then list b. sort of like fd/bounded-listo. it should be possible to write my own, but I'm a bit out of my depths XD
03:51amalloysmaller like, has fewer elements?
03:52amalloythat doesn't sound like a finite-domain thing, it sounds like general logic programming
04:11felixnamalloy: one of the two lists is constant throughout, so I realized it should be fine to just m/project the length of it, so I can just use fd/bounded-listo!
04:11amalloysure, if one is constant that sounds fine
04:15felixnall this core.logic/.fd stuff is blowing my mind, and it's easy to use. just dug pretty deep into the logic.fd stuff, I think I have a slightly better grasp on something I didn't realize existed an hour ago heh
06:24jonathanjcan i set the media-type of a request from liberator's :handle-exception handler?
06:25jonathanjfor example, if the media-type was going to be "application/pdf" but now there's an exception, i need to change the media type
07:21oracle123how to use json in clojure jdbc with postgresql? I want to insert a column of type json.
11:34BRODUSany ideas on how I could write an expression that would effectively be (take-while-plus-the-failing-value ...)
11:46dxlr8rwell, you could put in a for loop, and return the position
11:47dxlr8rit will then return the last position of the "while" and you can add Ok1
11:47dxlr8r+1
11:49dxlr8ror you can use loop / recur
11:52justin_smith,(defn take-while-plus-fail [p? [el & rem :as coll]] (lazy-seq (if (p? el) [el] (cons p (take-while-plus-fail p? rem)))))
11:52clojurebot#error {\n :cause "Unable to resolve symbol: p in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: p in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: p in this context"\n ...
11:52justin_smith,(defn take-while-plus-fail [p? [el & rem :as coll]] (lazy-seq (if (p? el) [el] (cons el (take-while-plus-fail p? rem)))))
11:52clojurebot#'sandbox/take-while-plus-fail
11:53justin_smith,(take-while-plus-fail even? [0 2 4 5 7])
11:53clojurebot(0)
11:53justin_smithhrm
11:54justin_smith,(defn take-while-plus-fail [p? [el & rem :as coll]] (lazy-seq (if (p? el) (cons el (take-while-plus-fail p? rem) [el]))))
11:54clojurebot#'sandbox/take-while-plus-fail
11:54justin_smith,(take-while-plus-fail even? [0 2 4 5 7])
11:54clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/cons--4090>
11:54justin_smith,(defn take-while-plus-fail [p? [el & rem :as coll]] (lazy-seq (if (p? el) (cons el (take-while-plus-fail p? rem)) [el])))
11:54clojurebot#'sandbox/take-while-plus-fail
11:55justin_smith,(take-while-plus-fail even? [0 2 4 5 7])
11:55clojurebot(0 2 4 5)
11:55BRODUSnice
13:06BRODUSany recommendations on profiling clojure code in emacs?
13:07justin_smithfor micro-benchmarks, use criterium, for actual profiling use a java profiler, yourkit is excellent, but jvisualvm is free and comes with the jdk
13:09BRODUSjustin_smith: thanks
13:15lokien_clj-refactor replacement for vim?
14:09renartany automated tools for identifying unused dependencies in project.clj? i've cluttered mine up something fierce.
14:13justin_smithrenart: you could tru commenting out a dep followed by lein check, if lein check passes the dep was not being used
14:14justin_smith*try
14:14renartjustin_smith: i'm going to bet that doing a manual traversal will be faster than enduring the clojure startup time.
14:15justin_smithrenart: good luck, I don't know of any automated tool that even knows how to map namespaces to deps in project.clj, not to mention finding unused deps
14:16rhg135Clojure actually starts reasonably fast
14:17justin_smithrhg135: but the plan I suggested requires starting lein repeatedly, that is not fast
14:17rhg135Oh right
14:27ghost__do people still reject using clojure for small programs, because "startup is too slow"?
14:28rhg135Not me. I'm writing scripts in it.
14:29justin_smithlein with nrepl is so easy to use, people never find out how much faster startup could be
14:30rhg135And less convenient, but for dev time I don't think it's a big deal
14:31justin_smithjust today I created an uberjar with clojure.core, criterium, core.async, and prismatic/schema in order to have a repl with fast startup to hash out ideas in
14:31rhg135Like running javac also takes a while
14:31justin_smithright
14:32renartjustin_smith, rhg135: compiling my own uberjar and jacking into that's faster/better?
14:32justin_smithrenart: no jacking
14:32justin_smithrenart: java -cp my-uber.jar clojure.main starts in ~1 second
14:33justin_smithrenart: no hacking on the clojure stack - I just made a project with no source code, just a project.clj with the deps I want, then made an uberjar
14:33rhg135I'm writing a single file script but I do wonder what shebang to use
14:33justin_smithany uberjar that contains clojure.core can be run that way
14:33renarthuh
14:33renartso what's so slow about the leiningen boot up process?
14:34justin_smithrenart: everything. It's equal parts lein itself, and nrepl last I checked
14:34renarthm
14:34justin_smithwith clojure.main you can run a repl without nrepl
14:34justin_smith(or load and run an arbitrary clojure file, or whatever)
14:35justin_smithrhg135: #!/usr/bin/java -cp clojure.jar
14:35justin_smithrhg135: something like this
14:36rhg135I wanted to avoid distributing 2 files,but I thought so
14:37rhg135Guess uberjar it is
14:38justin_smithrhg135: it is possible to make an uberjar runnable via shebang
14:38justin_smithas long as your -main is set up properly etc.
14:38rhg135Yeah
14:42ghost__justin_smith: how is it possible?
14:43justin_smithghost__: https://coderwall.com/p/ssuaxa/how-to-make-a-jar-file-linux-executable
14:45ghost__justin_smith: and what should I have in main for this to work?
14:49justin_smithghost__: -main should take any number of strings as arguments, and its namespace should be aot-compiled. Or you could set clojure.main as your main and it would just give you a repl.
14:50ghost__justin_smith: thank you
14:58tolstoyInteresting. I still have clojars problems. I can publish jars to the repo, but the pom.asc and jar.asc is denied. Wrong password or something? I've even associated the correct public key to my account (I think ... how would I know)?
14:59justin_smithtolstoy: for the asc, the password needed is your pgp key for signing with
14:59justin_smithnot your clojars password
15:00tolstoyRight. I think it all works. I just get this:
15:00tolstoyCould not transfer artifact com.zentrope:quiescent:pom:0.2.2 from/to clojars (https://clojars.org/repo/): Access denied to: https://clojars.org/repo/com/zentrope/quiescent/0.2.2/quiescent-0.2.2.pom, ReasonPhrase: Forbidden.
15:01justin_smithwhat does that have to do with the asc files?
15:01tolstoyjustin_smith: https://gist.github.com/zentrope/7c21bdb8d5de5e20a209
15:02justin_smiththe asc files and the jar uploaded fine, the pom is the problem
15:02tolstoyThe actual jars are there, but the metadata (?) that would make them show up in searches is not there.
15:03justin_smithright, it needs the pom file for search stuff I bet
15:03tolstoyFor some reason, uploading the pom file seems to be forbidden.
15:03justin_smithyes, that's the only upload that failed
15:04justin_smithI am guessing there was something that went wrong previously, and led to a pom file that already exists that you don't have the rights to replace? that's weird though
15:04tolstoyMy clojars password and username checks out (or I couldn't even get this far).
15:04justin_smithright, all the uploads except for the pom seem to have succeeded
15:04tolstoySame with the signing stuff. If I enter wrong passwords, there's no attempt to publish.
15:05justin_smithyeah, sounds like an administration problem on the clojars end
15:06tolstoyI wonder if my public key must be published? (lein help gpg says it only matters if other people need it).
15:08tolstoyTrying again leads to the "redeploying non-snapshots" issue. Presumably the "pom" stuff would still work (given there are four separate requests).
15:14tolstoyjustin_smith: Ah hah! It's the :pom-additions key in my project.clj file. Commented that out and it now works.
15:15justin_smithinteresting
15:15tolstoyjustin_smith: Clue was in here. https://github.com/clojars/clojars-web/issues/270
15:27tolstoyFor some reason, "lein deps :verify" says my artifact has a bad signature. Oy.
15:28justin_smithtolstoy: pom.xml won't match pom.asc because you changed pom between generating the asc and the successful upload
15:28tolstoyI hope that's it. ;)
15:32domgetterI have a question about transducers: https://gist.github.com/domgetter/f50aa2cda6d4f8b0c6eb
15:32domgetterSpecifically about what (map inc) returns
15:32justin_smith,(type (map inc))
15:33clojurebotclojure.core$map$fn__4537
15:33justin_smithit's a function, specifically a transducing function
15:33domgetter,(((map inc) +) 1 2 3)
15:33clojurebot#error {\n :cause "Wrong number of args (2) passed to: core/inc"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: core/inc"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 36]\n [clojure.lang.AFn applyToHelper "AFn.java" 156]\n [clojure.lang.AFn app...
15:34domgetterI know (map inc) returns a function which takes a reducing function, and if I give THAT a reduction function, it returns a function that can take many things and reduce them with the reducing function and the original inc
15:37domgetterDoes (transduce (map inc) + '(1 2 3)) do something special?
15:38Bronsa`it invokes `reduce`
15:38Bronsa`,(reduce ((map inc) +) '(1 2 3))
15:38clojurebot8
15:39domgetterah okay
15:40domgetterah, so ((map inc) +) isn't a function I can just call, it's a function I can reduce with
15:40domgetterthat makes sense now, thank you
15:40Bronsa`((map inc) +) is a reducing function
15:40Bronsa`s/is/returns/
15:40justin_smithdomgetter: you can call it, if you give it the right arguments
15:41domgetterjustin_smith: If I call it the way reduce does?
15:41Bronsa`yes, if you called it with 1 2 rather than 1 2 3 it would have worked for example
15:41Bronsa`because that's just the reducing arity
15:42domgetterOh right, and then call it again with 4 3
15:42justin_smith,((map inc) +) 1 2)
15:42clojurebot#object[clojure.core$map$fn__4537$fn__4538 0x612ce7b "clojure.core$map$fn__4537$fn__4538@612ce7b"]
15:42justin_smithoops
15:42justin_smith,(((map inc) +) 1 2)
15:42clojurebot4
15:42Bronsa`it only worked because map can reduce over more than one collection
15:42Bronsa`but (inc 2 3) doesn't work
15:43justin_smithright
15:43Bronsa`,(((map +) +) 1 2 3 4)
15:43clojurebot10
16:06domgetterWhat would be considered more idiomatic? (reduce ((map inc) +) 0 [4 5 6]) or (transduce (map inc) + 0 [4 5 6]) ?
16:11justin_smithdomgetter: the transduce one
16:12BRODUS,(transduce (map inc) + 0 [4 5 6])
16:12clojurebot18
16:15domgetterokay cool
16:22rhg135can anyone suggest good dev music?
16:26BRODUSrhg135: philip glass is nice
16:27rhg135hmm, thx
16:28yendalately I usually like to listen to Infected Mushrooms, good for the flow :D
16:34ridcullyi hope this is a band
16:34justin_smithridcully: actually you just let some mushrooms rot and shove them in your ear holes
16:34justin_smithit's pretty neat, all the cool kids are doing it
16:35rhg135we have tons of those in the fridge
16:41yendathis is psytrance music :D
16:43yendais there a way to pretty print an edn file in emacs like you would do with json-pretty-print-buffer ?
16:44jkogutrhg135, biosphere (Geir Jenssen)
16:50BRODUSanyone here familiar with the enlive library?
17:09felixnjust would like to say I'm loving clojure XD core.logic & zip are awesome, and everything just feels simple. and I'm sure when I need them, the stateful idioms & async will be solid as well
17:15ben_vulpesyo justin_smith the cider parallel clj/s repls story seems to be working these days
17:16dxlr8rrhg135: pink floyd, wish you where here, etc.
17:16ben_vulpesgranted i'm running 2 jvm's side-by-side, but i'm getting code sent to the browser via C-c C-k and code sent to the cljvm via the same combo entirely transparently.
17:17ben_vulpesi can't quite figure out how to get my reagent components to re-render yet, that's the next hurdle to clear in dwarfclojureforetress this weekend
17:22yendaben_vulpes: do you have some readings on how you achieved that ? (the clj and cljs repl connexion and one shortcut)
17:32ridcullyben_vulpes: are we talking full blown df?
18:00renartridcully: no, just that every time i dive into the clj/s tooling it's like playing dwarf fortress
18:01renartit's kind of an in-joke with some other devs in my personalnet, regarding arcane knowledge entirely useless outside of the context in which it was originally won
18:02ben_vulpesyenda: tbqh i think it's just that cider's docs finally laid out how to configure everything
18:02ben_vulpes(and perhaps that cider now actually works[!])
18:02ben_vulpesthe tl;dr is:
18:03ben_vulpes- M-x customize-group <RET> cider-cljs-repl (set this to weasel)
18:03ben_vulpesget weasel into your deps
18:03ben_vulpes- stick a weasel repl connect stanza in your main/equivalent in the clojurescript
18:04ben_vulpesM-x cider-jack-in-clojurescript
20:42justin_smithben_vulpes: cool
20:54ridcullysince 0.9 of catacumba, my [:prefix "secured" [:any #'check-login] ...] seems to get ignored. have i missed some breaking change?
21:21RazorX-clojure
21:30chomwitta newbie question: all the tutorial i've read so far create a lein project but in project.clj the put handwritten versions of dependencies each time different! can i avoid that ?
21:31justin_smithchomwitt: you can use lein-ancient to find out the latest version of deps, but in the clojure world we don't typically specify dependencies without explicit versions
21:32justin_smithit might be possible, but probably isn't a good idea
21:33chomwittjustin_smith: ok. lein-ancient seems helpfull enough! i'll try it . thanks!
21:34chomwittlein-ancient will find 'latest version' compatible with my installation , or latest latest ? :-)
21:35justin_smithwhat does "compatible with my installation" mean?
21:35chomwitti mean if i have clojure 1.4 maybe latest ring-core wont work as good as a previous one ?
21:37justin_smithchomwitt: that's not how it works - your project.clj file decides which clojure version you get
21:37justin_smithlein ancient will tell you to pull in a newer clojure
21:38justin_smithI know it's a bit weird, but clojure itself is just another dep
21:38chomwittjustin_smith: but i have clojure already installed in my debian system
21:38justin_smithdon't use that clojure
21:38justin_smithit's just a library
21:38chomwitt!
21:39justin_smithchomwitt: if you are using lein, I promise lein is not using that clojure version that debian installed
21:39justin_smithchomwitt: clojure is a java library that contains a bytecode compiler, it's a language as a library that runs on java
21:39chomwitta! u r rigth. i have 1.6 installed and in a test project it says 1.7
21:40justin_smithchomwitt: the installed version is useful if you didn't want to use lein - if you just wanted to manually do dep management, and let debian control which jars you have
21:40justin_smithbut that's the hard way to do it
21:40justin_smithlein is much easier, and it doesn't use any of your debian installed things, except for java itself
21:41chomwitti definately follow the lein way! :-)
21:42justin_smithchomwitt: on the other hand, lein is a dev tool - once you have something to deploy, use lein to make an "uberjar" and just use that with java - end users or servers don't need to mess with lein
21:44chomwittthanks for the clojure epiphany moment you offered me!! :-) i should have know that the mustache guy shouldnt be taken ligtly!! :-)
21:44justin_smithhah, no problem
21:45justin_smithchomwitt: it works out really nicely, but it's totally different from building C or python or ruby or js or... just about anything else I know of
21:45justin_smithI guess haskell has a slightly similar system, but not quite as radical as the clojure model in terms of dep isolation I don't think (at least not by most common usage)
22:51rhg135I have a question. If I have {\a [1 2 3] \d [4 5 6] \c [7 8 9]} how can I get ([1 7 4] [1 7 5] [1 7 6] [1 8 4] ...)?
22:52justin_smith,(map vector (vals {\a [1 2 3] \d [4 5 6] \c [7 8 9]}))
22:52clojurebot([[1 2 3]] [[4 5 6]] [[7 8 9]])
22:52justin_smith,(apply map vector (vals {\a [1 2 3] \d [4 5 6] \c [7 8 9]}))
22:52clojurebot([1 4 7] [2 5 8] [3 6 9])
22:52justin_smithwait no that's not what you wanted at all :)
22:54rhg135yeah, I tried that. the tricky bit is order matters for this
22:55justin_smithrhg135: order based on keys or order based on vals?
22:56rhg135I have an a seq of keys
22:56rhg135like, I have the map and [\a \c \d]
23:10lambda-11235,(let [[xs ys zs] (vals (into (sorted-map) {\a [1 2 3] \d [4 5 6] \c [7 8 9]}))] (for [x xs y ys z zs] [x y z]))
23:10clojurebot([1 7 4] [1 7 5] [1 7 6] [1 8 4] [1 8 5] ...)
23:12lambda-11235rhg135: It looks like converting to a sorted map will do the trick.
23:13justin_smithlambda-11235: another option is (map m (sort (vals m)))
23:13justin_smitherr
23:13justin_smithI mean (map m (sort (keys m)))
23:15rhg135problem is thiss is not consistent ordering, but I think I got it
23:16justin_smithrhg135: then use (map m key-order)
23:16rhg135I got this https://www.refheap.com/112940
23:17justin_smithrhg135: (partial get m) is m
23:17rhg135seems not ram-friendly if distinct works like I think
23:17rhg135oh doh! thx
23:18justin_smithrhg135: but with that use of destinct, eventually the function will hang forever
23:18rhg135how so?
23:19justin_smithbecause clojure doesn't know every result possible has been generated, so it will infinitely produce new combinations, all of which are deleted by distinct
23:19rhg135ah, II see
23:19justin_smithand there is no stop condition, so it will hang indefinitely
23:19rhg135I can't think of one though
23:20rhg135well how to do it
23:20justin_smithrhg135: you can programmatically produce all the combinations - if you know the length of each val you can use the method of lambda-11235 above, otherwise it can be done with a recursive function calling mapcat
23:21amalloyrhg135: https://gist.github.com/amalloy/38295629f7b7ec3ca6ea
23:21rhg135I can get the length in O(1) so that works
23:22rhg135ah
23:22rhg135let me try that
23:25amalloyrhg135: that code is an application of a very common pattern in functional programming: exploring a decision tree (here, each entry in m is a node with 3 children) and creating a list of the options. you can use this same skeleton for a lot of functions if you see how they fit into the structure
23:26amalloyie, a doubly-nested for with recursion in the second binding
23:26rhg135yeah, I've seen this before, repeatedly
23:27rhg135it seems to hang for me
23:28amalloyworks for me on your example input
23:30rhg135it's not idle at least
23:31justin_smithhttp://i.imgur.com/K634Yg0.gif
23:31rhg135might just take a while, it's large
23:36rhg135amalloy: now that I think it over, isn't that (map m order)?
23:37amalloyno
23:37amalloyit's something like (mapcat #(map ... %) order)
23:39rhg135I'm sorry I don't see it. I guess I'm done for the day
23:40amalloy,(for [x [1 2 3] y '[a b c]] [x y])
23:40clojurebot([1 a] [1 b] [1 c] [2 a] [2 b] ...)
23:40amalloythis is just turning your map/order thing into that
23:43rhg135the code seems to add the vector at the key to the front
23:44amalloyin the same way that clojure.core/map does, because it conses onto the recursive call
23:46rhg135OH!
23:46rhg135sheesh. I read for as let
23:47rhg135I'm done
23:47amalloythe old classic (let [...] (let [...] )) joke
23:50rhg135I need a new font
23:57rhg135idk why it wasn't working, but it is now
23:57rhg135(inc amalloy)
23:57sdegutis(inc rhg135)
23:58rhg135?