#clojure logs

2014-02-10

00:01benkayif 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
00:03akurilin2Hey 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?
00:05akurilin2Actually I guess there's distinct, which is cool, let me figure out whether it uses the earlier or later entries in the sequence.
00:05arrdemakurilin2: so.. our core sort takes an optional comparison argument...
00:05arrdemakurilin2: and yeah there's distinct...
00:05arrdem,(doc sort)
00:05clojurebot"([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."
00:07akurilin2arrdem: aah there's no distinct-by, sad.
00:07arrdemakurilin2: no, but there's group-by...
00:08arrdem,(source group-by)
00:08clojurebotSource not found\n
00:08arrdemdamnit clojurebot
00:08arrdemhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6514
00:09akurilin2No I got it, thanks, I've used it plenty before.
00:09arrdemyep. it's conj based.
00:09arrdemso you're order safe to use first or last to select the first or last value to exhibit a key.
00:10akurilin2so 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
00:11arrdemyarp.
00:11arrdemwell.. map first over vals
00:11akurilin2oh yeah
00:20akurilin2arrdem: cool thank seems to work, had to dome some mental stretching there :P
00:21arrdem:D
00:27jergasonare there any clojure git libraries?
00:27arrdemjergason: as in a Clojure git fs API?
00:27jergasonso i want to manipulate a git repo - check out commits, list them, run git blame on files, ect
00:28jergasonis there a library that can do this in pure clojure before I do a bunch of (sh) calls?
00:29arrdem$google github clojure git toolkit
00:29lazybot[heroku/heroku-buildpack-clojure · GitHub] https://github.com/heroku/heroku-buildpack-clojure
00:29arrdemI'm gonna guess not.
00:32akurilin2Working with libgit is not the most fun experience from what I hear.
00:32akurilin2Remember trying to use the Obj-C port, that was gross.
00:36jergasonarrdem: yeah i'm pretty okay at googling stuff
00:36arrdemjergason: my appologies. you wouldn't belive the number of times I've answered someone's question like that.
00:37jergasonnp, i'm sure ill ask plenty of easily-googled questions :)
00:38jergasonhrrrm, i might just use ruby or something then if this is just going to be a glorified shell script
00:38turbofailthere's jgit
00:38jergason!
00:38jergasonthere is the noobness. i didn't even think of a java git lib
00:39arrdem's ok. I didn't either :P
00:39jergason:)
00:39arrdem(inc turbofail) ;; the fail is with us today
00:39lazybot⇒ 2
00:47daccjergason: make us a nice clojure wrapper for it =)
00:48jergasoni'm probably a few months away from being able to do that :)
00:49turbofaili feel like there was one already
00:50turbofailhm. looks like there are several possibly half-assed ones floating around
00:53turbofailon further inspection there is actually only one half-assed wrapper, the others are shelling out
00:53arrdemplz make not half assed one
01:09muhoojgit sucks but is best i could find
01:17jergasondoes it suck for normal java reasons?
01:17jergasonverbose etc
01:34muhooslow, weird, verbose.
01:34muhoobut, it works
01:37benkay,(Integer/toBinaryString (long 0xd9b4bef9))
01:37clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 3652501241>
01:37benkaywhat am i doing wrooooong
01:38benkayi just want four bytes representing that string to write into a socket and i can't figure this outtttt :(
01:39muhoo,(Long/toBinaryString (long 0xd9b4bef9)) ; ??
01:39lazybotmuhoo: Definitely not.
01:39clojurebot"11011001101101001011111011111001"
01:39muhoobenkay: ^
01:39benkayoh well derp
01:39benkaythanks, muhoo.
01:39muhoolazybot: piss off
01:39muhoobenkay: np
01:40benkayi have no java and clojure is my first lisp
01:40benkayjust just wtf all the way down
01:40muhooi feel ya
01:42benkaywell, to represent that long.
01:45muhoojergason: also, IIRC jgit is what eclipse uses internally for git, so it's a pretty safe bet for being maintained/bugfixed
02:02benkayso 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?
02:02benkaythe full 4-bytes i want to send is ,0xd9b4bef9
02:03benkay,0xd9b4bef9
02:03clojurebot3652501241
02:03Cr8,(unchecked-byte 0xd9)
02:03clojurebot-39
02:03benkayunchecked-byte?
02:04Cr8JVM numbers are all unsigned, but you can get what you probably want by forcing an unchecked cast
02:04benkay,(count (unchecked-byte 0xd9b4bef9))
02:04clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: count not supported on this type: Byte>
02:04Cr8that returns a byte, not a list of any time
02:04Cr8,(type (unchecked-byte 0xd9))
02:04clojurebotjava.lang.Byte
02:04benkayyeah i see that now
02:05Cr8,(into-array Byte/TYPE (map unchecked-byte [0xd9 0xb4 0xbe 0xf9]))
02:05clojurebot#<byte[] [B@843e34>
02:05benkayoh man
02:05benkay,(vec (into-array Byte/TYPE (map unchecked-byte [0xd9 0xb4 0xbe 0xf9])))
02:05clojurebot[-39 -76 -66 -7]
02:05benkaygroovy.
02:06benkaynow 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.
02:06Cr8https://github.com/apage43/hex
02:06Cr8is a thing I did, mostly to use at the REPL
02:06Cr8for stuff like that
02:07benkayah neato.
02:07benkaythat'll probably work for testing.
02:07Cr8,(apply str (map #(format "%02x" %) (into-array Byte/TYPE (map unchecked-byte [0xd9 0xb4 0xbe 0xf9]))))
02:07clojurebot"d9b4bef9"
02:09benkaymany thanks sir! I do believe that I have enough to run with from here.
02:09benkayfor at least another few hours ;)
02:09Cr8have fun
02:12sm0kehere 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 ?
02:12sm0keoutput type*
02:12dsrxsm0ke: there's something like that for haskell
02:12sm0kedsrx: remeber the name?
02:12dsrxtrying to
02:14dsrxsm0ke: djinn
02:14sm0keit looks like a theorem prover, can that be employed?
02:16sm0kehmm now that i think of it cant core.logic be used for this?
02:22Cr8ztellman's byte-streams does something like that
02:22Cr8https://github.com/ztellman/byte-streams
02:23dsrxsm0ke: the curry-howard correspondence says that a program and its type are directly related to a proof and its proposition
02:23dsrx... or something like that
02:23ztellmansm0ke: all you need is a memoized lookup of a exhaustive graph traversal
02:23ztellmannothing too fancy
02:23dsrxso it turns out theorem provers can generate a program given a type
02:24dsrx(and a bunch of other programs)
02:28dsrxand yeah, I imagine you could do something like that with core.logic
02:31Cr8now think about how you'd pull off these nifty cost hints https://github.com/ztellman/byte-streams/blob/master/src/byte_streams.clj#L613
02:35sm0keztellman: yea makes sense, wanted to void doing that
02:35sm0keavoid*
02:36sm0keas ideally i would have to write a shortest path algo
02:36ztellmansm0ke way simpler than anything else you just mentioned
02:36ztellmansm0ke or you can just use def-conversion in byte-streams
02:36ztellmanit works on arbitrary types
02:37sm0keah thanks i will go though the code
02:39sm0kewould it make sense to seperate it out into a library?
02:40sm0keor is it too trivial
02:40ztellmansm0ke maybe, haven't figured out any other real use cases besides the one I'm using it for
02:40ztellmanI can't generalize without multiple concrete use cases
03:08sm0kemore i look at the code in byte_streams, i see exactly what i wanted, conversions with a cost. very nice indeed
04:41marianoguerrahi! what's the best way to do the following without race conditions and as efficient as possible?
04:41marianoguerratry to get a key from a map if it's there if not create it and return it
04:44clgvmarianoguerra: this task occurs in memoization. you can read several variants over here: https://kotka.de/blog/2010/03/memoize_done_right.html
04:44ambrosebsmarianoguerra: I assume you're talking about a mutable map?
04:45clgvmarianoguerra: the above is assuming a clojure map
04:46marianoguerraI was thinking of an agent or an (atom {})
04:46marianoguerrabut checking what's the correct way
04:47marianoguerra"Deutsche Bahn Version (or: „Delay is our core competence“)"
04:48clgvmarianoguerra: check the atom version of memoize in the link above
04:48clgvyeah that's awesome ;)
04:48marianoguerraclgv: thanks!
04:48opqdonutto really get it right you will most probably need a lock
04:48marianoguerrawill look into it
04:48llasramopqdonut: Drink more koolaid!
04:48opqdonutdoing everything with one swap! is a very restricted model
04:48llasram~guards
04:48clojurebotSEIZE HIM!
04:49opqdonutespecially since swap! is implemented wrong[tm]
04:49llasramopqdonut: How so?
04:49clgvopqdonut: yep. depending on how complicated it gets a `ref` might become mandatory
04:49opqdonutllasram: it returns the new value and not the old
04:49clgvwhy is that wrong?
04:49pyrtsaopqdonut: It's pretty easy to add the implementation that returns the old value.
04:49opqdonutor well, both variants are useful but I find myself often wanting the version that returns the previous value
04:49llasramopqdonut: Which 99% of the time is what you want
04:49pyrtsaclgv: Otherwise you can't see which value you swapped out.
04:50opqdonute.g. implementing a queue with (atom []) is impossible using the current swap!
04:50clgvpyrtsa: your functions sees it when you swap it ;)
04:50opqdonutwell you don't see the authoritative previous value
04:50llasramSure, but implementing a queue with (atom []) is a terrible idea anyway, because you can't pop off the first element. A stack maybe :-)
04:50opqdonutyour function might get run multiple times
04:50llasramYes -- that's the whole point
04:51pyrtsaclgv: You often need to do something with the old value after the swap.
04:51opqdonutllasram: you could pop the first element if swap! returned the previous value
04:51pyrtsaopqdonut: https://gist.github.com/pyrtsa/7871080
04:51llasramopqdonut: I meant vectors don't allow you to efficiently pop the first element
04:51pyrtsaclgv: Example in the above link. ^
04:51opqdonutllasram: well, persistent-queue or whatever it's called then
04:51llasramSure
04:51opqdonutllasram: or let's just say stack instead of queue
04:52opqdonutpyrtsa: sure, one can always compare-and-set!
04:52llasramEither way -- the point of atoms (and refs) is that you trade the risk of deadlocks for the risk of retries
04:52pyrtsaThere 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.
04:53llasramNothing is stopping you from calling `locking`
04:54opqdonutllasram: sure
04:54opqdonutand as I said, you will most probably need a lock
04:55opqdonutpyrtsa: 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
04:55llasramMost of the rest of the Clojure community will just need to agree to disagree with you
04:55llasram:-)
04:55opqdonut(or well, you can, but then you need to implement the logic using compare-and-set!)
04:56pyrtsaopqdonut: But that's exactly what I'm saying!
04:56pyrtsa...although it's cleaner with my above definition of exchange!.
04:56opqdonutI'm just mildly irked by not having swap-done-right! in the core
04:56opqdonutaka exchange!
04:56opqdonutyeah
04:56pyrtsaYeah. It ought to be there.
04:59clgvpyrtsa: well. why dont you suggest it in jira?
05:01pyrtsaclgv: Haven't used it before. As a matter of fact, I will!
05:09ddellacostaopqdonut: can't you just get the old value with add-watch? seems like an easy way to do what you want
05:14llasramddellacosta: Getting the old value with add-watch is pretty roundabout, especially given how the implementation works
05:14llasramWhenever you swap!, you have both the old and the new value. It's just the choice of which to return
05:29Anderkent]awayllasram: eh, can you expand on that? swap! doesn't really let you return the old value.
05:30llasramAnderkent: 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
05:30Anderkentah. yeah, I agree with that
05:31llasramThat's all I meant. You missed some early discussion where opqdonut claimed the current behavior to be incorrect
05:31Anderkenttbh 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
05:32llasramIt does seem to be a common request. I've found it useful once or twice. Maybe it'll be in core some day :-)
05:32llasramIn the mean time, really is easy enough to cart around in a utility namespace
05:32pyrtsaI'm adding it to Jira today as soon as I have a minute of time for it.
05:34AnderkentI 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
05:34Anderkentwe went with transactions in the end, I think
05:34llasramAnderkent: That's what you do -- use compare-and-swap! directly to implement a swap!-like function which gives you the old value
05:35llasramcompare-and-swap! is a feature, not an implementation detail :-)
05:35pyrtsaIndeed!
05:36Anderkentmhm, 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
05:36llasramBut that's exactly what swap! does. Minus the failing -- it just retries forever
05:36pyrtsaI don't think swap! fails after N retries.
05:36Anderkentyeash, I know. I just want it abstracted away! :P
05:37llasramWell abstract it into a function yourself and you're good :-)
05:47borkdudeClojure rocks, just saying.
05:48dsrxdisagree, a much better language is hask... oh, not the permitted time of day
05:52llasramheh
06:07TheBraynwhat would you recommend for someone who has not done much functional programming yet to learn clojure?
06:08broquaintTheBrayn: 4clojure.com might be a good place to start.
06:08broquaintIf you'd prefer to apply yourself to a book then I believe the Joy of Clojure may be apt.
06:11AimHereif 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.
06:13klokbaskehi there! newest version of lighttable gives me "No reader function for tag js" when I evaluate eg (def another-array #js [1 2 3])
06:13TheBraynbroquaint: 4clojure looks like fun, thanks
06:15broquaintnp, enjoy :)
06:25klokbaskeoh, seems I didn't run the latest version. 0.5.20 just told me it was, but little does it know ...
06:28borkdudeTheBrayn Just pick any book and start doing clojure development
06:28borkdudeTheBrayn I like Clojure Programming and The Joy of Clojure
06:29clgvis there a way to produce exceptions with line number information of the input param of a macro?
06:31borkdudeTheBrayn Here you can read something about the differences among clojure books: http://michielborkent.nl/comparingclojurebooks.html
06:41llasramclgv: I believe you can get that information from the metadata on &form
06:42clgvllasram: humm but how do I structure error handling within the macro?
06:42llasramJust throw an exception
06:43llasramThat's what the core macros do. Well, although is also one reason for the amazing stack traces
06:44bob2such terrible stacktraces:(
06:44clgvllasram: 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"
06:44llasramok
06:45clgva concrete error is a name used in the "body" which does not occur among the loop variables or outer bindings
06:47clgvllasram: ^
06:48llasramI must be missing something -- what do you not get with just throwing an exception in the macro code reporting that error?
06:49clgvllasram: the line information in the inserted code snippet which I can access via &form or such
06:50llasramclgv: Well, add it? :-) Check out clojure.core/assert-args maybe
06:51clgvllasram: thats the question how to do that. I have a look
06:52AnderkentI'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
06:53clgve.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"
06:55nano-Is it possible to run Clojure under any of the JDK8 compact profiles?
06:56nano-(building and trying is ofc one solution, but asking is probably a bit faster)
07:00Anderkentcompact2 might work? dunno, just looking at the packages
07:00Anderkentof course all java-using libs you depend on would also have to run on it
07:00clgvllasram: the assert-args approach wont work
07:01llasramOh?
07:03clgvllasram: 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
07:03clgvbut without a macro I'd get the line information of (conj res x)
07:05llasramRight. 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
07:05llasramOr, wait
07:05clgvwell that's a huge effort then
07:06llasramWhy does it not work to just expand to code mentioning `res`, then let the compiler throw a normal exception when `res` is undefined?
07:07clgvllasram: oh wait. you are right. seems it was only the error during macro expansion before where no appropriate line information was present
07:08llasramAwesome
07:11clgvthx :D
07:18clgvllasram: 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
07:18clgvthat's weird
07:23clgvllasram: within a map which is a macro parameter only lists get metadata?
07:25llasramclgv: I haven't fiddled with it enough to say off the top of my head. Would need to dig into LispReader.java
07:26clgvllasram: when printing with *print-meta* true it seems like that
07:30clgvso with the current state I'd need to use lists for let-like bindings to get the correct line metadata. :/
07:31clgvhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L7273
07:33Anderkentclgv: I think only lists get line numbers in general I'm afraid
07:33Anderkentclgv: it's been a huge pain for me in cloverage
07:34clgvAnderkent: and probably no plans on changing that?
07:34Anderkentclgv: 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
07:35clgvAnderkent: I'd add it to all persistent data structure literals and symbols
07:35Anderkentif you ever do, give me a ping, I could use it :D
07:35Anderkentclgv: that'd be nice, wouldn't it
07:35Anderkentmaybe tools.reader does it? not sure
07:35clgvAnderkent: you didn't create a jira ticket I can vote on? ;)
07:35llasramI believe tools.reader gives you line information for all IObjs
07:35Anderkentnope:P
07:35llasramNot that that helps clgv, but might help Anderkent
07:36llasramAnderkent: Hah, I need to type faster :-)
07:36clgvwell, to have that line meta only on lists is probably an optimization I guess
07:40mskou72hi
07:41mskou72There's a lot of outdated docs (for 1.2 and 1.3) online. Where should a newbie go for docs and examples?
07:42llasrammskou72: 1.3 is OK. The changes since 1.3 have largely been incremental additions of new features
07:43llasramFor functions which exist in 1.3 (the vast majority), clojuredocs.org is still an excellent resource
07:43TheBraynhttps://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?
07:43TheBraynit should emulate nth just with recursion
07:43llasrammskou72: For newer stuff and more detail, there are some good guides on http://clojure-doc.org/
07:44llasrammskou72: 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
07:44mskou72Ok, thanks :-)
07:45llasramTheBrayn: `((if ...))` -- you are calling the result of the `if` as a function
07:46TheBraynoh I thought that was the function body
07:47llasramTheBrayn: Also note that Clojure doesn't automatically make functions tail-recursive, so this implementation will use a new stack frame for each recursion
07:47TheBraynok
07:48llasramYou can fix that by calling `recur` in tail position instead of re-calling the recursive function by name
07:48TheBrayncool, thanks
07:49TheBraynI ofcourse made this much more complicated than needed but it's a good excercise nonetheless
07:59sm0kewhats the right way to transform maps in clojure
07:59sm0ke(into {} (map ... is ugly
08:01llasramsm0ke: A `map-vals` utility function is a fairly common solution
08:04sm0keyea, probly should do that
08:05jowag,wat
08:05clojureboteval service is offline
08:05jowagI am very sorry
08:05llasram,1
08:05clojureboteval service is offline
08:05llasramHuh
08:05sm0kedoes a closure over a transient also creates a copy?
08:06llasramsm0ke: It holds a reference to the transient, if that's what you mean.
08:06sm0kellasram: yes?
08:06jowag##foo
08:06daGrevisis there a fn that would allow me to get nth elem from a seq and modified seq without that nth elem?
08:06sm0kellasram: in case of immutable a copy is made right
08:07llasramNo
08:07llasramAlways references
08:07sm0kehmm
08:07sm0kereally?
08:07sm0kewouldnt that defeat the purpose of closures
08:07llasramThe immutable types work by disallowing mutation, and returning structure-sharing copies on modification
08:07TheBrayndaGrevis: of course
08:07TEttingerdaGrevis, like pop but with an index?
08:07sm0kellasram: makes sense
08:08clgv"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?
08:08sm0keif closures are internally class instances thats how it should work
08:08sm0kehmm now that is think of it i am scared
08:08llasram?
08:09sm0keso many places i used partial functions in my code without worrying about it
08:09jowagso, where do I report a bug in clojurebot?
08:09llasramdaGrevis: Not that I'm aware of. Maybe with zippers? It's difficult to do without mutation
08:09llasramsm0ke: What are you worried about?
08:09sm0kellasram: that the values i closed over were mutable
08:10sm0kecrap!
08:10llasramWell, are they? :-)
08:10llasramjowag: I believe hiredman is the person operating clojurebot
08:10TheBraynwhy not just return a tuple of the nth element + concat of take and take-last?
08:11jowagllasram: thanks
08:11llasramjowag: https://github.com/hiredman/clojurebot
08:11daGrevis,(nth 3 [1 2 3 4 5])
08:11clojureboteval service is offline
08:11daGrevis,(pop 3 [1 2 3 4 5])
08:11clojureboteval service is offline
08:12TEttinger##(pop 3 [1 2 3 4 5])
08:12lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$pop
08:12daGrevisTEttinger, kike pop with index, y
08:12llasramTheBrayn: You can, but the new sequence is actually a nested collection of references to the original sequence
08:12TEttinger##(pop [1 2 3 4 5])
08:12lazybot⇒ [1 2 3 4]
08:12daGrevisok, lets start from the beginning. i have a vector
08:13daGrevisand i want to divide it in three parts
08:13llasramTheBrayn: If you keep doing that without fulling realizing the seqs, you'll just end up getting a deeper and deeper nesting
08:13TEttingerlike partition or split?
08:13daGrevis[half of it] middle element [other half]
08:13TEttinger^ daGrevis
08:14TEttingerah ok
08:14Anderkentllasram: 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
08:14Anderkentbut that feels scary
08:15clgv,(type (vec (range 10)))
08:15clojureboteval service is offline
08:15clgv:/
08:15clgv&(type (vec (range 10)))
08:15lazybot⇒ clojure.lang.PersistentVector
08:15TEttinger##(let [midpoint (fn [idx coll] [(take idx coll) (nth coll idx) (drop (inc idx) coll)])](midpoint 3 [1 2 3 4 5]))
08:15lazybot⇒ [(1 2 3) 4 (5)]
08:15daGrevisi 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
08:15Anderkent&(type (vec (int-array (range 10))))
08:15lazybot⇒ clojure.lang.PersistentVector
08:16TEttinger##(let [midpoint (fn [idx coll] [(vec (take idx coll)) (nth coll idx) (vec (drop (inc idx) coll))])](midpoint 3 [1 2 3 4 5]))
08:16lazybot⇒ [[1 2 3] 4 [5]]
08:16daGrevisTEttinger, correct answer should be [(1 2) 3 (4 5)]
08:16AnderkentdaGrevis: 1 indexing!?
08:16daGrevisAnderkent, ?
08:17AnderkentdaGrevis: (midpoint 3 [1 2 3 4 5]) should surely give you 4?
08:17TEttingerno... the index for 4 is 3. unless you want to split by value
08:17Anderkentoh
08:18TEttinger##(nth [1 2 3 4 5] 3)
08:18daGrevisi know! i can use split-at 2 coll and then rest on second elem
08:18lazybot⇒ 4
08:18TEttingersure, you'd just need to restructure it
08:20TEttingeralso, the way split-by is implemented is exactly how I did it
08:21daGreviscool ^^
08:22TEttingerwait do you want the middle element to only be in the center? like balanced middle?
08:24TEttinger##(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]))
08:24lazybot⇒ [[1 2 3] 4 [5 6 7]]
08:25Anderkentnot sure about that, doesnt handle even collections well
08:25Anderkentthe one with an explicit index does what you'd expect every time :P
08:26daGrevisTEttinger, yes, balanced middle
08:26TEttingerAnderkent, finding the exact center of an even-count collection isn't defined anyway right?
08:27daGrevisdo clojure programs tend to call functions get-foo?
08:27daGrevisdo clojure programs tend to call functions get-foo ?
08:27AnderkentTEttinger: 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.
08:27TEttingerkinda
08:27Anderkentsorry :P
08:27TEttingerit's fine
08:28TEttingerdaGrevis, people tend to use dashes in names, but single-word names are preferred when there's a good word for it
08:28TEttingerpartition vs. cutAtIntervals
08:33pyrtsaAny 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.
08:33pyrtsas/defining/implementing/
08:37pyrtsaOr, in other words, what't the rationale of having `(seq? [])` return false?
08:37Anderkentpyrtsa: not sure if ISeq promises constant time next(), but if so that'd disqualify vectors
08:38pyrtsaOh? Because of O(log32(N))?
08:38Anderkenthm, well, I guess you can make a wrapper vector that'd just translate every access to n+1
08:39Anderkentso I guess that's not strictly true.
08:39pyrtsaFWIW, (seq xs) is defined for vectors, as well as (first xs), (next xs), (cons xs).
08:39minikomi##((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?
08:39lazybot⇒ [[0 1 2 3 4] 5 [6 7 8 9 10 11 12 13 14]]
08:40pyrtsaI mean, (cons x xs).
08:40Anderkentpyrtsa: seq first next on vectors will convert it to a seq first, I think?
08:40pyrtsaSure. But the conversion is shallow, of course.
08:43clgvpyrtsa: I think the relevant distinction here is between Seq and Seqable
08:43TEttinger##(seq? [])
08:43lazybot⇒ false
08:44clgvpyrtsa: vector, map, set are no Seq but can be turned into one by using `seq`
08:44pyrtsaBut why such distinction? I know about clojure.core.incubator/seqable?, and to be honest, its definition creeps me somewhat. :)
08:48clgvwell 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
08:49Anderkentit seems a useful thing to know, whether your collection is a seq or a different data type - it changes what things like conj do
08:49clgvbut 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
08:49Anderkentif you don't care, you can just (seq thing) and know it's a seq now.
08:50pyrtsaNod.
08:50clgvprobably JVM is a reason as well, since eah specific class knows best how its most efficient sequence implementation has to look like
08:51circ-user-HInXenick ajs
08:51clgv^^ as a reason for Sequable
08:54pyrtsaLooking 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).
08:55clgvpyrtsa: the one-value case is the one I encountered often when visualizing data
08:56clgvit's the case where you'd kill for (atomar? x) to return true for non-collections/sequences ...
08:56AnderkentI never needed sequable?, but I needed list? that works; that turns out to be seq?
08:56pyrtsaclgv: `atomar?` meaning `(complement seqable?)`, you mean?
08:59blrmjoin #robottelo
09:00blrmsorry, mistype :)
09:00clgvpyrtsa: returning true for single values so to say as oposed to data structures with multiple values ;)
09:00clgvlist? and vector? are often handy for macros
09:01pyrtsaYeah, that's what the above is.
09:01pyrtsaI use vector? a lot in macros.
09:01clgvdoes seqable? return true for seqs?
09:01Anderkentclgv: depends on how you implement it
09:01pyrtsaIt should.
09:01Anderkentclgv: my preferred implementation would be ,(try (seq x) true (catch IllegalArg... false)) :P
09:01pyrtsaclgv: It does.
09:01clgvAnderkent: yeah I meant the mentioned implementation ;)
09:02pyrtsa,(clojure.core.incubator/seqable? (seq '(1 2 3)))
09:02clojureboteval service is offline
09:02pyrtsaOh.
09:02Anderkent&(clojure.core.incubator/sequable? (seq '(1 2 3)))
09:02lazybotjava.lang.RuntimeException: No such var: clojure.core.incubator/sequable?
09:02Anderkentoh well
09:02clgv&(require 'clojure.core.incubator)
09:02lazybot⇒ nil
09:03clgv&(clojure.core.incubator/sequable? (seq '(1 2 3)))
09:03lazybotjava.lang.RuntimeException: No such var: clojure.core.incubator/sequable?
09:03pyrtsahttps://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L83-92
09:03clgvold version ;)
09:03cleatoma&(clojure.core.incubator/sequable? (seq '(1 2 3)))
09:03lazybotjava.lang.RuntimeException: No such var: clojure.core.incubator/sequable?
09:03cleatomaOops
09:03cleatoma&(clojure.core.incubator/seqable? (seq '(1 2 3)))
09:03lazybot⇒ true
09:04Anderkentis there a way of making google include the ? in 'list?'. Verbatim doesnt do it
09:04AnderkentI remember there was some issue with list?, where the reader could construct a list that wasnt a list?
09:04Anderkentbut can't remember the details
09:05scape_,(byte 129)
09:05clojureboteval service is offline
09:05llasramAnderkent: Hmm. I don't remember the reader constructing non-list? sequences, but you can certainly e.g. return one from a macro just fine
09:09Anderkenthm, maybe I'm misremembering. Can't find it now ;/
09:11daGrevisnaive implementation of quicksort https://gist.github.com/daGrevis/8862352
09:26scape_,(byte 129)
09:26clojureboteval service is offline
09:27Anderkentscape_: it'll throw an exception afaik
09:27Anderkent&(byte 129)
09:27lazybotjava.lang.IllegalArgumentException: Value out of range for byte: 129
09:27scape_why do I see (byte) 129 in java?
09:28scape_http://stackoverflow.com/a/12471677/1298523
09:28Anderkent&(unchecked-byte 129)
09:28lazybot⇒ -127
09:28Anderkentis what you want, I suppose
09:28scape_oh
09:28scape_they're signed? I know so little about bytes :-\
09:28Anderkenteverything's signed in java AFAIK
09:29scape_thx let me work with that, it's supposed to be -127 too, so that must be it
09:49stuartsierraMany Java APIs return ints to represent bytes.
09:51gfredericksstuartsierra: do you think that's because of signedness issues or because ints are more first-class in the bytecode?
09:52stuartsierradunno
09:52AnderkentI'd think signedness; let the compiler worry about the byte code :P
09:52scape_I was confused because this is a typecast I found in a java example: (byte) 129;
09:55Anderkentwhen 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
09:56Anderkent&(bit-and (int (unchecked-byte 127)) 0xff)
09:56lazybot⇒ 127
09:56evantraversesh
09:57scape_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
09:57Anderkentobviously 127 was a bad example
09:57gfredericks,[(byte 127) (byte 278)]
09:57clojureboteval service is offline
09:57gfredericks&[(byte 127) (byte 278)]
09:57lazybotjava.lang.IllegalArgumentException: Value out of range for byte: 278
09:57gfredericks&[(unchecked-byte 127) (unchecked-byte 278)]
09:57lazybot⇒ [127 22]
09:58gfredericksI'm bad at this
09:58gfredericks&[(unchecked-byte 129) (unchecked-byte 278)]
09:58lazybot⇒ [-127 22]
09:58Anderkentnot sure where you're going
09:59gfredericksI'm done going there and it wasn't worth the effort
09:59Anderkenthaha :D
09:59scape_hah
09:59gfredericksI was confirming to myself that the sign of the output was just related to the 8th bit, not any higher bits
09:59Anderkentobviously if you get n > 255 then no magic will make it work with a sign byte
10:00clgvtwo-complement ;)
10:37clgv&(transient (vector-of :int))
10:37lazybotjava.lang.ClassCastException: clojure.core.Vec cannot be cast to clojure.lang.IEditableCollection
10:37clgvwill that be fixed?
10:38Anderkenteventually probably?
10:38Anderkenthttp://dev.clojure.org/jira/browse/CLJ-787
10:39Anderkenthm, not sure if that's exactly the same thing
10:39Anderkentbut it's similar enough
10:39Marc_auth
10:40Guest43154?
10:40clgvAnderkent: at least it is vetted
10:41TheBraynwhat was the function called that took multiple functions as an argument and applied them to a value?
10:41AimHerejuxt?
10:41clojurebotjuxt is completely uncontroversial in its splendour
10:42Anderkent&((juxt inc dec) 2)
10:42lazybot⇒ [3 1]
10:43TheBraynlike: (<func> f g k x) which does (f (g (k x)))
10:43AimHereThat sounds more like comp
10:43TheBraynyeah that's what I meant, thanks
10:44clgv&((comp dec inc) 0)
10:44lazybot⇒ 0
10:44Anderkent#wastingcycles
10:44Anderkent:P
10:44TheBrayn#yolo
10:44AimHereMaybe the compiler optimized away the inc/dec
10:44gfredericks&((apply comp (repeat 1000000 inc)) 42)
10:45clgvAimHere: very unlikely
10:45lazybotExecution Timed Out!
10:45gfredericks&((apply comp (repeat 100000 inc)) 42)
10:45lazybot⇒ 100042
10:46AimHere,((apply juxt (repeat 100000 inc)) 42)
10:46clojurebot[43 43 43 43 43 ...]
10:49luxbockanyone able to point out what I'm doing wrong with the following Instaparse: https://gist.github.com/luxbock/8918050
10:50luxbockI keep running into this same error with the expected parentheses "(" at the end of the file
10:52MarcFromNYCcan someone tell me what's wrong with this macro:
10:52MarcFromNYC(defmacro foo [x] `(let [y# (map inc x)] (prn ~@y#)))
10:52MarcFromNYCResults in CompilerException java.lang.RuntimeException: Unable to resolve symbol: y# in this context
10:53michaniskinMarcFromNYC: why do you unquote y#?
10:53tim____MarcFromNYC: you don't need to unquote a auto generated sym
10:53AimHereIsn't that because you have an unquoted y# there?
10:53MarcFromNYCi want to splice it in
10:53AnderkentMarcFromNYC: you splice things that are calculated in the macro, not things that are in the code that the macro generates
10:53MarcFromNYCthis is a simple case, i could apply in this case, but what if prn were a macro instead.
10:54AnderkentMarcFromNYC: you can't splice things that come form runtime, you don't know what could be inside x
10:54Anderkentunless it's a constant list/vector, in which case you can do
10:55Anderkent(defmacro foo [x] (let [y (map inc x)] `(prn ~@y)))
10:55MarcFromNYCAnderkent: thx. i'll try that.
10:58jonathanj,(help juxt)
10:58clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:58Anderkentluxbock: try running with :total true and make sure it's what oyu'd expect?
10:58AnderkentAlso I get different errors with the gist you posted (Expected "\"")
11:00luxbockrunning it with :total true gives me: [:project-alist [:projects]] so I guess I'm doing multiple things wrong
11:00luxbockI think I need to spend some more time trying to understand how context free grammars work to begin with
11:02luxbockI'm trying to capture 'name' 'kw' and 'val'
11:02Anderkentluxbock: for me it fails on the name, since you eat the closing double quote in your regex
11:02luxbockah yeah
11:02Anderkentluxbock: you should be really careful about using regexes in instaparse; they don't backtrack
11:04luxbockyeah I think I understand what I was doing wrong now
11:07Anderkentluxbock: 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:09luxbockyeah for me this is a simplified case as the actual config can contain comments and other expressions before and after
11:10luxbockdoesn't seem like there's any easier way though
11:12scape_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:15scape_am getting array oob :-\
11:19Anderkentscape_: inputStream.read() gives you an int, not a byte. Why do you cast mlen?
11:20arrdem,(println "arrdem: ping") ;; testing sauron-mode
11:20clojurebotarrdem: ping\n
11:20Anderkentwait, are you trying the writing or the reading
11:20scape_decode/read right now. and your right, it does
11:20scape_the java example on that SO post is so-so
11:21Anderkentalso no need to do the (unchecked-byte 127), you can give an int (0xff) to bit-and
11:22scape_,0xff
11:22clojurebot255
11:22Anderkentoups
11:22Anderkentmy bad :P
11:22scape_:D
11:23Anderkentalso I misread, your mlen corresponds to rLength in the code, not len?
11:23Anderkent*in the java code
11:23scape_yes, the pseudo code above it, or the python and javascript below might be easier to read.
11:24scape_mlen is not the right name for it, i should rename that to be honest
11:24scape_but the purpose is to determine the mask start position
11:25scape_the error is somewhere in the loop i believe
11:25Anderkentscape_: what's the type of data? byte array?
11:25scape_byte array
11:27amalloyscape_: why are you implementing this yourself at all? it sounds like just a websocket protocol implementation, and those exist in clojure already
11:28scape_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:29scape_Anderkent: think I figured it out :)
11:29Anderkentscape_: oh, what was it?
11:29Anderkentoff by one in the array length?
11:29scape_I read the buffer at a fixed size and didn't resize the array
11:29scape_:D
11:30Anderkentah
11:30scape_so it's passing garbage after the content
11:31Anderkentright, so pass the length of data or trim the aray; I'd also consider using amap instead of manually looping
11:31Anderkentamap / areduce are so nice
11:31amalloyscape_: there's a websocket client/server in aleph, and http-kit has one too, though i haven't used that one
11:31scape_i'll look in to that, yea the loop is ugly but wanted to figure it out first
11:31scape_both use netty i believe
11:32amalloywhy is that a problem?
11:32scape_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:33mikerodIf 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:33mikerod(not using a macro)
11:34Anderkentmikerod: yeah, if oyu take code as data you will have to eval it somewhere
11:34amalloymikerod: yeah, but like...that's generally evil
11:34mikerod(defn i-take-code [s-expr] (fn [x y z]
11:34mikerod(s-expr)))
11:34mikerodAnderkent: that's what I was thinking
11:34mikerodamalloy: I figured...
11:34amalloyit'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:37Anderkentscape_: untested, but might plausibly work: https://www.refheap.com/35945
11:37AnderkentI'd say 50-50 that it works as is :P
11:38myeHi. Is an infinite core.async (go (loop ... GC'd when the channel it returns is closed?
11:39Anderkentmye: no, the writes will just start returning false afaik
11:40amalloyAnderkent: i think his english misled you: he means "when is the channel it returns closed?"
11:41amalloyoh
11:41myeAnderkent: do you mean 'reads'? Can a go block read from the channel it returns?
11:41amalloyno he didn't. sorry, too early for me
11:41Anderkentis it? I understood 'will a (go (loop ...)) block automaticall stop and GC when its channel is closed
11:41myeamalloy: mostly trying to figure out how not to leak an unlimited number of (go)
11:42Anderkentmye: ah, sorry; I misunderstood too. I forgot go blocks return channels
11:43Anderkentmye: 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:44Anderkent[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:44mikeyg6754Hello, 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:45myeMy 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:45stuartsierraGo 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:45chronnomye: 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:45Anderkentmikerod: is your request content-type 'application/x-www-form-urlencoded' or something like that?
11:51mikeyg6754Anderkent: tried changing the content type. That didn't work.
11:52Anderkentmikeyg6754: Hm. Weird, I think there's a ring middleware that handles form-encoded bodies and puts that into params
11:52mikeyg6754Anderkent: I have wrap-params and wrap-file-info currently
11:55Anderkentmikeyg6754: other than double-checking your content type, no idea. wrap-params should definitely consume the body and assoc :form-params and :params
11:55Anderkentsee https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/params.clj
11:56mikeyg6754Anderkent: hmmm, maybe it's something http-kit is doing. This is my first time working with it.
11:57no7hinganybody tried accessing a scala Tuple2 from clojure?
11:57no7hing(._1 tuple) should work
11:57Anderkentmikeyg6754: 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:58ptcekHello, 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:58mikeyg6754Anderkent: Thanks, I appreciate your help!
12:00Anderkentptcek: query takes a :result-set-fn function that runs over the entire result set, and is vec / doallb y default
12:00Anderkentptcek: you probably want to supply (parital take 10) as :result-set-fn so that you only get 10 results?
12:01ptcekAnderkent: I tried exactly that with this error: SQLRecoverableException Closed Resultset: next oracle.jdbc.driver.OracleResultSetImpl.next (OracleResultSetImpl.java:229)
12:03Anderkentptcek: try (doall (take 10))
12:03Anderkentptcek: I think because take is lazy it's escaping the context where your db connection is open
12:03Anderkentthus when it tries to realize later on the conn is closed and you get that exception
12:03luxbockAnderkent: I got it working, woo
12:04Anderkentluxbock: yay :)
12:08ptcekAnderkent: doall takes coll as and argument so I tried :result-set-fn #(doall (take 10 %)) and it's working!
12:09Anderkentptcek: yeah, that's what I meant :)
12:09ptcekAnderkent: I played with it the whole day and now you have it in 2 minutes. Thank you very much Anderkent!
12:10Anderkentthat's what we're here for (other than procrastinating on actual work, that is)
12:13mikerodamalloy_: sorry I was in a meeting; I figured the feedback I'd hear would be "it is not a good design/idea" :)
12:14mikerodamalloy_: 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:15mikerodIt 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:15Anderkentyep, exactly like a macro :P
12:17mikerodAnderkent: yeah... when described like this it does; so I guess I'll try to dig at what I'm missing here.
12:17mikerodI appreciate the feedback.
12:19ambroseb_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:33RaynesMan, the rate of pastes on refheap these days is almost worrisome. :p
12:34RaynesI'm might have to make refheap webscale or something!
12:34Raynes;)
12:36Anderkentclearly got to switch to node & mongodb now
12:36AnderkentI've noticed that refheap occasionally takes forever to 'establish secure connection' as google tells me
12:36Anderkentthough not as common recently
12:39TimMcRaynes: You need to start using http://www.supersimplestorageservice.com/
12:39RaynesTimMc: Clearly
12:40RickInAtlantallasram: I just sent you an email but I thought it might be faster to reach you here.
12:41ecounysisa
12:42seangroveIt's too bad the programmers aren't allowed to learn a new language after picking up their first one.
12:43technomancyseangrove: 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:44seangrovetechnomancy: So, ruby => python then, clearly?
12:44technomancyseangrove: all I'm saying is that all these sites teaching JS to new programmers is starting to make sense
12:44TimMctechnomancy: TI-89 Basic -> Java, checks out.
12:44TimMchaha
12:45seangrovetechnomancy: Yeah, I'm certainly fine with it. Just saddened by the reasoning behind this comment https://news.ycombinator.com/item?id=7211623
12:45technomancywelp.gif
12:45seangroveIt'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:47mikerodseangrove: exactly
12:48mikerodHowever, sounds like JavaScript is the answer to everything
12:48mikerodwhat a perfect language
12:48technomancy«I'll take "languages designed in under 10 days" for $200, Alex.»
12:48seangrove"How do you take your coffee?" "JavaScript"
12:48TheBraynnah that would be coffeescript, right?
12:49mikerodit's so easy to learn JavaScript and JQuery inside and out
12:49mikerodand then you are an unstoppable programming force
12:49lockstechnomancy: you're just bummed that Clojure isn't a Lisp
12:49mikerodmaybe throw in a framework or 2
12:49technomancylocks: gonna start a folk of clojure with support for every data type that isn't a list removed. that'll show em!
12:50locksha!
12:50seangrovemikerod: Seriously, what can't be accomplished with Javascript, jQuery, and an unlimited amount of energy, time, and blood letting?
12:50rasmustotechnomancy: folk lore
12:50mikerodseangrove: exactly, endless possibilities
12:50locksyou can't let blood unless you're using ES6 seangrove
12:50locksI'll be here all week.
12:50teslanick*instantrimshot*
12:51mikerodI wnat to make a language with only abstractions; and no concrete implementations
12:51mikerodWith this language, you cannot actually do anything at all
12:51seangrovemikerod: I hesitate, but... Haskell?
12:52mikerodseangrove: eh, maybe close; I guess someone beat me to it
12:52seangroveThey may have erred on the can-do-a-little-bit side though
12:52locksprolog?
12:52locksapl?
12:53mikerod:P
12:53seangrovelocks: clojure?
12:53seangrovemikerod: You though it was a joke, but actually it's a highly-contested prize in a very competitive field
12:53locksseangrove: clojure has implementations, no?
12:54teslanickOnly when you (doall)
12:54locksI mean, it's just Java
12:54seangrovelocks: 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:54locks;P
12:55teslanick"I'm not bigoted, I hate everyone equally!"
12:55jcrossley3RickInAtlanta: i'm guessing we're rescheduling tomorrow's meetup, right? ;)
12:55RickInAtlantajcrossley3: yeah, I am trying to reach Marshall now, to figure out when
12:56RickInAtlantaexpect a notice shortly
12:56jcrossley3cool
12:56mikerodseangrove: fair enough
12:56RickInAtlantaI am going to be AFK for a bit, so if you see a message from him in channel, ask him to reschedule :)
12:56jcrossley3RickInAtlanta: will do
13:14llasramjcrossley3, RickInAtlanta: the snow isn't supposed to start until midnight, is it?
13:15jcrossley3llasram: tonight, i thought
13:16llasramI'm just seeing overcast tonight, rain tomorrow, and then snow starting around midnight
13:18llasramBleeergh
13:20muhoomeh, cofeescript looks like javascript with enough sugar to make it palatable to ruby programmers
13:22TimMcmuhoo: Unfortunately, you can't really take full advantage of the syntactic transforms without second-guessing the compiler.
13:22technomancymuhoo: dunno, ruby programmers are pretty conditioned to hate whitespace-sensitivity through python flamewars
13:22TimMcI keep having to check the output to make sure the nesting is correct.
13:22RickInAtlantallarsam: I thought snow was midnight tonight
13:24SegFaultAXtechnomancy: I hate significant whitespace and I've been doing Python for almost 10 years.
13:24muhooi'm slowly approaching cljs/om from the side, and like what i've seen so far.
13:24rasmustoSegFaultAX: ^I^I hate it too
13:25RickInAtlantallarsam: If you want to wait until tomorrow to see if we need to reschedule, that is fine.
13:25SegFaultAXMy 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:26muhooadvantage to significant whitespace is at least it cuts off indenting flamewars at the knees. Indentation styles: There Can Be Only One.
13:26technomancySegFaultAX: being unable to automate re-indentation after a merge conflict soundsn like a nightmare too
13:26SegFaultAXNot that Python would have those things if the syntax /could/ support it, but it isn't even an option.
13:26muhoo(speaking as someone who has sat in all-day meetings debating c indenting styles)
13:26SegFaultAXtechnomancy: And that, but you get used to it after doing it for a long time.
13:26rasmustoSegFaultAX: multi-line list comprehensions are a nightmare
13:26technomancymuhoo: doesn't python still have wars over 2-space vs 4-space vs tab?
13:26SegFaultAXrasmusto: Yes! Especially when nested.
13:26melbamuhoo, we can argue 4 spaces vs 2 spaces
13:27rasmusto[an eye for an eye]
13:27SegFaultAXpep8 says 4
13:27muhootechnomancy, melba: hmm, good call. i guess there is no end to flamewars as long as humans are involved.
13:27rasmustoI had a wonderful codebase with combination 5 space and ^I
13:27melba:D
13:27SegFaultAXMost people I think try to at least start at pep8, so that adds some consistency.
13:27melbai use 2
13:27technomancymuhoo: mostly been able to avoid it in lisp-land thankfully
13:27rasmustoI can't tell you how much time I wasted plugging a pep8 linter into my editor and making terrible whitespace commits :(
13:27SegFaultAXmelba: I prefer 2, but my current company uses [mostly] pep8, so 4 it is.
13:28muhooi should write a language which uses significant smiely-face emojiis
13:28SegFaultAXmelba: I had to make a special case in my vimrc just to accomodate. :)
13:28rasmustoif the language can't handle ggVG= it makes me sad now
13:28jcrossley3llasram: 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:28SegFaultAXrasmusto: Then don't use python.
13:29llasramjcrossley3: Fiiiiine
13:29rasmustoSegFaultAX: I avoid it when I can, and write not-very-nested stuff when I can't
13:29jcrossley3llasram: :)
13:29rasmustoSegFaultAX: not_very_nested*
13:29muhootechnomancy: 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:30RickInAtlantallasram: 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:30technomancymuhoo: it happens, but most people who do that understand that they're wrong once you explain things =)
13:30rasmustoif only vcs could look at code structure and not whitespace :(
13:30muhoo~paredit
13:30clojurebotparedit is not for everyone, but what you need to understand ís how to become the kind of person that paredit ís for.
13:30SegFaultAXrasmusto: 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:31mynomotodakrone: Found an old thread about clojuredocs.org in the group. How it the new version going on?
13:31llasramRickInAtlanta: I'm convinced. Let me see if I can get the space next week
13:32dakronemynomoto: 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:32Rick_AFKyeah, 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:32Rick_AFKthanks!
13:34mynomotodakrone: I want to contribute, is there something that I can do?
14:00jowag,(+ 0.1 0.2)
14:00clojurebot0.30000000000000004
14:00`cbp,:-)
14:00clojurebot:-
14:02TimMc,(+ 0.1 0.2 -0.3)
14:02clojurebot5.551115123125783E-17
14:03AimHere(+ 1.7 0.1)
14:03AimHerem(+ 1.7 0.1)
14:03rplacawelcome to floating point math! :)
14:03AimHere,(+ 1.7 0.1)
14:03clojurebot1.8
14:03AimHereBoo, was a worse error in my repl
14:03rasmusto##(+ 1.7 0.1)
14:03lazybot⇒ 1.8
14:22hombottoHi, I'm having problems with midje :autotest, any help?
14:28rasmusto~anyone
14:28clojurebotJust 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:28mskou72Why 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:32ucbhow can I find out what interfaces/protocols a particular symbol implements?
14:33stuartsierraucb: (ancestors (class foo))
14:33ucbstuartsierra: thanks!
14:33stuartsierranp
14:33ucbstuartsierra: just wondering because of this https://gist.github.com/ulises/8805830
14:36stuartsierraucb: `get` on anything not a map returns `nil`. http://stuartsierra.com/2013/02/04/affordance-concision
14:36ucbstuartsierra: that'd explain it, thanks :)
14:36stuartsierrayou're welcome
14:36ucbmind you, I found out in a rather inconvenient way, but otoh yay tests
14:37AeroNotixis there any ring middleware which creates a handler for JVM statistics?
14:37AeroNotixor some other fancy pants monitoring stuff would be cool, too
14:37AeroNotixI want a /health endpoint which my ops dudes can query
14:38ucbAeroNotix: shouldn't be that hard to write with codahale's metrics lib
14:39AeroNotixucb: 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:39AeroNotixthe API is practically the same, yet different enough for it to not work together
14:39AeroNotixwe tried hooking it up to clojure-metrics and a Cassandra client graphite reporter
14:39AeroNotixno dice
14:40AeroNotixbut sure, we're using that already
14:40AeroNotixI wanted something which was just (get-jvm-statistics) or something
14:40ucbAeroNotix: interesting; I've used clojure-metrics and codahale's lib directly with not much grief. Even started wrapping up the latest version myself.
14:41AeroNotixucb: 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:42ucbAeroNotix: oh, I see. My use case was far simpler :)
14:42AeroNotixucb: no worries
14:45hombottoHow to I get midje :autotest to rerun my tests, when i change a src/x.clj file in a lein project?
14:46AeroNotixhombotto: do you really want that?
14:46hombottoI assumed, that I was testing the changes in my src/x.clj files?
14:47hombottoSpecifically I'm working on this project: https://github.com/iloveponies/p-p-p-pokerface
14:48hombottoAeroNotix, I assumed the tests should be rerun against changed functions in src/x.clj
14:49hombottoAm I missing something?
14:49AeroNotixDunno, 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:51hombottoAeroNotix, well I'm changing the functions implementations in src/x.clj, not just whitespace
14:51AeroNotixForget it, you miss my point.
14:52hombottoAeroNotix, Sorry. Am i using midje incorrectly? Do you have experience with using it correctly?
14:53AeroNotixhombotto: 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:53AeroNotixwhat's wrong with Alt-tab, Up, return?
14:53AeroNotixthat's my :autotest
14:54hombottoAeroNotix, I'm used to autorunning tests in all language, I use :-) As a workaround, I'm autorunning the midje tests using inotify events
14:55AeroNotixThen go for it
14:55LLKCKfanIs there any natural ways to relieve pain without using herbs or weed? No drugs. Prayer does not help
14:55hombottoAeroNotix, But I can't get it to work :-)
14:55AeroNotixLLKCKfan: masturbation
14:56TimMctechnomancy: ^ I'm not sure what LLKCKfan's game is, but they should probably be banned? Dunno.
14:56LLKCKfanAeroNotix No
14:56TimMcor at least kicked repeatedly
14:56zerowidthLLKCKfan: try lisp, let the parentheses embrace you like a hug
14:56AeroNotixLisp really is painless, Lein is mostly painless, Clojure eases you in. Just go for it
14:57AeroNotixthe pieces just click together
14:57zerowidthif it hurts it's probably because you're learning something
14:58mikeyg6754Does 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:00technomancyLLKCKfan: inclined to agree with TimMc; consider this a warning
15:06JoelMcCrackenwhat is the name of that chef-like tool in clojure?
15:10grzmpallet?
15:10clojurebotpallet is https://github.com/pallet and http://palletops.com
15:12JoelMcCrackenyeah, thx
15:28dbaschI'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:30tbaldridgedbasch: yeah, it's a well known problem
15:30tbaldridgepersonally I use ALT+) instead, but some people have gotten it to work
15:30tbaldridgerkneufeld: didn't you have a how-to on this?
15:32pbostromdbasch: I think you can get it to work with iTerm2 and then set terminal type to xterm
15:33dbaschtbaldridge: thanks, I'll try another key binding
15:34pbostromdbasch: actually, I got it to work adding something to my init.el file, let me put it in a gist
15:36dsrxC-<Right> works for me, but I use M-) myself
15:37scape_,(Integer/toBinaryString(unchecked-byte 129)) ;;expecting 1000 0001
15:37clojurebot"11111111111111111111111110000001"
15:40xuseremacs key bindings hell
15:40stuartsierradbasch: http://offbytwo.com/2012/01/15/emacs-plus-paredit-under-terminal.html
15:40xusersometimes I think emacs is just meant to be run in GUI mode
15:40veronviiiiim
15:41winkNotepad.exe *ducks and runs*
15:42dbaschstuartsierra: thanks, I'll try this
16:07rkneufeldtbaldridge: Do you mean https://gist.github.com/rkneufeld/5126926#a-special-note-for-mac-users ?
16:07tbaldridgeyeah, thanks
16:08tbaldridgeand dbasch is gone.....oh well.
16:13cmiles74cemerick: 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:13cemerickcmiles74: you mean, when it's redirecting after a successful auth?
16:14cmiles74cemerick: Yep, right then.
16:14cmiles74cemerick: I'm thinking maybe I want to write my own interactive form workflow, but thought I'd ask first.
16:14cemerickcmiles74: 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:15cmiles74cemerick: It sounds very reasonable when you say it like that. ;-) Thank you.
16:16cemerick(fn [resp] (if (ring-response? resp) (add-header resp ...) resp)) ; modify to use the actual helpers in ring, etc
16:16cemerickcmiles74: np :-)
16:17LLKCKfanI 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:19arohnerhrm, do I /ignore LLKCKfan, or do I wait to see the inevitable kick?
16:19arohner:-)
16:20seangrovethanks you arohner
16:20arohnerseangrove: thank technomancy
16:20seangroveWell, thank you for bringing it to his attention, anyway ;)
16:25mdrogaliscemerick: ping
16:28sajHi all
16:28sajIf anyone here has used korma
16:29brehaut~help
16:29clojurebotNobody 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:29brehauthmm thats not the right one
16:29brehaut~question
16:29clojurebotHuh?
16:29brehautbah
16:29sajis there a way to perform joins on an entity that references itself, like a comment that references a parent or child comment?
16:29technomancybrehaut: you're looking for ~anyone
16:30technomancythough it's too late =)
16:30brehauttechnomancy: thanks
16:30brehautyes
16:31cemerickmdrogalis: shoot
16:40mynomotosaj: I haven't used Korma in a while but I remember seen a thread in the Korma group about how to do that.
16:46sajmynomoto: do you remember anything about what it was called? I posted in there a long time ago but got no response
16:57sdegutisHow's the LT paredit plugin these days?
16:57sdegutisI just scrolled in emacs and lost my selection because of it.
16:57ucbcan anybody explain this to me? https://gist.github.com/ulises/8924971
16:57arrdemexistant and under active development, but I don't know how good it is.
16:57ucbI understand what's going on, but I'd like to understand why this is so
16:58llasramucb: Why keywords are functions?
16:58ucbllasram: no, why (let [..] ...) becomes a Runnable
16:58arrdem(dec so) ;; still waging war on those two guys.
16:58lazybot⇒ -5
16:58ucbI assume it's to do with let*
16:58llasramucb: It has nothing to do with the let
16:58arrdemucb: because the value it produces is runnable.
16:58arrdemucb: remember let "returns" its tail expression
16:58llasramIt's because `a` is bound to `:a` and ##(ifn? :a)
16:59teslanickucb: (let [a :a] a) returns a
16:59lazybot⇒ true
16:59ucbllasram: oh, right, of course !
16:59teslanicker :A
16:59ucbI 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:59ucband with-open results in a let construct, so I was puzzled
17:04effyi'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:04effyi fail to understand how calling def inside a function doesn't work, could someone show me the light ?
17:04gfredericksdoes reducers work well on sets?
17:05brehauteffy: it takes a symbol literal as its first arg right? if you pass a list literal in, its not going to be happy
17:05arrdemeffy: 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:06arrdemeffy: normal Clojure code never hits eval. it doesn't need to.
17:06gfredericksmy guess based on crude benchmarks is no
17:06gfredericksis reducers mostly only useful for vectors then?
17:06hyPiRioneffy: 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:07arrdem,(defn f [x] (def myfoo x))
17:07arrdem,(f 3)
17:07clojurebot#'sandbox/f
17:07clojurebot#'sandbox/myfoo
17:07arrdem0.o
17:07arrdem,myfoo
17:07clojurebot3
17:07effyhyPiRion: oh ok i see with the exemple but then we could still emulate this by passing a (my-defn '('foo 'bar)) no ?
17:08hyPiRioneffy: nope, because you define sym, not 'foo.
17:09hyPiRion,(defn my-def [sym val] (def sym val))
17:09clojurebot#'sandbox/my-def
17:09hyPiRion,(my-def 'foo 'bar)
17:09clojurebot#'sandbox/sym
17:09hyPiRion,(my-def 'baz 'bar)
17:09clojurebot#'sandbox/sym
17:10effy(defn my-def [foo] (def (first foo) (second foo)) (my-def '('a 'b))
17:10effydoes it make sense ?
17:10Bronsano
17:10Bronsadef is a special form, it has special evaluation semantics
17:10effymeaning i cannot pass a (first foo) as an argument ?
17:10Bronsaright
17:11hyPiRionexactly, it has to be a symbol
17:11effyok, that's way clearer now :) thanks you
17:12hyPiRionnp, enjoy the rest of the book :)
17:12Wild_Catwait, so calling def anywhere but at the toplevel of a namespace doesn't alter the namespace?
17:13llasramWild_Cat: It does. `def` interns a name in a namespace, creating a var if necessary
17:13hyPiRionWild_Cat: sure does
17:13Wild_CatOK, nevermind, I misread your explanation.
17:30arrdemis there an existing tookit for dealing with regexes as abstract patterns?
17:32broquaintarrdem: Like this? https://github.com/jclaggett/seqex
17:32arrdembroquaint: ooh shiny
17:33broquaintIt is rather, haven't found an excuse to use it yet :)
17:33seangrovePretty interesting about Pedestal. Makes me happy they're not averse to adopting React if it works out for the best
17:33arrdem:P it looks awesome, but I was really looking for a toolkit that did regex string to abstract state machine translation :P
17:33arrdemI'll probably just have to roll my own because it's so specific...
17:34arrdem(dec so) ;; this guy...
17:34lazybot⇒ -6
17:34AimHereWell clojure being clojure, all it does is use the underlying Java regexes, I'm led to believe
17:34arrdemAimHere: correct it does. I'm pondering a project where I want to be able to disassemble regular patterns.
17:47srrubyHow do I get (1 2 1 2 1 3) from (1 2) ?
17:48srrubyI meant (1 2 1 2 1 2) from (1 2)
17:49dnolen_,(take 3 (cycle '(1 2)))
17:49clojurebot(1 2 1)
17:49dnolen_,(take 6 (cycle '(1 2)))
17:49`cbp,(take 6 (cycle '(1 2)))
17:49clojurebot(1 2 1 2 1 ...)
17:49clojurebot(1 2 1 2 1 ...)
17:49srrubythanks!!
17:49srrubyI forgot cycle
17:49arrdemdnolen_: can core.logic use dynamically emitted constraints?
17:51dnolen_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:51dnolen_"tricky to do"
17:54arrdemdnolen_: okay, thanks. sounds like that's probably a no then.
17:56dnolen_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:56dnolen_of the issues)
17:59arrdemdnolen_: 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:00arrdemthe alternative being "try anything and if a dynamic rule predicate fails, it isn't legal abort".
18:00arrdems/anything/everything/
18:03dnolen_arrdem: sounds interesting, but yeah hard for me to say if core.logic is a good fit - clara-rules might interesting here?
18:04dnolen_s/might/might be
18:05arrdemdnolen_: clara-rules is definitely along the same lines for rule composition. may or may not be useful.
18:06arrdemanyhow. thanks!
18:53karlgrzHey 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:54karlgrzI keep seeing this error when I try to run :Eval
18:54karlgrzIllegalAccessError index-buffer does not exist clojure.core/refer (core.clj:384
18:54karlgrz9)
18:54arrdemkarlgrz: sounds like your fireplace is working just fine and your code is wrong...
18:55karlgrzarrdem: that surprises me very little ;-)
18:55arrdemkarlgrz: paste? http://refheap.com
18:56karlgrzarrdem: https://www.refheap.com/36143
18:56karlgrzsuper simple
18:57karlgrzI'm on OS X mavericks, running iTerm with two tabs, one running "leon repo" from my project's root
18:57arrdemurgh. this looks like an error in overtone....
18:57karlgrzthe other with a source window
18:57karlgrzah
18:57arrdemkarlgrz: is there a longer stacktrace you can show me?
18:57akurilin2howdy
18:57karlgrzlet's see...that's all I got from the vim windows
18:57karlgrz*window
18:57akurilin2I'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:58akurilin2What's the best way for me to extract that code and move it into a local library?
18:58akurilin2I'm sure there's something in lein for this :P
18:59akurilin2Ideally 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:59karlgrzarrdem: to note, when I just go to the repo window and type commands in they work as expected
18:59karlgrzarrdem: for example:
18:59karlgrzuser=> (use 'overtone.live)
18:59karlgrznil
18:59karlgrzuser=> (demo (sin-osc))
18:59karlgrz#<synth-node[loading]: user/audition-synth 32>
18:59karlgrzand I hear the desired beep
19:00karlgrzI installed SuperCollider properly (I think)
19:03dbaschIf 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:05dsrxa 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:06dobry-denQuestion 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:07Cr8its embedded in the output
19:08Cr8the thing "encrypt" returns contains both the bcrypt hash and the salt
19:08dobry-denThe 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:08Cr8that work done against one hash isn't valid against another
19:08Cr8that is, no work you do cracking user A's password hash is useful against user B's
19:09Cr8salts aren't secrets
19:09Cr8they just exist to perturb the hash and add a random factor
19:09karlgrzarrdem: if I do a :lopen I see what appears to be some stack traces, but nothing much related to the error, I think
19:10arrdemkarlgrz: you'd be surprised... paste please?
19:10dobry-denCr8: so checkpw can't split the unsalted hash from the salt. it can only see what the salt is?
19:11Cr8checkpw grabs the salt, runs encrypt against the user input with the same salt, and compares against the hash
19:11Cr8that's it
19:12Cr8you could easily split out the unsalted hash if you *wanted* to
19:12Cr8but that wouldn't be useful
19:12karlgrzarrdem: https://www.refheap.com/36147
19:12Cr8as it's not "unsalted"
19:13Cr8you still need to know the salt value to check against it
19:13arrdemkarlgrz: okay yeah that stacktrace is pretty useless :P
19:14karlgrzarrdem: ;-) ohhhh yea
19:14karlgrzarrdem: the only plugins I have installed are vim-fireplace, vim-clojure-static, and vim-classpath
19:15dobry-denCr8: 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:15karlgrzarrdem: SORRY...also nerdtree
19:15Cr8at any rate, correct usage is to store the exact output of the encrypt fn, and check it with the checkpw fn
19:15dobry-denoh duh, they are hashed together
19:15Cr8yeah
19:15dobry-denso it'd be "abc" + hash("abc" + "q1w2e3")
19:15dobry-dendamn
19:15Cr8sort of
19:15Cr8bcrypt is a bit more complex than that
19:15dobry-denright
19:16dobry-denthanks.
19:16Cr8does lots of iterations and stuff to be more expensive
19:16Cr8but the general concept of the salt being used as early input to the function is accurate
19:16Cr8which is why the salt doesn't need to be a secret, it's already done its job :)
19:16karlgrzarrdem: I just tried opening from the project root instead of the src folder...no change.
19:16dobry-den(encrypt "secret") and then (checkpw "secret" (:digest user)) just felt too simple
19:17dobry-deni see
19:17Cr8\(and also why you use a new salt for each thing you hash. which some folks get wrong)
19:17arrdemkarlgrz: sorry I can't help much here. I transitioned from Vim to Emacs for Clojure work before fireplace arrived :P
19:17Cr8(encrypt "secret") is probably the correct usage, that way you can't make that mistake
19:17Cr8it'll *always* generate you a brand new salt
19:17Cr8which is what you want
19:17arrdemkarlgrz: I was looking for an obvious Clojure side issue and failed.
19:17karlgrzarrdem: all good, thanks for trying!
19:18karlgrzarrdem: I'll keep hacking at it...might need to reach out to the debs of those plugins
19:21karlgrzarrdem: success!
19:21karlgrzarrdem: in vim, I had to type cqq to get my code into the repl
19:21karlgrzarrdem: then it threw that exception to me, but it played the tone
19:22arrdem:o
19:22sdegutis_So Hy is the new Clojure it turns out?
19:22dobry-denI 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:22karlgrzarrdem: weird shit...I'm gonna have to figure that out
19:22karlgrzarrdem: but at least it's working kind of
19:22dobry-densdegutis_: more impressive: https://github.com/halgari/clojure-py
19:22arrdemyeah.. the "working kinda" is what ultimately drove me to Emacs...
19:22sdegutis_dobry-den: I heard it died.
19:22holoi'm feeling hy, so i'm going to port some clojure fn
19:22arrdemthe "kinda" days get old. fast.
19:23dobry-densdegutis_: for fun i tried to make some clojure functions for Hy https://github.com/danneu/hyclops/blob/master/hyclops.hy
19:23sdegutis_arrdem: I scrolled in emacs today and it ruined my selection.
19:23sdegutis_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:24arrdemnope. that was an open glare.
19:24dobry-denholo: i meant to ping you https://github.com/danneu/hyclops/blob/master/hyclops.hy
19:25holodobry-den, no worries, i was reading it anyway.. looking for interleave and couldn't find it. did you think about porting it? :>
19:25arrdemsdegutis_: 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:25karlgrzarrdem: :-) 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:25arrdemsdegutis_: because really it was never designed for mouse navigation.
19:25karlgrzarrdem: thanks again for the nudges in the right direction
19:25arrdem$google all I do is win youtube
19:25lazybot[DJ Khaled "All I Do Is Win" feat. Ludacris, Rick Ross, T ... - YouTube] http://www.youtube.com/watch?v=GGXzlRoNtHU
19:26dobry-denholo: 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:27holodobry-den why?
19:27karlgrzarrdem: \m/
19:28dobry-denholo: i think everyone that was on at the moment was just having a bad day.
19:28holodobry-den, why not try again? maybe today is better
19:29dobry-deni create a lot of dumb projects. it's not something that had any real follow through.
19:29dobry-denbut since you're interested in Hy, there might be some low hanging fruit you can grab from it
19:30dobry-deni learned pretty quickly how easy clojure's seq abstraction makes this language
19:30dobry-denand my efforts to add clojure fns to hy and elisp immediately miss that magical fruit
19:33holoi see
19:33holoyes, i'll keep your file, thanks
19:44dobry-denWould 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&quot;, :request/target <ResourceRef>}?
19:45sdegutis_arrdem: and 30 years later they haven't caught onto the idea
19:45arrdemsdegutis_: eh... still OK with it.
19:46dobry-denI'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:20greg`newbie question, best resource for learning clojure?
20:22technomancygreg`: clojurebook.com is a great place to start
20:29dobry-dengreg`: http://www.braveclojure.com/ is a real lightweight resource
20:32dobry-denwhat's a rule of thumb when deciding to create a :created "column" in datomic vs. just leaning on the tx time?
20:32dobry-denthe obvious one of course would be if you actually intend to every change it
20:32greg`thanks
20:42dobry-denI 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:42dobry-denWhat image library would you use for this kind of thing?
20:42dobry-denI'd even use a Python or Ruby lib/wrapper if it's easier
20:58`szxdobry-den: I've used libgd in nodejs/ruby and VIPS in ruby to compose images, not sure if either has a java binding
21:13dobry-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:23bob2so, 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:24bob2(I can do it with apply and dissoc)
21:25muhoodobry-den: it's write constrained due to the transactr
21:26muhooi wouldn't use it for logging responses or anything write-bound
21:26bob2hm, I guess I just return {} from the function swap! invoked
21:32noto2bob2, reset!
21:38dobry-denmuhoo: how would you personally log a datastructure that looks like {:visitor/ip "1.2.3.4", :visitor/referer "http://example.com&quot;, :visitor/target <Resource ID>}?
21:43rhg135TEttinger, side effecting fns make y'all sound excited
21:44TEttingerha
21:44rhg135it adds spice
21:44arrdemrhg135: technically they are STM fns. normal fns with side-effects don't get the !, only STM ones.
21:45arrdemI'ts A Feature™
21:45rhg135rly?
21:45arrdemyarly
21:46bob2TEttinger, hm - (reset! x (atom {})) ?
21:46TEttingerno, no atom
21:47TEttinger (reset! x {})
21:49bob2hmm
21:53muhoodobry-den: the cheap and dirty thing would be just to stream it to disk as edn
21:54muhoodobry-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:56john2xhello. why is my font having "extra" space at the bottom here? http://i.imgur.com/H85K1jR.png in other programs it doesn't.
21:57john2x(see how the blocks on the parens go beyond the parens shape)
21:59brehautjohn2x: sure you've got the right channel?
22:00john2xoh wow. sorry
22:01brehautjohn2x: fwiw it looks like a foible of the particular monospace font you are using
22:01brehautjohn2x: that line of text has no descenders (tails of eg lower case g, p, q, y)
22:02brehautjohn2x: but if it did, they would use most of that space below the baseline
22:03systemfaultLet'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:05xusersystemfault: I though Liberator was the clojure thing for that :)
22:05systemfaultxuser: I saw a video on it recently, looks too amazing to be real.
22:05systemfaultSo.. I wanted to know what people are actually using :)
22:06bob2systemfault, liberator and compojure is going ok for me so far
22:07bob2it's a bit uh detailed if you let it be
22:07systemfaultOk good :)
22:08systemfaultAnd from what I understand... there are a few "ring-compatible" libraries, which one should I use? Read that Httpkit is ring-compatible
22:08systemfault(I'm a total noob.. just reading... and reading..)
22:09bob2for serving? I'm just using jetty for now
22:09systemfaultOk
22:09akhudeksystemfault: 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:10systemfaultakhudek: Ah, good to know, thank you
22:12akurilin2Lein 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:12systemfaultLast question... I'm a fan of static typing, if I'm a beginner, should I bother using core.typed?
22:12arrdemakurilin2: it's invisible
22:12akurilin2or at the very least the snippet from that project.clj
22:12arrdemakurilin2: just do a local build, and `lein install`
22:12bob2systemfault, I'd say no
22:13arrdemakurilin2: the lein project looks identical.
22:13ambrosebssystemfault: probably not if you're just starting out
22:13akurilin2arrdem: ok let me investigate lein install
22:13systemfaultOk guys, your opinions are invaluable to me. Thank you so much
22:13arrdemakurilin2: for arbitrary jars you have to muck with maven :c
22:13akurilin2arrdem: 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:13arrdemyarp
22:13ambrosebssystemfault: if you're looking for better errors, dynalint might help
22:14akurilin2that's pretty damn
22:14akurilin2convenient
22:14bob2dynalint seems to not want to install for me :/
22:14systemfaultAh :)
22:15ambrosebsbob2: oh, what went wrong?
22:15bob2java.io.FileNotFoundException: Could not locate dynalint/lint__init.class or dynalint/lint.clj on classpath:
22:16bob2$ grep dynalin project.clj
22:16bob2 [lein-dynalint "0.1.3"]]
22:16ambrosebsbob2: ah there's a new requirement. You need to add a version of com.ambrosebs/dynalint to your profiles
22:17ambrosebs$ grep com.ambrosebs/dynalint project.clj
22:17ambrosebs:P
22:17ambrosebscheck the lein-dynalint readme
22:17bob2ah, I did not read carefully enough, sorry!
22:18ambrosebsbob2: I'll update lein-dynalint to give a better error
22:18ambrosebsit's confusing, but means I don't need to release lein-dynalint just because there's a new dynalint
22:18bob2ohhh right
22:20bob2ambrosebs, works now - thanks!
22:20ambrosebsbob2: great
22:21akurilin2OK 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:21akurilin2Is this just one of those cases where I have to do it by hand?
22:22akurilin2As in, I'd like that ns to be called "myorg.foo.core"
22:28akurilin2Oooh leiningen won't install new versions of my lib until I change version numbers.
22:28akurilin2Sad.
22:28akurilin2And makes total sense.
22:31akurilin2Hm does anybody know how to make this a bit snappier?
22:31brehautMechanical Bull. Game Changer. Innovate
22:31arrdembrehaut: lolz
22:31arrdemakurilin2: not really. lein already does some stuff to make JVM startup fast-ish
22:32arrdemakurilin2: lein ancient is your friend
22:34akurilin2arrdem: 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:35arrdemyes
22:35akurilin2ok
22:35akurilin2arrdem: should my boot times be sped up if a giant chunk of my existing codebase suddenly is crammed into a jar?
22:36arrdemnot really...
22:36arrdemafaik
22:36akurilin2ok
22:37lgasHi. 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:37lgas*namespace references
22:38akurilin2Seems 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:38akurilin2So I'm moving that chunk into its own lib
22:46dsrxis it a known bug that (.start (Thread. #(println "hello world"))) does not print to the repl buffer in cider?
22:46dsrxseems like futures work ok
22:53brehautdsrx: you probably have to flush the buffer
22:53brehaut(doc flush)
22:53clojurebot"([]); Flushes the output stream that is the current value of *out*"
22:54brehautor, alternatively, make sure that *out* is the same *out* as in the main thread
22:54dsrxbrehaut: yeah, all of my printed messages are going to *nrepl-server*
22:55dsrxso i guess it's just a matter of rebinding *out* then
22:56dsrxahh nice, thanks brehaut
22:56dsrx(inc brehaut)
22:56lazybot⇒ 22
22:56brehautnp
22:56brehautconsider it some lucky guessing
22:57dsrx:)
23:03akurilin2arrdem: btw thanks for explaining the lein install stuff, super helpful.
23:03arrdemakurilin2: np :D
23:29munderwoHi 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:34dobry-denmunderwo: 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:35dobry-denmunderwo: for example, i use http://jayfields.com/expectations/ and it has this plugin https://github.com/jakemcc/lein-autoexpect
23:35dobry-denlein autoexpect
23:35dobry-denthere's a similar plugin for clojure's standard test lib and https://github.com/marick/Midje (another test lib)
23:36munderwodobry-den: so I'm using just the standard clojure.test … any idea what the plugin for lein is for that?
23:37dobry-denmunderwo: looks like this https://github.com/jakemcc/lein-test-refresh
23:37dobry-den(found it here https://github.com/technomancy/leiningen/wiki/Plugins)
23:37munderwodobry-den: so I think it might also be lein-prism?
23:38dobry-denid just roll with the one with the most stars and/or most recent activity
23:39dobry-denlooks like https://github.com/jakemcc/lein-test-refresh
23:40akurilin2Korma 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:40akurilin2is that a false rumor?
23:44akurilin2Or is it all defdb or nothing, huh?
23:45technomancyakurilin2: re: restarting when your dependencies change, take a look at lein's checkouts feature
23:45technomancyit's meant to help avoid restarts
23:47dbell(doc require)
23:47clojurebot"([& 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:48akurilin2technomancy: aaaaah that sounds awesome <3
23:48akurilin2I thought you guys were seriuosly going to make me lein install for my life ;)
23:50technomancyakurilin2: 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:51akurilin2Thank you so much :P
23:52dsrxlein checkouts are great
23:52seubertare they dsrx ???
23:52lazybotseubert: Yes, 100% for sure.
23:53seubertlazybot too good at his/her job
23:53technomancylazybot: botsnack
23:53lazybottechnomancy: Thanks! Om nom nom!!