#clojure log - Feb 10 2014

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

0:01 benkay: if anyone in here has some java experience I'd appreciate a bit of help reading something that's totally opaque to me: https://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/Utils.java#130 i get that we're stepping through a 4-byte-wide byte array and setting each byte individually but this hairy (0xFF & (val >> 24)) stuff is breaking my poor brain

0:03 akurilin2: Hey folks. Are there any standard library functions that would help me simulate an ORDER BY + DISTINCT ON? E.g. get the latest records of types a,b,c?

0:05 Actually I guess there's distinct, which is cool, let me figure out whether it uses the earlier or later entries in the sequence.

0:05 arrdem: akurilin2: so.. our core sort takes an optional comparison argument...

0:05 akurilin2: and yeah there's distinct...

0:05 ,(doc sort)

0:05 clojurebot: "([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."

0:07 akurilin2: arrdem: aah there's no distinct-by, sad.

0:07 arrdem: akurilin2: no, but there's group-by...

0:08 ,(source group-by)

0:08 clojurebot: Source not found\n

0:08 arrdem: damnit clojurebot

0:08 * arrdem googles

0:08 arrdem: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6514

0:09 akurilin2: No I got it, thanks, I've used it plenty before.

0:09 arrdem: yep. it's conj based.

0:09 so you're order safe to use first or last to select the first or last value to exhibit a key.

0:10 akurilin2: so it sounds like I'd have to sort, then group by, then map to get the first of each group, then basically take the vals

0:11 arrdem: yarp.

0:11 well.. map first over vals

0:11 akurilin2: oh yeah

0:20 arrdem: cool thank seems to work, had to dome some mental stretching there :P

0:21 arrdem: :D

0:27 jergason: are there any clojure git libraries?

0:27 arrdem: jergason: as in a Clojure git fs API?

0:27 jergason: so i want to manipulate a git repo - check out commits, list them, run git blame on files, ect

0:28 is there a library that can do this in pure clojure before I do a bunch of (sh) calls?

0:29 arrdem: $google github clojure git toolkit

0:29 lazybot: [heroku/heroku-buildpack-clojure · GitHub] https://github.com/heroku/heroku-buildpack-clojure

0:29 arrdem: I'm gonna guess not.

0:32 akurilin2: Working with libgit is not the most fun experience from what I hear.

0:32 Remember trying to use the Obj-C port, that was gross.

0:36 jergason: arrdem: yeah i'm pretty okay at googling stuff

0:36 arrdem: jergason: my appologies. you wouldn't belive the number of times I've answered someone's question like that.

0:37 jergason: np, i'm sure ill ask plenty of easily-googled questions :)

0:38 hrrrm, i might just use ruby or something then if this is just going to be a glorified shell script

0:38 turbofail: there's jgit

0:38 jergason: !

0:38 there is the noobness. i didn't even think of a java git lib

0:39 arrdem: 's ok. I didn't either :P

0:39 jergason: :)

0:39 arrdem: (inc turbofail) ;; the fail is with us today

0:39 lazybot: ⇒ 2

0:47 dacc: jergason: make us a nice clojure wrapper for it =)

0:48 jergason: i'm probably a few months away from being able to do that :)

0:49 turbofail: i feel like there was one already

0:50 hm. looks like there are several possibly half-assed ones floating around

0:53 on further inspection there is actually only one half-assed wrapper, the others are shelling out

0:53 arrdem: plz make not half assed one

1:09 muhoo: jgit sucks but is best i could find

1:17 jergason: does it suck for normal java reasons?

1:17 verbose etc

1:34 muhoo: slow, weird, verbose.

1:34 but, it works

1:37 benkay: ,(Integer/toBinaryString (long 0xd9b4bef9))

1:37 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3652501241>

1:37 benkay: what am i doing wrooooong

1:38 i just want four bytes representing that string to write into a socket and i can't figure this outtttt :(

1:39 muhoo: ,(Long/toBinaryString (long 0xd9b4bef9)) ; ??

1:39 lazybot: muhoo: Definitely not.

1:39 clojurebot: "11011001101101001011111011111001"

1:39 muhoo: benkay: ^

1:39 benkay: oh well derp

1:39 thanks, muhoo.

1:39 muhoo: lazybot: piss off

1:39 benkay: np

1:40 benkay: i have no java and clojure is my first lisp

1:40 just just wtf all the way down

1:40 muhoo: i feel ya

1:42 benkay: well, to represent that long.

1:45 muhoo: jergason: also, IIRC jgit is what eclipse uses internally for git, so it's a pretty safe bet for being maintained/bugfixed

2:02 benkay: so i want to stick ,0xd9 into a byte so that I can then send that out on a socket later, but this is the integer 217 which is too large for the java bytes (which go from -127 to 127). what am I conceptually missing in constructing this message?

2:02 the full 4-bytes i want to send is ,0xd9b4bef9

2:03 ,0xd9b4bef9

2:03 clojurebot: 3652501241

2:03 Cr8: ,(unchecked-byte 0xd9)

2:03 clojurebot: -39

2:03 benkay: unchecked-byte?

2:04 Cr8: JVM numbers are all unsigned, but you can get what you probably want by forcing an unchecked cast

2:04 benkay: ,(count (unchecked-byte 0xd9b4bef9))

2:04 clojurebot: #<UnsupportedOperationException java.lang.UnsupportedOperationException: count not supported on this type: Byte>

2:04 Cr8: that returns a byte, not a list of any time

2:04 ,(type (unchecked-byte 0xd9))

2:04 clojurebot: java.lang.Byte

2:04 benkay: yeah i see that now

2:05 Cr8: ,(into-array Byte/TYPE (map unchecked-byte [0xd9 0xb4 0xbe 0xf9]))

2:05 clojurebot: #<byte[] [B@843e34>

2:05 benkay: oh man

2:05 ,(vec (into-array Byte/TYPE (map unchecked-byte [0xd9 0xb4 0xbe 0xf9])))

2:05 clojurebot: [-39 -76 -66 -7]

2:05 benkay: groovy.

2:06 now i think i'm back at my "how do i see if this is going out over my socket as the correct hex" problem, but i think i'll leave that for tomorrow.

2:06 Cr8: https://github.com/apage43/hex

2:06 is a thing I did, mostly to use at the REPL

2:06 for stuff like that

2:07 benkay: ah neato.

2:07 that'll probably work for testing.

2:07 Cr8: ,(apply str (map #(format "%02x" %) (into-array Byte/TYPE (map unchecked-byte [0xd9 0xb4 0xbe 0xf9]))))

2:07 clojurebot: "d9b4bef9"

2:09 benkay: many thanks sir! I do believe that I have enough to run with from here.

2:09 for at least another few hours ;)

2:09 Cr8: have fun

2:12 sm0ke: here is a idea, given a set of functions which take a type of input and give a type of output, is there something which facilitates writing a generic function which given input and desired output types, chains functions automaticaly and optimally ?

2:12 output type*

2:12 dsrx: sm0ke: there's something like that for haskell

2:12 sm0ke: dsrx: remeber the name?

2:12 dsrx: trying to

2:14 sm0ke: djinn

2:14 sm0ke: it looks like a theorem prover, can that be employed?

2:16 hmm now that i think of it cant core.logic be used for this?

2:22 Cr8: ztellman's byte-streams does something like that

2:22 https://github.com/ztellman/byte-streams

2:23 dsrx: sm0ke: the curry-howard correspondence says that a program and its type are directly related to a proof and its proposition

2:23 ... or something like that

2:23 ztellman: sm0ke: all you need is a memoized lookup of a exhaustive graph traversal

2:23 nothing too fancy

2:23 dsrx: so it turns out theorem provers can generate a program given a type

2:24 (and a bunch of other programs)

2:28 and yeah, I imagine you could do something like that with core.logic

2:31 Cr8: now think about how you'd pull off these nifty cost hints https://github.com/ztellman/byte-streams/blob/master/src/byte_streams.clj#L613

2:35 sm0ke: ztellman: yea makes sense, wanted to void doing that

2:35 avoid*

2:36 as ideally i would have to write a shortest path algo

2:36 ztellman: sm0ke way simpler than anything else you just mentioned

2:36 sm0ke or you can just use def-conversion in byte-streams

2:36 it works on arbitrary types

2:37 sm0ke: ah thanks i will go though the code

2:39 would it make sense to seperate it out into a library?

2:40 or is it too trivial

2:40 ztellman: sm0ke maybe, haven't figured out any other real use cases besides the one I'm using it for

2:40 I can't generalize without multiple concrete use cases

3:08 sm0ke: more i look at the code in byte_streams, i see exactly what i wanted, conversions with a cost. very nice indeed

4:41 marianoguerra: hi! what's the best way to do the following without race conditions and as efficient as possible?

4:41 try to get a key from a map if it's there if not create it and return it

4:44 clgv: marianoguerra: this task occurs in memoization. you can read several variants over here: https://kotka.de/blog/2010/03/memoize_done_right.html

4:44 ambrosebs: marianoguerra: I assume you're talking about a mutable map?

4:45 clgv: marianoguerra: the above is assuming a clojure map

4:46 marianoguerra: I was thinking of an agent or an (atom {})

4:46 but checking what's the correct way

4:47 "Deutsche Bahn Version (or: „Delay is our core competence“)"

4:48 clgv: marianoguerra: check the atom version of memoize in the link above

4:48 yeah that's awesome ;)

4:48 marianoguerra: clgv: thanks!

4:48 opqdonut: to really get it right you will most probably need a lock

4:48 marianoguerra: will look into it

4:48 llasram: opqdonut: Drink more koolaid!

4:48 opqdonut: doing everything with one swap! is a very restricted model

4:48 llasram: ~guards

4:48 clojurebot: SEIZE HIM!

4:49 opqdonut: especially since swap! is implemented wrong[tm]

4:49 llasram: opqdonut: How so?

4:49 clgv: opqdonut: yep. depending on how complicated it gets a `ref` might become mandatory

4:49 opqdonut: llasram: it returns the new value and not the old

4:49 clgv: why is that wrong?

4:49 pyrtsa: opqdonut: It's pretty easy to add the implementation that returns the old value.

4:49 opqdonut: or well, both variants are useful but I find myself often wanting the version that returns the previous value

4:49 llasram: opqdonut: Which 99% of the time is what you want

4:49 pyrtsa: clgv: Otherwise you can't see which value you swapped out.

4:50 opqdonut: e.g. implementing a queue with (atom []) is impossible using the current swap!

4:50 clgv: pyrtsa: your functions sees it when you swap it ;)

4:50 opqdonut: well you don't see the authoritative previous value

4:50 llasram: Sure, but implementing a queue with (atom []) is a terrible idea anyway, because you can't pop off the first element. A stack maybe :-)

4:50 opqdonut: your function might get run multiple times

4:50 llasram: Yes -- that's the whole point

4:51 pyrtsa: clgv: You often need to do something with the old value after the swap.

4:51 opqdonut: llasram: you could pop the first element if swap! returned the previous value

4:51 pyrtsa: opqdonut: https://gist.github.com/pyrtsa/7871080

4:51 llasram: opqdonut: I meant vectors don't allow you to efficiently pop the first element

4:51 pyrtsa: clgv: Example in the above link. ^

4:51 opqdonut: llasram: well, persistent-queue or whatever it's called then

4:51 llasram: Sure

4:51 opqdonut: llasram: or let's just say stack instead of queue

4:52 pyrtsa: sure, one can always compare-and-set!

4:52 llasram: Either way -- the point of atoms (and refs) is that you trade the risk of deadlocks for the risk of retries

4:52 pyrtsa: There is a persisten queue in Clojure, use (clojure.lang.PersistentQueue/EMPTY) to make an empty one and (conj q x), (into q xs) etc to use it.

4:53 llasram: Nothing is stopping you from calling `locking`

4:54 opqdonut: llasram: sure

4:54 and as I said, you will most probably need a lock

4:55 pyrtsa: yes, of course, but it's immutable. if you want to use one of those to synchronize between threads, you can't just put it in an atom

4:55 llasram: Most of the rest of the Clojure community will just need to agree to disagree with you

4:55 :-)

4:55 opqdonut: (or well, you can, but then you need to implement the logic using compare-and-set!)

4:56 pyrtsa: opqdonut: But that's exactly what I'm saying!

4:56 ...although it's cleaner with my above definition of exchange!.

4:56 opqdonut: I'm just mildly irked by not having swap-done-right! in the core

4:56 aka exchange!

4:56 yeah

4:56 pyrtsa: Yeah. It ought to be there.

4:59 clgv: pyrtsa: well. why dont you suggest it in jira?

5:01 pyrtsa: clgv: Haven't used it before. As a matter of fact, I will!

5:09 ddellacosta: opqdonut: can't you just get the old value with add-watch? seems like an easy way to do what you want

5:14 llasram: ddellacosta: Getting the old value with add-watch is pretty roundabout, especially given how the implementation works

5:14 Whenever you swap!, you have both the old and the new value. It's just the choice of which to return

5:29 Anderkent]away: llasram: eh, can you expand on that? swap! doesn't really let you return the old value.

5:30 llasram: Anderkent: The implementation in terms of compare-and-swap! has both the old and new values in order to compare-and-swap!. It's an interface decision which (or both) to return

5:30 Anderkent: ah. yeah, I agree with that

5:31 llasram: That's all I meant. You missed some early discussion where opqdonut claimed the current behavior to be incorrect

5:31 Anderkent: tbh I wish it returned the old one - with the old one and the function you can recreate the new one, can't really go the other way around

5:32 llasram: It does seem to be a common request. I've found it useful once or twice. Maybe it'll be in core some day :-)

5:32 In the mean time, really is easy enough to cart around in a utility namespace

5:32 pyrtsa: I'm adding it to Jira today as soon as I have a minute of time for it.

5:34 Anderkent: I guess; though when we hit that problem with a coworker (implementing a queue-like structure; i.e. a map where one element was a queue) and he proposed using compare-and-set! directly (i.e. reimplementing swap!) I was kinda meh'd

5:34 we went with transactions in the end, I think

5:34 llasram: Anderkent: That's what you do -- use compare-and-swap! directly to implement a swap!-like function which gives you the old value

5:35 compare-and-swap! is a feature, not an implementation detail :-)

5:35 pyrtsa: Indeed!

5:36 Anderkent: mhm, seemed a bit too low level for my taste; having to do the looping and retries and presumably failing after N retries all seems a little messy

5:36 llasram: But that's exactly what swap! does. Minus the failing -- it just retries forever

5:36 pyrtsa: I don't think swap! fails after N retries.

5:36 Anderkent: yeash, I know. I just want it abstracted away! :P

5:37 llasram: Well abstract it into a function yourself and you're good :-)

5:47 borkdude: Clojure rocks, just saying.

5:48 dsrx: disagree, a much better language is hask... oh, not the permitted time of day

5:52 llasram: heh

6:07 TheBrayn: what would you recommend for someone who has not done much functional programming yet to learn clojure?

6:08 broquaint: TheBrayn: 4clojure.com might be a good place to start.

6:08 If you'd prefer to apply yourself to a book then I believe the Joy of Clojure may be apt.

6:11 AimHere: if you're using the 4clojure route, remember to 'watch' a bunch of people so you can check out their solutions to things, so that you might find a better or more idiomatic way of doing your clojuring.

6:13 klokbaske: hi there! newest version of lighttable gives me "No reader function for tag js" when I evaluate eg (def another-array #js [1 2 3])

6:13 TheBrayn: broquaint: 4clojure looks like fun, thanks

6:15 broquaint: np, enjoy :)

6:25 klokbaske: oh, seems I didn't run the latest version. 0.5.20 just told me it was, but little does it know ...

6:28 borkdude: TheBrayn Just pick any book and start doing clojure development

6:28 TheBrayn I like Clojure Programming and The Joy of Clojure

6:29 clgv: is there a way to produce exceptions with line number information of the input param of a macro?

6:31 borkdude: TheBrayn Here you can read something about the differences among clojure books: http://michielborkent.nl/comparingclojurebooks.html

6:41 llasram: clgv: I believe you can get that information from the metadata on &form

6:42 clgv: llasram: humm but how do I structure error handling within the macro?

6:42 llasram: Just throw an exception

6:43 That's what the core macros do. Well, although is also one reason for the amazing stack traces

6:44 bob2: such terrible stacktraces:(

6:44 clgv: llasram: my scenario is that I have a DSL where I specify a nested loop-recur so I have several parts of code that get inserted. loop initialization, recursion statement, "body"

6:44 llasram: ok

6:45 clgv: a concrete error is a name used in the "body" which does not occur among the loop variables or outer bindings

6:47 llasram: ^

6:48 llasram: I must be missing something -- what do you not get with just throwing an exception in the macro code reporting that error?

6:49 clgv: llasram: the line information in the inserted code snippet which I can access via &form or such

6:50 llasram: clgv: Well, add it? :-) Check out clojure.core/assert-args maybe

6:51 clgv: llasram: thats the question how to do that. I have a look

6:52 Anderkent: I'm still not clear on whether you want the line to be the line in the macro that hit the failed assertion, or the line in the code that callse the macro

6:53 clgv: e.g. (my-macro (let [x (* y y)] (conj res x))) if "res" is not defined in the generated surrounding context where that body is put, I want the line information of the expression using "res"

6:55 nano-: Is it possible to run Clojure under any of the JDK8 compact profiles?

6:56 (building and trying is ofc one solution, but asking is probably a bit faster)

7:00 Anderkent: compact2 might work? dunno, just looking at the packages

7:00 of course all java-using libs you depend on would also have to run on it

7:00 clgv: llasram: the assert-args approach wont work

7:01 llasram: Oh?

7:03 clgv: llasram: e.g. (my-macro (let [x (* y y)] (conj res x))) is put into some loop-recur environment. now I get an exception for an unknown "res" but there is no line information associated except the one of the macro

7:03 but without a macro I'd get the line information of (conj res x)

7:05 llasram: Right. In your macro you'll need yourself to detect the problem, grab the :line metadata (in this case of the (conj res x) form), and throw an exception mentioning that line

7:05 Or, wait

7:05 clgv: well that's a huge effort then

7:06 llasram: Why does it not work to just expand to code mentioning `res`, then let the compiler throw a normal exception when `res` is undefined?

7:07 clgv: llasram: oh wait. you are right. seems it was only the error during macro expansion before where no appropriate line information was present

7:08 llasram: Awesome

7:11 clgv: thx :D

7:18 llasram: only the metadata on the first line of the map that I pass to the macro has a line number that is off by one

7:18 that's weird

7:23 llasram: within a map which is a macro parameter only lists get metadata?

7:25 llasram: clgv: I haven't fiddled with it enough to say off the top of my head. Would need to dig into LispReader.java

7:26 clgv: llasram: when printing with *print-meta* true it seems like that

7:30 so with the current state I'd need to use lists for let-like bindings to get the correct line metadata. :/

7:31 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L7273

7:33 Anderkent: clgv: I think only lists get line numbers in general I'm afraid

7:33 clgv: it's been a huge pain for me in cloverage

7:34 clgv: Anderkent: and probably no plans on changing that?

7:34 Anderkent: clgv: you could possibly try to pull out the line number of the wrapping form, then read the source of the wrapping function, then manually corellate forms to lines

7:35 clgv: Anderkent: I'd add it to all persistent data structure literals and symbols

7:35 Anderkent: if you ever do, give me a ping, I could use it :D

7:35 clgv: that'd be nice, wouldn't it

7:35 maybe tools.reader does it? not sure

7:35 clgv: Anderkent: you didn't create a jira ticket I can vote on? ;)

7:35 llasram: I believe tools.reader gives you line information for all IObjs

7:35 Anderkent: nope:P

7:35 llasram: Not that that helps clgv, but might help Anderkent

7:36 Anderkent: Hah, I need to type faster :-)

7:36 clgv: well, to have that line meta only on lists is probably an optimization I guess

7:40 mskou72: hi

7:41 There's a lot of outdated docs (for 1.2 and 1.3) online. Where should a newbie go for docs and examples?

7:42 llasram: mskou72: 1.3 is OK. The changes since 1.3 have largely been incremental additions of new features

7:43 For functions which exist in 1.3 (the vast majority), clojuredocs.org is still an excellent resource

7:43 TheBrayn: https://gist.github.com/anonymous/8915135 this outputs ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn my-stuff.core/eval1364/rec--1365 (form-init2646726723610872721.clj:5), why?

7:43 it should emulate nth just with recursion

7:43 llasram: mskou72: For newer stuff and more detail, there are some good guides on http://clojure-doc.org/

7:44 mskou72: If you're into books, a new edition of /Joy of Clojure/ should be out any day now, and an advance edition is available now

7:44 mskou72: Ok, thanks :-)

7:45 llasram: TheBrayn: `((if ...))` -- you are calling the result of the `if` as a function

7:46 TheBrayn: oh I thought that was the function body

7:47 llasram: TheBrayn: Also note that Clojure doesn't automatically make functions tail-recursive, so this implementation will use a new stack frame for each recursion

7:47 TheBrayn: ok

7:48 llasram: You can fix that by calling `recur` in tail position instead of re-calling the recursive function by name

7:48 TheBrayn: cool, thanks

7:49 I ofcourse made this much more complicated than needed but it's a good excercise nonetheless

7:59 sm0ke: whats the right way to transform maps in clojure

7:59 (into {} (map ... is ugly

8:01 llasram: sm0ke: A `map-vals` utility function is a fairly common solution

8:04 sm0ke: yea, probly should do that

8:05 jowag: ,wat

8:05 clojurebot: eval service is offline

8:05 jowag: I am very sorry

8:05 llasram: ,1

8:05 clojurebot: eval service is offline

8:05 llasram: Huh

8:05 sm0ke: does a closure over a transient also creates a copy?

8:06 llasram: sm0ke: It holds a reference to the transient, if that's what you mean.

8:06 sm0ke: llasram: yes?

8:06 jowag: ##foo

8:06 daGrevis: is there a fn that would allow me to get nth elem from a seq and modified seq without that nth elem?

8:06 sm0ke: llasram: in case of immutable a copy is made right

8:07 llasram: No

8:07 Always references

8:07 sm0ke: hmm

8:07 really?

8:07 wouldnt that defeat the purpose of closures

8:07 llasram: The immutable types work by disallowing mutation, and returning structure-sharing copies on modification

8:07 TheBrayn: daGrevis: of course

8:07 TEttinger: daGrevis, like pop but with an index?

8:07 sm0ke: llasram: makes sense

8:08 clgv: "ClassCastException clojure.core.Vec cannot be cast to clojure.lang.IEditableCollection clojure.core/transient" - I thought I had a vector there. what is c.c.Vec?

8:08 sm0ke: if closures are internally class instances thats how it should work

8:08 hmm now that is think of it i am scared

8:08 llasram: ?

8:09 sm0ke: so many places i used partial functions in my code without worrying about it

8:09 jowag: so, where do I report a bug in clojurebot?

8:09 llasram: daGrevis: Not that I'm aware of. Maybe with zippers? It's difficult to do without mutation

8:09 sm0ke: What are you worried about?

8:09 sm0ke: llasram: that the values i closed over were mutable

8:10 crap!

8:10 llasram: Well, are they? :-)

8:10 jowag: I believe hiredman is the person operating clojurebot

8:10 TheBrayn: why not just return a tuple of the nth element + concat of take and take-last?

8:11 jowag: llasram: thanks

8:11 llasram: jowag: https://github.com/hiredman/clojurebot

8:11 daGrevis: ,(nth 3 [1 2 3 4 5])

8:11 clojurebot: eval service is offline

8:11 daGrevis: ,(pop 3 [1 2 3 4 5])

8:11 clojurebot: eval service is offline

8:12 TEttinger: ##(pop 3 [1 2 3 4 5])

8:12 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: core$pop

8:12 daGrevis: TEttinger, kike pop with index, y

8:12 llasram: TheBrayn: You can, but the new sequence is actually a nested collection of references to the original sequence

8:12 TEttinger: ##(pop [1 2 3 4 5])

8:12 lazybot: ⇒ [1 2 3 4]

8:12 daGrevis: ok, lets start from the beginning. i have a vector

8:13 and i want to divide it in three parts

8:13 llasram: TheBrayn: If you keep doing that without fulling realizing the seqs, you'll just end up getting a deeper and deeper nesting

8:13 TEttinger: like partition or split?

8:13 daGrevis: [half of it] middle element [other half]

8:13 TEttinger: ^ daGrevis

8:14 ah ok

8:14 Anderkent: llasram: tools reader would be nice, but I'm currently considering hooking into clojure.core/load-lib; I suppose I could hook in and replace RT/load with tools.reader/read followed by eval

8:14 but that feels scary

8:15 clgv: ,(type (vec (range 10)))

8:15 clojurebot: eval service is offline

8:15 clgv: :/

8:15 &(type (vec (range 10)))

8:15 lazybot: ⇒ clojure.lang.PersistentVector

8:15 TEttinger: ##(let [midpoint (fn [idx coll] [(take idx coll) (nth coll idx) (drop (inc idx) coll)])](midpoint 3 [1 2 3 4 5]))

8:15 lazybot: ⇒ [(1 2 3) 4 (5)]

8:15 daGrevis: i got middle index using quot. i can get it as elem using nth. no idea how can i get vector as first and second part

8:15 Anderkent: &(type (vec (int-array (range 10))))

8:15 lazybot: ⇒ clojure.lang.PersistentVector

8:16 TEttinger: ##(let [midpoint (fn [idx coll] [(vec (take idx coll)) (nth coll idx) (vec (drop (inc idx) coll))])](midpoint 3 [1 2 3 4 5]))

8:16 lazybot: ⇒ [[1 2 3] 4 [5]]

8:16 daGrevis: TEttinger, correct answer should be [(1 2) 3 (4 5)]

8:16 Anderkent: daGrevis: 1 indexing!?

8:16 daGrevis: Anderkent, ?

8:17 Anderkent: daGrevis: (midpoint 3 [1 2 3 4 5]) should surely give you 4?

8:17 TEttinger: no... the index for 4 is 3. unless you want to split by value

8:17 Anderkent: oh

8:18 TEttinger: ##(nth [1 2 3 4 5] 3)

8:18 daGrevis: i know! i can use split-at 2 coll and then rest on second elem

8:18 lazybot: ⇒ 4

8:18 TEttinger: sure, you'd just need to restructure it

8:20 also, the way split-by is implemented is exactly how I did it

8:21 daGrevis: cool ^^

8:22 TEttinger: wait do you want the middle element to only be in the center? like balanced middle?

8:24 ##(let [midpoint (fn [coll] (let [idx (quot (count coll) 2)] [(vec (take idx coll)) (nth coll idx) (vec (drop (inc idx) coll))]))](midpoint [1 2 3 4 5 6 7]))

8:24 lazybot: ⇒ [[1 2 3] 4 [5 6 7]]

8:25 Anderkent: not sure about that, doesnt handle even collections well

8:25 the one with an explicit index does what you'd expect every time :P

8:26 daGrevis: TEttinger, yes, balanced middle

8:26 TEttinger: Anderkent, finding the exact center of an even-count collection isn't defined anyway right?

8:27 daGrevis: do clojure programs tend to call functions get-foo?

8:27 do clojure programs tend to call functions get-foo ?

8:27 Anderkent: TEttinger: yeah, that's why I'd rather have something that does something well defined for every input :P I'm just nitpicking at this point, I guess.

8:27 TEttinger: kinda

8:27 Anderkent: sorry :P

8:27 TEttinger: it's fine

8:28 daGrevis, people tend to use dashes in names, but single-word names are preferred when there's a good word for it

8:28 partition vs. cutAtIntervals

8:33 pyrtsa: Any idea why vectors, sets and maps aren't defining clojure.lang.ISeq? The interface itself (first/next/more/cons) would be easy to implement, of course not retuning the original type.

8:33 s/defining/implementing/

8:37 Or, in other words, what't the rationale of having `(seq? [])` return false?

8:37 Anderkent: pyrtsa: not sure if ISeq promises constant time next(), but if so that'd disqualify vectors

8:38 pyrtsa: Oh? Because of O(log32(N))?

8:38 Anderkent: hm, well, I guess you can make a wrapper vector that'd just translate every access to n+1

8:39 so I guess that's not strictly true.

8:39 pyrtsa: FWIW, (seq xs) is defined for vectors, as well as (first xs), (next xs), (cons xs).

8:39 minikomi: ##((fn midpoint [idx v] (let [h (subvec v 0 idx) t (subvec v idx)] [h (first t) (subvec t 1)])) 5 (vec (range 15))) ; using subvec might be quicker?

8:39 lazybot: ⇒ [[0 1 2 3 4] 5 [6 7 8 9 10 11 12 13 14]]

8:40 pyrtsa: I mean, (cons x xs).

8:40 Anderkent: pyrtsa: seq first next on vectors will convert it to a seq first, I think?

8:40 pyrtsa: Sure. But the conversion is shallow, of course.

8:43 clgv: pyrtsa: I think the relevant distinction here is between Seq and Seqable

8:43 TEttinger: ##(seq? [])

8:43 lazybot: ⇒ false

8:44 clgv: pyrtsa: vector, map, set are no Seq but can be turned into one by using `seq`

8:44 pyrtsa: But why such distinction? I know about clojure.core.incubator/seqable?, and to be honest, its definition creeps me somewhat. :)

8:48 clgv: well you can ask the question the other way round why should they implement ISeq? I am not sure if any of the books I read explained the reasons therefore in details

8:49 Anderkent: it seems a useful thing to know, whether your collection is a seq or a different data type - it changes what things like conj do

8:49 clgv: but it is pretty consistent way of marking sequences that do not need any conversion to be used by sequence functions and those data structures which need to be turned into a seq first

8:49 Anderkent: if you don't care, you can just (seq thing) and know it's a seq now.

8:50 pyrtsa: Nod.

8:50 clgv: probably JVM is a reason as well, since eah specific class knows best how its most efficient sequence implementation has to look like

8:51 circ-user-HInXe: nick ajs

8:51 clgv: ^^ as a reason for Sequable

8:54 pyrtsa: Looking back at the code I've written, there seem to be two uses for `seqable?`: 1) to verify early (as a :pre condition) if an argument is valid, and 2) to make a function behave differently for Seqables (many values) and non-Seqables (one value).

8:55 clgv: pyrtsa: the one-value case is the one I encountered often when visualizing data

8:56 it's the case where you'd kill for (atomar? x) to return true for non-collections/sequences ...

8:56 Anderkent: I never needed sequable?, but I needed list? that works; that turns out to be seq?

8:56 pyrtsa: clgv: `atomar?` meaning `(complement seqable?)`, you mean?

8:59 blrm: join #robottelo

9:00 sorry, mistype :)

9:00 clgv: pyrtsa: returning true for single values so to say as oposed to data structures with multiple values ;)

9:00 list? and vector? are often handy for macros

9:01 pyrtsa: Yeah, that's what the above is.

9:01 I use vector? a lot in macros.

9:01 clgv: does seqable? return true for seqs?

9:01 Anderkent: clgv: depends on how you implement it

9:01 pyrtsa: It should.

9:01 Anderkent: clgv: my preferred implementation would be ,(try (seq x) true (catch IllegalArg... false)) :P

9:01 pyrtsa: clgv: It does.

9:01 clgv: Anderkent: yeah I meant the mentioned implementation ;)

9:02 pyrtsa: ,(clojure.core.incubator/seqable? (seq '(1 2 3)))

9:02 clojurebot: eval service is offline

9:02 pyrtsa: Oh.

9:02 Anderkent: &(clojure.core.incubator/sequable? (seq '(1 2 3)))

9:02 lazybot: java.lang.RuntimeException: No such var: clojure.core.incubator/sequable?

9:02 Anderkent: oh well

9:02 clgv: &(require 'clojure.core.incubator)

9:02 lazybot: ⇒ nil

9:03 clgv: &(clojure.core.incubator/sequable? (seq '(1 2 3)))

9:03 lazybot: java.lang.RuntimeException: No such var: clojure.core.incubator/sequable?

9:03 pyrtsa: https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L83-92

9:03 clgv: old version ;)

9:03 cleatoma: &(clojure.core.incubator/sequable? (seq '(1 2 3)))

9:03 lazybot: java.lang.RuntimeException: No such var: clojure.core.incubator/sequable?

9:03 cleatoma: Oops

9:03 &(clojure.core.incubator/seqable? (seq '(1 2 3)))

9:03 lazybot: ⇒ true

9:04 Anderkent: is there a way of making google include the ? in 'list?'. Verbatim doesnt do it

9:04 I remember there was some issue with list?, where the reader could construct a list that wasnt a list?

9:04 but can't remember the details

9:05 scape_: ,(byte 129)

9:05 clojurebot: eval service is offline

9:05 llasram: Anderkent: Hmm. I don't remember the reader constructing non-list? sequences, but you can certainly e.g. return one from a macro just fine

9:09 Anderkent: hm, maybe I'm misremembering. Can't find it now ;/

9:11 daGrevis: naive implementation of quicksort https://gist.github.com/daGrevis/8862352

9:26 scape_: ,(byte 129)

9:26 clojurebot: eval service is offline

9:27 Anderkent: scape_: it'll throw an exception afaik

9:27 &(byte 129)

9:27 lazybot: java.lang.IllegalArgumentException: Value out of range for byte: 129

9:27 scape_: why do I see (byte) 129 in java?

9:28 http://stackoverflow.com/a/12471677/1298523

9:28 Anderkent: &(unchecked-byte 129)

9:28 lazybot: ⇒ -127

9:28 Anderkent: is what you want, I suppose

9:28 scape_: oh

9:28 they're signed? I know so little about bytes :-\

9:28 Anderkent: everything's signed in java AFAIK

9:29 scape_: thx let me work with that, it's supposed to be -127 too, so that must be it

9:49 stuartsierra: Many Java APIs return ints to represent bytes.

9:51 gfredericks: stuartsierra: do you think that's because of signedness issues or because ints are more first-class in the bytecode?

9:52 stuartsierra: dunno

9:52 Anderkent: I'd think signedness; let the compiler worry about the byte code :P

9:52 scape_: I was confused because this is a typecast I found in a java example: (byte) 129;

9:55 Anderkent: when you're working with a network protocol that's based on unsigned bytes, you probably want your constants to be positive; casting with (byte) just chops off the high bytes, so the bit pattern shuold be the same

9:56 &(bit-and (int (unchecked-byte 127)) 0xff)

9:56 lazybot: ⇒ 127

9:56 evantravers: esh

9:57 scape_: it's curious why websockets were designed the way they were-- the entire bit masking concept seems silly, but I sort of understand why they set the frames up the way they did-- bc javascript is not threaded I assume

9:57 Anderkent: obviously 127 was a bad example

9:57 gfredericks: ,[(byte 127) (byte 278)]

9:57 clojurebot: eval service is offline

9:57 gfredericks: &[(byte 127) (byte 278)]

9:57 lazybot: java.lang.IllegalArgumentException: Value out of range for byte: 278

9:57 gfredericks: &[(unchecked-byte 127) (unchecked-byte 278)]

9:57 lazybot: ⇒ [127 22]

9:58 gfredericks: I'm bad at this

9:58 &[(unchecked-byte 129) (unchecked-byte 278)]

9:58 lazybot: ⇒ [-127 22]

9:58 Anderkent: not sure where you're going

9:59 gfredericks: I'm done going there and it wasn't worth the effort

9:59 Anderkent: haha :D

9:59 scape_: hah

9:59 gfredericks: I was confirming to myself that the sign of the output was just related to the 8th bit, not any higher bits

9:59 Anderkent: obviously if you get n > 255 then no magic will make it work with a sign byte

10:00 clgv: two-complement ;)

10:37 &(transient (vector-of :int))

10:37 lazybot: java.lang.ClassCastException: clojure.core.Vec cannot be cast to clojure.lang.IEditableCollection

10:37 clgv: will that be fixed?

10:38 Anderkent: eventually probably?

10:38 http://dev.clojure.org/jira/browse/CLJ-787

10:39 hm, not sure if that's exactly the same thing

10:39 but it's similar enough

10:39 Marc_: auth

10:40 Guest43154: ?

10:40 clgv: Anderkent: at least it is vetted

10:41 TheBrayn: what was the function called that took multiple functions as an argument and applied them to a value?

10:41 AimHere: juxt?

10:41 clojurebot: juxt is completely uncontroversial in its splendour

10:42 Anderkent: &((juxt inc dec) 2)

10:42 lazybot: ⇒ [3 1]

10:43 TheBrayn: like: (<func> f g k x) which does (f (g (k x)))

10:43 AimHere: That sounds more like comp

10:43 TheBrayn: yeah that's what I meant, thanks

10:44 clgv: &((comp dec inc) 0)

10:44 lazybot: ⇒ 0

10:44 Anderkent: #wastingcycles

10:44 :P

10:44 TheBrayn: #yolo

10:44 AimHere: Maybe the compiler optimized away the inc/dec

10:44 gfredericks: &((apply comp (repeat 1000000 inc)) 42)

10:45 clgv: AimHere: very unlikely

10:45 lazybot: Execution Timed Out!

10:45 gfredericks: &((apply comp (repeat 100000 inc)) 42)

10:45 lazybot: ⇒ 100042

10:46 AimHere: ,((apply juxt (repeat 100000 inc)) 42)

10:46 clojurebot: [43 43 43 43 43 ...]

10:49 luxbock: anyone able to point out what I'm doing wrong with the following Instaparse: https://gist.github.com/luxbock/8918050

10:50 I keep running into this same error with the expected parentheses "(" at the end of the file

10:52 MarcFromNYC: can someone tell me what's wrong with this macro:

10:52 (defmacro foo [x] `(let [y# (map inc x)] (prn ~@y#)))

10:52 Results in CompilerException java.lang.RuntimeException: Unable to resolve symbol: y# in this context

10:53 michaniskin: MarcFromNYC: why do you unquote y#?

10:53 tim____: MarcFromNYC: you don't need to unquote a auto generated sym

10:53 AimHere: Isn't that because you have an unquoted y# there?

10:53 MarcFromNYC: i want to splice it in

10:53 Anderkent: MarcFromNYC: you splice things that are calculated in the macro, not things that are in the code that the macro generates

10:53 MarcFromNYC: this is a simple case, i could apply in this case, but what if prn were a macro instead.

10:54 Anderkent: MarcFromNYC: you can't splice things that come form runtime, you don't know what could be inside x

10:54 unless it's a constant list/vector, in which case you can do

10:55 (defmacro foo [x] (let [y (map inc x)] `(prn ~@y)))

10:55 MarcFromNYC: Anderkent: thx. i'll try that.

10:58 jonathanj: ,(help juxt)

10:58 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(NO_SOURCE_PATH:0:0)>

10:58 Anderkent: luxbock: try running with :total true and make sure it's what oyu'd expect?

10:58 Also I get different errors with the gist you posted (Expected "\"")

11:00 luxbock: running it with :total true gives me: [:project-alist [:projects]] so I guess I'm doing multiple things wrong

11:00 I think I need to spend some more time trying to understand how context free grammars work to begin with

11:02 I'm trying to capture 'name' 'kw' and 'val'

11:02 Anderkent: luxbock: for me it fails on the name, since you eat the closing double quote in your regex

11:02 luxbock: ah yeah

11:02 Anderkent: luxbock: you should be really careful about using regexes in instaparse; they don't backtrack

11:04 luxbock: yeah I think I understand what I was doing wrong now

11:07 Anderkent: luxbock: yeah getting them right can be a little tricky - took me at least a day to make https://github.com/JacekLach/doctest/blob/master/resources/doctest/doctest.grammar work :P

11:09 luxbock: yeah for me this is a simplified case as the actual config can contain comments and other expressions before and after

11:10 doesn't seem like there's any easier way though

11:12 scape_: if anyone is savvy with websockets, I'm trying to replicate this but am having a hard time: http://stackoverflow.com/questions/8125507/how-can-i-send-and-receive-websocket-messages-on-the-server-side/12471677#12471677 with this: https://gist.github.com/viperscape/8918565

11:15 am getting array oob :-\

11:19 Anderkent: scape_: inputStream.read() gives you an int, not a byte. Why do you cast mlen?

11:20 arrdem: ,(println "arrdem: ping") ;; testing sauron-mode

11:20 clojurebot: arrdem: ping\n

11:20 Anderkent: wait, are you trying the writing or the reading

11:20 scape_: decode/read right now. and your right, it does

11:20 the java example on that SO post is so-so

11:21 Anderkent: also no need to do the (unchecked-byte 127), you can give an int (0xff) to bit-and

11:22 scape_: ,0xff

11:22 clojurebot: 255

11:22 Anderkent: oups

11:22 my bad :P

11:22 scape_: :D

11:23 Anderkent: also I misread, your mlen corresponds to rLength in the code, not len?

11:23 *in the java code

11:23 scape_: yes, the pseudo code above it, or the python and javascript below might be easier to read.

11:24 mlen is not the right name for it, i should rename that to be honest

11:24 but the purpose is to determine the mask start position

11:25 the error is somewhere in the loop i believe

11:25 Anderkent: scape_: what's the type of data? byte array?

11:25 scape_: byte array

11:27 amalloy: scape_: why are you implementing this yourself at all? it sounds like just a websocket protocol implementation, and those exist in clojure already

11:28 scape_: bit of a learning thing, but also I don't know of a clojure websocket library-- it's all from netty from what I've seen; I was interested in integrating ws into my socket server. I'm just about there

11:29 Anderkent: think I figured it out :)

11:29 Anderkent: scape_: oh, what was it?

11:29 off by one in the array length?

11:29 scape_: I read the buffer at a fixed size and didn't resize the array

11:29 :D

11:30 Anderkent: ah

11:30 scape_: so it's passing garbage after the content

11:31 Anderkent: right, so pass the length of data or trim the aray; I'd also consider using amap instead of manually looping

11:31 amap / areduce are so nice

11:31 amalloy: scape_: there's a websocket client/server in aleph, and http-kit has one too, though i haven't used that one

11:31 scape_: i'll look in to that, yea the loop is ugly but wanted to figure it out first

11:31 both use netty i believe

11:32 amalloy: why is that a problem?

11:32 scape_: i'm not against netty, just that I had something for sockets already-- now I have it accepting both raw and websocket clients simultaneously, kinda slick I think

11:33 mikerod: If a fn takes code (as a data structure) and wants to return a callable fn that has that code embedded within; is the only way to do this with an eval?

11:33 (not using a macro)

11:34 Anderkent: mikerod: yeah, if oyu take code as data you will have to eval it somewhere

11:34 amalloy: mikerod: yeah, but like...that's generally evil

11:34 mikerod: (defn i-take-code [s-expr] (fn [x y z]

11:34 (s-expr)))

11:34 Anderkent: that's what I was thinking

11:34 amalloy: I figured...

11:34 amalloy: it's hard to imagine that being a good idea, really. either it should be a macro, or it should take a function instead of an expression

11:37 Anderkent: scape_: untested, but might plausibly work: https://www.refheap.com/35945

11:37 I'd say 50-50 that it works as is :P

11:38 mye: Hi. Is an infinite core.async (go (loop ... GC'd when the channel it returns is closed?

11:39 Anderkent: mye: no, the writes will just start returning false afaik

11:40 amalloy: Anderkent: i think his english misled you: he means "when is the channel it returns closed?"

11:41 oh

11:41 mye: Anderkent: do you mean 'reads'? Can a go block read from the channel it returns?

11:41 amalloy: no he didn't. sorry, too early for me

11:41 Anderkent: is it? I understood 'will a (go (loop ...)) block automaticall stop and GC when its channel is closed

11:41 mye: amalloy: mostly trying to figure out how not to leak an unlimited number of (go)

11:42 Anderkent: mye: ah, sorry; I misunderstood too. I forgot go blocks return channels

11:43 mye: I'd expect it to collect eventually after it writes a value to the channel it returned. I don't think you have to read it for it to clean itself up, but not sure there.

11:44 [I was thinking of a (go (loop (>! some-third-channel a-value))), in which case you have to look at the result of your write to know if your channel was closed and you should exit]

11:44 mikeyg6754: Hello, I'm working on processing a POST request with liberator. I am also using http-kit and compojure, when I get the response the body is: :body #<BytesInputStream BytesInputStream[len=8897]>. I'm not sure how to get :body as a map.

11:45 mye: My design problem is a service abstraction that keeps taking requests from its queue. To do that I let a (go) spin on the service queue and spawn other (go)'s that handle the requests

11:45 stuartsierra: Go blocks should be GC'd when they are no longer reachable, such as blocked on a channel which has been GC'd. Anything else is a bug.

11:45 chronno: mye: according to a comment from tbaldridge (https://groups.google.com/forum/#!topic/clojure/X6JoXczcRYw) all the go blocks get GC'ed when the channel is

11:45 Anderkent: mikerod: is your request content-type 'application/x-www-form-urlencoded' or something like that?

11:51 mikeyg6754: Anderkent: tried changing the content type. That didn't work.

11:52 Anderkent: mikeyg6754: Hm. Weird, I think there's a ring middleware that handles form-encoded bodies and puts that into params

11:52 mikeyg6754: Anderkent: I have wrap-params and wrap-file-info currently

11:55 Anderkent: mikeyg6754: other than double-checking your content type, no idea. wrap-params should definitely consume the body and assoc :form-params and :params

11:55 see https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/params.clj

11:56 mikeyg6754: Anderkent: hmmm, maybe it's something http-kit is doing. This is my first time working with it.

11:57 no7hing: anybody tried accessing a scala Tuple2 from clojure?

11:57 (._1 tuple) should work

11:57 Anderkent: mikeyg6754: I'd open the ring jar in <editor-of-choice> and add printouts in relevant functions; see if the middleware is being called at all and if so why it's not doingX

11:58 ptcek: Hello, I am trying to fetch lazily a resultset from a database using clojure.java.jdbc to process huge dataset. I tried to (take 10 (query ...)) but it loads the whole set, even after setting :fetch-size. Anyone know what am I doing wrong? Details here: http://pastebin.com/4XnsEcqE

11:58 mikeyg6754: Anderkent: Thanks, I appreciate your help!

12:00 Anderkent: ptcek: query takes a :result-set-fn function that runs over the entire result set, and is vec / doallb y default

12:00 ptcek: you probably want to supply (parital take 10) as :result-set-fn so that you only get 10 results?

12:01 ptcek: Anderkent: I tried exactly that with this error: SQLRecoverableException Closed Resultset: next oracle.jdbc.driver.OracleResultSetImpl.next (OracleResultSetImpl.java:229)

12:03 Anderkent: ptcek: try (doall (take 10))

12:03 ptcek: I think because take is lazy it's escaping the context where your db connection is open

12:03 thus when it tries to realize later on the conn is closed and you get that exception

12:03 luxbock: Anderkent: I got it working, woo

12:04 Anderkent: luxbock: yay :)

12:08 ptcek: Anderkent: doall takes coll as and argument so I tried :result-set-fn #(doall (take 10 %)) and it's working!

12:09 Anderkent: ptcek: yeah, that's what I meant :)

12:09 ptcek: Anderkent: I played with it the whole day and now you have it in 2 minutes. Thank you very much Anderkent!

12:10 Anderkent: that's what we're here for (other than procrastinating on actual work, that is)

12:13 mikerod: amalloy_: sorry I was in a meeting; I figured the feedback I'd hear would be "it is not a good design/idea" :)

12:14 amalloy_: I was thinking in a scenario where I'm parsing a DSL sort of syntax and generating sort a map of data on it. I tend to minimize the use of macros and make most things behave just as simple functions.

12:15 It seems natural to me to have a fn that took code-as-data, and wanted to do some processing to it and return some callable code the code-as-data input. Then again, I know this sort of just sounds like describing a macro I guess.

12:15 Anderkent: yep, exactly like a macro :P

12:17 mikerod: Anderkent: yeah... when described like this it does; so I guess I'll try to dig at what I'm missing here.

12:17 I appreciate the feedback.

12:19 ambroseb_: tpope: if I figure out how to do it, would you consider a vim-fireplace patch to preserve line/column/source information when Eval'ing with a motion?

12:33 Raynes: Man, the rate of pastes on refheap these days is almost worrisome. :p

12:34 I'm might have to make refheap webscale or something!

12:34 ;)

12:36 Anderkent: clearly got to switch to node & mongodb now

12:36 I've noticed that refheap occasionally takes forever to 'establish secure connection' as google tells me

12:36 though not as common recently

12:39 TimMc: Raynes: You need to start using http://www.supersimplestorageservice.com/

12:39 Raynes: TimMc: Clearly

12:40 RickInAtlanta: llasram: I just sent you an email but I thought it might be faster to reach you here.

12:41 ecounysis: a

12:42 seangrove: It's too bad the programmers aren't allowed to learn a new language after picking up their first one.

12:43 technomancy: seangrove: something I read somewhere "Your second language can be anything, as long as it makes you ask what the hell was wrong with your first one."

12:44 seangrove: technomancy: So, ruby => python then, clearly?

12:44 technomancy: seangrove: all I'm saying is that all these sites teaching JS to new programmers is starting to make sense

12:44 TimMc: technomancy: TI-89 Basic -> Java, checks out.

12:44 haha

12:45 seangrove: technomancy: Yeah, I'm certainly fine with it. Just saddened by the reasoning behind this comment https://news.ycombinator.com/item?id=7211623

12:45 technomancy: welp.gif

12:45 seangrove: It's neglecting another option, which is, "You've learned to be a good developer, and you pick up a new language on the job."

12:47 * locks starts chanting Java Script, Java Script, Java Script

12:47 mikerod: seangrove: exactly

12:48 However, sounds like JavaScript is the answer to everything

12:48 what a perfect language

12:48 * teslanick trots out Atwood's Law

12:48 technomancy: «I'll take "languages designed in under 10 days" for $200, Alex.»

12:48 seangrove: "How do you take your coffee?" "JavaScript"

12:48 TheBrayn: nah that would be coffeescript, right?

12:49 mikerod: it's so easy to learn JavaScript and JQuery inside and out

12:49 and then you are an unstoppable programming force

12:49 locks: technomancy: you're just bummed that Clojure isn't a Lisp

12:49 mikerod: maybe throw in a framework or 2

12:49 * seangrove curls up into a ball

12:49 technomancy: locks: gonna start a folk of clojure with support for every data type that isn't a list removed. that'll show em!

12:50 locks: ha!

12:50 seangrove: mikerod: Seriously, what can't be accomplished with Javascript, jQuery, and an unlimited amount of energy, time, and blood letting?

12:50 rasmusto: technomancy: folk lore

12:50 mikerod: seangrove: exactly, endless possibilities

12:50 locks: you can't let blood unless you're using ES6 seangrove

12:50 I'll be here all week.

12:50 teslanick: *instantrimshot*

12:51 mikerod: I wnat to make a language with only abstractions; and no concrete implementations

12:51 * seangrove wonders where all the blood he lost trying to wrangle complexity in Javascript went in that case

12:51 mikerod: With this language, you cannot actually do anything at all

12:51 seangrove: mikerod: I hesitate, but... Haskell?

12:52 mikerod: seangrove: eh, maybe close; I guess someone beat me to it

12:52 seangrove: They may have erred on the can-do-a-little-bit side though

12:52 locks: prolog?

12:52 apl?

12:53 mikerod: :P

12:53 seangrove: locks: clojure?

12:53 mikerod: You though it was a joke, but actually it's a highly-contested prize in a very competitive field

12:53 locks: seangrove: clojure has implementations, no?

12:54 teslanick: Only when you (doall)

12:54 locks: I mean, it's just Java

12:54 seangrove: locks: Yeah, didn't want to come off as bigoted, so it's appropriate to criticize our own language as well. Even when it's inappropriate.

12:54 locks: ;P

12:55 teslanick: "I'm not bigoted, I hate everyone equally!"

12:55 jcrossley3: RickInAtlanta: i'm guessing we're rescheduling tomorrow's meetup, right? ;)

12:55 RickInAtlanta: jcrossley3: yeah, I am trying to reach Marshall now, to figure out when

12:56 expect a notice shortly

12:56 jcrossley3: cool

12:56 mikerod: seangrove: fair enough

12:56 RickInAtlanta: I am going to be AFK for a bit, so if you see a message from him in channel, ask him to reschedule :)

12:56 jcrossley3: RickInAtlanta: will do

13:14 llasram: jcrossley3, RickInAtlanta: the snow isn't supposed to start until midnight, is it?

13:15 jcrossley3: llasram: tonight, i thought

13:16 llasram: I'm just seeing overcast tonight, rain tomorrow, and then snow starting around midnight

13:18 Bleeergh

13:20 muhoo: meh, cofeescript looks like javascript with enough sugar to make it palatable to ruby programmers

13:22 TimMc: muhoo: Unfortunately, you can't really take full advantage of the syntactic transforms without second-guessing the compiler.

13:22 technomancy: muhoo: dunno, ruby programmers are pretty conditioned to hate whitespace-sensitivity through python flamewars

13:22 TimMc: I keep having to check the output to make sure the nesting is correct.

13:22 RickInAtlanta: llarsam: I thought snow was midnight tonight

13:24 SegFaultAX: technomancy: I hate significant whitespace and I've been doing Python for almost 10 years.

13:24 muhoo: i'm slowly approaching cljs/om from the side, and like what i've seen so far.

13:24 rasmusto: SegFaultAX: ^I^I hate it too

13:25 RickInAtlanta: llarsam: If you want to wait until tomorrow to see if we need to reschedule, that is fine.

13:25 SegFaultAX: My reason is simple: while the code may be superficially pretty, it restricts what the syntax can admit to such an extent that super useful things (multi-line lambdas, Ruby-style blocks, etc.) simply aren't possible.

13:26 muhoo: advantage to significant whitespace is at least it cuts off indenting flamewars at the knees. Indentation styles: There Can Be Only One.

13:26 technomancy: SegFaultAX: being unable to automate re-indentation after a merge conflict soundsn like a nightmare too

13:26 SegFaultAX: Not that Python would have those things if the syntax /could/ support it, but it isn't even an option.

13:26 muhoo: (speaking as someone who has sat in all-day meetings debating c indenting styles)

13:26 SegFaultAX: technomancy: And that, but you get used to it after doing it for a long time.

13:26 rasmusto: SegFaultAX: multi-line list comprehensions are a nightmare

13:26 technomancy: muhoo: doesn't python still have wars over 2-space vs 4-space vs tab?

13:26 SegFaultAX: rasmusto: Yes! Especially when nested.

13:26 melba: muhoo, we can argue 4 spaces vs 2 spaces

13:27 rasmusto: [an eye for an eye]

13:27 SegFaultAX: pep8 says 4

13:27 muhoo: technomancy, melba: hmm, good call. i guess there is no end to flamewars as long as humans are involved.

13:27 rasmusto: I had a wonderful codebase with combination 5 space and ^I

13:27 melba: :D

13:27 SegFaultAX: Most people I think try to at least start at pep8, so that adds some consistency.

13:27 melba: i use 2

13:27 technomancy: muhoo: mostly been able to avoid it in lisp-land thankfully

13:27 rasmusto: I can't tell you how much time I wasted plugging a pep8 linter into my editor and making terrible whitespace commits :(

13:27 SegFaultAX: melba: I prefer 2, but my current company uses [mostly] pep8, so 4 it is.

13:28 muhoo: i should write a language which uses significant smiely-face emojiis

13:28 SegFaultAX: melba: I had to make a special case in my vimrc just to accomodate. :)

13:28 rasmusto: if the language can't handle ggVG= it makes me sad now

13:28 jcrossley3: llasram: according to weather.com, the rain/snow will start tomorrow morning, with a "winter storm watch" commencing about the time you take the podium :)

13:28 SegFaultAX: rasmusto: Then don't use python.

13:29 llasram: jcrossley3: Fiiiiine

13:29 rasmusto: SegFaultAX: I avoid it when I can, and write not-very-nested stuff when I can't

13:29 jcrossley3: llasram: :)

13:29 rasmusto: SegFaultAX: not_very_nested*

13:29 muhoo: technomancy: occasionally i get someone's clojure code that isn't done in clojure-mode in emacs, and i do M-x indent-buffer and all of a sudden the git commit is polluted with a bunch of indenting changes, but not often.

13:30 RickInAtlanta: llasram: jcrossley3: it seems to matter a lot where you are. I checked weather in brookhaven, and I was thinking we would be ok. Flowery Branch, otoh is going to suck.

13:30 technomancy: muhoo: it happens, but most people who do that understand that they're wrong once you explain things =)

13:30 rasmusto: if only vcs could look at code structure and not whitespace :(

13:30 muhoo: ~paredit

13:30 clojurebot: paredit is not for everyone, but what you need to understand ís how to become the kind of person that paredit ís for.

13:30 SegFaultAX: rasmusto: Avoiding nesting in general is good, IMHO. Of course it's easier to nest if you have delimited blocks (or some other syntactic form of nesting like sexps) though.

13:31 mynomoto: dakrone: Found an old thread about clojuredocs.org in the group. How it the new version going on?

13:31 llasram: RickInAtlanta: I'm convinced. Let me see if I can get the space next week

13:32 dakrone: mynomoto: not much progress on it currently, clojure/core was going to do some kind of work with the data too (haven't heard any feedback about it yet)

13:32 Rick_AFK: yeah, next week would be great. If not, I suggest delaying till next month, since we do have the evening with Stuart Sierra later this month.

13:32 thanks!

13:34 mynomoto: dakrone: I want to contribute, is there something that I can do?

14:00 jowag: ,(+ 0.1 0.2)

14:00 clojurebot: 0.30000000000000004

14:00 `cbp: ,:-)

14:00 clojurebot: :-

14:02 TimMc: ,(+ 0.1 0.2 -0.3)

14:02 clojurebot: 5.551115123125783E-17

14:03 AimHere: (+ 1.7 0.1)

14:03 m(+ 1.7 0.1)

14:03 rplaca: welcome to floating point math! :)

14:03 AimHere: ,(+ 1.7 0.1)

14:03 clojurebot: 1.8

14:03 AimHere: Boo, was a worse error in my repl

14:03 rasmusto: ##(+ 1.7 0.1)

14:03 lazybot: ⇒ 1.8

14:22 hombotto: Hi, I'm having problems with midje :autotest, any help?

14:28 rasmusto: ~anyone

14:28 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

14:28 mskou72: Why does this result in out of memory (map println (lazy-seq (file-seq (clojure.java.io/file "/Users/martin")))) when this does not (count (lazy-seq (file-seq (clojure.java.io/file "/Users/martin"))))

14:32 ucb: how can I find out what interfaces/protocols a particular symbol implements?

14:33 stuartsierra: ucb: (ancestors (class foo))

14:33 ucb: stuartsierra: thanks!

14:33 stuartsierra: np

14:33 ucb: stuartsierra: just wondering because of this https://gist.github.com/ulises/8805830

14:36 stuartsierra: ucb: `get` on anything not a map returns `nil`. http://stuartsierra.com/2013/02/04/affordance-concision

14:36 ucb: stuartsierra: that'd explain it, thanks :)

14:36 stuartsierra: you're welcome

14:36 ucb: mind you, I found out in a rather inconvenient way, but otoh yay tests

14:37 AeroNotix: is there any ring middleware which creates a handler for JVM statistics?

14:37 or some other fancy pants monitoring stuff would be cool, too

14:37 I want a /health endpoint which my ops dudes can query

14:38 ucb: AeroNotix: shouldn't be that hard to write with codahale's metrics lib

14:39 AeroNotix: ucb: lol, you would be surprised. We looked into codahale's stuff and it seems SOME libs use yammer, some use codahale's, it's a mess

14:39 the API is practically the same, yet different enough for it to not work together

14:39 we tried hooking it up to clojure-metrics and a Cassandra client graphite reporter

14:39 no dice

14:40 but sure, we're using that already

14:40 I wanted something which was just (get-jvm-statistics) or something

14:40 ucb: AeroNotix: interesting; I've used clojure-metrics and codahale's lib directly with not much grief. Even started wrapping up the latest version myself.

14:41 AeroNotix: ucb: It was just the integration with cassandra we found annoying, one lib has it, one doesn't, some ring endpoint reporter middleware used the other... seemed a mess

14:42 ucb: AeroNotix: oh, I see. My use case was far simpler :)

14:42 AeroNotix: ucb: no worries

14:45 hombotto: How to I get midje :autotest to rerun my tests, when i change a src/x.clj file in a lein project?

14:46 AeroNotix: hombotto: do you really want that?

14:46 hombotto: I assumed, that I was testing the changes in my src/x.clj files?

14:47 Specifically I'm working on this project: https://github.com/iloveponies/p-p-p-pokerface

14:48 AeroNotix, I assumed the tests should be rerun against changed functions in src/x.clj

14:49 Am I missing something?

14:49 AeroNotix: Dunno, that just seems like a waste of time to me. If you change some minor whitespace do you really want the test suite running?

14:51 hombotto: AeroNotix, well I'm changing the functions implementations in src/x.clj, not just whitespace

14:51 AeroNotix: Forget it, you miss my point.

14:52 hombotto: AeroNotix, Sorry. Am i using midje incorrectly? Do you have experience with using it correctly?

14:53 AeroNotix: hombotto: I'm just saying that perhaps autorunning test suites may sound cool and fancy pants but is probably more effort than it's worth

14:53 what's wrong with Alt-tab, Up, return?

14:53 that's my :autotest

14:54 hombotto: AeroNotix, I'm used to autorunning tests in all language, I use :-) As a workaround, I'm autorunning the midje tests using inotify events

14:55 AeroNotix: Then go for it

14:55 LLKCKfan: Is there any natural ways to relieve pain without using herbs or weed? No drugs. Prayer does not help

14:55 hombotto: AeroNotix, But I can't get it to work :-)

14:55 AeroNotix: LLKCKfan: masturbation

14:56 TimMc: technomancy: ^ I'm not sure what LLKCKfan's game is, but they should probably be banned? Dunno.

14:56 LLKCKfan: AeroNotix No

14:56 TimMc: or at least kicked repeatedly

14:56 zerowidth: LLKCKfan: try lisp, let the parentheses embrace you like a hug

14:56 AeroNotix: Lisp really is painless, Lein is mostly painless, Clojure eases you in. Just go for it

14:57 the pieces just click together

14:57 zerowidth: if it hurts it's probably because you're learning something

14:58 mikeyg6754: Does anyone know of a way to throw an error from a Liberator post! handler? I'm uploading an image and I don't want to return a 201 if it fails.

15:00 technomancy: LLKCKfan: inclined to agree with TimMc; consider this a warning

15:06 JoelMcCracken: what is the name of that chef-like tool in clojure?

15:10 grzm: pallet?

15:10 clojurebot: pallet is https://github.com/pallet and http://palletops.com

15:12 JoelMcCracken: yeah, thx

15:28 dbasch: I'm using emacs in paredit mode in an OSX terminal, and I can't get C - right arrow to slurp forward. Anyone experienced this?

15:30 tbaldridge: dbasch: yeah, it's a well known problem

15:30 personally I use ALT+) instead, but some people have gotten it to work

15:30 rkneufeld: didn't you have a how-to on this?

15:32 pbostrom: dbasch: I think you can get it to work with iTerm2 and then set terminal type to xterm

15:33 dbasch: tbaldridge: thanks, I'll try another key binding

15:34 pbostrom: dbasch: actually, I got it to work adding something to my init.el file, let me put it in a gist

15:36 dsrx: C-<Right> works for me, but I use M-) myself

15:37 scape_: ,(Integer/toBinaryString(unchecked-byte 129)) ;;expecting 1000 0001

15:37 clojurebot: "11111111111111111111111110000001"

15:40 xuser: emacs key bindings hell

15:40 stuartsierra: dbasch: http://offbytwo.com/2012/01/15/emacs-plus-paredit-under-terminal.html

15:40 xuser: sometimes I think emacs is just meant to be run in GUI mode

15:40 veron: viiiiim

15:41 wink: Notepad.exe *ducks and runs*

15:42 dbasch: stuartsierra: thanks, I'll try this

16:07 rkneufeld: tbaldridge: Do you mean https://gist.github.com/rkneufeld/5126926#a-special-note-for-mac-users ?

16:07 tbaldridge: yeah, thanks

16:08 and dbasch is gone.....oh well.

16:13 cmiles74: cemerick: Hello! I'm using Friend for authentication and was wondering if there's an easy way to add an additional header to the interactive form workflow. I'd like to jam a token in there for the client to use later.

16:13 cemerick: cmiles74: you mean, when it's redirecting after a successful auth?

16:14 cmiles74: cemerick: Yep, right then.

16:14 cemerick: I'm thinking maybe I want to write my own interactive form workflow, but thought I'd ask first.

16:14 cemerick: cmiles74: comp a function onto the result of (interactive-form ...) that adds the header in question when its return value is a ring response, and does nothing otherwise

16:15 cmiles74: cemerick: It sounds very reasonable when you say it like that. ;-) Thank you.

16:16 cemerick: (fn [resp] (if (ring-response? resp) (add-header resp ...) resp)) ; modify to use the actual helpers in ring, etc

16:16 cmiles74: np :-)

16:17 LLKCKfan: I have some chicken strip that have already been cook and then freeze(where freeze when we go them) how can I heat them up on the stove?

16:19 arohner: hrm, do I /ignore LLKCKfan, or do I wait to see the inevitable kick?

16:19 :-)

16:20 seangrove: thanks you arohner

16:20 arohner: seangrove: thank technomancy

16:20 seangrove: Well, thank you for bringing it to his attention, anyway ;)

16:25 mdrogalis: cemerick: ping

16:28 saj: Hi all

16:28 If anyone here has used korma

16:29 brehaut: ~help

16:29 clojurebot: Nobody can help with "X doesn't work". Please provide context: what you did, what you hoped would happen, and what happened instead. A stack trace is especially helpful, if applicable.

16:29 brehaut: hmm thats not the right one

16:29 ~question

16:29 clojurebot: Huh?

16:29 brehaut: bah

16:29 saj: is there a way to perform joins on an entity that references itself, like a comment that references a parent or child comment?

16:29 technomancy: brehaut: you're looking for ~anyone

16:30 though it's too late =)

16:30 brehaut: technomancy: thanks

16:30 yes

16:31 cemerick: mdrogalis: shoot

16:40 mynomoto: saj: I haven't used Korma in a while but I remember seen a thread in the Korma group about how to do that.

16:46 saj: mynomoto: do you remember anything about what it was called? I posted in there a long time ago but got no response

16:57 sdegutis: How's the LT paredit plugin these days?

16:57 I just scrolled in emacs and lost my selection because of it.

16:57 ucb: can anybody explain this to me? https://gist.github.com/ulises/8924971

16:57 * sdegutis declares war against emacs.

16:57 arrdem: existant and under active development, but I don't know how good it is.

16:57 ucb: I understand what's going on, but I'd like to understand why this is so

16:58 llasram: ucb: Why keywords are functions?

16:58 ucb: llasram: no, why (let [..] ...) becomes a Runnable

16:58 arrdem: (dec so) ;; still waging war on those two guys.

16:58 lazybot: ⇒ -5

16:58 ucb: I assume it's to do with let*

16:58 llasram: ucb: It has nothing to do with the let

16:58 arrdem: ucb: because the value it produces is runnable.

16:58 ucb: remember let "returns" its tail expression

16:58 llasram: It's because `a` is bound to `:a` and ##(ifn? :a)

16:59 teslanick: ucb: (let [a :a] a) returns a

16:59 lazybot: ⇒ true

16:59 ucb: llasram: oh, right, of course !

16:59 teslanick: er :A

16:59 ucb: I was puzzled by a piece of code along the lines of (defn foo [^Runnable f] ... do stuff with f) and (foo (with-open [bindings here] ...))

16:59 and with-open results in a let construct, so I was puzzled

17:04 effy: i'm reading the book Programming clojure, and in chapter 7 macros, the author describe the defstruct macro, and say: "This macro looks so simple that you may be tempted to try to write it as a function. You won’t be able to, because def is a special form. You must generate def at macro time; you cannot make “dynamic” calls to def at runtime."

17:04 i fail to understand how calling def inside a function doesn't work, could someone show me the light ?

17:04 gfredericks: does reducers work well on sets?

17:05 brehaut: effy: it takes a symbol literal as its first arg right? if you pass a list literal in, its not going to be happy

17:05 arrdem: effy: so def is a special form, it isn't truly a function. The compiler has to deal with a def, which means invoking (eval `(def ...))

17:06 effy: normal Clojure code never hits eval. it doesn't need to.

17:06 gfredericks: my guess based on crude benchmarks is no

17:06 is reducers mostly only useful for vectors then?

17:06 hyPiRion: effy: Calling def works inside a function, but what would (defn my-def [sym val] (def sym val)) do? It'll just redefine "sym" all the time

17:07 arrdem: ,(defn f [x] (def myfoo x))

17:07 ,(f 3)

17:07 clojurebot: #'sandbox/f

17:07 #'sandbox/myfoo

17:07 arrdem: 0.o

17:07 ,myfoo

17:07 clojurebot: 3

17:07 effy: hyPiRion: oh ok i see with the exemple but then we could still emulate this by passing a (my-defn '('foo 'bar)) no ?

17:08 hyPiRion: effy: nope, because you define sym, not 'foo.

17:09 ,(defn my-def [sym val] (def sym val))

17:09 clojurebot: #'sandbox/my-def

17:09 hyPiRion: ,(my-def 'foo 'bar)

17:09 clojurebot: #'sandbox/sym

17:09 hyPiRion: ,(my-def 'baz 'bar)

17:09 clojurebot: #'sandbox/sym

17:10 effy: (defn my-def [foo] (def (first foo) (second foo)) (my-def '('a 'b))

17:10 does it make sense ?

17:10 Bronsa: no

17:10 def is a special form, it has special evaluation semantics

17:10 effy: meaning i cannot pass a (first foo) as an argument ?

17:10 Bronsa: right

17:11 hyPiRion: exactly, it has to be a symbol

17:11 effy: ok, that's way clearer now :) thanks you

17:12 hyPiRion: np, enjoy the rest of the book :)

17:12 Wild_Cat: wait, so calling def anywhere but at the toplevel of a namespace doesn't alter the namespace?

17:13 llasram: Wild_Cat: It does. `def` interns a name in a namespace, creating a var if necessary

17:13 hyPiRion: Wild_Cat: sure does

17:13 Wild_Cat: OK, nevermind, I misread your explanation.

17:30 arrdem: is there an existing tookit for dealing with regexes as abstract patterns?

17:32 broquaint: arrdem: Like this? https://github.com/jclaggett/seqex

17:32 arrdem: broquaint: ooh shiny

17:33 broquaint: It is rather, haven't found an excuse to use it yet :)

17:33 seangrove: Pretty interesting about Pedestal. Makes me happy they're not averse to adopting React if it works out for the best

17:33 arrdem: :P it looks awesome, but I was really looking for a toolkit that did regex string to abstract state machine translation :P

17:33 I'll probably just have to roll my own because it's so specific...

17:34 (dec so) ;; this guy...

17:34 lazybot: ⇒ -6

17:34 AimHere: Well clojure being clojure, all it does is use the underlying Java regexes, I'm led to believe

17:34 arrdem: AimHere: correct it does. I'm pondering a project where I want to be able to disassemble regular patterns.

17:47 srruby: How do I get (1 2 1 2 1 3) from (1 2) ?

17:48 I meant (1 2 1 2 1 2) from (1 2)

17:49 dnolen_: ,(take 3 (cycle '(1 2)))

17:49 clojurebot: (1 2 1)

17:49 dnolen_: ,(take 6 (cycle '(1 2)))

17:49 `cbp: ,(take 6 (cycle '(1 2)))

17:49 clojurebot: (1 2 1 2 1 ...)

17:49 (1 2 1 2 1 ...)

17:49 srruby: thanks!!

17:49 I forgot cycle

17:49 arrdem: dnolen_: can core.logic use dynamically emitted constraints?

17:51 dnolen_: arrdem: constraints are reify instances, so you can construct interesting constraints on the fly, but it's going to be tricky to something super dynamic.

17:51 "tricky to do"

17:54 arrdem: dnolen_: okay, thanks. sounds like that's probably a no then.

17:56 dnolen_: arrdem: the API around constraints isn't well documented because I'm still unsure exactly what it should look like - there are lot of tricky things around designing constraints that work well together. It's surprisingly easy to have unsound combinations - especially arbitrary predicates (which is supported but again haven't really talked about much because

17:56 of the issues)

17:59 arrdem: dnolen_: sure. Basically what I'm looking at is an AI search problem in a game with dynamic rules. So some things which would normally be valid options may become illegal due to special rules in play. I was thinking that rather than build an abort based system with dynamic predicates that I could just rewrite the search constraint(s) based on rules in play and hopefully perform better as a result.

18:00 the alternative being "try anything and if a dynamic rule predicate fails, it isn't legal abort".

18:00 s/anything/everything/

18:03 dnolen_: arrdem: sounds interesting, but yeah hard for me to say if core.logic is a good fit - clara-rules might interesting here?

18:04 s/might/might be

18:05 arrdem: dnolen_: clara-rules is definitely along the same lines for rule composition. may or may not be useful.

18:06 anyhow. thanks!

18:53 karlgrz: Hey all, I'm a newb clojure'r hacking on overtone and trying to get live coding working in vim. Anyone have experience setting up vim-clojure-static and vim-fireplace?

18:54 I keep seeing this error when I try to run :Eval

18:54 IllegalAccessError index-buffer does not exist clojure.core/refer (core.clj:384

18:54 9)

18:54 arrdem: karlgrz: sounds like your fireplace is working just fine and your code is wrong...

18:55 karlgrz: arrdem: that surprises me very little ;-)

18:55 arrdem: karlgrz: paste? http://refheap.com

18:56 karlgrz: arrdem: https://www.refheap.com/36143

18:56 super simple

18:57 I'm on OS X mavericks, running iTerm with two tabs, one running "leon repo" from my project's root

18:57 arrdem: urgh. this looks like an error in overtone....

18:57 karlgrz: the other with a source window

18:57 ah

18:57 arrdem: karlgrz: is there a longer stacktrace you can show me?

18:57 akurilin2: howdy

18:57 karlgrz: let's see...that's all I got from the vim windows

18:57 *window

18:57 akurilin2: I'd like to move out the peristence layer of a project of mine into its own library so that I can share it across multiple web apps.

18:58 What's the best way for me to extract that code and move it into a local library?

18:58 I'm sure there's something in lein for this :P

18:59 Ideally I'd be able to run everything off of source so that I can edit both the projects and the dependencies without having to rebuild each time

18:59 karlgrz: arrdem: to note, when I just go to the repo window and type commands in they work as expected

18:59 arrdem: for example:

18:59 user=> (use 'overtone.live)

18:59 nil

18:59 user=> (demo (sin-osc))

18:59 #<synth-node[loading]: user/audition-synth 32>

18:59 and I hear the desired beep

19:00 I installed SuperCollider properly (I think)

19:03 dbasch: If it's helpful to anyone, the reason Control arrows didn't work for me on Emacs under OSX was that Mission Control intercepts those keys. I disabled them and now it works.

19:05 dsrx: a leiningen question (which might be more of a maven question): if my clojurescript project is intended to be used as a library, is it best practice to depend on as old a version as possible?

19:06 dobry-den: Question about noir.util.crypt: (encrypt (BCrypt/gensalt) "secret-password") generates a salted password. But how does it know what the salt is later when you go to authenticate a password?

19:07 Cr8: its embedded in the output

19:08 the thing "encrypt" returns contains both the bcrypt hash and the salt

19:08 dobry-den: The underlying Java is here http://www.mindrot.org/files/jBCrypt/jBCrypt-0.2-doc/BCrypt.html - If (BCrypt/checkpw hashed-and-salted-pw raw-pw) can extract the salt, then what does a salt add at all?

19:08 Cr8: that work done against one hash isn't valid against another

19:08 that is, no work you do cracking user A's password hash is useful against user B's

19:09 salts aren't secrets

19:09 they just exist to perturb the hash and add a random factor

19:09 karlgrz: arrdem: if I do a :lopen I see what appears to be some stack traces, but nothing much related to the error, I think

19:10 arrdem: karlgrz: you'd be surprised... paste please?

19:10 dobry-den: Cr8: so checkpw can't split the unsalted hash from the salt. it can only see what the salt is?

19:11 Cr8: checkpw grabs the salt, runs encrypt against the user input with the same salt, and compares against the hash

19:11 that's it

19:12 you could easily split out the unsalted hash if you *wanted* to

19:12 but that wouldn't be useful

19:12 karlgrz: arrdem: https://www.refheap.com/36147

19:12 Cr8: as it's not "unsalted"

19:13 you still need to know the salt value to check against it

19:13 arrdem: karlgrz: okay yeah that stacktrace is pretty useless :P

19:14 karlgrz: arrdem: ;-) ohhhh yea

19:14 arrdem: the only plugins I have installed are vim-fireplace, vim-clojure-static, and vim-classpath

19:15 dobry-den: Cr8: so if the pwd is "secret", the salt is "abc", and the hash is "q1w2e3", and together it's "abc-q1w2e3" in the database, then q1w2e3 is in your rainbow table

19:15 karlgrz: arrdem: SORRY...also nerdtree

19:15 Cr8: at any rate, correct usage is to store the exact output of the encrypt fn, and check it with the checkpw fn

19:15 dobry-den: oh duh, they are hashed together

19:15 Cr8: yeah

19:15 dobry-den: so it'd be "abc" + hash("abc" + "q1w2e3")

19:15 damn

19:15 Cr8: sort of

19:15 bcrypt is a bit more complex than that

19:15 dobry-den: right

19:16 thanks.

19:16 Cr8: does lots of iterations and stuff to be more expensive

19:16 but the general concept of the salt being used as early input to the function is accurate

19:16 which is why the salt doesn't need to be a secret, it's already done its job :)

19:16 karlgrz: arrdem: I just tried opening from the project root instead of the src folder...no change.

19:16 dobry-den: (encrypt "secret") and then (checkpw "secret" (:digest user)) just felt too simple

19:17 i see

19:17 Cr8: \(and also why you use a new salt for each thing you hash. which some folks get wrong)

19:17 arrdem: karlgrz: sorry I can't help much here. I transitioned from Vim to Emacs for Clojure work before fireplace arrived :P

19:17 Cr8: (encrypt "secret") is probably the correct usage, that way you can't make that mistake

19:17 it'll *always* generate you a brand new salt

19:17 which is what you want

19:17 arrdem: karlgrz: I was looking for an obvious Clojure side issue and failed.

19:17 karlgrz: arrdem: all good, thanks for trying!

19:18 arrdem: I'll keep hacking at it...might need to reach out to the debs of those plugins

19:21 arrdem: success!

19:21 arrdem: in vim, I had to type cqq to get my code into the repl

19:21 arrdem: then it threw that exception to me, but it played the tone

19:22 arrdem: :o

19:22 sdegutis_: So Hy is the new Clojure it turns out?

19:22 dobry-den: I have a simple app where kids drop [url=example.com/view/q1w2e3][img=example.com/image/q1w2e3.gif][/url] in their forum signature and the app tracks unique requests to /view/q1w2e3 and /image/q1w2e3.gif. Is logging IP address and ensuring referrer enough to get a rough idea of unique visits?

19:22 karlgrz: arrdem: weird shit...I'm gonna have to figure that out

19:22 arrdem: but at least it's working kind of

19:22 dobry-den: sdegutis_: more impressive: https://github.com/halgari/clojure-py

19:22 arrdem: yeah.. the "working kinda" is what ultimately drove me to Emacs...

19:22 sdegutis_: dobry-den: I heard it died.

19:22 holo: i'm feeling hy, so i'm going to port some clojure fn

19:22 arrdem: the "kinda" days get old. fast.

19:23 dobry-den: sdegutis_: for fun i tried to make some clojure functions for Hy https://github.com/danneu/hyclops/blob/master/hyclops.hy

19:23 sdegutis_: arrdem: I scrolled in emacs today and it ruined my selection.

19:23 Emacs can't handle the concept of your cursor not being visible on the screen. It just can't wrap its head around that idea.

19:23 * sdegutis_ glares subtly at emacs

19:24 arrdem: nope. that was an open glare.

19:24 dobry-den: holo: i meant to ping you https://github.com/danneu/hyclops/blob/master/hyclops.hy

19:25 holo: dobry-den, no worries, i was reading it anyway.. looking for interleave and couldn't find it. did you think about porting it? :>

19:25 arrdem: sdegutis_: see... there is some shit I'm willing to put up with, and as I'm slowly evolving away from my mouse for editing, I'm OK with Emacs having shall we say unfortunate mouse behavior.

19:25 karlgrz: arrdem: :-) if it means I don't need to re-learn my text editor just to get some metronome beats for my guitar playing, that's a load of win in my book ;-)

19:25 arrdem: sdegutis_: because really it was never designed for mouse navigation.

19:25 karlgrz: arrdem: thanks again for the nudges in the right direction

19:25 arrdem: $google all I do is win youtube

19:25 lazybot: [DJ Khaled "All I Do Is Win" feat. Ludacris, Rick Ross, T ... - YouTube] http://www.youtube.com/watch?v=GGXzlRoNtHU

19:26 dobry-den: holo: i thought it was a kinda funny project i wrote in an afternoon but the reception it got in #hy actually put me off of it

19:27 holo: dobry-den why?

19:27 karlgrz: arrdem: \m/

19:28 dobry-den: holo: i think everyone that was on at the moment was just having a bad day.

19:28 holo: dobry-den, why not try again? maybe today is better

19:29 dobry-den: i create a lot of dumb projects. it's not something that had any real follow through.

19:29 but since you're interested in Hy, there might be some low hanging fruit you can grab from it

19:30 i learned pretty quickly how easy clojure's seq abstraction makes this language

19:30 and my efforts to add clojure fns to hy and elisp immediately miss that magical fruit

19:33 holo: i see

19:33 yes, i'll keep your file, thanks

19:44 dobry-den: Would it be a bad fit for Datomic to track visits to a resource? {:request/ip "1.2.3.4", :request/referer "http://example.com/hello", :request/target <ResourceRef>}?

19:45 sdegutis_: arrdem: and 30 years later they haven't caught onto the idea

19:45 arrdem: sdegutis_: eh... still OK with it.

19:46 dobry-den: I've been using Datomic as my general purpose database for so long that even trying to use Redis on a recent project slowed me way down.

20:20 greg`: newbie question, best resource for learning clojure?

20:22 technomancy: greg`: clojurebook.com is a great place to start

20:29 dobry-den: greg`: http://www.braveclojure.com/ is a real lightweight resource

20:32 what's a rule of thumb when deciding to create a :created "column" in datomic vs. just leaning on the tx time?

20:32 the obvious one of course would be if you actually intend to every change it

20:32 greg`: thanks

20:42 dobry-den: I know this isn't a good hour for questions, but I'll try one more. I have a bunch of "Head" images, "Body" images, "Legs" and "Arms". I'd like to write an abstraction that lets me set, say, and "anchor point" on the body for the head, armL, armR, legL, legR (and an anchor point on each body part) that will compose them into an image.

20:42 What image library would you use for this kind of thing?

20:42 I'd even use a Python or Ruby lib/wrapper if it's easier

20:58 `szx: dobry-den: I've used libgd in nodejs/ruby and VIPS in ruby to compose images, not sure if either has a java binding

21:13 dobry-den: `szx: thanks. i'm having a go using Java's ImageIO and i'll check those out if i can't figure out my issue

21:23 bob2: so, I have a global (atom map) that I'm using to fake out a db for the moment. in my test-fixture I'd like to empty the map out after each test, but I can't seem to figure out how to neatly delete all the keys from map. is there a simple way? is this a terrible idea?

21:24 (I can do it with apply and dissoc)

21:25 muhoo: dobry-den: it's write constrained due to the transactr

21:26 i wouldn't use it for logging responses or anything write-bound

21:26 bob2: hm, I guess I just return {} from the function swap! invoked

21:32 noto2: bob2, reset!

21:38 dobry-den: muhoo: how would you personally log a datastructure that looks like {:visitor/ip "1.2.3.4", :visitor/referer "http://example.com", :visitor/target <Resource ID>}?

21:43 rhg135: TEttinger, side effecting fns make y'all sound excited

21:44 TEttinger: ha

21:44 rhg135: it adds spice

21:44 arrdem: rhg135: technically they are STM fns. normal fns with side-effects don't get the !, only STM ones.

21:45 I'ts A Feature™

21:45 rhg135: rly?

21:45 arrdem: yarly

21:45 * rhg135 learned something

21:46 bob2: TEttinger, hm - (reset! x (atom {})) ?

21:46 TEttinger: no, no atom

21:47 (reset! x {})

21:49 bob2: hmm

21:53 muhoo: dobry-den: the cheap and dirty thing would be just to stream it to disk as edn

21:54 dobry-den: or use some other database that's optimized for write speed. but i've been able to make datomic choke on heavy writes

21:56 john2x: hello. why is my font having "extra" space at the bottom here? http://i.imgur.com/H85K1jR.png in other programs it doesn't.

21:57 (see how the blocks on the parens go beyond the parens shape)

21:59 brehaut: john2x: sure you've got the right channel?

22:00 john2x: oh wow. sorry

22:01 brehaut: john2x: fwiw it looks like a foible of the particular monospace font you are using

22:01 john2x: that line of text has no descenders (tails of eg lower case g, p, q, y)

22:02 john2x: but if it did, they would use most of that space below the baseline

22:03 systemfault: Let's say I would like trying to write a RESTful/ish web service using clojure, what framework/lib would you suggest me to use?

22:05 xuser: systemfault: I though Liberator was the clojure thing for that :)

22:05 systemfault: xuser: I saw a video on it recently, looks too amazing to be real.

22:05 So.. I wanted to know what people are actually using :)

22:06 bob2: systemfault, liberator and compojure is going ok for me so far

22:07 it's a bit uh detailed if you let it be

22:07 systemfault: Ok good :)

22:08 And from what I understand... there are a few "ring-compatible" libraries, which one should I use? Read that Httpkit is ring-compatible

22:08 (I'm a total noob.. just reading... and reading..)

22:09 bob2: for serving? I'm just using jetty for now

22:09 systemfault: Ok

22:09 akhudek: systemfault: depends on your requirements. Jetty is fine for a lot of things. Don't have much experience with http-kit, but it seems to fair well in benchmarks and is based on an async model, and immutant is there if you need HA and other serious features.

22:10 systemfault: akhudek: Ah, good to know, thank you

22:12 akurilin2: Lein question: does anybody have a sample project.clj where you use a local repository to link against a custom clj library that's not in clojars?

22:12 systemfault: Last question... I'm a fan of static typing, if I'm a beginner, should I bother using core.typed?

22:12 arrdem: akurilin2: it's invisible

22:12 akurilin2: or at the very least the snippet from that project.clj

22:12 arrdem: akurilin2: just do a local build, and `lein install`

22:12 bob2: systemfault, I'd say no

22:13 arrdem: akurilin2: the lein project looks identical.

22:13 ambrosebs: systemfault: probably not if you're just starting out

22:13 akurilin2: arrdem: ok let me investigate lein install

22:13 systemfault: Ok guys, your opinions are invaluable to me. Thank you so much

22:13 arrdem: akurilin2: for arbitrary jars you have to muck with maven :c

22:13 akurilin2: arrdem: basically what you're saying is that lein install will add the library to the current user's m2 repo and will check against that, right?

22:13 arrdem: yarp

22:13 ambrosebs: systemfault: if you're looking for better errors, dynalint might help

22:14 akurilin2: that's pretty damn

22:14 convenient

22:14 bob2: dynalint seems to not want to install for me :/

22:14 systemfault: Ah :)

22:15 ambrosebs: bob2: oh, what went wrong?

22:15 bob2: java.io.FileNotFoundException: Could not locate dynalint/lint__init.class or dynalint/lint.clj on classpath:

22:16 $ grep dynalin project.clj

22:16 [lein-dynalint "0.1.3"]]

22:16 ambrosebs: bob2: ah there's a new requirement. You need to add a version of com.ambrosebs/dynalint to your profiles

22:17 $ grep com.ambrosebs/dynalint project.clj

22:17 :P

22:17 check the lein-dynalint readme

22:17 bob2: ah, I did not read carefully enough, sorry!

22:18 ambrosebs: bob2: I'll update lein-dynalint to give a better error

22:18 it's confusing, but means I don't need to release lein-dynalint just because there's a new dynalint

22:18 bob2: ohhh right

22:20 ambrosebs, works now - thanks!

22:20 ambrosebs: bob2: great

22:21 akurilin2: OK I'm going to ask a silly one: if I want to group my libraries under a prefix like "myorg.", how do I still get lein new to spit out core.clj by default? Right now if I do lein new myorg.foo, it will generate src/myorg/foo.clj

22:21 Is this just one of those cases where I have to do it by hand?

22:22 As in, I'd like that ns to be called "myorg.foo.core"

22:28 Oooh leiningen won't install new versions of my lib until I change version numbers.

22:28 Sad.

22:28 And makes total sense.

22:31 Hm does anybody know how to make this a bit snappier?

22:31 brehaut: Mechanical Bull. Game Changer. Innovate

22:31 arrdem: brehaut: lolz

22:31 akurilin2: not really. lein already does some stuff to make JVM startup fast-ish

22:32 akurilin2: lein ancient is your friend

22:34 akurilin2: arrdem: So if I'm understanding correctly, if I change a library and run lein install, I HAVE to restart the process to pick up the newer jar?

22:35 arrdem: yes

22:35 akurilin2: ok

22:35 arrdem: should my boot times be sped up if a giant chunk of my existing codebase suddenly is crammed into a jar?

22:36 arrdem: not really...

22:36 afaik

22:36 akurilin2: ok

22:37 lgas: Hi. Is there an idiom for handling the namespace refers if you want to library that takes advantage of another library (e.g. prismatic's schema) if it's installed, but installs just fine without it?

22:37 *namespace references

22:38 akurilin2: Seems like a pretty frequent pattern you encounter when working with storage is implementing the persistence layer once and then wanting to use it across a variety of applications

22:38 So I'm moving that chunk into its own lib

22:46 dsrx: is it a known bug that (.start (Thread. #(println "hello world"))) does not print to the repl buffer in cider?

22:46 seems like futures work ok

22:53 brehaut: dsrx: you probably have to flush the buffer

22:53 (doc flush)

22:53 clojurebot: "([]); Flushes the output stream that is the current value of *out*"

22:54 brehaut: or, alternatively, make sure that *out* is the same *out* as in the main thread

22:54 dsrx: brehaut: yeah, all of my printed messages are going to *nrepl-server*

22:55 so i guess it's just a matter of rebinding *out* then

22:56 ahh nice, thanks brehaut

22:56 (inc brehaut)

22:56 lazybot: ⇒ 22

22:56 brehaut: np

22:56 consider it some lucky guessing

22:57 dsrx: :)

23:03 akurilin2: arrdem: btw thanks for explaining the lein install stuff, super helpful.

23:03 arrdem: akurilin2: np :D

23:29 munderwo: Hi all, so I played around with the clojure Koans and they had a nifty thing with their unit tests where they auto-re-ran… does anybody know how to get that? I just want to avoid the repl reload

23:34 dobry-den: munderwo: there's a lein plugin for every testing framework that you can add to ~/.lein/profiles.clj that lets you run some variant of 'lein autotest'

23:35 munderwo: for example, i use http://jayfields.com/expectations/ and it has this plugin https://github.com/jakemcc/lein-autoexpect

23:35 lein autoexpect

23:35 there's a similar plugin for clojure's standard test lib and https://github.com/marick/Midje (another test lib)

23:36 munderwo: dobry-den: so I'm using just the standard clojure.test … any idea what the plugin for lein is for that?

23:37 dobry-den: munderwo: looks like this https://github.com/jakemcc/lein-test-refresh

23:37 (found it here https://github.com/technomancy/leiningen/wiki/Plugins)

23:37 munderwo: dobry-den: so I think it might also be lein-prism?

23:38 dobry-den: id just roll with the one with the most stars and/or most recent activity

23:39 looks like https://github.com/jakemcc/lein-test-refresh

23:40 akurilin2: Korma time: I heard there's a version of the API where I get to pass in the DB map rather than using the dynamically scoped var

23:40 is that a false rumor?

23:44 Or is it all defdb or nothing, huh?

23:45 technomancy: akurilin2: re: restarting when your dependencies change, take a look at lein's checkouts feature

23:45 it's meant to help avoid restarts

23:47 dbell: (doc require)

23:47 clojurebot: "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents define a library of

23:48 akurilin2: technomancy: aaaaah that sounds awesome <3

23:48 I thought you guys were seriuosly going to make me lein install for my life ;)

23:50 technomancy: akurilin2: nope; I lived through like four months of doing that with maven, and that's pat of what made me start working on lein

23:51 akurilin2: Thank you so much :P

23:52 dsrx: lein checkouts are great

23:52 seubert: are they dsrx ???

23:52 lazybot: seubert: Yes, 100% for sure.

23:53 seubert: lazybot too good at his/her job

23:53 technomancy: lazybot: botsnack

23:53 lazybot: technomancy: Thanks! Om nom nom!!

Logging service provided by n01se.net