#clojure logs

2016-01-17

01:25zeebrahlein repl shows i'm using nREPL 0.2.10 but i'd like to be at 0.2.12. I've just done a lein upgrade and in my ~/.lein/profile.clj i've put the tools.nrepl dependency as 0.2.12. Any ideas?
02:41zeebrahis there a prettier way to write this: user> (map #(inc (int (- (int %) (int \A)))) "ABCDE")
02:41zeebrah(1 2 3 4 5)
03:31favetelinguis,(let [r (ref {:id []})] (dosync (alter r assoc :g 2)) @r)
03:31clojurebot{:id [], :g 2}
03:32favetelinguisHow can i conj a value into the vector?
03:34zeebrah,(conj [1 2 3] 5)
03:34clojurebot[1 2 3 5]
03:36scottjfavetelinguis: (let [r (ref {:id []})] (dosync (alter r update-in [:id] conj 2)) @r
03:41zeebrahif i have a vector of characters, is there a way to check if a certain character is contained in the vector?
03:41favetelinguisscottj: thanks
03:46scottjzeebrah: (some #{character} characters)
03:53ridcullyzeebrah: just shorter: ,(map #(- (int %) (int \A) -1) "ABCDE")
03:57zeebrahthanks scottj and ridcully. i cant get the some form to work. i think im not very good at clojure haha
03:59scottjzeebrah: reading a book helps. feel free to paste a small example of what you have
04:01zeebrahscottj: think I got it. there was a problem with cider saying "error in process filter: Wrong type argument: characterp, nil". Startd a fresh instance and it works
04:02zeebrahseems to be a bug in cider
04:28justin_smithyeah, that's a classic "your elisp code is broken" message from emacs
04:37zeebrahcan trigger it fairly easy again and again.. so weird
04:37zeebrahjust by evaluating that some form
04:50justin_smithzeebrah: if you want to figure out what is wrong, emacs has a great step debugger
04:50justin_smithor you can just accept it's a cider bug and move on
04:55zeebrahi figurd it was to do with escaping eg, \A confuses emacs somehow, sometimes
04:55justin_smithemacs can handle \A fine, it's cider that gets confused
05:09zeebrahah you're probably right
06:55John[Lisbeth]I'm using tryclj.com
06:56John[Lisbeth]and I believe I am trying to (defn square [x] (* x x))(square 10)
06:58ridcullyput it in two lines
06:58John[Lisbeth]I get this error goo.gl/RjilZv . I did indeed put it in two lines.
07:05taspathi, after "lein new chestnut something" I added cljs-ajax "0.5.3." dependency. Then in core.cljs I've added [ajax.core :refer [GET POST]] and it breaks the core.cljs. What is wrong there?
07:08ridcullytaspat: has it worked before? can you share the error and maybe the project.clj somewhere?
07:08ridcullyJohn[Lisbeth]: for me this url gives a 404
07:09taspatclojure.lang.ExceptionInfo: failed compiling file:src/cljs/something/core.cljs
07:09taspat
07:10ridcullytaspat: there for sure is more than this?
07:10taspatproject.clj is the default generated by chestnut plus this line: [cljs-ajax "0.5.3"]
07:11ridcullythen maybe some error in your core.cljs?
07:12taspathttps://gist.github.com/anonymous/d02295060030d17fdca5
07:16ridcullyalso this template uses rather old cljs and friends. there where lots of changes - not saying that this is the problem, but clj-ajax is on 1.7, so i'd be suspicious
07:17taspatridcully: what template would you suggest?
07:19John[Lisbeth]www.hastebin.com/raw/wulodiwevi
08:10justin_smithJohn[Lisbeth]: tryclj automatically clears the sandbox on a schedule
08:10justin_smithjust rerun the code
08:10justin_smithJohn[Lisbeth]: it isn't exactly 15 minutes after your definition that it is cleared - just exactly once every 15 minutes or so, all definitions go
08:10John[Lisbeth]I found another web clojure repl to use
08:10John[Lisbeth]called himera
08:10justin_smithso this can happen any time
08:10justin_smithOK
08:11justin_smithridcully: funny thing is, if you do it all on one line that error won't happen
08:40John[Lisbeth]when I am running java -cp clojure.<version>.jar clojure.main, what java package do I need for that initial java command?
08:41quigonjinnJohn[Lisbeth]: distro?
08:42justin_smithJohn[Lisbeth]: any java newer than 1.5
08:42justin_smithJohn[Lisbeth]: 1.8 works great. You don't need a jdk, a jre suffices.
08:45quigonjinnJohn[Lisbeth]: I'm using jdk8-openjdk in parabola . And yes jre8-openjdk suffices
08:47justin_smithJohn[Lisbeth]: also, it's great to start out with just java and clojure.jar, but if you get to the point of using the wonderful libs our community provides, you'll find it much easier to use a build tool - it will let you pick the clojure version and the libraries used on a project by project basis and do all the messy classpath and jar building things for you. lein is the most popular, but boot looks pretty cool too as a newer option.
10:15TimMcridcully: Philosophers have been asking this question since time immemorial
10:15TimMcugh, was in scrollback
10:15TimMc"07:10 < ridcully> taspat: there for sure is more than this?" for reference
10:19kwladykaDo you know site with good examples when use async or agent?
10:42M-martinklepschHello from vector.im :)
11:01luxbockM-martinklepsch: what is vector.im?
11:21rogeralsingComplete noob on Clojure here.. but when using Leiningen and Cursive in IntelliJ. what is the difference between leiningen tasks and normal run configs? and what defines what tasks there are?
11:38ridcullyrogeralsing: the tasks for lein are from leiningen and the installed plugins. the run-configs are basically what clojure.main provides with the classpath setup properly. all the other might (or might not) be idea stuff
11:42rogeralsingridcully: if I reference e.g. core-async in the project.clj, I can see that it is fetched and used when I use the "test" task in Leiningen.. but if I set up a run config using Leiningen, it will fail at runtime with filenot found exception when referencing core async.. what am I missing?
11:42ridcullyreload the config
11:43ridcullyopen that right hand side window with the vertical "leiningen"
11:43ridcullythere is a list of tasks and on the top is one button, that allows to refresh the deps
11:44ridcullyif you dont see vertical tabs at the right hand side, you might need to click that small square on the lower left side of your window, which shows them all
11:49rogeralsingridcully: thanks, that did the trick!
11:51visofhi guys
11:51visof,(= 1 1)
11:51clojurebottrue
11:51visof,(== 1 1)
11:51clojurebottrue
11:51visof,(= nil nil)
11:51clojurebottrue
11:51visof,(== nil nil)
11:51clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers equiv "Numbers.java" 212]\n [sandbox$eval97 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval97 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" ...
11:51visofwhy this error occur?
11:51visofwhat == is exactly?
11:53visofhi there?
11:54lambda-11235visof: == only compares numbers, it cannot be used for any other object.
11:55visofah ok
11:55visoflambda-11235: so = is another replacement?
11:55visof,(== "hello" "hello")
11:55clojurebot#error {\n :cause "java.lang.String cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers equiv "Numbers.java" 208]}]\n :trace\n [[clojure.lang.Numbers equiv "Numbers.java" 208]\n [sandbox$eval121 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval121 invoke "NO_SOURCE_FILE" ...
11:57visof,( "hello" "hello")
11:57clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval145 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval145 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval145 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java...
11:57visof,(= "hello" "hello")
11:57clojurebottrue
11:59lambda-11235visof: (= foo boo) is kinda like foo.equals(boo) in java.
12:04visoflambda-11235: i don't know java
13:24shazzlowhow do I open simple vim buffer with fireplace to evaluate expressions in the current context?
13:32ridcullyshazzlow: open temp.clj, start lein repl, do `:Connect <url lein tells you>`. cpp/:Eval away
14:24beakyhello
14:24beakyhow do i batch sql in clojure.jdbc
14:25beakyhttps://ideone.com/fZ2p6S so i can batch the insert! and the db-do-prepared-return-keys
14:35seakoyou can do (apply db/insert! db-spec table-name column-names column-values) or (apply db/insert! db-spec table-name maps-of-key-value-data)
14:36seakoby default the insert will run in a transaction
14:40beakyah
14:41beakythanks
14:52seakonp
14:56favetelinguisif i close! a subscription channel will that be ok or do i have to first use unsub and then close! that channel?
16:09justin_smithfavetelinguis: I made a gist showing it is safe to close! without unsub (bench.jar is just a clojure.jar uberjarred together with core.async and some other deps) https://gist.github.com/noisesmith/bb9bb3b658924bed334c
16:10justin_smithfavetelinguis: so :a only consumes 2 values before close!, then :b consumes 3, etc. etc. and all the others still run
16:10justin_smiththen when 0-9 have all been sent out, it exits
16:31novak`I would like to use some functions from Leiningen's leiningen.new.templates namespace in my project which is not a lein template. Is it possible to add it as a dependency somehow?
16:31justin_smithyes, you could add the apropriate lein namespace to your dependencies
16:32justin_smithnovak`: one thing to keep in mind is that some leiningen code was designed to run once and exit, and may have problems in a longer running program
16:35novak`justin_smith: I wold like to use name-to-path,year,sanitize,sanitize-ns,project-name... It looks like this functions are safe from that danger.
16:35justin_smithnovak`: good chance, yeah
16:40lsyoyomgo free
16:40novak`justin_smith: So, what should I try to provide as group-id, artifact-id and version to get leiningen.new.templates?
16:42justin_smithnovak`: why not make some junk up and fix it later if it breaks the output? I'm really not sure.
16:44novak`justin_smith: leiningen-core is only jar available on Clojars, unfortunately, it doesn't provide leiningen.new.templates
16:45justin_smithnovak`: leiningen itself is on clojars
16:45justin_smithhttps://clojars.org/leiningen
16:45justin_smithif you put that in your deps, you should find leiningen.new.templates
16:52novak`justin_smith: Hm... It's actually the whole Leiningen packed as a dependency for just few functions. But, thank you anyway. :)
16:53justin_smithnovak`: yeah, I don't think they provide anything factored smaller
16:53justin_smithit's that or make your own fork and jar
16:58novak`justin_smith: I found that leiningen.new.templates came to leiningen main repository from https://github.com/Raynes/lein-newnew and it's now deprecated. That is one more option - to retain on a deprecated library.
16:59novak`... maybe the worst option
17:01justin_smithnovak`: just because leiningen.jar is on your classpath doesn't mean the whole thing goes in your heap - namespaces that are required are loaded from it individually
17:05novak`justin_smith: I know but still, less jars smaller distribution
17:06novak`justin_smith: when it goes out as a uberjar of course
17:06justin_smithright
17:06justin_smithnovak`: sounds like it's time to make the lein unterjar plugin
17:07justin_smithuberjar pulls in your code plus all your deps, unterjar makes a new smaller jar with only the parts you use...
17:08TMAisn't that intractable? (because of eval at least)
17:09justin_smithTMA: "lein unterjar is incompatible with code that uses eval at runtime" - done!
17:10justin_smithTMA: in sane code, your required namespaces should all be in your ns forms, and static analysis can build the whole tree. Any exceptions that load new namespaces at runtime can be enumerated by hand.
17:10TMAjustin_smith: I am afraid that even for stating the restriction there might not be a computable function
17:10justin_smithTMA: who cares - code broke because you did a thing that the library does not support
17:10justin_smithdoesn't matter if a program can prove it or not
17:10TMAjustin_smith: oh, I meant pruning the namespaces for unused vars
17:11justin_smithI meant pruning project for unused namespaces
17:11justin_smiththat's different, yeah
17:12justin_smithTMA: novak`'s case was that he wanted to use some namespace that's in leiningen, but not the rest of the project. Namespace granularity seems reasonable to me.
17:12TMAon the ns level with the "no dynamic ns" restriction it should be fine
17:12justin_smithyeah, I wonder how hard this would be to build...
17:13TMAexcept for the cases of poorly written libraries that implicitly depend on other namespaces [not explicitly depended on] being present in the same jar
17:14justin_smithTMA: cool, now they would have an incentive to be better written
17:42melladricHello guys, I am new to clojure and have been looking at Zippers. Can someone say if it is a good (or bad) idea to have MANY zippers (one for each node) for a single "tree"?
17:43melladricI mean supose each node has a zipper, and I want to add a child to node X. So I can simply append-child to it and I am done. Does that make sense?
17:43justin_smithmelladric: depends if you are doing any of the modification operations
17:43melladricYes, appending children is my goal
17:44justin_smithmelladric: this won't affect any of the other zippers though
17:44justin_smithmelladric: clojure data is immutable, the append is only seen in that zipper, and the resulting seq-zip if any.
17:45melladricYou are right, I considering to use atom to hold the zipper, but I guess this wont work for this many zippers
17:45justin_smithmelladric: you don't need an atom, you can just do each of the actions in series
17:45melladricHmmm, the problem I am trying to solve is to append children to a tree in a fast way
17:45justin_smithall in one zipper that is
17:46melladrichm, If i have one zipper, and a receive a list of "edges" like 1 -> 2 I should search for the node 1 in the zipper and then append?
17:46justin_smith,(update-in [[[[][]]]] [0 0 1] conj :a)
17:47clojurebot[[[[] [:a]]]]
17:47justin_smithyou don't need zippers
17:47justin_smithI mean sure you could do that
17:47melladricSo a hash-map is enough?
17:47justin_smithwhat hash map?
17:48melladricThe other way, without zippers, would be somehitn like this: {:1 :2}
17:48melladricis the same as 1 -> 2
17:48melladricif I would append 1 -> 3 it would be {:1 [:2 :3]}
17:48justin_smithwat
17:48justin_smith:1 is a terrible keyword, just use the number
17:49justin_smithbut why does it even need to be a hash-map?
17:49melladricWhat else could I use?
17:49melladric(sorry for my lack of knowledge)
17:49justin_smith,{1 [2 3]}
17:49clojurebot{1 [2 3]}
17:50justin_smithin this data structure, what is "1" meant to represent? what are [2 3] meant to represent?
17:50melladric1 is the node label and [2 3] are the children list
17:50justin_smithOK so this is an adjacency list
17:51beakyi love adjacency lists
17:51melladricYes, since i am dealing with trees i could do node -> to its parent too
17:52melladricHmmm, I asked about zippers , because this is the first time I am using clojure and I am trying to solve a problem that needs to build a tree.
17:52melladricAnd i need to expose this built tree in a web service. (So my idea was to have a map or zipper in an atom and read from it when asked)
17:53justin_smitha zipper on an atom makes no sense
17:53justin_smithan atom holding a zipper might be feasible
17:53justin_smithabove I was just trying to show that nested updates are possible without zippers (and often much easier without them)
17:54melladrichmm, i see
17:54justin_smiththe key, with immutable data, is that you can't just make separate updates uncoordinated from one another, because the input data never changed
17:54melladricIn your opinion, when is a good idea to use a zipper then?
17:54justin_smithso you could have an atom with a zipper, and then use swap! to move and append inside that atom
17:55justin_smithor you could use a recursive function or loop, then you don't need an atom
17:55melladricIn my case I probably need an atom because a web endpoint append nodes and the other "prints" the tree. (or am I wrong again?)
17:56justin_smithyou could wrap all the request handling in one loop but that would be ugly
17:56justin_smithyes, you could do your updates to the zipper for each request, and then have another endpoint that turns the current state of the atom's zipper back into a seq
17:57melladricAlso, is there a efficient way to append the nodes? I mean, the whole idea of lots of zippers, would be to avoid the worst case input like "1 2; 2 3; 3 4; 1 999"
17:57melladricLet me explain: 1 points to 2 , then 2 points to 3 and so on
17:58justin_smithmultiple zippers only makes sense if you want parallel values that would be merged later, or do not need to be coordinated or merged
17:58melladricIf i used a zipper this means zip/down followed by zip/append-child
17:58melladricSo after the input I would be way tooo deep in the tree
17:58melladricI would have to go way up to append again
17:59melladricIf I used one zipper, that is.
17:59justin_smithif you had two zippers, how would they stay in sync?
17:59justin_smithhow would one see the changes made in the other?
17:59melladricYeah, you made me realized this wasnt a feasible idea..
18:00justin_smithmelladric: you could save all the operations, and then sort them in an order that can all be applied efficiently... maybe? I don't know if this would actually be helpful or not
18:01justin_smithmelladric: also note that there is "root" that directly takes you to the top node http://conj.io/store/v1/org.clojure/clojure/1.7.0/clj/clojure.zip/root/
18:01melladricAh yes, I am aware. That was a example.
18:01melladricFinding an optimal order is good
18:02melladricunfortunately from a point onward the input is dynamic/unknow (call to the append web endpoint)
18:02melladricjustin_smith: Thank you for the help :)
18:02justin_smithif all you are doing is appending at specific places, update-in or assoc-in might be a lot easier than zippers
18:02melladricYes, I will try that way
18:03melladricZippers would be cool because latter I have to operate on the tree
18:03melladric(i.e doing some tree algorithms) but I'll get by
18:03melladricAh
18:03melladricone more question
18:03justin_smith,(-> [] (update-in [0] conj [:a]) (update-in [0 0] conj :b) (update-in [0] conj [:c]))
18:03clojurebot#error {\n :cause "clojure.lang.PersistentList cannot be cast to clojure.lang.Associative"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList cannot be cast to clojure.lang.Associative"\n :at [clojure.lang.RT assoc "RT.java" 792]}]\n :trace\n [[clojure.lang.RT assoc "RT.java" 792]\n [clojure.core$assoc__4365 invokeStatic "core.clj" 191]\n [clojure.core$upda...
18:03justin_smithergh
18:03melladrichaha
18:04melladricNah , the question was silly. Not asking anymore. I still gotta think about the problem
18:05melladricThank you for the help, justin_smith
18:06papphammar Now when there is talk about trees, recursive loops... and such, maybe I can throw in a question also? :-)
18:06justin_smith,(-> [] (assoc-in [0] [:a]) (assoc-in [0 1] :b) (assoc-in [0 2] [:c]) (assoc-in [0 2 1] :d))
18:06clojurebot[[:a :b [:c :d]]]
18:06papphammarBut I have to show a couple lines of JS-code, can I do that here, or will clojurebot destroy me? ;-)
18:07melladricjustin_smith: [[:a :b [:c :d]]] represents?
18:07justin_smithpapphammar: for multiple lines use a paste site
18:07justin_smithmelladric: it's a tree built up by the individual modifications each specified as a chain of coordinates followed by a value
18:08justin_smithwell a kind of a tree at least
18:09papphammarI'm trying to translate the JS-code to CLJS, but I'm stuck...
18:09papphammarhere are the code: fmAixmtTv6Buv3ftjwzVPu
18:09papphammaroops
18:09papphammarpaste.ofcode.org/fmAixmtTv6Buv3ftjwzVPu
18:09melladricOk, I'll try without using zippers after all, actually I'll compare both ways and see the better one (using my worst case input). Thank you agian for the guidance.
18:10justin_smithpapphammar: that can't be a proper tail recursive function since it branches out to the children
18:12papphammarI have tried loop/recur and... seq
18:12justin_smithpapphammar: but it could be something like (fn measure [item, size] (if-let [s (:size item)] (apply + s (map measure (:children item))) size))
18:13justin_smithpretty straightforward translation I'd say
18:15justin_smith, ((fn measure [item, size] (if-let [s (:size item)] (apply + s (map #(measure % 0) (:children item))) size)) {:size 4 :children [{:size 2 :children [{:size 5}]}]} 0)
18:15clojurebot11
18:15justin_smithpapphammar: that's correct, no?
18:16papphammarI'm not that familiar I'm not that familiar with clj yet, but would that code example take into account multi levels of children?
18:16justin_smithpapphammar: I used your input
18:16justin_smith{:size 4 :children [{:size 2 :children [{:size 5}]}]} is the clojure version of {size:4, children: [{size: 2, children:[{size: 5}]}]}
18:17papphammarthe items in ":children" vectors can also have children... and so on.
18:17justin_smithpapphammar: they do!
18:18justin_smithright there in the call I sent to clojurebot, I used your example input
18:19justin_smith{:size 4 :children [{:size 2 :children [{:size 5}]}]} is the clojure version of {size:4, children: [{size: 2, children:[{size: 5 :children [{:size 42} {:size 666}]}]}]} ; even more nesting
18:19justin_smitherrr
18:20justin_smith, ((fn measure [item, size] (if-let [s (:size item)] (apply + s (map #(measure % 0) (:children item))) size)) {:size 4 :children [{:size 2 :children [{:size 5 :children [{:size 42} {:size 666}]}]}]} 0) ; even more nesting, I mean
18:20clojurebot719
18:21papphammaroh wait... I think I forgot somehting in the code...
18:22justin_smithoh?
18:26justin_smithpapphammar: simplified it
18:26justin_smith,(defn measure [item] (apply + (:size item) (map measure (:children item))))
18:27clojurebot#'sandbox/measure
18:27justin_smith,(measure {:size 4 :children [{:size 2 :children [{:size 5 :children [{:size 42} {:size 666}]}]}]})
18:27clojurebot719
18:27justin_smiththe size arg is never actually needed
18:29papphammarwow, that was a beautiful line of code. And it seems to work just my js-example.
18:29justin_smithit's pretty close!
18:29justin_smithclojure can be elegant
18:29papphammarI like clj/lisp more and more...
18:49papphammarjustin_smith: Got time for one more small question? I'm playing around with your code and trying to print the size (incl. descendants) for each item...
18:56justin_smithpapphammar: you could either use let bindings or use doto
18:58papphammarI'll try that... thanks!
19:01justin_smith,(inc (doto 2 println))
19:01clojurebot2\n3
19:07gojiberryHow can I transform a seq of strings (e.g. ["a" "b"]) into an InputStream?
19:08justin_smithgojiberry: would reading that InputStream get you "ab" ?
19:08gojiberryjustin_smith: yup!
19:09justin_smith,(slurp (java.io.ByteArrayInputStream. (.getBytes (apply str ["a" "b" "foo"]))))
19:09clojurebot"abfoo"
19:09justin_smithso yeah, ByteArrayInputStream / getBytes
19:09gojiberryjustin_smith: but what if (apply str ...) won't fit in memory?
19:09justin_smithhmm...
19:10justin_smithyou could do something with a loop and reify I guess...
19:10justin_smithmuch trickier, unless there's a trick I don't know here
19:15amalloyinto a stream? not a reader?
19:16amalloyanyway https://github.com/ninjudd/io/blob/develop/src/flatland/io/core.clj#L30 concats streams
19:17amalloyso just turn each string into a stream,and then construct the concatenation of those strings
19:17amalloystreams
19:17justin_smithamalloy: woah, one step ahead of me, I was just playing with SequenceInputStream and was about to ask if anyone knew how to make an Enumeration out of a lazy-seq
19:18justin_smithwhich is exactly what that code does, of course
19:18amalloyyeah
19:18amalloyturns out it's not hard
19:19justin_smithI'm gonna have to remember clojure.lang.SeqEnumeration
19:19amalloyflatland.io also has the rather nice, imo, flatland.io.core.InputStream, an implementation of java.io.InputStream that you can reify instead of proxy
19:20justin_smith,(slurp (java.io.SequenceInputStream. (clojure.lang.SeqEnumeration. (map #(java.io.ByteArrayInputStream. (.getBytes %)) ["a" "b" "c" "foo"]))))
19:20clojurebot"abcfoo"
19:24SomelauwI don't think there is a debian version of leiningen as they say here https://github.com/technomancy/leiningen/wiki/Packaging
19:25justin_smithSomelauw: even if there is on, don't use it
19:26justin_smithSomelauw: the only global install leiningen needs is the jvm, and it works out better for lein to be a per-user install not system wide, in ~/bin/
19:26Somelauwokay, then how do I keep the leiningen script up to date?
19:27justin_smith"lein update"
19:27justin_smithit's a dependency managing tool, it's good at updating its own version
19:27noncom|2pomegranate?
19:28Somelauwnice
19:29noncom|2is there a core function to get into an ns *only* if the ns exists?
19:30justin_smith#(when (find-ns %) (in-ns %))
19:31justin_smith,(clojure.repl/apropos #"ns$")
19:31clojurebot(clojure.core/all-ns clojure.core/booleans clojure.core/chunk-cons clojure.core/cons clojure.core/create-ns ...)
19:33justin_smithnoncom|2: it might be handy to do (fn [n] (require 'n) (when (find-ns n) (in-ns n))) - I'd assume you would always want to load it if possible
19:33justin_smithoops, extranious ' in there, of course
19:33noncom|2ah, i see
19:33noncom|2were you talking about pomegranate that it can update itself?
19:33noncom|2just interesting
19:34justin_smithnoncom|2: well, leiningen does use pomegranate for deps and such
19:34justin_smithand yeah, I think it uses pomegranate to update itself
19:34noncom|2yeah, i know but just interesting if i ever use this functionality (and i might) - that'd be good to know
19:35justin_smithpallet/alembic is a handy way to use pomegranate - let's you use a syntax like lein
19:35noncom|2wow
19:36justin_smithalso it lets you load a dep (and all that deps deps) into a repl for experimentation
19:43gojiberryjustin_smith amalloy thanks a lot, guys! That one was tricky
20:15Somelauwdoes emacs cider mode have an alternative for m-tab, because this maps to alt+tab for me?
20:16justin_smithSomelauw: sure, if nothing else you can use Escape, tab
20:16SomelauwI use a plugin that captures escape :-(
20:16justin_smithWindows+tab or command+tab can be made to work too
20:17SomelauwI have control + tab would be okay.
20:59neoncontrailsI keep hitting a wall while trying to debug my Postgresql app. I know that I need to somehow wrap the queries in a (.try (sql/insert! <myquery>) (.catch e)) block format
20:59neoncontrailsotherwise there is no error message, only "BatchUpdateException Batch entry 0 CREATE TABLE testing (data text) was aborted. Call getNextException to see the cause. org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError (AbstractJdbc2Statement.java:2762)"
21:00neoncontrailsI'm not sure how to pass those methods to Java, though. In what format does it expect them?
21:14noncom|2neoncontrails: (try ... (catch Exception e ...)) ?
21:15noncom|2can someone remind me, how do i tunnel nrepl through ssh ?
21:15neoncontrailsnoncom|2: do the args not have to be prepended with a dot?
21:16neoncontrails*prefixed oh god I've started making up words
21:16noncom|2neoncontrails: no, like (try (println "i may throw up!") (println "meee toooo") (catch Exception e (println "someone threw it up! " (.getMessage e)))))
21:23neoncontrailsnoncom|2: thank you thank you it never occurred to me the dot in (.getNextException e) was passing the method to the *exception* object
21:24noncom|2neoncontrails: yah, don't forget that in all oop languages, like java, every non-static method implicitly takes "this" as its [first] argument
21:24noncom|2here we see this.
21:53justin_smithnoncom|2: tell nrepl to use a specific port, and then use the -R argument to ssh to map that port from the remote host to your own machine
21:54justin_smithnoncom|2: simplest version is -R 4444:127.0.0.1:4444 but you can change the port it maps to on your own side (the righthand 4444)
21:54noncom|2cool! thanks!
21:55justin_smithnoncom|2: if you don't tell nrepl to start on a specific port, then you have to start a connection after the nrepl process starts, and make sure you map the port it used
21:55noncom|2yeah right
21:59noncom|2gonna save this instruction somewhere this time
22:00justin_smithnoncom|2: ssh with -R can also be used to access a db that is only accessible from another host (even if it's not running on that host) by changing the 127.0.0.1 arg to the host you want to hop to
22:02noncom|2heh, useful things :) leaning over time..
23:07amalloyjustin_smith: -R seems like the much harder way to do that than -L
23:08justin_smithoh did I flip those again
23:08justin_smithmy bad
23:09justin_smithamalloy: -L [bind_address:]port:host:hostport Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
23:10justin_smith -R [bind_address:]port:host:hostport Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
23:10justin_smithwhen I look at those two, -R sounds like the right one
23:21justin_smithI'm probably reading "forwarded to" backward
23:25justin_smithI know this isn't a politics channel, but someone made a topical joke mentioning clojure about the debate tonight https://twitter.com/ra/status/688932984888659969
23:50rhg135yeah, -R would be for a server that's running on the box with the client