#clojure log - Mar 09 2015

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

0:00 Jabberz: so is friend deprecated now in favor of buddy?

0:00 justin_smith: they are from different authors

0:00 I am sure more people are using friend

2:07 irctc__: what do * functions mean typically?

3:35 michaelr`: justin_smith: are you here?

3:44 nicferrier: fantastically frustratedd with all the clojure xml parsers out there.

3:45 what would you expect to get from this? "<a><div>blah</div></a>" ? I'd expect (a (div "blah"))

3:45 but I'm getting (a)(div "blah")

3:46 michaelr`: nicferrier: I used xml vtd clojure wrapper when I needed to work with XML.

3:46 nicferrier: michaelr`: ptr?

3:48 michaelr`: nicferrier: try this maybe https://github.com/diamondap/clj-vtd-xml

3:49 nicferrier: here is another one https://github.com/mudge/riveted

3:54 nicferrier: well. I'll try it.

3:55 in some sense what tagsoup is doing might be considered correct. but not in any sense I am familiar with.

3:58 michaelr`: yes, the example you've pasted looks strange

3:59 nicferrier: hey ho, I'll give yours a go.

4:00 michaelr`: heh ok

4:52 BeeCeeM: hello

5:02 whodidthis: how do i write natural_number(0). natural_number(s(X)) :- natural_number(X). in core.logic. wondering how to do the compound term destructuring

5:09 nicferrier: michaelr`: does vtd parse non-well formed? eg: html5?

5:35 kungi: Why do I get an error concerning an uneven number of forms in this map? https://gist.github.com/Kungi/a3d4b342fef1acbd9b87

5:38 Hmm ok it's the quotes

5:39 The single quotes

5:39 noncom: whodidthis: there is a topical chat for core.logic, afaik, called #minikanren

5:40 i think getting an ansewr is more probable there

5:53 i am using core.async, and i have a go block inside a function that gets called by a java thread on a regular basis. should this somehow cause problems with core.async?

5:57 clgv: noncom: you'll have to be more specific. did you experience strange behaviour already?

6:37 mercwithamouth: halp! so i added the buddy library to my project....my server will not start up for some reason. https://www.refheap.com/98220

6:46 i'm assuming it's complaining about line 18 https://github.com/funcool/buddy-auth/blob/master/src/clojure/buddy/auth.clj

6:52 engblom: Do you know about any set of programming exercises made for Clojure? I am not asking for a generic set of excersises like Project Euler & Co.

6:54 mercwithamouth: clojurekoans

6:54 ahh.. a java inconsistency issue

6:55 ro_st: engblom: 4clojure.com

6:55 wagjo: engblom: 4clojure.com

6:55 engblom: Besides clojure-koans. Those were nice as first introduction but I want a bit more advanced stuff.

6:56 mercwithamouth: ahh i'm good ={

6:56 personal project time?

6:56 engblom: ro_st, wagjo: Thanks, there I found a list of exercises

6:56 mercwithamouth: if you want more advanced than why not euler?

6:57 you said thats what you didnt want but....past clojurekoans if you don't want to do euler/math stuff.....i'd think the next step is just to find a project

6:58 ro_st: doing pure algo stuff like 4clojure is great, but the rubber meets the road when you need to do Real stuff like manage user data and organise code

6:58 4clojure is just not going to give you that

6:59 engblom: mercwithamouth: I liked the clojure-koans, but they do not help you in forming basic algorithms in a logic order. You just add something simple inside of a ready written line. Project Euler is not made for clojure, so you might quickly need advanced stuff from the beginning. It is not neccessary a logical order.

7:01 clgv: mercwithamouth: sounds like an AOT issue

7:02 noncom: clgv: i get lots of these: https://www.refheap.com/98222

7:03 clgv: noncom: awesome. no idea about that

7:03 noncom: clgv: the essential part is that the "async-dispatch-#" is ever increasing, and the error is in ioc_macros

7:03 heh :)

7:04 clgv: noncom: I'd build a minimal viable gist and file an issue

7:04 noncom: yeah, i will try to reproduce it first.. within a minimal case.. i know, it is hard to tell from the current point

7:05 mercwithamouth: where do you all find various white papers related to computer science?

7:06 are there like any sites dedicated or that give a list of popular/interesting papers?

7:06 clgv: mercwithamouth: google scholar

7:06 mercwithamouth: google scholar. gotcha =P

7:06 clgv: ah not like that ;)

7:06 mercwithamouth: sweet

7:06 lol are you sure? =)

7:07 clgv: mercwithamouth: otherwise the usual publishers: ACM, IEEE, Springer, Elsevier, ...

7:07 mercwithamouth: sure about what?

7:08 mercwithamouth: i have no idea...it's 7am...i've been up for 26 hours and i'm loopy

7:12 clgv: mercwithamouth: another alternative - search through the recent conferences about the topics you are interested

7:14 mercwithamouth: clgv: not a bad idea. i just hear guys... nolen, etc that mention various papers in their talks so i figured they're something to look over oppossed to just books and articles

7:15 devll: I am messing up execution order in my code. anyone could have look at my code?

7:15 http://pastebin.com/BHaeSQFv

7:16 I am doing a batch insert ,but the (println "batch done") is execute before the loop is done.

7:18 clgv: devil: or maybe your loop is done early as you think ;)

7:18 *earlier

7:19 devll: there are many duplicated errors which are throwed later.

7:19 ro_st: you're starting a new thread in each catch, devll. is that intended?

7:19 clgv: devll: yeah those futures might execute after the loop

7:19 devll: I know this.

7:20 hmm.

7:20 so loop should have been executed ?

7:20 clgv: devll: btw do you know `if-let`?

7:20 devll: yes.

7:20 thanks for bringing up.

7:20 clgv: saves you the duplicate computation ;)

7:21 devll: I am inserting like 5000 links

7:23 I guess I am operating on a remote repl.

7:23 this was the reason.

7:33 wei_: is there a packaged version of bootstrap.js for use in clojurescript?

7:35 ro_st: www.webjars.org https://github.com/webjars/bootstrap

7:35 yes

7:35 wei_: perfect, thank you

7:37 dnolen: wei_: ro_st: with the caveat that doesn't ship externs far as I can tell

7:38 ro_st: i checked cljsjs, no bootstrap there

7:38 martinklepsch: ro_st: there's an issue for it

7:39 wei_: ah, not having to deal with externs was my main reason for doing this

7:40 martinklepsch: feel free to +1 it

7:40 (there's also a link to externs in that issue)

7:42 wei_: i see, thanks

7:42 btw, would this work as well? https://github.com/luxbock/bootstrap-cljs

7:42 or this one: https://github.com/elaatifi/packages/tree/react-bootstrap/react-bootstrap

7:45 ro_st: wei_: are you using Om?

7:45 wei_: reagent

7:45 but anyways, React

7:45 ro_st: https://github.com/racehub/om-bootstrap

8:24 justin_smith: $mail mercwithamouth I would try requiring the ns from buddy that defines that exception before requiring the namespace that imports the exception.

8:24 lazybot: Message saved.

9:36 dysfun: i'm having a little difficulty understanding why my tests are failing. i'm using with-redefs to assert that a function is being called. i'm using midje https://www.refheap.com/98229

9:37 justin_smith: dysfun: that with-redefs changes the arity of the function, right?

9:37 won't that function complain if it gets an arg?

9:37 dysfun: aha

9:38 yes, it's changing the arity

9:38 thanks

9:38 justin_smith: constantly might help

9:38 or maybe not...

9:38 also, consider using delay or promise instead of an atom if all you do is test whether a specific change has occurred

9:39 dysfun: hrm, it still failed

9:39 yeah, a promise should be better

9:39 clgv: you are testing whether debug logging was triggered? O_o

9:40 justin_smith: dysfun: also, is timbre/debug a function or a macro?

9:40 clgv: very likely a macro

9:40 justin_smith: that would mess with with-redefs, I would guess

9:40 clgv: at least the same functionality in tools.logging is a macro

9:40 dysfun: ugh

9:41 clgv: dysfun: you should not test that at all, afaik

9:41 justin_smith: clgv: since the point of the thing is to do logging, that seems an OK thing to test (another option would be to override *out* and test that what you expect, or something like it, is written)

9:41 clgv: justin_smith: is that really something you want to test?

9:42 dysfun: i've hoisted it out into another function so i can override it. thanks for the pointers

9:42 clgv: dysfun: with the disadvantages going along with that

9:43 dysfun: usually it would report the correct location in the stacktrace, I assume

9:43 dysfun: well, it's not properly tested now, because i've had to write code that i can't test heh

9:43 clgv: but probably not that import for the middleware

9:43 dysfun: that the middleware actually performs the designated function seems like a useful thing to test

9:44 clgv: but now you are only testing if some concrete function is called, which is clearly an implementation detail

9:45 e.g. if you change from "debug" to "trace" your test will fail ;)

9:45 dysfun: tests are designed to exercise code. i don't mind coupling my tests to my code

9:45 yes, that's intended too

9:46 clgv: should work then

10:00 engblom: Wow! Why have I never stumbled upon (recur) without (loop) before? I did not know it is possible. This will make the code more easy to read

10:01 I thought loop and recur had to be used together.

10:01 alcazoid: what will it do without loop?

10:01 engblom: alcazoid: http://rosettacode.org/wiki/Greatest_common_divisor#Clojure

10:02 alcazoid: hm

10:02 engblom: alcazoid: It is self-explaining there

10:02 alcazoid: yes

10:02 need to google tail call optimization

10:03 ha

10:03 that's quite cool

10:03 i actually had a question about recursion depth limits due to stack size on my mind

10:05 justin_smith: well, with recur, there is no depth limit

10:05 mavbozo: alcazoid: it's one of clojure special forms http://clojure.org/special_forms#Special%20Forms--%28recur%20exprs*%29

10:06 the recursion point can be function or loop

10:07 alcazoid: thanks guys, i'm only starting learning clojure

10:07 engblom: Somebody should chance the documentation to say tell the recursion point can be function or loop: http://clojuredocs.org/clojure.core/recur

10:08 While I love clojure more for each day that goes, the documentation for clojure is among the worst I have seen. You really have to dig for information and find examples.

10:10 dysfun: google is quite good for that

10:11 dvdt: hi all, i have an issue with records that is really perplexing me. is this the right avenue to ask for help?

10:11 engblom: I know... but a bit better documentation by (doc what-ever) would be great

10:11 justin_smith: dvdt: definitely

10:12 dvdt: ok great. my question is do you guys know of a situation where something like this can occur?

10:12 user=> (defrecord MyRecord []) user.MyRecord user=> (instance? MyRecord (->MyRecord)) false user=> (instance? MyRecord (MyRecord.)) true

10:12 justin_smith: dvdt: if you have evaluated the defrecord form more than once

10:12 dvdt: classic reloading problem

10:13 you can end up with two MyRecord classes, that are not in fact the same class

10:13 dvdt: justin_smith: hm ok thanks! i'll put some debug statements in my code to check that out

10:13 dysfun: i get this one using reloaded workflow a lot :/

10:14 clgv: engblom: I'd argue that this example (recur) is explained in the available books in depth

10:16 justin_smith: dvdt: usually the source of the issue is you have instances of a record that were created before MyRecord was redefined

10:16 daniel`: never heard complaints over the docs before

10:16 can't say i agree that they are the worst i have seen

10:16 justin_smith: dvdt: if reloading the definition of MyRecord also involves redefining any used instances in scope, that should avoid the error

10:17 clgv: daniel`: you have to listen more ;)

10:17 daniel`: i try clgv but can't hear everything

10:18 mavbozo: lacks of example in official docs compared to, say, PHP

10:18 clgv: but there is information that certainly does not fit into docstrings

10:18 but a lot of that is covered in the books

10:18 dysfun: mavbozo: most of the php manual's utility is the comments though. also the worst of the web is on there mixed on

10:18 clgv: mavbozo: well PHP needs it for all the weird exceptions :P

10:19 dysfun: clgv: you mean "unexpected token T_PAAMAYIM_NEKUDOTAYIM' isn't self-documenting? ;)

10:21 alcazoid: > a lot of that is covered in the books

10:21 i hate reading books on programming, i like to dive in

10:21 clgv: dysfun: I didnt mean exceptions as in "java exceptions" but as in 1+"" = 1 (dont know if that's a real one ;) )

10:21 mavbozo: we have clojuredocs.org, which is not official, but like PHP's, has examples and comments

10:21 alcazoid: is clojure's documentation that bad?

10:22 clgv: alcazoid: well then you might never grasp some of the general concepts since they cant be documented in docstrings :P

10:22 dysfun: clgv: oh it's full of crap like that. my particular favourite is that you have to use '@' (suppress warnings) in order to check the return value without filling the error log ;)

10:22 mavbozo: alcazoid: clojuredocs.org is good

10:22 alcazoid: also the books

10:23 clgv: alcazoid: no, you can work with it and there are additional resources as clojuredocs.org and clojure-doc.org

10:24 alcazoid: clgv: mavbozo i read Clojure for the Brave and True atm and it's good. but generally i don't have enough attention span for Big Books on Programming, so i prefer to try to do smth and google/SO a lot

10:24 dysfun: also if there's a particular thing you want to know about, asking in here is a good way to learn

10:25 alcazoid: dysfun: thanks

10:25 justin_smith: also, once you learn a few tricks, Clojure is very friendly to exploratory programming, where you use the facilities of the language itself to learn the language.

10:25 ,(clojure.repl/apropos "!")

10:25 clojurebot: (clojure.core/alter-meta! clojure.core/assoc! clojure.core/compare-and-set! clojure.core/conj! clojure.core/disj! ...)

10:26 dvdt: justin_smith: ok well the issue i'm having is i'm trying to dispatch a multimethod off of MyRecordA vs MyRecordB. my defmethods are all in the same namespace as my defprotocols, so shouldn't that mean they get redefined together?

10:27 clgv: $findfn inc [1 2 3] [2 3 4]

10:27 lazybot: []

10:27 clgv: $findfn 5 2 2

10:27 lazybot: [clojure.core/primitives-classnames clojure.core/dosync clojure.core/merge-with clojure.core/min clojure.core/quot clojure.core/when clojure.core/default-data-readers clojure.core/char-name-string clojure.core/*data-readers* clojure.core/*clojure-version* clojure.cor... https://www.refheap.com/98231

10:27 justin_smith: dvdt: no, defmethod is defonce

10:28 you need to do (def my-multimethod nil) before reloading

10:28 or else the multimethod will not be re-evaluated

10:28 clgv: what? $findfn seems broken

10:28 $findfn 7 3 2

10:28 alcazoid: i'm mostly processing data with python nowadays, trying algorythms on data etc etc. are there any machine learning or statistical models libraries for clojure?

10:28 lazybot: [clojure.core/quot clojure.core/unchecked-divide-int]

10:28 clgv: ah ok ;)

10:31 justin_smith: clgv: I think there are a lot of functions in clojure that are really hash maps or vectors, where (f a b) returns b because of get

10:31 ,(= (get get get get) get)

10:31 clojurebot: true

10:32 clgv: justin_smith: yeah guessed so, hence the input change ;)

10:32 justin_smith: s/I think//

10:37 dvdt: justin_smith: I tried your suggestion of (def my-multimethod nil) to reload my multimethod and it seems like I am on the right track. thanks!

10:38 justin_smith: dvdt: np

10:55 michaelr`: justin_smith: hi

10:55 justin_smith: i remember you've said once that you work with big data style stuff, is that right?

10:56 TEttinger: big but fits in memory, I think he said

10:56 jack0: Hi!

10:56 michaelr`: hehe

10:56 TEttinger: hey jack0

10:56 michaelr`: sorry, i read it as big butt fits in memory..

10:57 i need some architectural advice in that field

10:57 jack0: Are there any gsoc mentors here?

10:57 justin_smith: michaelr`: no, I don't personally do big data so much

10:57 I beleive I mentioned it as something I knew of people doing in clojure

10:58 michaelr`: justin_smith: right. for some reason I remembered it was you.. :)

10:59 justin_smith: I am sure some of the big data folks hang out here (may or may not be around right now, the ones I know of specifically are West coast, and it is early morning on a Monday right now)

10:59 West coast US, that is

11:00 michaelr`: regardless, it can't hurt to ask your question, someone may know the answer even if they don't consider themselves a "big data expert"

11:00 michaelr`: justin_smith: exactly :)

11:04 so the story is about ads, when a user sees an ad, an event is collected then in the next five minutes subsequent events are collected as the user continues to hang on that page or whatever. all of these events come with the same id, and they are supposed to be merged into one event which then goes to kafka and later uploaded in batches to s3.

11:05 agarman: all events for a given id end up in same partition of kafka?

11:05 michaelr`: the question is, what would be the most straightforward/simple/elegant approach to implement that first part where events should be collected for 5 minutes and then merged. subsequent events with the same id after 5 minutes should be ignored.

11:06 agarman: it could be, i'm designing the system..

11:07 i gathered that to combine these events some kind of state is needed.. was thinking in the direction of cassandra

11:08 but really, I want hear what other people might suggest..

11:08 agarman: is it fixed 5 minute windows or do they vary? e.g. 11:00 to 11:04:59, 11:05 to 11:09:59 OR starting now 11:08:37 to 11:12:38?

11:09 michaelr`: the five minutes are counted from the moment the first event with that id arrives..

11:10 agarman: the second one

11:10 justin_smith: michaelr`: sounds like something you could do with a promise or delay, a test if said promise or delay is realized, and a future that sleeps and then delivers to said promise or delay. Even better if instead of a future you can use core.async / go block

11:11 so the accumulator would check if the "done" delay is delivered, and accumulate if not

11:11 and the deliverer would sleep for 5 minutes, and then deliver to that delay

11:11 *force that delay

11:12 that's the most elegant way I can think of doing it at least. Especially since you may want to add other conditions that cancel the accumulation, and it's easy enough to have other code force a delay.

11:14 michaelr`: justin_smith: i'm not sure that i would like to write custom software to do all that. this thing should work at scale - think millions of events at the same..

11:14 jack0: How do I invoke map or set?

11:14 justin_smith: yeah, definitely don't want millions of futures

11:14 jack0: by calling them

11:14 ,({:a 0} :a)

11:14 clojurebot: 0

11:15 justin_smith: unless you have some nonstandard definition of invoke?

11:16 michaelr`: yeah, clearly I am out of my depth on that one

11:20 michaelr`: justin_smith: thanks :)

11:24 justin_smith: for admitting I can't help? Any time, I guess :)

11:25 ddellacosta: michaelr`: this is not necessarily the right thing for the job but it reminds me of how riemann (http://riemann.io/) works. Maybe just taking a look at that could provoke some inspiration, or lead you down the right path by looking at other systems which work similarly (stream processing)...?

11:26 michaelr`: justin_smith: for being always willing to help of course..

11:26 ddellacosta: ok, i'll check riemann thanks

11:26 ddellacosta: michaelr`: "...a stock Riemann config on commodity x86 hardware can handle *millions* of events per second at sub-ms latencies..." etc.

11:27 michaelr`: yeah, hope that helps

11:27 agarman: don't use Reimann for any data that you can't lose. It does a best effort to process a stream but by-design it will drop messages

11:28 jack0: What are the arguments that map can take?

11:28 justin_smith: ,(doc map)

11:28 clojurebot: "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no coll...

11:28 justin_smith: jack0: the first one ([f]) is only available in version 1.7

11:29 ,(map +)

11:29 clojurebot: #<core$map$fn__4507 clojure.core$map$fn__4507@2cae49a9>

11:29 justin_smith: ,(map + [1])

11:29 clojurebot: (1)

11:29 justin_smith: ,(map + [1] [3])

11:29 clojurebot: (4)

11:29 justin_smith: ,(map + [1] [3] [5])

11:29 clojurebot: (9)

11:29 justin_smith: etc.

11:30 jack0: or did you mean a hash-map?

11:31 jack0: Hash-Map

11:31 justin_smith: ,(doc get)

11:31 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

11:31 justin_smith: a hash-map as a function ends up calling get

11:31 ,({:a 0} :b)

11:31 clojurebot: nil

11:32 justin_smith: ,({:a 0} :b :nothing)

11:32 clojurebot: :nothing

12:17 dnolen: https://github.com/clojure/clojurescript/wiki/Quick-Start

12:17 literally *everyone* that uses ClojureScript should run through this, it doesn't matter what you use cljsbuild/boot etc. ^

12:22 engblom: Is it possible to do the naive implementation of fibonacci with double recursion without blowing the stack? I would want to really test the strength of (memoize).

12:24 gfredericks: you can do that with vars

12:24 ,(defn fib [n] (if (< n 2) n (+ (fib (dec n)) (fib (- n 2)))))

12:24 clojurebot: #'sandbox/fib

12:24 gfredericks: ,(fib 5)

12:24 clojurebot: 5

12:24 gfredericks: ,(fib 10)

12:24 clojurebot: 55

12:25 gfredericks: ,(alter-var-root #'fib memoize)

12:25 clojurebot: #<core$memoize$fn__5435 clojure.core$memoize$fn__5435@63cea432>

12:25 gfredericks: ,(fib 20)

12:25 clojurebot: 6765

12:25 gfredericks: ,(fib 30)

12:25 clojurebot: 832040

12:25 gfredericks: ,(fib 200N)

12:25 clojurebot: #<ArithmeticException java.lang.ArithmeticException: integer overflow>

12:25 gfredericks: gotta tweak the fib to make it use big numbers but otherwise that should work

12:26 engblom: ,(defn fib [n] (if (< n 2) n (+' (fib (dec n)) (fib (- n 2)))))

12:26 clojurebot: #'sandbox/fib

12:26 gfredericks: actually I'm not sure why it doesn't already work

12:26 engblom: ,(fib 200N)

12:26 clojurebot: Execution Timed Out

12:26 engblom: ,(alter-var-root #'fib memoize)

12:26 clojurebot: #<core$memoize$fn__5435 clojure.core$memoize$fn__5435@14cd9cc8>

12:27 engblom: ,(fib 200N)

12:27 clojurebot: 280571172992510140037611932413038677189525N

12:27 gfredericks: does anybody know why my original one doesn't work?

12:27 ooo

12:28 because it had already been memoized with longs

12:28 so if you call it first with a bigint then it should work

12:28 sneaky :)

12:28 engblom: I added +

12:28 I added +'

12:28 To automatically promote

12:28 gfredericks: right but mine doesn't need that as long as you only call it with bignums

12:28 the problem was I had called it previously with longs and that's what went into the memoization map

12:30 chouser: wow. I'm still not getting it, gfredericks.

12:30 {blake}: dnolen: Where does build.clj go? What directory?

12:31 gfredericks: chouser: you see why it works okay when not memoized?

12:31 engblom: Still we get stack overflow even with memoize. Clojure seem to not allow double recur. recur only works with tail

12:31 (fib 1000)

12:31 gfredericks: chouser: because if you call it with a bigint you get bigints all the way down?

12:31 engblom: ,(fib 1000)

12:31 clojurebot: 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875N

12:31 chouser: gfredericks: autopromotion by +

12:31 gfredericks: chouser: I'm talking about my original one that uses +, thus not autopromoting

12:32 engblom: I blowed the stack with (fib 1000) in my own computer

12:32 gfredericks: but if you use bigints up front it can work

12:32 clgv: engblom: you ouldnt want to use the implementation with exponential runtime anyway ;)

12:32 engblom: clgv: Nope, but it is interesting to see what Clojure can do. So far I have not seen any programming language handle this naive implementation well

12:32 gfredericks: engblom: memoize also affects stack usage, so calling it with smaller values first makes it less stackful

12:32 chouser: ah ... I'm confusing autopromotion with coercion to the bigger type

12:33 dnolen: {blake}: in the current directory, tutorial clarified

12:34 gfredericks: chouser: still confused about something or all better?

12:34 {blake}: dnolen: So, the project root.

12:34 dnolen: {blake}: yep

12:34 chouser: gfredericks: I think I've got it.

12:35 {blake}: dnolen: I booted under windows this morning. When I do the java -cp cljs...etc. I get "Could not find or load main class clojure.main."

12:35 dnolen: {blake}: you're truncating your java command, what did you actually type

12:36 {blake}: there maybe Windows issues, these will have to get sorted out later

12:36 {blake}: but I do want to see JIRA tickets for anything anyone encounters on windows

12:36 amalloy: C:\> java -jar whatever c'mon pls just run my code you know how it goes

12:37 gfredericks: C:\> is a weird smiley

12:37 {blake}: dnolen: Well, up till this point it was okay. Windows' mkdir doesn't need the -p and Windows doesn't come with a touch.

12:37 dnolen: I copied in "java -cp cljs.jar:src clojure.main build.clj"

12:37 amalloy: gfredericks: it's been so long since i saw a windows shell prompt. i probably put the \ in the wrong place

12:37 justin_smith: gfredericks: jaunty clown hat

12:37 gfredericks: hey I don't know what it looks like either

12:37 dnolen: {blake}: yeah dunno, I use `lein uberjar clojure.main` to build cljs.jar, anyways write it up in JIRA, thanks.

12:38 {blake}: gfredericks: lol...you guys are like..."That brothel in town is a disgrace." "Yeah, especially the wallpaper."

12:38 dnolen: OK.

12:38 dnolen: {blake}: for the `mkdir` bits, happy for people write out the alternative commands for Windows

12:38 the wiki is community editable

12:39 {blake}: dnolen: Cool.

13:11 timvisher: anyone feel like helping me debug a s3 private wagon issue?

13:11 i'm failing to download a -SNAPSHOT jar that i've been able to download successfully before

13:11 i can view the directory using awscli

13:11 there are in fact jars there

13:12 i have my LEIN_USERNAME and LEIN_PASSPHRASE set up, matching the aws creds (id, secret key)

13:52 amalloy: so i'm writing this server, composed of some number of component pieces; each component has a shutdown function, to be called when it's time to stop. of course i can easily have the server compose together all these shutdown functions into one "stop everything"

13:52 but what i'm stuck on is, suppose one of the services is broken, and i want to let it stop the whole server. how do i manage the mutual recursion between these? i don't have the composed "stop everything" function until all components are started, so i can't pass it to their constructors

13:54 justin_smith: amalloy: what about a "meta server" which reduces over all servers to get the "stop server" callbacks, and then calls all of them and returns via reduced if one of them fails?

13:55 amalloy: my current plan is to give each sub-service a (promise), and then deliver the shutdown-all function to that promise once i have it

13:55 tying the knot haskell-style, but it seems gross

13:56 justin_smith: and that doesn't handle the case where you know you have to shut it all down before they are all started

13:57 timvisher: i get 403s when trying to retrieve the pom and the jar

13:57 amalloy: i don't understand your meta-server suggestion at all, justin_smith

13:58 justin_smith: amalloy: the idea is that if you had a sequence of services to start, you can reduce over it to get a sequence of "stop server" callbacks (if each returned one when started)

13:59 amalloy: then, as soon as one returned an invalid value, it could call all the stop-server callbacks it collected so far, and then exit via reduced, not starting the rest

13:59 amalloy: there's a good chance I made some assumption about your setup in all this that does not hold

14:00 amalloy: justin_smith: my question is not about what to do if one of the services fails to start at all (although that's probably something i also need to work on), but about when, after all services start successfully, one of them later breaks somehow and decides to shut down

14:02 justin_smith: amalloy: oh, right. A promise would work for that, but I was definitely answering a different question than the one you asked (perhaps I got sidetracked with my own quesiton: what about the corner case where you need to shut down but the promise is not delivered because they aren't even all started yet?)

14:02 amalloy: right. a valid concern

14:02 i think i'm okay in that regard because i'm giving each service its own thread, so they can afford to block on the promise

14:03 but it all seems sloppy and lame

14:03 justin_smith: yeah, I am sure there is an elegant way to do this

14:03 amalloy: i have been pondering whether core.async helps

14:03 since this seems like a communication problem

14:04 justin_smith: timvisher: are the perms shown by the aws cli tools the same on those artifacts as the others?

14:05 mgaare: amalloy: if you're broadly using the model of stuart sierra's components, the "system" component could pass all the subcomponents a shutdown function that has an async channel that system listens to and shuts down all the components

14:06 amalloy: yeah, that's the core.async solution i am thinking about. it seems basically the same as sending them a promise, though; a single-use one-way channel is basically just a promise

14:07 justin_smith: amalloy: makes sense, core.async is about more cleanly representing callbacks

14:07 and that promise is a callback

14:08 another option is to pass (delay :quit) to each one, and have them test if it is realized and exit if/when

14:09 but that requires explicitly checking in a loop, which may not work for the service logic

14:28 puredanger: fyi, there will be a promise-chan in next core.async release http://dev.clojure.org/jira/browse/ASYNC-103

14:29 Bronsa: puredanger: saw your mail re: tools.reader of a couple of days ago -- no worries

14:29 puredanger: and (presuming this ticket gets done), all channels will be derefable http://dev.clojure.org/jira/browse/ASYNC-102

14:29 Bronsa: good. I released a new version with that :)

14:31 Bronsa: puredanger: cool, thanks!

14:35 timvisher: what can make a -SNAPSHOT dependency behave like a normal dependency?

14:35 `lein deps :tree` is trying to retrieve the `x.x.x-SNAPSHOT.pom` from the s3 bucket

14:36 amalloy: timvisher: that probably depends on what you mean by "behave like a normal dependency"

14:36 timvisher: which i don't think is a thing for SNAPSHOT deps

14:36 other `-SNAPSHOT` deps are being pulled down fine

14:36 there's no typeo afaict

14:36 typo*

14:37 other devs here are able to use this version of this project and pull down that dependency fine

14:37 and i'm able to switch to a slightly different version of that dep `x.x.(inc x)-SNAPSHOT` and have it be retrieved fine

14:38 it seems to not understand that this particular `x.x.x-SNAPSHOT` is in fact a snapshot

14:38 is there cacheing somewhere?

14:39 amalloy: snapshots have pom files

14:40 timvisher: amalloy: but they don't get retrieved as `x.x.x-SNAPSHOT.pom`

14:40 amalloy: you seem to have reached an erroneous conclusion about what is wrong, and are trying to debug perfectly normal behavior (fetching pom files) instead of the real problem

14:40 timvisher: maven has to pull the metadata and then select the latest jar from it

14:40 amalloy: i'd be really happy if that were the case :)

14:40 amalloy: what? of course they do. check your ~/.m2/repo for some snapshot versions; they all have foo-a.b.c-SNAPSHOT.pom

14:40 puredanger: snapshots are only pulled once per day by default

14:40 timvisher: amalloy: none of ours do

14:41 well, let me check :)

14:41 amalloy: if that were the case none of your snapshots would work at all

14:41 timvisher: puredanger: iut, but if they're not in the local repo then they'll be pulled always, right?

14:41 puredanger: yes, should be

14:42 you might check lein pom, then mvn dependency:tree

14:43 sometimes maven gives better error messages in lein for stuff like this

14:43 timvisher: amalloy: i only see `snapshots/project/x.x.x-SNAPSHOT/maven-metadata.xml etc` and `snapshots/project/x.x.x-SNAPSHOT/project.x.x.x-SNAPSHOT.timestamp.pom`

14:43 puredanger: yep. tried that

14:43 in this instance it was having the same problem

14:44 what _has_ solved the problem now is `rm -rf ~/.m2`

14:44 but wat?

14:44 puredanger: and then maven has the -U to force update of snapshots

14:44 timvisher: amalloy: is that different than what you see? that was how i understood snapshots to work

14:44 xml for the selection, and then timestamped jars for the actual dep resolution

14:44 amalloy: puredanger: lein has the same flag available: lein -U deps

14:44 puredanger: cool, couldn't remember

14:45 timvisher: `-U` is good to know about :)

14:45 amalloy: (or, really, lein -U whatever)

14:45 timvisher: i'm not sure why we're depending on this SNAPSHOT anyway but i still am completely confused as to what could've been causing the dependency to fail

14:45 puredanger: prob also worth mentioning the savings time change

14:46 timvisher: given that i thought SNAPSHOT was all a dependency needed to be 'marked' as a snapshot dep

14:46 does lein have a debug mode or something where it can spit out all of the actual intermediary steps it takes to look up the dependency?

14:46 or maven for that matter

14:46 puredanger: mvn -X

14:46 timvisher: i.e. it pulling the xml and then selecting the timestamp jar?

14:46 puredanger: thanks

14:47 puredanger: with lein I think you can set DEBUG to something in your env first?

14:48 yeah, env var: ;; DEBUG - increased verbosity

14:49 dnolen: {blake}: btw you have Java 8 installed right? re: cljs.jar troubles

15:05 timvisher: puredanger, amalloy: ok. here's what i think was happening. i think the snapshot initially failed to be retrieved because of something (probably misconfigured environment). it was then cached as unavailable in `.maven-metadata` and so it wasn't even trying to hit the network

15:07 puredanger: the best one is when a repo throws an html error page and that gets saved as a jar file in your repo

15:07 that's super awesome

15:09 timvisher: puredanger: futuretech

15:11 justin_smith: puredanger: oh man, once I tried to work from a cafe, and a whole tree of deps got downloaded, and all were the "sign in to use the internet" splash page for that cafe

15:11 that was fun to debug

15:11 amalloy: i think i remember that

15:11 puredanger: oh yeah, I've never spent whole days on that or anything

15:11 justin_smith: haha

15:11 amalloy: yeah, I think you helped me figure that one out

15:16 timvisher: maven :)

15:24 {blake}: dnolen: I think so. Let me check in a few.

15:26 dnolen: {blake}: k let me know I verified it work on OS X & Unbuntu w/ Java 8

15:34 christa: Hi. Im still learning clojure, and was thinking about the idiomatic way to map/reduce over a vector of maps, heres what i have atm. https://www.refheap.com/98238

15:35 is there a better way?

15:36 {blake}: christa: You could just directly use "sums".

15:37 gfredericks: christa: (->> sums (map :a) (reduce +))

15:37 note that in the code you have there the arg to `candidates` is being ignored

15:37 johnmendonca: christa: instead of (fn [coll] (coll :a)), I believe you can just say :a

15:38 christa: wow that terse

15:38 s

15:38 thnx

15:39 {blake}: christa: Like, "(reduce #(+ % (:a %2) 0 sums)".

15:39 pjstadig: puredanger: do you know if/when CLJ-1561 will get applied?

15:40 justin_smith: (apply + (map :a sums))

15:40 likely the best golfing of that one ^

15:41 christa: Heh, ill try to balance readability with golfing

15:41 justin_smith: christa: by "best" I was including readability

15:41 christa: terse, but still readable

15:41 justin_smith: or trying to, at least

15:42 puredanger: pjstadig: I assume the next time Stu looks at stuff to apply

15:43 I'm not actually sure how he managed to apply every other but missed that one :)

15:43 justin_smith: christa: for example, I don't see (fn [coll] (coll :a)) as more readable then :a

15:44 given the knowledge that keywords act as a function that does lookup

15:45 {blake}: dnolen: I get why specifying ":main" in build.clj allows us not have to include main.js in our HTML, but why does ":main" impact whether we have to specify "goog/base.js" in our HTML?

15:46 dnolen: {blake}: the Quick Start suggests examining out/main.js

15:46 {blake}: dnolen: No, I see that it's in there. I just don't get what it is about ":main" that says, "Yes, put that google closure in there."

15:47 dnolen: Get my meaning? Specifying ":main" in you build means you don't have to specify main in your HTML. Cool.

15:47 dnolen: But why also does it mean you don't have to specify goog base?

15:48 dnolen: {blake}: ah right, that's just the nice to have bit

15:48 {blake}: dnolen: OK, cool. Is there ever occasion you wouldn't need goog base?

15:49 dnolen: you always need goog/base.js :main just loads it for you

15:49 it's requirement everywhere, regardless of Rhino, Nashorn, Node.js, or browser

15:49 christa: justin_smith: just :a def is better, i didnt know you can refrence the key without the collection

15:50 {blake}: dnolen: Cool, thanks.

15:58 clojure-newb: hi guys, trying to generate some code to replace a ‘def’ in my program, but the code generated does not work in my program… the basics are at : https://www.refheap.com/98240 any ideas ?

16:00 gfredericks: ,(Object.)

16:00 clojurebot: #<Object java.lang.Object@4ac9dd40>

16:00 clojure-newb: sorry… fixed version at : https://www.refheap.com/98241

16:01 justin_smith: clojure-newb: why do you use strings in the first version, and numbers in the second?

16:03 clojure-newb: justin_smith: it ends up operated over by a (str) function later anyway

16:04 justin_smith: clojure-newb: ##(Integer. 1)

16:04 lazybot: ⇒ 1

16:04 justin_smith: so what's the error you get?

16:05 clojure-newb: my program code works fine with the ‘def’ version

16:05 justin_smith: also, you might as well use (mapv ...) instead of (into [] (map ...))

16:05 clojure-newb: routes through the vector datastructure fine…

16:05 oh, I’ll look into mapv, nice

16:05 piranha: anybody using pedestal here? Is it possible to strip trailing slash from incoming request so that it'll match my route instead of returning 404? Can't figure if I can do that with interceptors

16:05 clojure-newb: but the output from the function bersion is all garbled and the program won’t work with it

16:06 garbled = like #<myunit$something-fn_item$fn__372

16:06 justin_smith: "garbled" and "won't work" aren't much to work with

16:07 clojure-newb: [[#<myunit$something-fn_item$fn__372 …]]

16:07 justin_smith: oh, well the rirst one should have done that too

16:07 clojure-newb: instead of [[#(something= 1) …]]

16:07 justin_smith: #() never prints readably

16:08 decision should print just as "garbled"

16:08 clojure-newb: oh

16:08 I see

16:08 justin_smith: ,#()

16:08 clojurebot: #<sandbox$eval49$fn__50 sandbox$eval49$fn__50@1d842dd1>

16:08 clojure-newb: its fine literal in the code as a def, but println will garble it

16:08 Bronsa: justin_smith: well, it actually does since 5 hours ago

16:08 justin_smith: Bronsa: woah!

16:08 Bronsa: justin_smith: as does everything actually

16:09 gfredericks: hiredman: how often does clojurebot pull code from master?

16:09 Bronsa: justin_smith: user=> #()

16:09 well

16:09 user=> #()

16:09 damn

16:09 http://sprunge.us/JBFj there

16:09 justin_smith: fascinating

16:09 Bronsa: linux clipboards are weird

16:09 justin_smith: indeed

16:10 clojure-newb: so all this was a red herring and something else is up with what I am trying to do

16:10 justin_smith: clojure-newb: I think so. Are you intending to build up a bunch of functions of 0 arguments that don't get called?

16:10 clojure-newb: I’m basically trying to generate a vector of vectors

16:10 justin_smith: yeah, both the function and the top level def do that

16:11 and each sub vector contains two elements, each is a function of two arguments

16:11 none of the functions get called

16:11 clojure-newb: wondering why only the former is working (top level def)

16:11 yes they get called later

16:11 justin_smith: I still have no idea what you mean by "working", because the defn will produce a vector of vectors

16:11 as written there at least

16:11 SegFaultAX: Is there a hipchat bridge for clojurebot?

16:11 justin_smith: as long as you call it with an arg that gets ignored

16:12 Bronsa: so in 1.7 "don't know how to create ISeq from clojure.core$map .." is the new ArityException and "No reader function for tag object" is the new "Unreadable form" :P

16:12 justin_smith: haha

16:12 fun

16:16 hiredman: you forgot about can't cast to future

16:16 oh

16:17 nm

16:17 SegFaultAX: hiredman: If I hypothetically wanted to add a hipchat adapter/bridge to clojurebot, where would you suggest I start?

16:17 (Assuming such a thing does not already exist)

16:20 hiredman: that is an excellent question

16:21 clojurebot uses this crazy https://github.com/hiredman/conduit-irc library for irc, one way to make it work with hipchat would be to hack that library up to speak to hipchat instead of irc

16:21 gfredericks: SegFaultAX: have you seen the hiprepl lib?

16:21 SegFaultAX: gfredericks: Googling...

16:21 gfredericks: maybe it's more an app than a lib

16:22 /tailrecursion/hiprepl I think

16:22 SegFaultAX: hiredman: Ideally clojurebot doesn't care about the medium it's using, right? You just give it an adapter that fits a protocol (or set of protocols)

16:22 hiredman: ideally

16:23 SegFaultAX: gfredericks: Wow, that's awesome!

16:23 hiredman: at one time it was more like that, it is less like that now, and I don't spend a lot of time working on it now

16:25 gfredericks: SegFaultAX: I put a branch somewhere that makes the messages dispatch easier to extend

16:25 hiredman: ideally, what I think clojurebot should be is a message bus with a state machine for every user hanging off of it, but it definitely doesn't look like that now, and I dunno if it ever will

16:25 gfredericks: have a customized version at work that reimplements a bunch of the clojurebot stuff

16:25 which is mildly saddening

16:26 SegFaultAX: gfredericks: Well I think I have most of the feature through another bot already (hubot)

16:26 I'm currently only interested in the eval portion.

16:26 gfredericks: oh yeah and that's already there

16:26 SegFaultAX: I know nothing about JVM jails other than it's really hard black magic.

16:27 How has your experience been with hiprepl?

16:28 gfredericks: it's a tiny codebase so easy enough to hack

16:28 I wrote a bash script that reboots it every 6 hours or so just in case

16:28 SegFaultAX: I guess I'm more asking about clojail-related stuff.

16:28 Can I trust that it's *reasonably* sane?

16:28 gfredericks: what are you worried about?

16:29 are you making it public?

16:29 SegFaultAX: Nope, it's a company thing.

16:29 gfredericks: or just having to trust hipchat?

16:30 SegFaultAX: Don't care about hipchat. I guess if I just put the bot on an instance I don't care about, it doesn't matter.

16:34 gfredericks: yeah I run it on a dev box

16:41 aperiodic: SegFaultAX: if you're interested this is how have clojure evaluation in our hubot fork: https://github.com/puppetlabs/kerminator/blob/master/files/scripts/clojure.coffee

16:48 jarjar_prime: hi :)

16:48 anyone able to help me this... i'm getting

16:48 CompilerException java.lang.NullPointerException, compiling:(clojure/core/async.clj:1105:8)

16:49 (:require [clojure.core.async :as async :refer [go]])

16:51 it works in the repl

16:54 creese: I'm compiling an uberjar to run in a remove environment. When I run it, I get a java.io.FileNotFoundExecption when it tries to load from "resources/"

16:55 How can this be reconciled?

16:56 gfredericks: creese: are you using clojure.java.io/resource?

16:56 aperiodic: creese: you need to get the path to the resource using clojure.java.io/resource

16:56 and it shouldn't start with "resources/"

16:57 if you have `foo.html` in your resources, you'll want to call (clojure.java.io/resource "foo.html")

16:57 gfredericks: ,(Object.)

16:57 clojurebot: #<Object java.lang.Object@3920c2e4>

16:57 gfredericks: I'm waiting to see the new #object "..." printing

16:57 creese: aperiodic: it works in my local environment

16:58 aperiodic: creese: yeah, because the file "resources/foo.html" exists there. it doesn't when you're running from an uberjar; there are only the resources on the classpath, then

17:00 creese: aperiodic: actually, that's what I do

17:00 aperiodic: (load-config (clojure.java.io/resource "config.edn"))

17:18 puredanger: gfredericks: user=> (java.net.ServerSocket.) ;; #object[java.net.ServerSocket "ServerSocket[unbound]"]

17:19 cfleming: puredanger: The new REPL looks very interesting

17:19 puredanger: cfleming: thought you might be interested :)

17:19 cfleming: puredanger: How will data exchange work? Say I want to use it for implementing completion in Cursive, is there some framing in the protocol or something like that?

17:20 puredanger: How would I match requests to responses?

17:20 puredanger: Yes, no doubt :)

17:20 puredanger: cfleming: no, they're streams so write, then read

17:21 cfleming: puredanger: In my experience, that's difficult to use for tooling

17:21 puredanger: You end up having to parse streams, which is surprisingly tricky.

17:22 puredanger: Given that the server process is presumably asynchronous and might be writing output too

17:22 puredanger: Or is the intention that tools create a separate tooling connection?

17:22 puredanger: yes

17:23 each socket connection is a separate repl stack with dedicated input/output

17:24 cfleming: puredanger: Ok. We're still parsing stdout in order to find out which namespace a current repl is in, though, sounds like.

17:24 puredanger: *ns*

17:24 right?

17:24 cfleming: Say I have a user connection, and a tooling connection, for a particular REPL session

17:25 For the user connection, the user sends commands, and what I don't want to do is to have to parse what gets sent back

17:25 Since the remote process is async etc

17:26 puredanger: why not use the reader?

17:26 cfleming: I can use the tooling connection for completion etc, but to get the current ns of the user connection, I'd have to attempt to parse stdout on that connection, right?

17:26 puredanger: oh I think I see what you're saying

17:27 cfleming: The reader doesn't work well in the streaming model. The whole point of not having a req/resp is that they're not 1-1

17:28 gfredericks: cfleming: you don't use nrepl for this?

17:28 puredanger: btw, if you could drop these comments on the mailing list thread or the jira that would be helpful for rich to see

17:28 cfleming: puredanger: Sure, I will

17:28 gfredericks: Yeah, I do. But I'm going to have to support this new style REPL too for those that don't want nREPL.

17:29 gfredericks: yeah?

17:29 what are reasons people have for not wanting nrepl?

17:29 cfleming: gfredericks: https://gist.github.com/levand/b1012bb7bdb5fcc6486f

17:30 gfredericks: hmm

17:30 cfleming: gfredericks: Plus the datomic guys had a lot of problems with load-file, I'm not sure why - I don't know if they were sending very large files or what

17:31 hiredman: (why the heck would you use load-file?)

17:31 gfredericks: there was a crazy bug with middleware ordering until recently, could have caused any manner of problems

17:31 hiredman: load-file reads and executes

17:31 cfleming: I suspect there's some middle ground there, which IMO should be a simple framing protocol, because I think REPL interactions are fundamentally req/resp - I don't agree with Rich that they're fundamentally a streaming interaction

17:32 Bronsa: gah, I really don't like this new #object printing

17:32 cfleming: gfredericks: Maybe, but I think that the argument is often that nREPL is overly complicated, and I don't think anyone likes middleware very much.

17:32 hiredman: When I want to load a file?

17:32 hiredman: You need some way to do that.

17:33 hiredman: I must have missined some context

17:33 amalloy: Bronsa: how does it work? what's wrong with it?

17:33 cfleming: hiredman: require doesn't work over remote connections

17:33 hiredman: cfleming: sure

17:33 Bronsa: amalloy: http://sprunge.us/MRJP

17:34 hiredman: cfleming: I suspect the streaming interaction part is because of *out* and *err*

17:34 gfredericks: cfleming: nrepl + cursive isn't much more complex process-wise than new-raw-clojure-thing+cursive though

17:34 amalloy: Bronsa: and what's wrong with that?

17:34 puredanger: Bronsa: interested in feedback, don't think it's necessarily final

17:35 one that thing could still be changed (imo) is to make the new tagged-literal thing from read conditionals the default reader

17:35 Bronsa: puredanger: amalloy I understand why it's technically a better representation than #<..> but my eyes find it too noisy to parse as rapidly as the unreadable one

17:35 cfleming: hiredman: Sure, but you can stream out and err while having forms and values be req/resp

17:35 amalloy: Bronsa: that sounds like just a matter of practice though

17:35 the current one is not so great either, you've just seen it a lot

17:35 cfleming: gfredericks: If you take middleware out of the equation, I agree. Unfortunately I'm not the one you have to convince :)

17:36 puredanger: yeah, there's too many parens too ;)

17:36 Bronsa: amalloy: you're probably right, yes

17:36 nicferrier: has anyone had problems with the latest httpkit?

17:36 my servers won't start with a rather strange arity error.

17:36 brkpnt: how can i change the value of variable like (setf x *something*)

17:37 Bronsa: one advantage of the new "unreadable" printing is that you won't get `>` as the return value plus an "unable to resolve symbol" excecption

17:37 puredanger: cfleming: Rich will take your feedback seriously and sooner better

17:37 cfleming: puredanger: sure, is the JIRA the best place?

17:37 Bronsa: one disadvantage is that "no reader tag implemented for object" is not as direct as "unreadable form" imho

17:37 gfredericks: cfleming: roger

17:38 amalloy: brkpnt: most clojure values are immutable. you can't just setf stuff, you have to think functionally

17:38 puredanger: cfleming: either jira or mailing list

17:38 Bronsa: well that's where the default reader would help right?

17:38 Bronsa: puredanger: yup

17:38 puredanger: it would actually be read into a TaggedLiteral that had a tag and value

17:38 cfleming: gfredericks: I have other problems with nREPL - I think it tries to be too general. Trying to make it extensible is a mistake IMO.

17:39 gfredericks: cfleming: extensible which way?

17:39 cfleming: gfredericks: Although that's more or less the middleware argument in another form.

17:39 gfredericks: middlewares in particular?

17:39 middlewares are super difficult to develop; I've done things I'm not sure how I would do otherwise though

17:39 cfleming: gfredericks: Right, it seems like nREPL should execute forms, and perhaps load files, and not much more.

17:40 gfredericks: in particular github.com/gfredericks/debug-repl/

17:40 Bronsa: puredanger: uh, not sure i like that. might delay errors and hide the cause (even though I hardly if ever, see unreadable form exceptions other than in bad repl interactions)

17:41 gfredericks: puredanger: Bronsa: could also read by throwing "unreadable form" or so

17:41 cfleming: gfredericks: what about that requires middleware? Couldn't you just load the code like normal when the REPL starts?

17:41 gfredericks: cfleming: um oh man it's complicated

17:41 cfleming: I'm not even sure what you mean actually

17:41 cfleming: gfredericks: That's what I do with Cursive - it saves all the middleware/IDE version problems that Cider suffers from

17:42 gfredericks: From the readme, I'm not sure why that lib has to be middleware

17:42 gfredericks: cfleming: this is a special way to insert the repl in the middle of a function, with all the locals etc.

17:42 Bronsa: puredanger: i.e. (def x (map inc #<..>)) would return fine and complain about "taggedliteral cannot be cast to ISeq" or something among the line once x gets realized, and don't see the originating bad form either

17:43 gfredericks: cfleming: the thread executing the break! call just stops and waits for eval msgs, and the middleware diverts eval messages to that waiting thread

17:43 if you know of a simpler way to get that or similar behavior I would love to rewrite it :)

17:43 cfleming: gfredericks: I see. Yeah, that's pretty much impossible without something like that.

17:44 gfredericks: phew

17:44 pw4ever: hi, if I have several Clojure sexp forms in a text file, how can read them one by one using something like clojure.core/read or clojure.edn/read?

17:44 gfredericks: one thing I thought of is it could start up another nrepl server...which would be...great.

17:44 pw4ever: read appears to only read the first form from a PushbackReader

17:45 gfredericks: you can keep calling read, no?

17:46 pw4ever: @gfredericks wouldn't that keep on reading the first one? let me try using doseq

17:47 gfredericks: use repeatedly

17:48 amalloy: pw4ever: (let [reader (...)] (take 4 (repeatedly #(read reader))))

17:48 where of course you can do fancier stuff to get rid of the 4 literal

17:49 pw4ever: @amalloy thanks for the code snippet; I will give it a try

17:53 amalloy: indeed, "read" read subsequent forms (I thought it would only read the first one given the immutable pattern of Clojure data structs); one thing: reader requires "java.io.PushbackReader." and io/reader returns a BuferedReader

17:53 puredanger: Bronsa: no idea where that PAM change came from btw :)

17:53 pw4ever: so needs a (java.io.PushbackReader. (reader ..))

17:53 amalloy: mhm

17:56 Bronsa: puredanger: just don't talk to Rich about git add -p so I can keep hoping on seeing unrealated fixes in feature commits :P

17:57 puredanger: heh

18:06 {blake}: dnolen: I'm running Java version 1.8.0_25 when I get that "Error: Could not find or load main class clojure.main."

18:06 dnolen: {blake}: hrm ok, I have no good way to test Windows sadly

18:06 {blake}: dnolen: I did the quick-start under Mint 17.1, meanwhile. It's really helpful.

18:06 dnolen: {blake}: k cool

18:07 pw4ever`: for the record, loop/recur of "edn/read" works for me as follows: (let [r (->> the-file io/resource io/reader (#(java.io.PushbackReader. %)))] (loop [l (edn/read {:eof nil} r)] (when l (println l) (recur (edn/read {:eof nil} r)))))

18:07 the {:eof nil} in edn/read prevents EOF RuntimeException of being thrown

18:07 {blake}: dnolen: So, java is looking for clojure.main, which you have in the cljs.jar, but for whatever reason, java under Windows isn't finding that in the jar?

18:08 dnolen: {blake}: seems like, the AOTed JAR is produced via `lein uberjar clojure.main`

18:08 amalloy: pw4ever`: instead of that loop/recur, you can just write (take-while identity (repeatedly #(edn/read {:eof nil} r)))

18:08 note that both of these versions stop when they read a nil or false

18:09 pw4ever`: thanks @amalloy, that's definitely a more functional way to write it

18:09 {blake}: dnolen: From the Clojurescript root dir? So if I git cloned this: https://github.com/clojure/clojurescript and did the "lein uperjar clojure.main", I'd get the same cljs.jar?

18:12 dnolen: {blake}: that's right

18:13 {blake}: script/uberjar

18:13 is what you want to run

18:14 the_danko: cfleming greetings! do you have any links you may be able to point me to about how to add java to a standard lein clojure project in cursive?

18:14 cfleming i mean to java source files. to make it a mixed project.

18:16 cfleming: gfredericks: I think I'd use a debugger in that case, to be honest

18:17 the_danko: cfleming ok i just found this https://github.com/technomancy/leiningen/blob/master/doc/MIXED_PROJECTS.md

18:19 imanc_: so I have map that has {:x someval, :y somewal} and want to do : if x < 0: x = scr_width; if x > scr_width: x = 0; if y < 0: y = scr_height; if y > scr_height: y = 0.

18:19 is there a way to cleanly do that without a load of nested if-lets or assocs, etc.?

18:22 amalloy: imanc_: write a function that takes in the current x and scr-width, and returns a new x. you can reuse that same function for manipulating y

18:22 then (-> m (wrap :x width) (wrap :y height))

18:23 imanc_: amalloy: that's perfect. Thanks!

18:23 Mercwithamouth: with ragtime when creating new migration files i notice the format is year/month/date..then there are additional numbers. is there any logic to those extras?

18:24 i'm surprised they don't allow lein ragtime new 'table-name'

18:39 cfleming: the_danko: Sorry, I have to go, but that's what you need, right

18:39 the_danko: cfleming thanks!

18:40 cfleming have a good whatever time of day it is over there

18:40 cfleming: the_danko: Just about lunchtime :)

18:50 amalloy: justin_smith: note that in the last example of http://stackoverflow.com/a/28944449/625403, you should strictly speaking quote the x you're let-binding: (list 'let ['x (list 'quote x)] ...)

18:50 your version only works for values which self-evaluate

18:51 justin_smith: amalloy: yes, see the comments

18:51 I should edit it

18:52 amalloy: justin_smith: i don't see a resolution in the comments. neither version will really work with (Object.), or at least not portably, but my version fixes the issue with, eg, (range 5)

18:53 s/portably/within the vague spec of "things rich says you're supposed to be allowed to do"/

18:53 justin_smith: yeah, I didn't mean it was resolved in comments, more that it was something actively being discussed

18:54 I should probably take out the whole "construct a let statement" part and just say "can't be done in any sane manner"

18:54 amalloy: perhaps so. still, i wanted to make sure you saw why your version has problems when x is (range 5) - you're double-evaluating x, basically

18:56 fegi: Hi everybody... Is anyone here sucessfully working as a clojure programmer? How did you get to that point? I'm very curious, as that seems like something I'd want to do.

18:57 justin_smith: fegi: I knew a guy who snuck some clojure into his company's web stack and they were like "OK cool let's hire another Clojure guy then" but I don't think that's very generalizable.

18:59 amalloy: thanks for the heads up, definitely an oversight on my part

19:01 {blake}: dnolen: I don't know if this is helpful but I get a "The Main-Class specified does not exist within the jar" when I uberjar.

19:02 dnolen: {blake}: not particularly helpful as it doesn't tell me what I need to fix :)

19:02 and yes I get that too

19:04 fegi: justin_smith: that's good to hear :-). I was hanging out with a friend who works at amazon, and they are considering clojurescipt as an alternative for componentising(?) their web stuff.

19:05 {blake}: dnolen: Oh, okay. So that's not news. =P

19:05 justin_smith: fegi: also, if you hang out here and follow the mailing list (google group), stuff comes up occasionally

19:09 dnolen: {blake}: yeah I think Windows fix will have to come in a later release, held off on this one long enough

19:11 {blake}: dnolen: Yeah, I wouldn't hold anything up for it. I'll try on some other machines to see if it's just something funky about this Win7 installation.

19:25 gfredericks: cfleming: yeah a general debugger is definitely a better goal; do you know of any that are not editor-specific?

19:31 justin_smith: gfredericks: if you want to do things in pure jvm terms, there is jdb, which the emacs gdb tooling (gud) can use iirc.

19:31 I wouldn't expect anything user friendly, but I have solved weird bugs that way

19:32 gfredericks: there is also schmetterling which can show you the context where a stack trace occured, and show locals (but unlike jdb does not do step debugging)

19:34 gfredericks: so similar to debug-repl

19:34 justin_smith: yeah, inspired by debug-repl actually

19:34 gfredericks: the original one I imagine

19:34 justin_smith: yeah, we wanted something that wasn't editor specific

19:35 gfredericks: does jdb let you run code? just skimmed the docs

19:35 justin_smith: gfredericks: yeah, but it's all gonna be in jvm terms

19:35 gfredericks: debug-repl isn't editor-specific; mine isn't certainly

19:35 justin_smith: so it accepts a java-like syntax

19:36 gfredericks: it's just nrepl, which is how cfleming & I got on this topic

19:36 justin_smith: gfredericks: right, what I meant is that was why we started with debug-repl

19:36 gfredericks: ohgotcha

19:41 eben_: I need some help with midje and datomic…

19:43 dnolen: https://groups.google.com/forum/#!msg/clojurescript/fdT3f1HxJzM/rCbi7L1AI24J

19:45 nullptr: (inc dnolen)

19:45 lazybot: ⇒ 21

19:54 rhickey: ping cfleming

19:54 cfleming: ping

20:05 crazydiamond: Hi. Is there any full-automatic kind of SQL library? I.e. one able to create databases and tables, as well as migrations. Seems that Korma lacks that features http://ylamaki.com/blog/2013/06/30/rediscover-the-beauty-of-programming-with-clojure-and-korma/ this guy is doing it manually there

20:11 {blake}: crazydiamond: I don't think so. You do have access to straight SQL, of course.

20:12 crazydiamond: yep. I see Korma is doing two things at time - i.e. isolates us from SQL (different dialects), but also adds level of abstraction

20:13 may be it would be useful to have rather two separate libraries

20:21 gfredericks: honeysql is the normal approach for generating sql

20:21 justin_smith: crazydiamond: I see exactly one function that is different for different sql backends in the korma codebase

20:23 crazydiamond: justin_smith, so, sqlite3/postgres etc helpers are different?

20:23 justin_smith: no, it has a mysql version that is optional.

20:24 it's one function that exists for mysql

20:24 crazydiamond: ah

20:24 justin_smith: for "count"

20:24 crazydiamond: https://github.com/korma/Korma/blob/master/src/korma/sql/fns.clj#L45

20:24 reading the codebase, that is the only db specific thing I can find

20:25 crazydiamond: I remember... about 6 years ago I was exploring PHPMyAdmin and there was sth like "about 1000 rows"

20:25 i.e. approximate count

20:25 not exact one

20:25 it was so when using certain storage

20:26 justin_smith: oh, and a few things starting here https://github.com/korma/Korma/blob/master/src/korma/db.clj#L90

20:26 for defining the db spec per-backend specific

20:27 crazydiamond: aha

20:28 justin_smith: so maybe just enough to abstract out to it's own "sql adaptor" lib

21:02 wenshan: Hi all, I'm trying to solve a coding challenge in Clojure (The Frequency, given a set of values, determine the frequency of the signal https://www.codeeval.com/browse/168/). I think I'll need to implement something like Matlab's polyfit first? Any idea?

21:04 amalloy: i think you need to have some kind of idea what algorithm you will want to use, before you can ask useful questions about clojure

21:05 polyfit looks for polynomials anyway, so it would be a very bad fit for a trigonometric function like a sine wave even if it were easy to implement

21:27 wenshan: amalloy: thank you, I'm not sure what algorithm I should use. I tried to calculate the difference between each value, e.g. [2 2 4 5 4 2 2 4 5] => [0 2 1 -1 -2 0 2 1], then count the number of values between two peaks (negative -> positive), but it doesn't work well due to the noises. Any pointer?

21:27 justin_smith: wenshan: how about average distance between peaks, you have multiple cycles to work with

21:28 and over enough cycles the noise will be less and less of a factor

21:29 also, of course, you can interpolate the "real peak" between the sample points via curve fitting

21:29 but that gets more complex

21:32 wenshan: justin_smith: average distance is the approach I'm taking, but I don't know how to pick the peak from a list of differences like (this is calculated from the first sample input): (2 1 2 2 0 3 0 0 1 -1 1 -1 1 -1 -2 0 -3 0 -2 -3 -1 -3 -3 -2 -2 -2 0 -4 -2 -2 ...)

21:33 justin_smith: clearly the peaks are where you go from positive to negative in the difference list

21:33 and visa versa

21:34 the zeroes are mostly the noise (though you can expect zeroes near the peaks too)

21:35 wenshan: you can see that there are 3 positive to negative in (1 -1 1 -1 1 -1)

21:36 justin_smith: yes, that's also noise - I would look for eg - a traversal of ~5 in 5 samples followed by a traversal of ~-5 in the next 5

21:37 you may find it useful to measure groups of 5 samples to get a "smoothed" view

21:40 ,(map #(/ (apply + %) 5.0) (partition 5 1 [2 1 2 2 0 3 0 0 1 -1 1 -1 1 -1 -2 0 -3 0 -2 -3 -1 -3 -3 -2 -2 -2 0 -4 -2 -2]))

21:40 clojurebot: (1.4 1.6 1.4 1.0 0.8 ...)

21:40 justin_smith: anyway, the pattern is smoother that way, but the cycle length is unchanged (just phase shifted, which does not change the frequency at all)

21:42 wenshan: justin_smith: good idea, thanks a lot :)

21:43 justin_smith: another option is take various possible partitionings, and sum over their modulus, and keep the one that is largest

21:43 eg try taking groups of 50, and summing every 0 item, every 1, etc.

21:44 then see if the magnitudes are larger than groups of 40

21:44 or if they are larger than groups of 60

21:44 remember the frequency must be a multiple of 10, and the grouping with the highest peak magnitudes in the sum, is the correct frequency

21:45 the measurement would be (max sum value) - (min sum value) across the overlapped partitions

21:46 I hope that was coherent enough, I think I worded it poorly

21:47 celwell: Can't seem to (System/exit 0) when in 'lein ring server'. Getting "Not matching method: exit"

21:47 Any ideas?

21:47 justin_smith: that's bizarre

21:48 what's your jvm version?

21:50 celwell: Oh, I think I fixed it. It looks like it was because it was in a thread macro so it was adding an extra, unwanted, argument.

21:50 justin_smith: yeah, that would do it

21:58 wenshan: so I was talking about something like this, where 20 would be a parameter, and the whole thing would have to be normalized ##(apply (juxt max min) (apply map + (partition 20 [2 1 2 2 0 3 0 0 1 -1 1 -1 1 -1 -2 0 -3 0 -2 -3 -1 -3 -3 -2 -2 -2 0 -4 -2 -2])))

21:58 lazybot: ⇒ [3 -3]

22:00 justin_smith: actually, the normaliation could just be multiplying each number by n (when splitting into groups of n), but that seems wrong? easy enough to test I guess

22:40 benzap: hello, I was wondering how i could pull in this particular github project into clojure? https://github.com/mrniko/netty-socketio

22:41 i'm assuming it's hosted somewhere

22:41 do I pull in information from the pom.xml file?

22:42 scratch that

22:42 ... I want a socket.io client

22:42 mgaare: benzap: might try this dependency atom: [com.corundumstudio.socketio/netty-socketio "1.7.7"]

22:42 benzap: so something like this https://github.com/nkzawa/socket.io-client.java

22:43 mgaare: ah ok

22:43 so it's [groupId/artifactId "modelVersion"] ?

22:43 in the pom.xml file?

22:43 mgaare: yea

22:43 typically

22:47 benzap: thanks mgaare, that did the trick

23:00 So i'm having a hard time figuring out how to import the library now

23:00 given this pom file https://github.com/nkzawa/socket.io-client.java/blob/master/pom.xml

23:00 i've tried (import com.github.nkzawa.socket.io-client)

23:01 mgaare: benzap: you need to import specific classes

23:01 justin_smith: benzap: you have to specify a class to import

23:01 you can't just import a package

23:01 benzap: justin_smith: yeah, I just tried (import com.github.nkzawa.socket.io-client.IO)

23:02 do I have the right idea though?

23:02 justin_smith: yeah

23:02 for that form you need a quote

23:02 but with (:import ...) in the ns form you don't need to quote it

23:03 benzap: ah ok

23:03 justin_smith: import also accepts a list form if you need multiple classes from one package (com.whatever Foo Bar Baz)

23:04 benzap: turns out it was (import 'com.github.nkzawa.socketio.client.IO)

23:04 justin_smith: it's better to use :import in the ns form

23:04 unless you have some reason to use top level import

23:04 benzap: justin_smith: thanks, i'll probably end up using that

23:04 no no, I was just trying it in the repl

23:05 justin_smith: and you don't need the ' in that case

23:05 right

23:27 wenshan: justin_smith: just came back from lunch nap, thanks a lot.

23:30 wei_: why does the cljsjs/jquery package version (1.9.0-0) not match its extern version (1.9.1)? https://github.com/cljsjs/packages/blob/master/jquery/resources/cljsjs/common/jquery.ext.js

23:31 wenshan: justin_smith: applied (map #(/ (apply + %) 5.0) (partition 5 1 [...]) on the first sample input, it seems the positive to negative noises have been reduced to a point where the distances between peaks can be easily calculated

23:34 now I need to write some clojure to count the sign changes

23:36 wei_: for cljs, what’s a good way to set *print-fn* to nop in production?

23:42 benzap: so i'm having an issue accessing a public static interface Foo which is in a com.Bar namespace

23:44 so for example (import 'com.Bar), where the Bar class has methods taht refer to an internal public static interface called Foo

23:44 i've tried (reify Bar.Foo ...), or (reify Bar.Foo ...)

23:44 *(reify Bar/Foo)

23:46 justin_smith: benzap: Bar$FOO

23:47 err, Bar$Foo

23:47 also, you need to import Bar$Foo separately

23:47 because on a vm level it isn't really part of Bar

23:48 benzap: interesting

23:49 yeah, that did the trick, thanks

23:49 only problem is varargs, how do I structure my reified function?

23:49 justin_smith: varargs are just an array

23:49 benzap: hmm

23:50 oh woops, I forgot 'this'

23:50 yeah, that's it

23:50 clojurebot: Cool story bro.

23:50 benzap: thank you clojurebot

23:51 also justin_smith, thanks for the help

23:51 justin_smith: np

23:51 benzap: maybe i'll contribute back by wrapping this socket.io library into a nifty clojure library

23:51 (to the best of my abilities)

Logging service provided by n01se.net