#clojure log - Dec 14 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:04 tolstoy: lein generates a test directory even though I've deleted it.

0:07 hiredman: that is an interesting hypothesis, what evidence do you have to support it?

0:09 jvava: clojurebot, ,(+ 1 2)

0:09 clojurebot: excusez-moi

0:09 jvava: clojurebot help

0:09 tolstoy: rm -rf test

0:10 lein uberjar

0:10 jvava: clojurebot (* 20 442)

0:10 tolstoy: ls -l

0:10 jvava: who say clojurebot can repl what i typed

0:10 clojurebot lein

0:11 &(+ 1 1)

0:11 hiredman: tolstoy: what version of lein?

0:11 tolstoy: hiredman: 2.5.3

0:11 hiredman: what plugins?

0:12 tolstoy: lein-ancient

0:14 hiredman: ah 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

0:14 tolstoy: hiredman: Seems like it was auto-creating "dev-resources" a few times, too.

0:20 hiredman: https://github.com/technomancy/leiningen/commit/e9d6d7885777537fe3b50f3308b8fec44a65c391

0:21 tolstoy: Interesting. Is that a bug, or just a design decision?

0:21 hiredman: hard to say, seems wrong, things run just fine without a test directory

0:27 kenrestivo: how can i test if a core.async channel is open or closed?

0:27 other than blocking a read waiting for nil?

0:29 amalloy: kenrestivo: 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

0:41 kenrestivo: cool, thanks

0:56 tolstoy: Hm. 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.

1:18 hiredman: Ah, thanks for reporting that bug.

2:31 Pupeno: I’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?

3:57 irctc: hello

3:57 anyone up?

3:57 stuck on this clojure project

3:57 its due in 5hours

3:58 Pupeno: Some people are up, not many. I suggest you just ask your question.

3:58 irctc: pastebin.com/H4ts9QZ9 java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

3:58 (with-open [r (reader "input.txt")]

3:59 pastebin has source

3:59 My first project with a functional langauge

4:00 (spit "results.txt" (grammarCHECK line)) is causing problems

4:04 TEttinger: irctc: that error is almost always caused by having a number as the first item in a parenthsized list, where a fn is expected

4:04 ,(+ 1 2) ; doesn't error

4:04 clojurebot: 3

4:04 TEttinger: ,(1 2) ; does error

4:04 clojurebot: #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]...

4:06 TEttinger: oddly enough, irctc, the issue is in what that calls, not on that actual line

4:06 (nth (split aline #"\s+") (thecount) "nothing found")

4:07 there, thecount is a number but you're trying to call it like a fn

4:07 take off the parens around thecount and it may improve

4:07 (or throw an error at another point)

4:08 ,(nth (split "hey everybody, how's it going?") 2 "nothing found")

4:08 clojurebot: #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...

4:08 TEttinger: ,(nth (clojure.string/split "hey everybody, how's it going?") 2 "nothing found")

4:08 clojurebot: #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...

4:08 TEttinger: man I'm off my game today

4:08 ,(nth (clojure.string/split "hey everybody, how's it going?" 2 "nothing found"))

4:08 clojurebot: #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...

4:08 TEttinger: a ha, I screwed up!

4:08 MJB47: split "," "string"

4:09 TEttinger: ,(nth (clojure.string/split "hey everybody, how's it going?" #"\s+") 2 "nothing found"))

4:09 clojurebot: "how's"

4:09 MJB47: or im wrong

4:09 TEttinger: MJB47, yeah you should be right, since that's the order join takes them in

4:09 but it's weird like that...

4:10 MJB47: consistency is for the weak anyway :P

4:23 irctc: Thanks TEttinger

4:23 TEttinger: no prob, it's a really easy mistake to make :)

4:40 Oogh8oso: Hi. 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?

4:41 ridcully_: Oogh8oso: there is also #clojurescript

4:42 jonathanj: Oogh8oso: what editor are you using?

4:43 Oogh8oso: ridcully_: I guess all folks from there are here too... or is it unappropriate to ask cljs-specific questions here?

4:43 jonathanj: um, sorry. It's emacs with cider.

4:44 jonathanj: Oogh8oso: the `clojure-mode` thing has a facility for controlling this, clojure-backtracking-indent

4:45 ridcully_: Oogh8oso: i just mentioned it. often the folks asking here are not aware

4:46 jonathanj: Oogh8oso: 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))

4:46 Oogh8oso: ridcully_: oh, I see.

4:46 jonathanj: yep, just figured it out. Thanks anyway.

4:46 jonathanj: probably #clojure-emacs is the correct place for the question

4:48 Oogh8oso: Also, I've heard they've added some metadata-controlled indentation in cider... I guess it's just not widely used yet.

4:48 Um, or is it possible at all to attach metadata to vars in cljs?

6:55 Pupeno: How do I generate the pom and other files for release with lein?

6:56 hyPiRion: lein uberjar, lein pom

6:56 lein jar if you make a lib only

7:34 Pupeno: hyPiRion: 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.

7:34 or touching my repo.

7:34 hyPiRion: Pupeno: if you need to generate the pom, you can just use lein pom

7:35 Pupeno: hyPiRion: yes, I know about lein pom.

7:35 but I still have to rename it and generate the sha1s.

7:35 hyPiRion: oh

8:41 oracle`: how to get a subvector for a vector by index?

8:41 hyPiRion: (doc subvec)

8:41 oracle`: such as [11 22 33 44], get [1 3] out of it, we should get [11,33] back.

8:42 clojurebot: "([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."

8:42 hyPiRion: oracle`: oh

8:43 ,(let [v [11 22 33 44] indices [1, 3]] (mapv v indices))

8:43 clojurebot: [22 44]

8:43 hyPiRion: ,(let [v [11 22 33 44] indices [1, 3]] (mapv #(get v (dec %)) indices)) ;; I guess then

8:43 clojurebot: [11 33]

9:33 iwo: hey, does anyone know how I can apply a timeout to a blocking put in core.async?

9:34 I want >!! with timeout

9:37 I could do this with a future of course, but it feels a bit untidy - does core.async offer any way to do this?

10:28 zerokarmaleft: iwo: use alt!!

10:30 one channel op in the body of alt!! takes from a timeout channel, and the other would be the >!!

10:40 iwo: zerokarmaleft: ah, that makes sense! I thought alt!! was only for take (not put)

10:40 thanks

11:21 alive876_: 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:23 also does anyone know why i cant run a repl on cloud9

11:25 oh disregard above, its my mistake

11:26 sorry1

12:11 domgetter: Is there a way to tell clojure to inline functions?

12:12 MJB47: the JVM will do it by itself

12:12 domgetter: What I mean is something like this: https://gist.github.com/domgetter/5118978273fc61cceb69

12:12 MJB47: i dont know if there is anyway to force it

12:13 domgetter: The call to asdf is still slower than if I'd put the + there in the first place

12:13 MJB47: that is interesting

12:14 domgetter: I mean, it does a pretty damn good job after I type hint, but I didn't know if I could do better

12:14 MJB47: have you tried using AOT?

12:15 domgetter: That's after I told lein to make a jar file

12:15 Does that aot it?

12:15 MJB47: ah

12:16 domgetter: I have :profiles {:uberjar {:aot :all}} set in my project.clj

12:16 MJB47: should do

12:21 justin_smith: aot can improve startup, but not runtime performance

12:22 domgetter: So it would be just the same if I'd run it in the repl?

12:25 justin_smith: yeah, 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:27 domgetter: And you have to do aot if you want to call clojure code from java, correct?

12:28 justin_smith: domgetter: depends - you can always load clj files via clojure.lang.RT (load up require or load file, then use one of those, etc.)

12:28 domgetter: ah ok

12:28 clojurebot: Pardon?

12:28 justin_smith: domgetter: 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:29 not using aot simplifies some stuff

12:49 sdegutis: Is there an excellent library for colorizing Clojure code?

12:49 domgetter: sdegutis: In what text editor/ide?

12:49 sdegutis: HTML.

12:51 Hmm. I'll look into a JS syntax highlighter.

12:54 domgetter: sdegutis: You could try highlight.js

12:54 sdegutis: Ahh good idea.

12:54 domgetter: https://highlightjs.org/static/demo/

12:55 sdegutis: If you click Lisp under language categories on the left, it will just down to clojure

12:55 sdegutis: Nice!

13:03 TimMc: ,(java.net.InetAddress/getByName "1.512")

13:03 clojurebot: #object[java.net.Inet4Address 0x46b6c876 "/1.0.2.0"]

13:03 TimMc: TIL

13:04 ghost_: 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:05 justin_smith: ghost_: 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:06 ghost_: justin_smith: emacs actually did some magic to my code as I wrote this, I'll check, a minute

13:07 justin_smith: ghost_: try, right before the point where you call assoc (println "type of x:" (type x)) - you might be surprised

13:07 also, "cannot be casted to clojure.lang.Associative" is preceded by a type, it's telling you what type it got instead already

13:08 ,(assoc "not a map" :a 0)

13:08 clojurebot: #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:08 justin_smith: so there it tells you it got a string, for example

13:08 ghost_: justin_smith: what does "^@" do? my editor inserted it before val's name

13:08 justin_smith: ghost_: that's a null byte in most editors

13:09 it's not clojure syntax

13:09 ghost_: oh, thanks

13:09 justin_smith: well... it could be derefing something to attach it to something else as metadata - but you wouldn't see that often...

13:10 ghost_: damn, how do I create a map without creating a new type for that map?

13:10 justin_smith: ?

13:10 ,(type {})

13:10 clojurebot: clojure.lang.PersistentArrayMap

13:11 justin_smith: ,(type (hash-map :a 0))

13:11 clojurebot: clojure.lang.PersistentHashMap

13:11 justin_smith: I might be misunderstanding your question, because it sounds kind of weird...

13:11 ghost_: wha-at is going on

13:11 I've named my map new-board

13:12 and it has a type of "new-board"

13:12 justin_smith: so you made a defrecord?

13:12 ghost_: darn, I'm stupid

13:12 sorry for taking away your time

13:13 I've screwed up with namind

13:13 naming*

13:51 Pupeno: What's the easies way to listen for keyboard events?

13:51 justin_smith: Pupeno: in what UI?

13:51 Pupeno: justin_smith: console.

13:52 justin_smith: Pupeno: probably jcurses

13:52 or maybe lanterna

13:53 it's not really simple, because the standard tty interface used by the repl doesn't have key events - it's line oriented

13:53 (except for interrupts like C-c of course)

13:54 in 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:56 rhg135: Lanterna will spawn a tty in a swing window for dev purposes

13:57 justin_smith: oh, cool

14:04 sjl: is there a workaround for http://dev.clojure.org/jira/browse/CLJ-700

14:04 I don't care if it's ugly

14:06 TimMc: sjl: You could use the ternary form of get

14:06 justin_smith: sjl: don't use contains? on transients

14:06 sjl: yeah I can probably live with that

14:06 TimMc: ,(get (transient {:x 5}) :y :no)

14:06 sjl: (using get with a sentinal)

14:06 clojurebot: :no

14:07 justin_smith: sjl: well technically that's following my suggestion too, though I admit mine was much less helpful :)

14:10 TimMc: I've added that workaround as a comment. (Sorry Stu.)

14:13 Argh, my code is doing impossible things. :-(

14:14 slester: with great power comes great responsibility. or something.

14:14 justin_smith: TimMc: that's your spidey sense telling you you are about to have a learning opportunity, of course

14:14 slester: lots of spiderman!

14:14 justin_smith: wait why are we talking about spiderman again?

14:14 haha

14:15 slester: because: spiderman.

14:16 I learned the hard way that using recur on a string that gets huge is not the best tactic. (Advent of Code problem)

14:16 TimMc: slester: Not really cool impossible things.

14:16 slester: TimMc: but they COULD be cool!

14:16 justin_smith: slester: oh, so switching the self-call to recur didn't help?

14:17 TimMc: Basically 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:17 slester: justin_smith: newp

14:17 TimMc: I guess that's cool in a way.

14:17 slester: it was still making new strings every time

14:17 justin_smith: slester: right, strings are not mutable

14:17 slester: and the string length got obscene so it was making new huge strings every iteration

14:17 justin_smith: slester: maybe you want a StringBuilder

14:17 slester: and passing it back in

14:18 justin_smith: is it concatenation only? if so StringBuilder should be just the trick

14:18 slester: no, not necessarily

14:18 I'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:18 justin_smith: oh, well there still might be a way to use StringBuilder constructively, but it might not be as simple

14:19 slester: justin_smith: http://hastebin.com/ojiyudegor.lisp (spoilers for day 10 of advent of code for those who care)

14:19 justin_smith: slester: "application error"

14:19 slester: oh my

14:19 MJB47: who broke hastebin

14:19 slester: I took down hastebin.

14:19 TimMc: It doesn't like spoilers. ;-)

14:20 slester: but I warned about spoilers!

14:20 let's try refheap: https://www.refheap.com/112689

14:21 rhg135: Whoa! It did break

14:23 justin_smith: slester: 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:25 slester: justin_smith: right, I was looking into that stuff

14:26 TimMc: I'm going to chalk this up to midje fuckery.

14:26 Even my print statements aren't behaving right.

14:27 justin_smith: ~midje

14:27 clojurebot: midje is :(

14:27 justin_smith: TimMc: ^

14:28 ystael: TimMc: Is the standard shit show of "your state mutation is happening outside the dynamic extent of the magic midje behavior rebinding" ?

14:28 i.e. the thing that used to force us from (provided) over to (with-redefs) all the time

14:29 TimMc: FFS

14:29 Laziness.

14:29 justin_smith: (dec laziness)

14:30 TimMc: (reset! my-atom (seq-producer)), and the second element of the seq threw an exception

14:30 ystael: justin_smith: => #object[clojure.lang.Delay 0x371812ef {:status :pending, :val nil}]

14:30 justin_smith: TimMc: and reset doesn't force it?

14:30 ystael: lol

14:31 TimMc: reset! should be forcing the lazy

14:31 ,(def a (atom nil))

14:31 clojurebot: #'sandbox/a

14:31 TimMc: Should it?

14:31 ystael: TimMc: but chunked-seqs?

14:31 (force 1 = force 32?)

14:31 TimMc: 3-ele,ent seq

14:31 s/,/m/

14:32 justin_smith: ,(do (reset! a (lazy-seq (cons (/ 1 0) nil))) nil)

14:32 TimMc: Assuming this is laziness, I can take another shot at a repro.

14:32 clojurebot: nil

14:32 justin_smith: hmm

14:32 ,a

14:32 clojurebot: #<ArithmeticException java.lang.ArithmeticException: Divide by zero>

14:32 justin_smith: oh, TIL

14:32 TimMc: reset! just grabs that lazy seq and shoves it in the atom

14:32 ystael: so it throws when midje tries to print your test results?

14:33 justin_smith: right, right - for some reason I assumed reset! would eagerly consume an input, but on secodn thought, why would it?

14:33 TimMc: But 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:33 justin_smith: ystael: or as soon as it derefs the atom for any reason, yeah

14:33 TimMc: which is deeply unsettling

14:33 because there *shouldn't be a seq*

14:33 justin_smith: wait, empty seq, as in nil?

14:33 TimMc: justin_smith: deref the atom and start to walk the seq, actually

14:33 ()

14:34 justin_smith: ,(seq ())

14:34 clojurebot: nil

14:34 justin_smith: that's what I meant

14:34 TimMc: empty list

14:37 ghost_: How to make a vector from map's values?

14:37 MJB47_: (vec ...)

14:37 or use (mapv ...)

14:37 justin_smith: ,(vals {:a 0 :b 1 :c 2})

14:37 clojurebot: (0 1 2)

14:38 justin_smith: ,(vec (vals {:a 0 :b 1 :c 2}))

14:38 clojurebot: [0 1 2]

14:38 MJB47_: oh you mean that kind of map

14:38 justin_smith: well, we each read it differently...

14:38 heh

14:38 ghost_: I've used vector and wondered why it didn't work :D thanks!

14:40 ,(vector (vals {:a 0 :b 1 :c 2}))

14:40 clojurebot: [(0 1 2)]

14:40 justin_smith: yeah, vec vs. vector can be tricky

14:49 TimMc: OK, 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:51 alive876: 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:52 justin_smith: alive876: are you using apt-get to install lein?

14:52 if so, you probably are not getting a new enough lein version

14:53 codefinger: heroku will have 2.5.3

14:53 alive876: no, i used the script

14:53 or a script

14:53 justin_smith: alive876: the script?

14:53 alive876: let me take a look

14:53 justin_smith: so you are directly installing lein on cloud9 ?

14:53 alive876: yes

14:54 justin_smith: what kind of failure do you get when it fails?

14:54 alive876: just a sec

14:57 hi

14:58 the error i get when i run lein repl in cloud9 is /home/ubuntu/bin/lein: line 391: 3489 Killed

14:59 lein 2.5.3

15:00 justin_smith: yeah, that's the version I have, line 391 is the last line of code

15:00 alive876: could it be running into memory usage limits?

15:01 KevinCorcoran: Any 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:01 alive876: that i don't know

15:01 how much memory does it need?

15:01 justin_smith: KevinCorcoran: I've used core.async with 1.7 extensively, and wouldn't see any reason not to move to 1.8

15:02 KevinCorcoran: Thanks, justin_smith!

15:02 justin_smith: alive876: mine easily exceed a gig, but my app is pretty big

15:03 alive876: ok, yes, the "killed" would lean me in that direction

15:04 justin_smith: yeah, it's the most likely reason I'd expect "killed" on a clojure process

15:04 alive876: hmm, yea, thatnks

15:04 justin_smith: alive876: see if you can run 'java -cp clojure.jar'

15:05 that gives a bare bones repl - clojure.jar will be in ~/.m2/ (or at least that's where lein puts it)

15:05 wait, make that 'java -jar clojure.jar"

15:06 alive876: yes that runs

15:06 justin_smith: so at least you can get a usable repl to test your code fragments

15:06 ystael: ... trying to remember the name of a core function I think I remember, not finding it in grimoire

15:06 justin_smith: that will be lighter weight than what lein starts

15:06 ystael: (0 1 2 3 4) |-> (() (0) (0 1) (0 1 2) (0 1 2 3) (0 1 2 3 4))

15:06 i could implement it easily enough but i'm blocking on the name

15:07 alive876: i see, ok thanks

15:07 justin_smith: ,(reductions conj [] (range 5))

15:07 clojurebot: ([] [0] [0 1] [0 1 2] [0 1 2 3] ...)

15:07 ystael: oh, reductions, that's what i wasn't finding

15:07 thank you!

15:07 Seylerius: (inc justin_smith)

15:07 ystael: ^

15:07 justin_smith: but with () the order would be opposite

15:07 heh

15:07 Seylerius: Is lazybot down again?

15:08 justin_smith: Seylerius: lazybot isn't around any more, but I appreciate the thought

15:08 alive876: another options to try "lein run -m clojure.main"

15:08 Seylerius: justin_smith: Where'd it go?

15:09 justin_smith: Seylerius: to the big farm where buggy programs can run and play and be happy forever

15:09 alive876: is there anything wrong with developing in the dyno?

15:09 ystael: justin_smith: that's so sad *sniff*

15:09 justin_smith: alive876: eventually cost maybe?

15:09 Seylerius: justin_smith: Heh. No one had time to save it?

15:09 ystael: justin_smith: not looking forward to explaining death to my 3 year old

15:10 justin_smith: Seylerius: we put some work into it, but the main issue (random undetected disconnects) never really got solved

15:11 rhg135: I have time

15:11 gfredericks: seems like there are good hacky solutions to that

15:11 Seylerius: justin_smith: Share the source?

15:11 TimMc: ystael: Bonus points if you work in the existentialist analogy of the time before birth as an equivalent sort of nonexistence.

15:11 rhg135: Maybe I'll finally gut it

15:12 TimMc: gfredericks: Loops. :-)

15:12 rhg135: Go pircbot and build a façade

15:13 justin_smith: gfredericks: yes, there are hacks, and maybe one of us will find free time to make one work

15:13 alive876: <justin_smith> that last one did open a repl, strangely

15:13 Seylerius: justin_smith: Does the source live somewhere easily accessible?

15:13 justin_smith: alive876: 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:14 alive876: so the resource usage should still be fairly low - until you try to load up the full app

15:14 Seylerius: yes, I believe it is still raynes/lazybot on github

15:14 alive876: oh, ok, so i think we can say its a memory issue

15:15 justin_smith: alive876: that's my assumption until you find conflicting evidence, yeah

15:15 ridcully_: alive876: don't you have any logs there? it should state oom etc

15:15 alive876: otherwise any "resource limitation" sould be a candidate

15:16 justin_smith: ridcully_: sure, but realistically, mem is the resource clojure uses up first, all else being equal

15:16 alive876: <ridcully_> good point, i never looked before, but thanks, that valuable

15:17 ystael: TimMc: I don't think it will help. When I figured out that I would eventually die I was inconsolable for a week.

15:17 Just trying to put that off for a few more years for her.

15:18 amalloy: Seylerius, 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:18 btu Raynes hasn't been around for a long time, and i got tired of starting lazybot up all the time myself

15:19 rhg135: Shell scripting to the rescue

15:19 amalloy: sure. that's what we do for 4clojure

15:20 the problem is that lazybot's deaths were not easy to detect

15:20 rhg135: It would still require human interference, but we can make it easy

15:21 gfredericks: what about rebootin' every 10 minutes?

15:21 Seylerius: amalloy: I'd be interested.

15:21 gfredericks: (is what I meant by "hacky")

15:21 amalloy: just 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:21 TimMc: *nod*

15:22 Seylerius: amalloy: Do we have any kind of lib that can do something heartbeat-flavored?

15:22 amalloy: i'll make it an hour, put together a cron job for Raynes account

15:22 gfredericks: another way to detect it would be to ping lazybot over irc maybe, but that's more work than the blind reboot

15:23 ridcully_: so the process does not die? it just loses the connection. netstat | grep && restart then?

15:24 Seylerius: amalloy: How much control do we have over that server?

15:25 amalloy: IE, can we run something that listens for a regularly-scheduled action from lazybot, defibrillates it when it misses a scheduled heartbeat?

15:26 rhg135: You could set up an irc client on that server to ping it and restart it if no response

15:26 Seylerius: rhg135: IRC bots to manage IRC bots?

15:26 TimMc: ystael, 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:26 rhg135: Yeah

15:27 Complexity ahoy!

15:28 Netcat and a bit of shell

15:29 Actually, bash can do sockets itself

15:29 TimMc: ystael, 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:30 amalloy: Seylerius: i have unlimited control but limited motivation

15:31 Seylerius: amalloy: I have no control and less-limited motivation. Perhaps we can work something out?

15:32 gfredericks: ~amalloy is the god from deism

15:32 clojurebot: You don't have to tell me twice.

15:32 Seylerius: gfredericks: Hah

15:34 rhg135: I'll try my hand at writing an irc defibrillator, like Seylerius suggested

15:35 Yay!

15:35 Seylerius: rhg135: I'd actually recommend using an existing heartbeat package that watches for some known kind of action.

15:36 Rather than another irc bot.

15:36 Although that would be lulz.

15:36 rhg135: I don't think one exists for irc

15:36 I don't think you can tell otherwise

15:36 Seylerius: Isn't there one that just makes a simple REST-ish API endpoint?

15:36 amalloy: so 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:37 Seylerius: And couldn't Lazybot just GET the API endpoint?

15:37 Does Lazybot already have any capabilities that require grabbing a URL?

15:37 amalloy: lazybot's webserver still works fine. it's just the irc stuff that gets disconnected

15:37 rhg135: Yeah...

15:37 amalloy: so any heartbeat that doesn't go over irc is pointless

15:37 Seylerius: amalloy: Ah. So the whole bot doesn't die, only the IRC connection?

15:38 Okay, then yes, we need an IRC heartbeat detector.

15:38 rhg135: Indeed

15:38 amalloy: well, "need" is a strong word

15:38 Seylerius: rhg135: Github it, I'll want to pitch in once I get caught up (likely Wednesday or Thursday).

15:38 rhg135: When you're bored, "need" means "why not"

15:39 zilti: I 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:39 rhg135: Sure, Seylerius

15:41 zilti: anyone remembers how to get around that?

15:41 ridcully_: as in "i need a beer"

15:50 justin_smith: Seylerius: this could consist of using an irc command to ask some authoritative service if it can hear us

15:51 Seylerius: eg. irc /ping - just a question of having a reliable nick to ping where unavailability can mean always reboot I guess?

15:54 * TimMc writes a script to simply reboot amalloy's server every 10 minutes

15:55 amalloy: justin_smith: ChanServ

15:55 TimMc: Asking for the nick list would be a pretty good test.

15:55 amalloy: although i guess netsplits could make ChanServ unavailable

15:57 justin_smith: amalloy: yeah, I was hoping there was a way to ping the server itself but maybe that is a completely different thing

15:58 ridcully_: is the connection to freenode gone (e.g. netstat) on that box?

15:59 or are there other connections/clients that would make that hard to detect?

15:59 justin_smith: amalloy: haha - this works! : /msg amalloy PING (substitute own nick here of course)

15:59 or maybe that still works even with no connection...

16:00 meshy: justin_smith: sorry for jumping in on the tail-end of a conversation here, but you can ping the server you connected to

16:00 https://tools.ietf.org/html/rfc2812#section-3.7.2

16:00 justin_smith: meshy: oh, that's probably the right way to do it :)

16:00 meshy: perhaps I've got the wrong end of the stick

16:00 cool :)

16:06 slester: Do 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:07 justin_smith: slester: there's fireplace for using nrepl from vim

16:07 slester: I use evil (the vim emulator in emacs)

16:07 slester: justin_smith: yeah, I've tried using it and it's a bit cumbersome. It won't detect open REPLs etc.

16:08 justin_smith: slester: 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:09 slester: hmm, maybe that's the problem, I don't see a dotfile

16:10 justin_smith: slester: now I'm wondering - maybe that's a cider feature

16:10 I'm not the best one to address this since I don't actually use an in editor repl

16:11 slester: no worries, I don't either but I was trying to up my game, so to speak

16:11 justin_smith: but when I used cider that file would be generated, and would be used to pick a "default" port to try connecting to

16:11 slester: I find I can get a lot done with (require 'some.ns :reload) or (load-file "full/path/to/changed_file.clj")

16:12 along with the occasional copy/paste from emacs into the repl or visa versa, of course

16:13 slester: yeah

16:13 the copypasta is what I've been doing

16:14 justin_smith: slester: 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:15 slester: you were talking about an .nrepl-something file?

16:15 .nrepl-port?

16:15 it was alluded to elsewhere but it isn't being created with `lein repl` for some reason

16:17 justin_smith: slester: right, I think it's something in the cider middleware that adds this - fireplace also uses cider iirc

16:18 slester: I did add the cider middleware to my .lein/profiles.clj

16:18 hrmmm

16:18 justin_smith: slester: at this point someone else can probably help you more than I can, considering I don't even use this functionality any more

16:25 d0ky: hello 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:27 slester: justin_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:00 ridcully_: slester: lein repl creates that dotfile. starting vim-fireplace in that dir then uses that automatically

17:00 slester: ridcully_: it's not actually making that file sadly

17:01 ridcully_: 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:01 slester: Right, but I want to avoid having to do that. (It does successfully connect if I do, though.)

17:02 ridcully_: if i do a lein new x; cd x; lein repl - the file is there

17:03 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:42 slester: ridcully_: ahh, it's because I don't have a project.clj it seems. I was just using lein exec to run things

17:45 ridcully_: slester: in that case open dummy.clj and use :Connect

17:45 slester: lein repl won't make the .nrepl-port file without a project.clj it seems

17:45 ridcully_: yes

17:49 justin_smith: lein really likes it when you use project files

17:49 without a project file, you might as well be using clojure.jar directly, really - except your favorite profile deps / plugins I guess

17:50 ridcully_: well there is lein try

17:50 justin_smith: true

17:55 slester: justin_smith: yeah, and when I'm doing stuff like advent of code, I don't want a huge file structure

17:55 I just want... a file that runs

17:56 justin_smith: yeah, that's where clojure.jar is awesome

17:56 it starts like 10 x faster than lein

17:56 much simpler

17:56 lein is when you have a project and automatic dep management and stuff

17:56 slester: java -jar clojure.jar

17:58 slester: err

17:58 so if I have a .clj file, just java -jar clojure.jar file.clj

17:59 ?

17:59 justin_smith: yes

17:59 that simple

17:59 slester: fancy

17:59 I still need deps though :(

17:59 like data.json

18:00 justin_smith: slester: java -cp clojure.jar:data.json.jar clojure.main file.clj

18:00 slester: haha

18:00 justin_smith: slester: as long as you know exactly which jars you need that is

18:01 seriously that works

18:01 and starts fast

18:01 ridcully_: slester: take a look into the try-plugin for leiningen

18:01 justin_smith: yes, there is that too :)

18:01 ridcully_: but tbh, the content of a line new so so shallow, i'd not even bother

18:01 slester: thanks!

18:02 yeah, I just have daily challenges and don't want to go into the whole shebang

18:02 ridcully_: s/line/lein/

18:02 lein new challenge-one

18:03 justin_smith: I'd make one repo with all the challenges, and then do lein run -m foo.challenge1; lein run -m foo.challenge2; etc.

18:03 ridcully_: numbers in a ns are fine, i guess? aoc/day-01

18:04 justin_smith: sure

18:04 ridcully_: and then make your new year resolution to rm -rf aoc

18:05 justin_smith: ridcully_: hell, just add it to crontab

18:06 ridcully_: at would be enough

18:06 justin_smith: does at work across reboots?

18:06 ridcully_: i have not used it in the last decade or so

18:06 i'd expect so

18:07 justin_smith: ridcully_: so the only advantage of cron would be making sure it's ready if you try to do aoc again next year too

18:08 ridcully_: right

18:08 slester: I didn't know about lein run -m :O

18:09 justin_smith: yup, having more than one main in one repo can be very handy

18:09 ridcully_: and you will be happy, if you start your Associace Office Colab project in 2016

18:09 justin_smith: and when running an uberjar, you can also tell clojure.main which namespace to execute with -m

18:10 java -cp my-uber.jar clojure.main -m foo.ns1

19:48 kenrestivo: what'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:49 and then continuing on. i'm guessing a reduce might work, but not sure if it'd be right

19:49 justin_smith: something like (mapcat (fn [e] (if (p? e) [e :magic] e)) coll)

19:50 ,(mapcat (fn [e] (if (odd? e) [e :odd!] [e])) (range))

19:50 clojurebot: (0 1 :odd! 2 3 ...)

19:50 justin_smith: oh man that cut off way too soon

19:50 but you probably get the idea

19:51 ,(mapcat (fn [e] (if (even? e) [e :even!] [e])) (range))

19:51 clojurebot: (0 :even! 1 2 :even! ...)

19:52 kenrestivo: mapcat seems simpler, thanks.

19:53 justin_smith: kenrestivo: related trick - mapcat can also be like filter if you choose to return an empty coll or nil for an item

19:53 it's kind of a cool function - "for each input give me zero or more outputs, all in a row"

20:08 kenrestivo: nice

20:46 nyon: Do (type foo) and (class foo) ever return different things? :-O

20:48 amalloy: only for weird foo

20:48 nyon: Ah...

21:02 justin_smith: ,(def weird? [x] (boolean (:type (meta x))))

21:02 clojurebot: #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:04 pyon: ,(defn weird? [x] (boolean (:type (meta x))))

21:04 clojurebot: #'sandbox/weird?

21:04 pyon: What would be a good argument for `weird?` there?

21:05 justin_smith: ,(type (with-meta [] {:type 'Foo}))

21:05 clojurebot: Foo

21:05 pyon: (weird? type)

21:05 Ah.

21:05 justin_smith: ,(weird? (with-meta [] {:type 'Foo}))

21:05 clojurebot: true

21:05 pyon: So, basically, the only way to make weird objects is to explicitly tamper with their metadata?

21:05 justin_smith: pyon: 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:05 yeah

21:06 pyon: Ah, okay, good. :-)

21:06 justin_smith: or use a function that tampers with the metadata, of course

21:06 pyon: Yeah.

21:06 amalloy: justin_smith: Thanks. :-)

21:07 justin_smith: metadata 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:07 s/consequence of/cause of the fact that

21:09 pyon: I 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:13 tolstoy: Interesting. 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:13 justin_smith: tolstoy: because cider is weird

21:14 tolstoy: Ah, found the way to embed it in your app. (The middleware.)

21:18 Oh, maybe not? It's a plugin. Hm.

21:22 justin_smith: tolstoy: it's a plugin that sets up classpath

21:22 so things should work if you do the right things to your classpath

21:22 tolstoy: I had a typo.

21:22 Works great.

21:23 pyon: Is there some way to delete a namespace and everything it contains in the REPL?

21:23 tolstoy: I've got that big jar that has all the deps for "general" scripting and so on, including nrepl and cider-repl. Worksish.

21:25 ns-unmap maybe?

21:25 justin_smith: remove-ns

21:25 ns-unmap gets rid of a var or use

21:25 tolstoy: Yeah, I was going for ns-map in combo with that, but remove-ns looks neat.

21:26 pyon: Ah! Thanks!

21:26 justin_smith: tolstoy: oh, I get it

21:26 interesting plan

21:27 tolstoy: The only name I could remember was "unintern" which doesn't exist.

21:27 justin_smith: tolstoy: 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:28 tolstoy: Heh. No matter what we do, the 10 years on folks will lament our idiocy.

21:28 But 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:29 justin_smith: nice, yeah

21:29 tolstoy: I'm sure it'll come to nothing, but it seems helpful at the moment.

21:29 justin_smith: you could make a git repo :)

21:29 tolstoy: I think I have all the tools to craft my own "mh" style build system.

21:29 justin_smith: what's mh again? to me mh is a mail client

21:30 tolstoy: It had those small apps that did one thing. "pick" to filter messages, etc. Can't remember. I just like the idea.

21:31 justin_smith: ah, so it was the thing I was thinking of

21:31 internally, git is kind of like that too

21:31 tolstoy: Yeah. FreeBSD pkg util seems like that as well.

21:32 I think mh let you pipe things together. It seemed like a neat idea totally destroyed by IMAP.

21:33 dnolen and co seem to do that kind of thing for CLJS stuff. mvn + pom for deps, everything else is a clojure <space> script.

21:36 Anyway, https://github.com/zentrope/cluj.

21:38 justin_smith: nice

21:38 ajm: ooh yeah that’s pretty cool

21:39 tolstoy: The 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:07 pyon: If `lein deps` fails, how do I clean up whatever it has installed so far?

22:10 justin_smith: pyon: it uses a cache - the cache is under ~/.m2/ but there is very rarely any reason to remove things from it

22:12 pyon: Ah.

22:14 justin_smith: pyon: 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:14 you 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:16 pyon: Makes sense.

22:50 kenrestivo: now that's interesting. top says clojure is using 100% of cpu. visualvm says it's using 0%. same pid.

22:50 justin_smith: that's odd

23:26 pyon: What version of cider-nrepl should I use?

23:34 I 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:35 justin_smith: hmm - are you sure that isn't nREPL 0.2.something and cider-nrepl 0.10.0 - these are two different things

23:35 the newest nREPL is 0.2.11

23:43 pyon: Oh.

23:57 Mmm. CIDER says that it needs nREPL 0.2.12 or newer, but the newest nREPL is 0.2.11? :-|

23:58 justin_smith: I was saying that based on the readme - perhaps the readme is out of date? maybe you are using an experimental cider version/

23:59 pyon: I'm using the cider package from MELPA.

23:59 tolstoy: Yes, the readme is out of date. I trust the "lein ancient" plugin.

23:59 pyon: Ah.

Logging service provided by n01se.net