#clojure logs

2015-12-14

00:04tolstoylein generates a test directory even though I've deleted it.
00:07hiredmanthat is an interesting hypothesis, what evidence do you have to support it?
00:09jvavaclojurebot, ,(+ 1 2)
00:09clojurebotexcusez-moi
00:09jvavaclojurebot help
00:09tolstoyrm -rf test
00:10tolstoylein uberjar
00:10jvavaclojurebot (* 20 442)
00:10tolstoyls -l
00:10jvavawho say clojurebot can repl what i typed
00:10jvavaclojurebot lein
00:11jvava&(+ 1 1)
00:11hiredmantolstoy: what version of lein?
00:11tolstoyhiredman: 2.5.3
00:11hiredmanwhat plugins?
00:12tolstoylein-ancient
00:14hiredmanah interesting, so lein 2.5.3 is doing that here two without any plugins, I would file a bug, it seems like a regression since 2.5.0
00:14tolstoyhiredman: Seems like it was auto-creating "dev-resources" a few times, too.
00:20hiredmanhttps://github.com/technomancy/leiningen/commit/e9d6d7885777537fe3b50f3308b8fec44a65c391
00:21tolstoyInteresting. Is that a bug, or just a design decision?
00:21hiredmanhard to say, seems wrong, things run just fine without a test directory
00:27kenrestivohow can i test if a core.async channel is open or closed?
00:27kenrestivoother than blocking a read waiting for nil?
00:29amalloykenrestivo: as long as you don't mind that the information could be out of date (ie, the channel closes right after telling you it's open), you can just alts between that channel and a short-lived timeout channel
00:41kenrestivocool, thanks
00:56tolstoyHm. Bundling fs pomegrante http-kit tools.cli data.json pandect, etc, etc, into a massive jar makes shell scripting with Clojure a lot of fun.
01:18tolstoyhiredman: Ah, thanks for reporting that bug.
02:31PupenoI’m working on a library and I need to test it on Heroku. Is there a way to do it without releasing an unfinished version to clojars?
03:57irctchello
03:57irctcanyone up?
03:57irctcstuck on this clojure project
03:57irctcits due in 5hours
03:58PupenoSome people are up, not many. I suggest you just ask your question.
03:58irctc pastebin.com/H4ts9QZ9 java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
03:58irctc(with-open [r (reader "input.txt")]
03:59irctcpastebin has source
03:59irctcMy first project with a functional langauge
04:00irctc (spit "results.txt" (grammarCHECK line)) is causing problems
04:04TEttingerirctc: that error is almost always caused by having a number as the first item in a parenthsized list, where a fn is expected
04:04TEttinger,(+ 1 2) ; doesn't error
04:04clojurebot3
04:04TEttinger,(1 2) ; does error
04:04clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6943]...
04:06TEttingeroddly enough, irctc, the issue is in what that calls, not on that actual line
04:06TEttinger (nth (split aline #"\s+") (thecount) "nothing found")
04:07TEttingerthere, thecount is a number but you're trying to call it like a fn
04:07TEttingertake off the parens around thecount and it may improve
04:07TEttinger(or throw an error at another point)
04:08TEttinger,(nth (split "hey everybody, how's it going?") 2 "nothing found")
04:08clojurebot#error {\n :cause "Unable to resolve symbol: split in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: split 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: split in this...
04:08TEttinger,(nth (clojure.string/split "hey everybody, how's it going?") 2 "nothing found")
04:08clojurebot#error {\n :cause "Wrong number of args (1) passed to: string/split"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: string/split"\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" 32]\n [sandbox$eval96 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eva...
04:08TEttingerman I'm off my game today
04:08TEttinger,(nth (clojure.string/split "hey everybody, how's it going?" 2 "nothing found"))
04:08clojurebot#error {\n :cause "java.lang.Long cannot be cast to java.util.regex.Pattern"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to java.util.regex.Pattern"\n :at [clojure.string$split invokeStatic "string.clj" 217]}]\n :trace\n [[clojure.string$split invokeStatic "string.clj" 217]\n [clojure.string$split invoke "string.clj" -1]\n [sandbox$eval120 invokeSt...
04:08TEttingera ha, I screwed up!
04:08MJB47split "," "string"
04:09TEttinger,(nth (clojure.string/split "hey everybody, how's it going?" #"\s+") 2 "nothing found"))
04:09clojurebot"how's"
04:09MJB47or im wrong
04:09TEttingerMJB47, yeah you should be right, since that's the order join takes them in
04:09TEttingerbut it's weird like that...
04:10MJB47consistency is for the weak anyway :P
04:23irctcThanks TEttinger
04:23TEttingerno prob, it's a really easy mistake to make :)
04:40Oogh8osoHi. I'm making my way through the Om next tutorial and have noticed that methods declared inside defui are not indented properly, i.e. like defrecord\deftype ones. How can I fix it?
04:41ridcully_Oogh8oso: there is also #clojurescript
04:42jonathanjOogh8oso: what editor are you using?
04:43Oogh8osoridcully_: I guess all folks from there are here too... or is it unappropriate to ask cljs-specific questions here?
04:43Oogh8osojonathanj: um, sorry. It's emacs with cider.
04:44jonathanjOogh8oso: the `clojure-mode` thing has a facility for controlling this, clojure-backtracking-indent
04:45ridcully_Oogh8oso: i just mentioned it. often the folks asking here are not aware
04:46jonathanjOogh8oso: since the documentation around this is kind of horrible, you can make `(defui)` be indented like `(defrecord)` by putting this somewhere in your emacs config: (put 'defui 'clojure-backtracking-indent '(1 1))
04:46Oogh8osoridcully_: oh, I see.
04:46Oogh8osojonathanj: yep, just figured it out. Thanks anyway.
04:46jonathanjprobably #clojure-emacs is the correct place for the question
04:48Oogh8osoAlso, I've heard they've added some metadata-controlled indentation in cider... I guess it's just not widely used yet.
04:48Oogh8osoUm, or is it possible at all to attach metadata to vars in cljs?
06:55PupenoHow do I generate the pom and other files for release with lein?
06:56hyPiRionlein uberjar, lein pom
06:56hyPiRionlein jar if you make a lib only
07:34PupenohyPiRion: I was hopping for something that would generate the pom with the correct name and the sha1, the same way lein release does, but without pushing to Clojars.
07:34Pupenoor touching my repo.
07:34hyPiRionPupeno: if you need to generate the pom, you can just use lein pom
07:35PupenohyPiRion: yes, I know about lein pom.
07:35Pupenobut I still have to rename it and generate the sha1s.
07:35hyPiRionoh
08:41oracle`how to get a subvector for a vector by index?
08:41hyPiRion(doc subvec)
08:41oracle`such as [11 22 33 44], get [1 3] out of it, we should get [11,33] back.
08:42clojurebot"([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."
08:42hyPiRionoracle`: oh
08:43hyPiRion,(let [v [11 22 33 44] indices [1, 3]] (mapv v indices))
08:43clojurebot[22 44]
08:43hyPiRion,(let [v [11 22 33 44] indices [1, 3]] (mapv #(get v (dec %)) indices)) ;; I guess then
08:43clojurebot[11 33]
09:33iwohey, does anyone know how I can apply a timeout to a blocking put in core.async?
09:34iwoI want >!! with timeout
09:37iwoI could do this with a future of course, but it feels a bit untidy - does core.async offer any way to do this?
10:28zerokarmaleftiwo: use alt!!
10:30zerokarmaleftone channel op in the body of alt!! takes from a timeout channel, and the other would be the >!!
10:40iwozerokarmaleft: ah, that makes sense! I thought alt!! was only for take (not put)
10:40iwothanks
11:21alive876_hi, newbie here, i am running through the clojure demo on heroku at the moment (from cloud9), which is all running nicely except in something called a dyno, a kind of virtual environment , im running a repl and and when i do this in the demo (require '[camel-snake-kebab.core :as kebab]), i get this which i assume is a classpath error (?): Could not locate camel_snake_kebab/core__init.class, any help greatly appreciated!
11:23alive876_also does anyone know why i cant run a repl on cloud9
11:25alive876_oh disregard above, its my mistake
11:26alive876_sorry1
12:11domgetterIs there a way to tell clojure to inline functions?
12:12MJB47the JVM will do it by itself
12:12domgetterWhat I mean is something like this: https://gist.github.com/domgetter/5118978273fc61cceb69
12:12MJB47i dont know if there is anyway to force it
12:13domgetterThe call to asdf is still slower than if I'd put the + there in the first place
12:13MJB47that is interesting
12:14domgetterI mean, it does a pretty damn good job after I type hint, but I didn't know if I could do better
12:14MJB47have you tried using AOT?
12:15domgetterThat's after I told lein to make a jar file
12:15domgetterDoes that aot it?
12:15MJB47ah
12:16domgetterI have :profiles {:uberjar {:aot :all}} set in my project.clj
12:16MJB47should do
12:21justin_smithaot can improve startup, but not runtime performance
12:22domgetterSo it would be just the same if I'd run it in the repl?
12:25justin_smithyeah, aot is just the same compilation that happens when you load the code at runtime, it's just the "optimization" of storing that byte code and loading it later, rather than compiling the code
12:27domgetterAnd you have to do aot if you want to call clojure code from java, correct?
12:28justin_smithdomgetter: depends - you can always load clj files via clojure.lang.RT (load up require or load file, then use one of those, etc.)
12:28domgetterah ok
12:28clojurebotPardon?
12:28justin_smithdomgetter: for example in my current production app, we don't aot compile our app, we just aot compile a small namespace that dynamically finds loads and launches the primary ns of the app at runtime
12:29justin_smithnot using aot simplifies some stuff
12:49sdegutisIs there an excellent library for colorizing Clojure code?
12:49domgettersdegutis: In what text editor/ide?
12:49sdegutisHTML.
12:51sdegutisHmm. I'll look into a JS syntax highlighter.
12:54domgettersdegutis: You could try highlight.js
12:54sdegutisAhh good idea.
12:54domgetterhttps://highlightjs.org/static/demo/
12:55domgettersdegutis: If you click Lisp under language categories on the left, it will just down to clojure
12:55sdegutisNice!
13:03TimMc,(java.net.InetAddress/getByName "1.512")
13:03clojurebot#object[java.net.Inet4Address 0x46b6c876 "/1.0.2.0"]
13:03TimMcTIL
13:04ghost_Hey! How to get rid of "cannot be casted to clojure.lang.Associative" error? I want to cast assoc on a map and recur with a new map, but it gives me this
13:05justin_smithghost_: there are no explicit casts in clojure, and the most common cause of that error is you are not actually passing in a map
13:06ghost_justin_smith: emacs actually did some magic to my code as I wrote this, I'll check, a minute
13:07justin_smithghost_: try, right before the point where you call assoc (println "type of x:" (type x)) - you might be surprised
13:07justin_smithalso, "cannot be casted to clojure.lang.Associative" is preceded by a type, it's telling you what type it got instead already
13:08justin_smith,(assoc "not a map" :a 0)
13:08clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.Associative"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.Associative"\n :at [clojure.lang.RT assoc "RT.java" 785]}]\n :trace\n [[clojure.lang.RT assoc "RT.java" 785]\n [clojure.core$assoc__4130 invokeStatic "core.clj" 191]\n [clojure.core$assoc__4130 invoke "core.c...
13:08justin_smithso there it tells you it got a string, for example
13:08ghost_justin_smith: what does "^@" do? my editor inserted it before val's name
13:08justin_smithghost_: that's a null byte in most editors
13:09justin_smithit's not clojure syntax
13:09ghost_oh, thanks
13:09justin_smithwell... it could be derefing something to attach it to something else as metadata - but you wouldn't see that often...
13:10ghost_damn, how do I create a map without creating a new type for that map?
13:10justin_smith?
13:10justin_smith,(type {})
13:10clojurebotclojure.lang.PersistentArrayMap
13:11justin_smith,(type (hash-map :a 0))
13:11clojurebotclojure.lang.PersistentHashMap
13:11justin_smithI might be misunderstanding your question, because it sounds kind of weird...
13:11ghost_wha-at is going on
13:11ghost_I've named my map new-board
13:12ghost_and it has a type of "new-board"
13:12justin_smithso you made a defrecord?
13:12ghost_darn, I'm stupid
13:12ghost_sorry for taking away your time
13:13ghost_I've screwed up with namind
13:13ghost_naming*
13:51PupenoWhat's the easies way to listen for keyboard events?
13:51justin_smithPupeno: in what UI?
13:51Pupenojustin_smith: console.
13:52justin_smithPupeno: probably jcurses
13:52justin_smithor maybe lanterna
13:53justin_smithit's not really simple, because the standard tty interface used by the repl doesn't have key events - it's line oriented
13:53justin_smith(except for interrupts like C-c of course)
13:54justin_smithin fact, spawning a swing window and grabbing key events there is probably more straightforward than getting key events in the terminal (especially if you want the repl to remain usable)
13:56rhg135Lanterna will spawn a tty in a swing window for dev purposes
13:57justin_smithoh, cool
14:04sjlis there a workaround for http://dev.clojure.org/jira/browse/CLJ-700
14:04sjlI don't care if it's ugly
14:06TimMcsjl: You could use the ternary form of get
14:06justin_smithsjl: don't use contains? on transients
14:06sjlyeah I can probably live with that
14:06TimMc,(get (transient {:x 5}) :y :no)
14:06sjl(using get with a sentinal)
14:06clojurebot:no
14:07justin_smithsjl: well technically that's following my suggestion too, though I admit mine was much less helpful :)
14:10TimMcI've added that workaround as a comment. (Sorry Stu.)
14:13TimMcArgh, my code is doing impossible things. :-(
14:14slesterwith great power comes great responsibility. or something.
14:14justin_smithTimMc: that's your spidey sense telling you you are about to have a learning opportunity, of course
14:14slesterlots of spiderman!
14:14justin_smithwait why are we talking about spiderman again?
14:14justin_smithhaha
14:15slesterbecause: spiderman.
14:16slesterI learned the hard way that using recur on a string that gets huge is not the best tactic. (Advent of Code problem)
14:16TimMcslester: Not really cool impossible things.
14:16slesterTimMc: but they COULD be cool!
14:16justin_smithslester: oh, so switching the self-call to recur didn't help?
14:17TimMcBasically I've got (reset! some-atom (compute-value)) and midje is telling me both that this expression is throwing an exception *and* that the atom is getting updated.
14:17slesterjustin_smith: newp
14:17TimMcI guess that's cool in a way.
14:17slesterit was still making new strings every time
14:17justin_smithslester: right, strings are not mutable
14:17slesterand the string length got obscene so it was making new huge strings every iteration
14:17justin_smithslester: maybe you want a StringBuilder
14:17slesterand passing it back in
14:18justin_smithis it concatenation only? if so StringBuilder should be just the trick
14:18slesterno, not necessarily
14:18slesterI'll show you what I did instead if you want? But the issue was, you take the string and redo the same function on the new string
14:18justin_smithoh, well there still might be a way to use StringBuilder constructively, but it might not be as simple
14:19slesterjustin_smith: http://hastebin.com/ojiyudegor.lisp (spoilers for day 10 of advent of code for those who care)
14:19justin_smithslester: "application error"
14:19slesteroh my
14:19MJB47who broke hastebin
14:19slesterI took down hastebin.
14:19TimMcIt doesn't like spoilers. ;-)
14:20slesterbut I warned about spoilers!
14:20slesterlet's try refheap: https://www.refheap.com/112689
14:21rhg135Whoa! It did break
14:23justin_smithslester: str uses a StringBuilder internally - but of course in a usage like yours where you can use the clojure wrapped version without needing the mutable version underneath that's always more pleasant
14:25slesterjustin_smith: right, I was looking into that stuff
14:26TimMcI'm going to chalk this up to midje fuckery.
14:26TimMcEven my print statements aren't behaving right.
14:27justin_smith~midje
14:27clojurebotmidje is :(
14:27justin_smithTimMc: ^
14:28ystaelTimMc: Is the standard shit show of "your state mutation is happening outside the dynamic extent of the magic midje behavior rebinding" ?
14:28ystaeli.e. the thing that used to force us from (provided) over to (with-redefs) all the time
14:29TimMcFFS
14:29TimMcLaziness.
14:29justin_smith(dec laziness)
14:30TimMc(reset! my-atom (seq-producer)), and the second element of the seq threw an exception
14:30ystaeljustin_smith: => #object[clojure.lang.Delay 0x371812ef {:status :pending, :val nil}]
14:30justin_smithTimMc: and reset doesn't force it?
14:30justin_smithystael: lol
14:31justin_smithTimMc: reset! should be forcing the lazy
14:31justin_smith,(def a (atom nil))
14:31clojurebot#'sandbox/a
14:31TimMcShould it?
14:31ystaelTimMc: but chunked-seqs?
14:31ystael(force 1 = force 32?)
14:31TimMc3-ele,ent seq
14:31TimMcs/,/m/
14:32justin_smith,(do (reset! a (lazy-seq (cons (/ 1 0) nil))) nil)
14:32TimMcAssuming this is laziness, I can take another shot at a repro.
14:32clojurebotnil
14:32justin_smithhmm
14:32justin_smith,a
14:32clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
14:32justin_smithoh, TIL
14:32TimMcreset! just grabs that lazy seq and shoves it in the atom
14:32ystaelso it throws when midje tries to print your test results?
14:33justin_smithright, right - for some reason I assumed reset! would eagerly consume an input, but on secodn thought, why would it?
14:33TimMcBut what I'm *seeing* is that the fn that does the reset! throws (according to midje) but the seq that is produced is the empty seq.
14:33justin_smithystael: or as soon as it derefs the atom for any reason, yeah
14:33TimMcwhich is deeply unsettling
14:33TimMcbecause there *shouldn't be a seq*
14:33justin_smithwait, empty seq, as in nil?
14:33TimMcjustin_smith: deref the atom and start to walk the seq, actually
14:33TimMc()
14:34justin_smith,(seq ())
14:34clojurebotnil
14:34justin_smiththat's what I meant
14:34TimMcempty list
14:37ghost_How to make a vector from map's values?
14:37MJB47_(vec ...)
14:37MJB47_or use (mapv ...)
14:37justin_smith,(vals {:a 0 :b 1 :c 2})
14:37clojurebot(0 1 2)
14:38justin_smith,(vec (vals {:a 0 :b 1 :c 2}))
14:38clojurebot[0 1 2]
14:38MJB47_oh you mean that kind of map
14:38justin_smithwell, we each read it differently...
14:38justin_smithheh
14:38ghost_I've used vector and wondered why it didn't work :D thanks!
14:40ghost_,(vector (vals {:a 0 :b 1 :c 2}))
14:40clojurebot[(0 1 2)]
14:40justin_smithyeah, vec vs. vector can be tricky
14:49TimMcOK, I have a test case I can start reducing. Source: https://github.com/timmc/sscce-midje-lazy-throw/blob/master/src/sscce_midje_lazy_throw/core.clj Test: https://github.com/timmc/sscce-midje-lazy-throw/blob/master/test/sscce_midje_lazy_throw/t_core.clj
14:51alive876 hi, newbie here. i use cloud9 as my ide, and heroku for my dev server. the problem is i can't run a repl in cloud9, but i can in a heroku dyno. (although dyno isn't persistant) is that the right way to do it, anybody know? thanks
14:52justin_smithalive876: are you using apt-get to install lein?
14:52justin_smithif so, you probably are not getting a new enough lein version
14:53codefingerheroku will have 2.5.3
14:53alive876no, i used the script
14:53alive876or a script
14:53justin_smithalive876: the script?
14:53alive876let me take a look
14:53justin_smithso you are directly installing lein on cloud9 ?
14:53alive876yes
14:54justin_smithwhat kind of failure do you get when it fails?
14:54alive876just a sec
14:57alive876hi
14:58alive876the error i get when i run lein repl in cloud9 is /home/ubuntu/bin/lein: line 391: 3489 Killed
14:59alive876lein 2.5.3
15:00justin_smithyeah, that's the version I have, line 391 is the last line of code
15:00justin_smithalive876: could it be running into memory usage limits?
15:01KevinCorcoranAny reason to avoid clojure 1.7 when using core.async? core.async's README suggests 1.6 but I'm guessing that is just out-of-date - https://github.com/clojure/core.async#releases-and-dependency-information
15:01alive876that i don't know
15:01alive876how much memory does it need?
15:01justin_smithKevinCorcoran: I've used core.async with 1.7 extensively, and wouldn't see any reason not to move to 1.8
15:02KevinCorcoranThanks, justin_smith!
15:02justin_smithalive876: mine easily exceed a gig, but my app is pretty big
15:03alive876ok, yes, the "killed" would lean me in that direction
15:04justin_smithyeah, it's the most likely reason I'd expect "killed" on a clojure process
15:04alive876hmm, yea, thatnks
15:04justin_smithalive876: see if you can run 'java -cp clojure.jar'
15:05justin_smiththat gives a bare bones repl - clojure.jar will be in ~/.m2/ (or at least that's where lein puts it)
15:05justin_smithwait, make that 'java -jar clojure.jar"
15:06alive876yes that runs
15:06justin_smithso at least you can get a usable repl to test your code fragments
15:06ystael... trying to remember the name of a core function I think I remember, not finding it in grimoire
15:06justin_smiththat will be lighter weight than what lein starts
15:06ystael(0 1 2 3 4) |-> (() (0) (0 1) (0 1 2) (0 1 2 3) (0 1 2 3 4))
15:06ystaeli could implement it easily enough but i'm blocking on the name
15:07alive876i see, ok thanks
15:07justin_smith,(reductions conj [] (range 5))
15:07clojurebot([] [0] [0 1] [0 1 2] [0 1 2 3] ...)
15:07ystaeloh, reductions, that's what i wasn't finding
15:07ystaelthank you!
15:07Seylerius(inc justin_smith)
15:07Seyleriusystael: ^
15:07justin_smithbut with () the order would be opposite
15:07justin_smithheh
15:07SeyleriusIs lazybot down again?
15:08justin_smithSeylerius: lazybot isn't around any more, but I appreciate the thought
15:08justin_smithalive876: another options to try "lein run -m clojure.main"
15:08Seyleriusjustin_smith: Where'd it go?
15:09justin_smithSeylerius: to the big farm where buggy programs can run and play and be happy forever
15:09alive876is there anything wrong with developing in the dyno?
15:09ystaeljustin_smith: that's so sad *sniff*
15:09justin_smithalive876: eventually cost maybe?
15:09Seyleriusjustin_smith: Heh. No one had time to save it?
15:09ystaeljustin_smith: not looking forward to explaining death to my 3 year old
15:10justin_smithSeylerius: we put some work into it, but the main issue (random undetected disconnects) never really got solved
15:11rhg135I have time
15:11gfredericksseems like there are good hacky solutions to that
15:11Seyleriusjustin_smith: Share the source?
15:11TimMcystael: Bonus points if you work in the existentialist analogy of the time before birth as an equivalent sort of nonexistence.
15:11rhg135Maybe I'll finally gut it
15:12TimMcgfredericks: Loops. :-)
15:12rhg135Go pircbot and build a façade
15:13justin_smithgfredericks: yes, there are hacks, and maybe one of us will find free time to make one work
15:13alive876 <justin_smith> that last one did open a repl, strangely
15:13Seyleriusjustin_smith: Does the source live somewhere easily accessible?
15:13justin_smithalive876: not strange at all - when you tell it to run clojure.main it gives you the same classpath, but doesn't pre-load any of the namespaces, and does not start nrepl
15:14justin_smithalive876: so the resource usage should still be fairly low - until you try to load up the full app
15:14justin_smithSeylerius: yes, I believe it is still raynes/lazybot on github
15:14alive876oh, ok, so i think we can say its a memory issue
15:15justin_smithalive876: that's my assumption until you find conflicting evidence, yeah
15:15ridcully_alive876: don't you have any logs there? it should state oom etc
15:15ridcully_alive876: otherwise any "resource limitation" sould be a candidate
15:16justin_smithridcully_: sure, but realistically, mem is the resource clojure uses up first, all else being equal
15:16alive876<ridcully_> good point, i never looked before, but thanks, that valuable
15:17ystaelTimMc: I don't think it will help. When I figured out that I would eventually die I was inconsolable for a week.
15:17ystaelJust trying to put that off for a few more years for her.
15:18amalloySeylerius, justin_smith: not monetary cost. the server lazybot is on still runs, and if anybody wants to be in charge of restarting him whenever he dies we can talk about giving you an account with the necessary permissions
15:18amalloybtu Raynes hasn't been around for a long time, and i got tired of starting lazybot up all the time myself
15:19rhg135Shell scripting to the rescue
15:19amalloysure. that's what we do for 4clojure
15:20amalloythe problem is that lazybot's deaths were not easy to detect
15:20rhg135It would still require human interference, but we can make it easy
15:21gfrederickswhat about rebootin' every 10 minutes?
15:21Seyleriusamalloy: I'd be interested.
15:21gfredericks(is what I meant by "hacky")
15:21amalloyjust an unconditional restart every X amount of time? i guess i could do that. it feels so bad but it's better than not working at all
15:21TimMc*nod*
15:22Seyleriusamalloy: Do we have any kind of lib that can do something heartbeat-flavored?
15:22amalloyi'll make it an hour, put together a cron job for Raynes account
15:22gfredericksanother way to detect it would be to ping lazybot over irc maybe, but that's more work than the blind reboot
15:23ridcully_so the process does not die? it just loses the connection. netstat | grep && restart then?
15:24Seyleriusamalloy: How much control do we have over that server?
15:25Seyleriusamalloy: IE, can we run something that listens for a regularly-scheduled action from lazybot, defibrillates it when it misses a scheduled heartbeat?
15:26rhg135You could set up an irc client on that server to ping it and restart it if no response
15:26Seyleriusrhg135: IRC bots to manage IRC bots?
15:26TimMcystael, justin_smith: OK, best I can figure: 1) Midje is inspecting the contents of the atom returned from update-atom and poking its nose into the seq inside it, triggering the exception latent in the seq. 2) When subsequently printing the seq, it is <mumbles> so that it only shows up as ().
15:26rhg135Yeah
15:27rhg135Complexity ahoy!
15:28rhg135Netcat and a bit of shell
15:29rhg135Actually, bash can do sockets itself
15:29TimMcystael, justin_smith: My takeaway is that I should have had doall in there anyhow since I *want* any exceptions to come up right away, not later. So... thanks, midje! I guess.
15:30amalloySeylerius: i have unlimited control but limited motivation
15:31Seyleriusamalloy: I have no control and less-limited motivation. Perhaps we can work something out?
15:32gfredericks~amalloy is the god from deism
15:32clojurebotYou don't have to tell me twice.
15:32Seyleriusgfredericks: Hah
15:34rhg135I'll try my hand at writing an irc defibrillator, like Seylerius suggested
15:35rhg135Yay!
15:35Seyleriusrhg135: I'd actually recommend using an existing heartbeat package that watches for some known kind of action.
15:36SeyleriusRather than another irc bot.
15:36SeyleriusAlthough that would be lulz.
15:36rhg135I don't think one exists for irc
15:36rhg135I don't think you can tell otherwise
15:36SeyleriusIsn't there one that just makes a simple REST-ish API endpoint?
15:36amalloyso i gave Raynes a crontab that will restart lazybot every hour on the hour. someone remember to check in 25 minutes and see if it worked
15:37SeyleriusAnd couldn't Lazybot just GET the API endpoint?
15:37SeyleriusDoes Lazybot already have any capabilities that require grabbing a URL?
15:37amalloylazybot's webserver still works fine. it's just the irc stuff that gets disconnected
15:37rhg135Yeah...
15:37amalloyso any heartbeat that doesn't go over irc is pointless
15:37Seyleriusamalloy: Ah. So the whole bot doesn't die, only the IRC connection?
15:38SeyleriusOkay, then yes, we need an IRC heartbeat detector.
15:38rhg135Indeed
15:38amalloywell, "need" is a strong word
15:38Seyleriusrhg135: Github it, I'll want to pitch in once I get caught up (likely Wednesday or Thursday).
15:38rhg135When you're bored, "need" means "why not"
15:39ziltiI just ran into a Cider "bug" I remember from about two years ago, but can't find the solution anymore. I get that FileNotFoundException because it tries to load the Emacs backup files
15:39rhg135Sure, Seylerius
15:41ziltianyone remembers how to get around that?
15:41ridcully_as in "i need a beer"
15:50justin_smithSeylerius: this could consist of using an irc command to ask some authoritative service if it can hear us
15:51justin_smithSeylerius: eg. irc /ping - just a question of having a reliable nick to ping where unavailability can mean always reboot I guess?
15:55amalloyjustin_smith: ChanServ
15:55TimMcAsking for the nick list would be a pretty good test.
15:55amalloyalthough i guess netsplits could make ChanServ unavailable
15:57justin_smithamalloy: yeah, I was hoping there was a way to ping the server itself but maybe that is a completely different thing
15:58ridcully_is the connection to freenode gone (e.g. netstat) on that box?
15:59ridcully_or are there other connections/clients that would make that hard to detect?
15:59justin_smithamalloy: haha - this works! : /msg amalloy PING (substitute own nick here of course)
15:59justin_smithor maybe that still works even with no connection...
16:00meshyjustin_smith: sorry for jumping in on the tail-end of a conversation here, but you can ping the server you connected to
16:00meshyhttps://tools.ietf.org/html/rfc2812#section-3.7.2
16:00justin_smithmeshy: oh, that's probably the right way to do it :)
16:00meshyperhaps I've got the wrong end of the stick
16:00meshycool :)
16:06slesterDo people here use emacs more or vi? I'm a vi user but a ton of stuff is written for emacs (including repl integration)
16:07justin_smithslester: there's fireplace for using nrepl from vim
16:07justin_smithslester: I use evil (the vim emulator in emacs)
16:07slesterjustin_smith: yeah, I've tried using it and it's a bit cumbersome. It won't detect open REPLs etc.
16:08justin_smithslester: it should - when you start a repl server with lein repl it will store the port number in a dot file in the project dir
16:09slesterhmm, maybe that's the problem, I don't see a dotfile
16:10justin_smithslester: now I'm wondering - maybe that's a cider feature
16:10justin_smithI'm not the best one to address this since I don't actually use an in editor repl
16:11slesterno worries, I don't either but I was trying to up my game, so to speak
16:11justin_smithbut when I used cider that file would be generated, and would be used to pick a "default" port to try connecting to
16:11justin_smithslester: I find I can get a lot done with (require 'some.ns :reload) or (load-file "full/path/to/changed_file.clj")
16:12justin_smithalong with the occasional copy/paste from emacs into the repl or visa versa, of course
16:13slesteryeah
16:13slesterthe copypasta is what I've been doing
16:14justin_smithslester: one option to beat the copy/paste is write a "scratch.clj" from your editor, followed by (load-file "scratch.clj") in repl - easy enough to automate from both ends - but fireplace truly working is probably much better
16:15slesteryou were talking about an .nrepl-something file?
16:15slester.nrepl-port?
16:15slesterit was alluded to elsewhere but it isn't being created with `lein repl` for some reason
16:17justin_smithslester: right, I think it's something in the cider middleware that adds this - fireplace also uses cider iirc
16:18slesterI did add the cider middleware to my .lein/profiles.clj
16:18slesterhrmmm
16:18justin_smithslester: at this point someone else can probably help you more than I can, considering I don't even use this functionality any more
16:25d0kyhello sorry for a question not about clojure but java but here are experienced programmers ... i would to know if there is any not thread sefe operation or how to do a reading from system.in while in timer generate event for writing to system.in each 10 seconds, can find how to read input without enter to write log and then continue reading already typed input until is entered
16:27slesterjustin_smith: thanks anyway! I mean the first bullet point in http://neo.com/2014/02/25/getting-started-with-clojure-in-vim/ is ... "it will automatically detect"
17:00ridcully_slester: lein repl creates that dotfile. starting vim-fireplace in that dir then uses that automatically
17:00slesterridcully_: it's not actually making that file sadly
17:01ridcully_slester: if it really doesn't, there is in the beginning of the output some url (nrepl://localhost:666) - in vim do :Connect <pasteurl>
17:01slesterRight, but I want to avoid having to do that. (It does successfully connect if I do, though.)
17:02ridcully_if i do a lein new x; cd x; lein repl - the file is there
17:03ridcully_well you could also install vim-salve. then you can just start vim and run :Console, which will start the repl to use for you
17:42slesterridcully_: ahh, it's because I don't have a project.clj it seems. I was just using lein exec to run things
17:45ridcully_slester: in that case open dummy.clj and use :Connect
17:45slesterlein repl won't make the .nrepl-port file without a project.clj it seems
17:45ridcully_yes
17:49justin_smithlein really likes it when you use project files
17:49justin_smithwithout a project file, you might as well be using clojure.jar directly, really - except your favorite profile deps / plugins I guess
17:50ridcully_well there is lein try
17:50justin_smithtrue
17:55slesterjustin_smith: yeah, and when I'm doing stuff like advent of code, I don't want a huge file structure
17:55slesterI just want... a file that runs
17:56justin_smithyeah, that's where clojure.jar is awesome
17:56justin_smithit starts like 10 x faster than lein
17:56justin_smithmuch simpler
17:56justin_smithlein is when you have a project and automatic dep management and stuff
17:56justin_smithslester: java -jar clojure.jar
17:58slestererr
17:58slesterso if I have a .clj file, just java -jar clojure.jar file.clj
17:59slester?
17:59justin_smithyes
17:59justin_smiththat simple
17:59slesterfancy
17:59slesterI still need deps though :(
17:59slesterlike data.json
18:00justin_smithslester: java -cp clojure.jar:data.json.jar clojure.main file.clj
18:00slesterhaha
18:00justin_smithslester: as long as you know exactly which jars you need that is
18:01justin_smithseriously that works
18:01justin_smithand starts fast
18:01ridcully_slester: take a look into the try-plugin for leiningen
18:01justin_smithyes, there is that too :)
18:01ridcully_but tbh, the content of a line new so so shallow, i'd not even bother
18:01slesterthanks!
18:02slesteryeah, I just have daily challenges and don't want to go into the whole shebang
18:02ridcully_s/line/lein/
18:02ridcully_lein new challenge-one
18:03justin_smithI'd make one repo with all the challenges, and then do lein run -m foo.challenge1; lein run -m foo.challenge2; etc.
18:03ridcully_numbers in a ns are fine, i guess? aoc/day-01
18:04justin_smithsure
18:04ridcully_and then make your new year resolution to rm -rf aoc
18:05justin_smithridcully_: hell, just add it to crontab
18:06ridcully_at would be enough
18:06justin_smithdoes at work across reboots?
18:06ridcully_i have not used it in the last decade or so
18:06ridcully_i'd expect so
18:07justin_smithridcully_: so the only advantage of cron would be making sure it's ready if you try to do aoc again next year too
18:08ridcully_right
18:08slesterI didn't know about lein run -m :O
18:09justin_smithyup, having more than one main in one repo can be very handy
18:09ridcully_and you will be happy, if you start your Associace Office Colab project in 2016
18:09justin_smithand when running an uberjar, you can also tell clojure.main which namespace to execute with -m
18:10justin_smithjava -cp my-uber.jar clojure.main -m foo.ns1
19:48kenrestivowhat's the idiom for going through a sequence, and if some criteria is met, inserting another item in the sequece after the current one?
19:49kenrestivoand then continuing on. i'm guessing a reduce might work, but not sure if it'd be right
19:49justin_smithsomething like (mapcat (fn [e] (if (p? e) [e :magic] e)) coll)
19:50justin_smith,(mapcat (fn [e] (if (odd? e) [e :odd!] [e])) (range))
19:50clojurebot(0 1 :odd! 2 3 ...)
19:50justin_smithoh man that cut off way too soon
19:50justin_smithbut you probably get the idea
19:51justin_smith,(mapcat (fn [e] (if (even? e) [e :even!] [e])) (range))
19:51clojurebot(0 :even! 1 2 :even! ...)
19:52kenrestivomapcat seems simpler, thanks.
19:53justin_smithkenrestivo: related trick - mapcat can also be like filter if you choose to return an empty coll or nil for an item
19:53justin_smithit's kind of a cool function - "for each input give me zero or more outputs, all in a row"
20:08kenrestivonice
20:46nyonDo (type foo) and (class foo) ever return different things? :-O
20:48amalloyonly for weird foo
20:48nyonAh...
21:02justin_smith,(def weird? [x] (boolean (:type (meta x))))
21:02clojurebot#error {\n :cause "Too many arguments to def"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.RuntimeException\n :message "Too many arguments to def"\n :at [clojure.lang.Util runtimeException "Util.jav...
21:04pyon,(defn weird? [x] (boolean (:type (meta x))))
21:04clojurebot#'sandbox/weird?
21:04pyonWhat would be a good argument for `weird?` there?
21:05justin_smith,(type (with-meta [] {:type 'Foo}))
21:05clojurebotFoo
21:05pyon(weird? type)
21:05pyonAh.
21:05justin_smith,(weird? (with-meta [] {:type 'Foo}))
21:05clojurebottrue
21:05pyonSo, basically, the only way to make weird objects is to explicitly tamper with their metadata?
21:05justin_smithpyon: it was a round about way of saying type is only different from class if you add a metadata to make a fake type
21:05justin_smithyeah
21:06pyonAh, okay, good. :-)
21:06justin_smithor use a function that tampers with the metadata, of course
21:06pyonYeah.
21:06pyonamalloy: justin_smith: Thanks. :-)
21:07justin_smithmetadata is not heavily used in clojure code, this is because, and also a consequence of, the fact that much clojure code doesn't handle metadata nicely
21:07justin_smiths/consequence of/cause of the fact that
21:09pyonI don't see myself wanting to tamper with the type/class system anyway. I was just curious about the existence of two functions that seemingly did exactly the same thing. :-p
21:13tolstoyInteresting. If you start up a nrepl server in some random JVM process, then hook to it with Cider, there's no middleware. Ok. But (+ 2 3) never shows up in the repl (just *nrepl-messages*).
21:13justin_smithtolstoy: because cider is weird
21:14tolstoyAh, found the way to embed it in your app. (The middleware.)
21:18tolstoyOh, maybe not? It's a plugin. Hm.
21:22justin_smithtolstoy: it's a plugin that sets up classpath
21:22justin_smithso things should work if you do the right things to your classpath
21:22tolstoyI had a typo.
21:22tolstoyWorks great.
21:23pyonIs there some way to delete a namespace and everything it contains in the REPL?
21:23tolstoyI've got that big jar that has all the deps for "general" scripting and so on, including nrepl and cider-repl. Worksish.
21:25tolstoyns-unmap maybe?
21:25justin_smithremove-ns
21:25justin_smithns-unmap gets rid of a var or use
21:25tolstoyYeah, I was going for ns-map in combo with that, but remove-ns looks neat.
21:26pyonAh! Thanks!
21:26justin_smithtolstoy: oh, I get it
21:26justin_smithinteresting plan
21:27tolstoyThe only name I could remember was "unintern" which doesn't exist.
21:27justin_smithtolstoy: for a moment I was imagining the sad user of pear (the awesome replacement for cider) 10 years from now, being like "why the hell do we need to use cider in order to manage this codebase again?"
21:28tolstoyHeh. No matter what we do, the 10 years on folks will lament our idiocy.
21:28tolstoyBut I just want to write scripts in Clojure, so this fat jar with pomegranate, http-kit, fs, repl-stuff, etc, is fun. Repl just to make a simple playground outside of a full blown project.
21:29justin_smithnice, yeah
21:29tolstoyI'm sure it'll come to nothing, but it seems helpful at the moment.
21:29justin_smithyou could make a git repo :)
21:29tolstoyI think I have all the tools to craft my own "mh" style build system.
21:29justin_smithwhat's mh again? to me mh is a mail client
21:30tolstoyIt had those small apps that did one thing. "pick" to filter messages, etc. Can't remember. I just like the idea.
21:31justin_smithah, so it was the thing I was thinking of
21:31justin_smithinternally, git is kind of like that too
21:31tolstoyYeah. FreeBSD pkg util seems like that as well.
21:32tolstoyI think mh let you pipe things together. It seemed like a neat idea totally destroyed by IMAP.
21:33tolstoydnolen and co seem to do that kind of thing for CLJS stuff. mvn + pom for deps, everything else is a clojure <space> script.
21:36tolstoyAnyway, https://github.com/zentrope/cluj.
21:38justin_smithnice
21:38ajmooh yeah that’s pretty cool
21:39tolstoyThe bsdpkg example thing is what got me going. Just too hard in BASH. I mean, I've already learned awk 20 times and completely forgotten it.
22:07pyonIf `lein deps` fails, how do I clean up whatever it has installed so far?
22:10justin_smithpyon: it uses a cache - the cache is under ~/.m2/ but there is very rarely any reason to remove things from it
22:12pyonAh.
22:14justin_smithpyon: when lein starts the java process, it gives the java program a path of jars on the classpath - very much like how you have a path of directories to find executables in your shell
22:14justin_smithyou don't delete jars because one project changed, any more than you delete some lib of your system because you removed a program that used it (that is to say - sometimes, but carefully, and for a specific reason)
22:16pyonMakes sense.
22:50kenrestivonow that's interesting. top says clojure is using 100% of cpu. visualvm says it's using 0%. same pid.
22:50justin_smiththat's odd
23:26pyonWhat version of cider-nrepl should I use?
23:34pyonI added [cider/cider-nrepl "0.10.0"] to my project's dependencies, but `M-x cider-jack` keeps trying to use cider-repl 0.2.something.
23:35justin_smithhmm - are you sure that isn't nREPL 0.2.something and cider-nrepl 0.10.0 - these are two different things
23:35justin_smiththe newest nREPL is 0.2.11
23:43pyonOh.
23:57pyonMmm. CIDER says that it needs nREPL 0.2.12 or newer, but the newest nREPL is 0.2.11? :-|
23:58justin_smithI was saying that based on the readme - perhaps the readme is out of date? maybe you are using an experimental cider version/
23:59pyonI'm using the cider package from MELPA.
23:59tolstoyYes, the readme is out of date. I trust the "lein ancient" plugin.
23:59pyonAh.