#clojure logs

2013-10-30

00:00tbaldridgehttps://github.com/clojure/tools.analyzer
00:00brehauttbaldridge: yes, though its still the single link with the best overview
00:00tbaldridgeyeah, there just isn't any work going on there anymore.
00:01jared314By changing requirement to choice, clj-in-clj will force people to choose a platform. But, most will choose the default because it is good. It's good reframing/marketing.
00:01jared314so the argument won't be what is better
00:01jared314it will be what are you doing, because the JVM is good enought
00:02jared314enough*
00:02tbaldridge"By changing the requirement to choice" not sure I understand that.
00:03danlentzrecently i ran across an early clojure prototype implemented in common-list. I'm a bit sad it didnt happen at the same time I recognise that leveraging the java investment companies have made is perhaps the most significant reason clojure is emerging as such a viable platform in the marketplace
00:03cmajor7I am looking at core.async ops, and wondering.. what happens to the ops that don't just reify the Channel, but actually depend on the data within a channel.. in case the data is streaming in. for example, let's take a "split". the go-loop will only stop/exit producing those two channels (a vector of true and false for a predicate) in case the channel is closed http://bit.ly/16KkbDl , but what if the data is constantly streaming
00:04danlentzer, common-lisp that is
00:05tbaldridgecmajor7: go loops kick off a new logical thread. So the split function should return almost instantly.
00:06cmajor7tbaldridge: ah.. and then whoever is listening on tc/fc will get updates.. very niice
00:07cmajor7tbaldridge: could not see the next level of "inception" :)
00:07tbaldridgecmajor7: you must go deeper, and see where the rabbit hole goes.
00:08cmajor7tbaldridge: I am following him as we speak..
00:08cmajor7tbaldridge: a rabbit that is..
00:08tbaldridgecmajor7: I should mention, like most of Rich's code, async.clj contains a ton of "high performance" code. Some of the stuff with reifying ReadPorts and the like is kindof black magic.
00:09tbaldridgehe wrote it so we don't have to, but most of the time you don't need drop to the primitives he's using.
00:11cmajor7tbaldridge: yea, I am just quietly walking the path of something I hope is "understanding the flow" not to reinvent a feature I am looking for..
00:12SegFaultAXAnyone see that Uber was doing kitten deliveries in SF today?
00:12cmajor7tbaldridge: thinking of doing "batching" with a channel. where I can call a function on that "batch" on either a timeout or when a certain batch size is reached
00:12SegFaultAXIt was /awesome/. They came to our office with 3 ADORABLE kittens and hung out for like 25 minutes. They even brought cupcakes and kitten ears.
00:13SegFaultAXNot rubbing it in or anything, but how often do you get kittens delivered to your office. :D
00:13cmajor7tbaldridge: that batch is state, so I wanted to see if I can leverage an internal channel to keep that state.. maybe..
00:13tbaldridgecmajor7: yeah, you just need a loop that takes from a channel with an alt! and a timeout. use a loop to manage the state
00:14jared314tbaldridge: what i'm saying is c-in-c simplifies porting, which, through community effort, expands platform choice. This also creates a paradox of choice, where most people will just end up picking the JVM.
00:14danlentzah. i was just searching the web looking for the definition of "kittens" as some sort of clojure/java technospeak
00:14SegFaultAXdanlentz: No, actual kittens.
00:14cmajor7tbaldridge: yes, I am very much into alt! for this.. but how do I chop that "batch" from a channel, as events keep coming in..
00:15danlentzsometimes a kitten is just a kitten...
00:15jared314tbaldridge: but they will no longer complain about it because it was their choice
00:15technomancySegFaultAX: I have had cats wandering into my office a few times
00:15technomancynot on demand though
00:15technomancy(my office is a shed in my back yard)
00:16danlentztechnomancy: did you follow the earlier discussion re: unsigned arithmetic?
00:16SegFaultAXWell I can assure you it was a welcomed distraction.
00:16technomancydanlentz: no
00:16SegFaultAXWell, it was in the middle of a heated ping pong match, but other than that, welcomed.
00:16technomancySegFaultAX: with me I kept worrying that I'd forget he was in there once he took a nap on the recliner and lock him in for th enight
00:17cmajor7tbaldridge: e.g. if it wasn't Clojure per se, I would use a concurrent.LinkedBlockingQueue and would syncronize it (with a lock) to "fetch-a- batch" on either timeout or when batch size is reached. in Clojure however I feel it is already solved for me.. I just don't see "the way" at the moment
00:17SegFaultAXtechnomancy: We used to have a very open animal policy. There were 2 office dogs. It was pretty amazing... that is until the property manager decided to be a dick bag. :(
00:17danlentzi've4 been struggling to get a reasonably efficient means of doing 64bit unsigned arithmetic and have failed at some point with every solution I've come up with
00:18`cbpSegFaultAX: all I gotta do for cats to show up at my desk is to leave food overnight
00:18amalloycmajor7: you have to look at core.async from the lens of javascript, where such niceties as blocking and threads don't exist
00:18`cbpand an open window
00:18amalloyit's still neat in clojure-jvm, in a similar way as lamina is, but it's not a huge deal
00:19SegFaultAX`cbp: Where is your office?
00:19danlentzpopular wisdom is to put and search for some java project that might have been fought and won in this quagmire
00:19danlentzpunt rather
00:19`cbpSegFaultAX: mexico
00:20cmajor7amalloy: I am really for looking at it differently, but since a channel is just a pipe with no meta data (size, peeking, chopping..), I am trying to understand/find an approach to "chop that batch" while data is still coming in to the channel
00:20danlentzbasically I need to do some bitwise manipulations for my uuid library and I'm struggling to get it to produce results equal to those implemented on platforms that natively support unsigned numeric representations
00:22SegFaultAX`cbp: Ah, neat!
00:22danlentzand i just had the unpleasant discovery that bigint cant do bitwise ops, and so there goes another approach
00:23jared314what happened with fogus's gloss project?
00:23cmajor7amalloy: can you think of one?
00:23tbaldridgecmajor7: this is what you want, I think https://gist.github.com/halgari/7226915
00:23amalloyno, because your desire is not expressed in a way i can understand
00:23jared314nm
00:24tbaldridgeeh, there's a bug there, < should be > I think
00:24danlentzgloss is close actually
00:24jared314danlentz: have looked at how ztelman did gloss yet?
00:25jared314danlentz: spelling not guaranteed.
00:25danlentzits good stuff but has a different focus and doesnt really get me there for the kind of bit-twiddling I'm trying to accomplish
00:26amalloydanlentz: you might ask ztellman, though - in addition to gloss he has done more low-level mathy stuff in clojure than anyone i can think of
00:27danlentzalso i've lookedv at primitive-math, byte-streams, byte-transforms, bit-sets, and a number of other libs but they dont really address the core issue i run into
00:27amalloyworking with primitives etc
00:27jared314danlentz: which is?
00:27cmajor7tbaldridge: for max-pending, right.. very cool. looks great. my mistake was thinking about holding that "batch" within an internal channel, but a simple vector hidden under the go hood is even better. thanks a lot Tim!
00:27coventrydanlentz: What is the core issue, anyway?
00:28danlentzwhich is the need to mask off bits and deposit replacements, etc
00:28tbaldridgecmajor7: you might be tempted to reset the timeout channel at each recur, but the way I have it may work better in situations where the semantics are "flush every sec" vs "flush after 1 sec of inactivity"
00:29danlentzthe common-lisp functions are: #'byte #'dpb, and #'ldb
00:29jared314danlentz: It sounds like a java ByteBuffer would work for that. What is wrong with it?
00:31danlentzonly my ignoance of it. maybe that is the answer... It definitely gives me a new avenue to work on anyway
00:31bitemyapp`cbp: awesome :)
00:31jared314danlentz: java.nio.ByteBuffers
00:32jared314danlentz: java.nio.ByteBuffer
00:32danlentzreflection of some of the difficulties picking up clojure without much of a java background...
00:32bitemyappI don't think picking up Clojure without Java is that hard.
00:32jared314danlentz: i learned about ByteBuffers from gloss
00:32tbaldridgeseems you could also use a byte array
00:33cmajor7tbaldridge: yea, I think "(recur new-pending tout)" in case a batch size wasn't reached makes more sense, then reseting it on every message (if I understood your comment correctly)
00:33danlentzyou're right. I remember seeing it. I think at the time my thought was i had found what i needed by simply following his unchecked primitives technique
00:33tbaldridgecmajor7: yeah, it depends on the semantics you want.
00:34cmajor7tbaldridge: right. again, thanks a lot. makes it so much easier than "me thinking reifying a Channel and holding that state" :)
00:35danlentzby the time I realized the difficulties down that road I seem to have forgotten it. thanks for the assist.
00:37danlentzbitemyapp: not insurmountable. just every so often one runs into some java thing that it would have been helpful to have known is all.
00:37danlentzJava for the aspiring clojurist would be an encellent book, if it existed
00:38technomancybitemyapp: it's not that; it's picking a good first project that's hard.
00:39technomancypart of picking a good first project is knowing what's going to drop you straight into the guts of java.nio.* and avoiding that
00:39technomancybut how are you supposed to know that starting out?
00:39jared314that's what happened to me. Listen to him and don't do what I did.
00:40danlentza good first project imho is one where you learn a lot, not necessarily write an excellent app. And I've definitely learned a lot by having to struggle a bit with this unsigned aritmetic
00:40`cbptry struggling with java.awt.print :P
00:41danlentzi hadn't the slightest idea it would be so difficult to get essentially the same functionality as the very simple common-lisp ldb and dpb functions
00:43danlentzand i've never encountered a situation where there was no concept of unsigned numbers -- very surprising how difficult it is to construct ones own unsigned representation using only a signed one
00:43jared314i've always found it strange to expect numbers to be bytebuffers
00:44danlentzi mean, doing the reverse is not that difficult
00:45danlentzalso, though, the jvm is overprotective in this regard when it thinks you are trying to represent an invalid number
00:46danlentzthings seem to dome down always to the fundamental issue of dealing with -0
00:46danlentzwhich it is never going to like, ever.
00:51danlentzso the representation of the word one would hope to create by means of (bit-shift-left 1 64) is just always going to run into problems even when you can create it with unchecked math trickery
00:53danlentzbit-and ing it with some other 2s complement analog of the unsigned number you mean becomes a task mired in special cases and potential exceptions
00:54bjl7so I have the form like (do (when x (get-new-y)) (recur y)). Is there a nice way to pass the value from the first statement in the do to the second? I'm not sure I want to clutter global var space.
00:54coventryDo you need it in a number format for the UUID application?
00:54danlentzin the end, there is one-less number representable in any given 2s complement byte-size than in unsigned of the same width
00:55danlentzcoventry: you're suggestingf manipulating a string representation?
00:56coventryA ByteBuffer representation maybe.
00:56danlentzalso an interesting idea. y the bytebuffer is my next approach
00:57jared314I like to image that old cereal commercial: You got a pointer in my numbers. No, you got numbers in my pointer. Oh well, lets just jump to the location and see what happens.
00:58danlentzalthough the bytes iun a bytebuffer are still signed so i'd have to use shorts in the bytebuffer and the basically reimplement the various bitwise-operations to support operating in that way
00:59danlentzi've also looked at chars, which are, in fact, unsigned numbers
01:00danlentzbut unfortunately they seem to be undefined over certain ranges something like FD00-FDFF or some such
01:00danlentzwhich i'm sure almost no java implementation probably checks, but still seems a bad idea to rely on that
01:01danlentzie, this would be viable, otherwise, to manipulate unsigned numbers as unicode strings
01:01danlentzutf16 or what hace you
01:08danlentzjared314: I think that's from reeses pointer-buffer cups
01:08jared314danlentz: now i'm hungry
01:12danlentzjared314: bytecode
01:15jared314(inc danlentz)
01:15lazybot⇒ 1
01:16jared314(identity danlentz)
01:16lazybotdanlentz has karma 1.
01:17danlentzjared314: your karma ran over my dogma...
01:18danlentzsorry that joke was pretty lame i know
01:20danlentzso... nicks represent a MUTABLE datatype?
01:21danlentzwouldnt have expected to find that here
01:21danlentz(identity danlentz)
01:21lazybotdanlentz has karma 1.
01:21danlentzhow un-ideomatic
01:23danlentz(swap! danlentz inc)
01:23danlentzhmm
01:25danlentzlazybot: learn clojure
01:25lazybotMy memory is more powerful than M-x butterfly. I won't forget it.
01:33jared314no, just a key in, I think, mongodb
01:34jared314and the inc is just a command it recognizes
01:34jared314https://github.com/flatland/lazybot/blob/master/src/lazybot/plugins/karma.clj
01:56danlentzztellman: hello -- you are author of byte-streams, gloss, primitive-math, etc?
01:56ztellmandanlentz: that's me
01:57danlentzwell you might be the most likely person to have encountered some of the issues i've been worjking through on my maiden voyage in clojure
01:57ztellmansuch as?
01:58danlentzi come from a common-lisp background where there are a very powerful means of dealing with unsigned, signed, or even arbitrary bit-vector representations
01:59danlentzas an excercise (and also b/c i need one) i've been working on a more useful UUID library extending java's UUID tyype
01:59danlentzand my issue is to get results that equal those on platforms capable of unsigned arithmetic
02:00ztellmanwell, primitive-math is decent at that
02:00ztellmanit's not doing what you expect?
02:00danlentzi'm fine, of couse, dealing with everything up to LONG
02:00danlentzy i've played with primitive math
02:01ztellmanso what's the issue?
02:01danlentzthe representation of the word one would hope to create by means of
02:01danlentz (bit-shift-left 1 64) is just always going to run into problems even when you
02:01danlentz can create it with unchecked math trickery
02:02ztellmanat that point you want to use BigInteger
02:02danlentzin the end, there is one-less number representable in any given 2s complement
02:02danlentz byte-size than in unsigned of the same width
02:02ztellmanhttps://github.com/ztellman/primitive-math/blob/master/src/primitive_math.clj#L247
02:02ztellmanthat allows arbitrary bitshifting, etc
02:02danlentzbut bitwise ops are not defined on bigint -- am I missing the obvious?
02:03ztellmanaren't they?
02:03ztellmanone sec
02:03danlentzif they were i'd be golden
02:03ztellmanthey are: http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html
02:03ztellmanoh, well, that's an ancient versoin
02:03ztellmanbut anyway
02:03ztellmanI'm talking about java.math.BigInteger, not clojure's BigInt
02:04ztellmannotice that's what primitive-math/long->ulong gives you
02:04danlentz(-> (bigint 1)
02:04danlentz (bit-shift-left 1))
02:04danlentzoh
02:04danlentzah
02:05ztellmanyeah, you'll just be using the Java API for this
02:05ztellmanbut it should do everything you need
02:05danlentzwell this is why i'm a dunce still -- i didnt realize there was a difference between bigint and BigInteger
02:07akurilinDoes anybody know if there's a way to force a non-validating SSL connection to PG in Korma?
02:08akurilinIn clojure jdbc you can just append sslfactory=org.postgresql.ssl.NonValidatingFactory to the DB address and you'll get an SSL connection even when the server cert is not trusted.
02:08andyfingerhut_danlentz: Be slightly cautious with BigIntegers in Clojure. Their hash is not consistent with = when comparing them with other integral types. http://dev.clojure.org/jira/browse/CLJ-1036
02:08andyfingerhut_danlentz: Sorry, that is throwing you into more details than you might care to dive into right now, but if you deal with BigInteger types frequently in Clojure that gotcha may come up.
02:09danlentzso also the clojure bitwise ops wont work and the whole deal is tyhrough java you're saying
02:09andyfingerhut_Clojure bitwise ops work on longs only, I believe.
02:10danlentzandyfingerhut_: no worries I'd rather have the idea where dragons be lurking
02:11andyfingerhut_It is easy to convert between bigint and BigInteger, but if you work with BigInteger a lot, could be a hassle to remember to do the conversion everywhere necessary. I'd recommend using bigint in most places, and try to isolate BigInteger to only the places you must have it.
02:11danlentzBigInteger is going to be relatively slow I'm assuming... but if it's a solution i'll take it
02:12andyfingerhut_relatively slow to some other arbitrary precision integer library? Compared to libgmp perhaps, but I haven't measured carefully.
02:13danlentzie coerce to BigInteger where i need to do the bit twiddling
02:13andyfingerhut_If you need something bigger than 64-bit ints, it is BigInteger, find someone patient enough to have written their own, or write your own, I would think.
02:13danlentz:}
02:13danlentzno 64 bit unsigned values are what i'm trying to represent
02:14andyfingerhut_Well, if it is already a bigint, the coercion should just be a cast, I think.
02:14danlentzneat
02:14andyfingerhutIf all you need are 64 bits, why not just use longs?
02:14danlentzugh
02:15danlentzbecause there are 1 fewer numbers representable in 2's complement signed arth than unsigned
02:15andyfingerhutI don't think that is true. There are exactly 2^64 of each.
02:15danlentz2^64 or -0 being illegal
02:15andyfingerhutN-bit signed 2's complement values range from -2^(N-1) through 2^N-1, inclusive.
02:15andyfingerhutexactly 2^N values.
02:16danlentz0x8000000000000000
02:16danlentz1000000000000000000000000000000000000000000000000000000000000000
02:16andyfingerhutThat is 2's complement representation for -2^63
02:16andyfingerhutIf I'm guessing that you've got 64 bits there.
02:17andyfingerhutAre you sure you are not thinking of 1's complement representation, where there are separate bit representations of +0 and -0? 2's complement doesn't have that.
02:18danlentzuser> (long 0x8000000000000000)
02:18danlentzIllegalArgumentException Value out of range for long: 9223372036854775808 clojure.lang.RT.longCast (RT.java:1134)
02:19andyfingerhutPut a minus sign in front of it, and you won't get an exception.
02:19danlentzso bitmasks that are pretty important like 0xFFFF000000000000 are not representable
02:19andyfingerhutThey are representable, but they are negative long values.
02:20danlentzonly (unchecked-neg 0x7FFF000000000000)
02:20danlentzwell right 0x8000000000000 is the crux of the issue
02:21andyfingerhutI'm not saying that is convenient to use them as unsigned values. I am saying that if you really want to avoid BigInteger, and you only need 64-bit values, longs are 64-bit values, with 2^64 different possible values, and + and - that give the same bit-level answers as unsigned values do.
02:21danlentzthats why to represent an unsigned byte one must roll over into shorts
02:21akurilinI guess I couldn't find an SSL switch in Korma, but adding ssl=true to the parameters in the connection URL seems to force SSL on.
02:21andyfingerhutYou can choose to, but you don't have to. signed bytes have 8 bits, just like unsigned bytes do.
02:22danlentza signed byte can't represent 128
02:22danlentz(byte 0x80)
02:22danlentzIllegalArgumentException Value out of range for byte: 128 clojure.lang.RT.byteCast (RT.java:1019)
02:22andyfingerhut,(byte -0x80)
02:22clojurebot-128
02:22andyfingerhutsame bit pattern as unsigned 0x80
02:22danlentzsigned bytes are -128->127
02:24danlentzits 0xFFFFFFFFFFFFFF80
02:24andyfingerhutIt might be more productive to talk about what you want to do with unsigned 64-bit values.
02:25danlentzwell, I need to mask off abitrary bits of a 64-bit word and replace them primarily
02:26danlentz;; The string representation of A UUID has the format:
02:26danlentz;;
02:26danlentz;; clock-seq-and-reserved
02:26danlentz;; time-mid | clock-seq-low
02:26danlentz;; | | |
02:26danlentz;; 6ba7b810-9dad-11d1-80b4-00c04fd430c8
02:26danlentz;; | | |
02:28danlentzsorry that got me booted ....
02:28andyfingerhutdanlentz: Links are better.
02:28danlentzi'm back
02:29danlentzy sorry abt that
02:29danlentzso the canonical representation of UUID for java is 2 longs
02:30andyfingerhutCanonical as in that is how many people choose to store a UUID in Java?
02:30danlentzi need to mask off the various fields and takeb thier values as uint8, uint32, uint16 etc
02:31danlentzthat is how the java.util.UUID class seems to be implemented
02:32danlentzone can extend type UUID e.g., (get-word-high [uuid]
02:32danlentz (.getMostSignificantBits uuid))
02:32danlentz (get-word-low [uuid]
02:33danlentz (.getLeastSignificantBits uuid))
02:33andyfingerhutIf you have two longs, the first holding the 6ba7b810-9dad-11d1 part in your example, you can use Zach's primitive-math library to do unsigned right shifts using the >>> macro (I think it is a macro -- maybe a function instead), e.g. (>>> long0 32) = 0x6ba7b810
02:33andyfingerhutThen convert that to a 32-bit int if you wish using unchecked-int
02:36andyfingerhutClojure does not have an unsigned right shift operation yet, unfortunately, but one may be added in the next release.
02:36danlentzbut what if those first 4 bytes are 0x80 0x80 0x80 0x80
02:37andyfingerhutbits are bits. Try this:
02:37andyfingerhutafter doing (use 'primitive-math) on Zach's library
02:37andyfingerhut(format "%08x" (unchecked-int (>>> -0x8000000000000000 32)))
02:38andyfingerhutYou should get out 80000000
02:38andyfingerhut(the string)
02:38amalloy,(format "%08x" (unchecked-int (>>> -0x8000000000000000 32)))
02:38clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: >>> in this context, compiling:(NO_SOURCE_PATH:0:0)>
02:38amalloyoh right, haha
02:39andyfingerhut>>> is part of primitive-math lib, not Clojure
02:40danlentzah -- you're right
02:41danlentzusing unchecked-int afterwards is what I was missing
02:41danlentzwow I think that really helped me out
02:41andyfingerhutIt is easy to freak out about Java not having unsigned types, but except for the numerical ranges of values they are normally printed or read as, signed and unsigned integers fill the hardware registers the same way
02:41danlentzthanks for sticking with me through that
02:42andyfingerhutnp. A-ha moments are a beautiful thing to have and behold.
02:42danlentzits been about a month now I've been banging my head on this
02:43danlentz>>> = primitive-math/bit-unsigned-shift-right, yes?
02:43andyfingerhutformat with %x is a nice way to print ints as unsigned values. There might be %u, too. Not sure about reading them, but I can experiment a bit.
02:44andyfingerhutYes. Just a bit shorter :)
02:45danlentzand (type -0x8000000000000000) = Long
02:45danlentzdear god i think this may help end my struggle!
02:45danlentz(inc andyfingerhut)
02:45lazybot⇒ 2
02:47andyfingerhutLooks like Java/Clojure's format is good for printing byte/short/int/longs as unsigned octal or hex, but I don't see a good way to do it in decimal unsigned.
02:47danlentzof course (type 0x8000000000000000) = clojure.lang.BigInt so some care is still in order w.r.t edge cases
02:48andyfingerhutYes, that value is not a signed 64-bit long value.
02:48danlentzive been using
02:48danlentz(defn pphex [x]
02:48danlentz (returning x
02:48danlentz (cl-format *out* "~&~A [~64,'0b]~%"
02:48danlentz (format "[%1$016X] " x) x)))
02:50andyfingerhutAll of what would be unsigned long values from 0x8000_0000_0000_0000 through 0xFFFF_FFFF_FFFF_FFFF are signed values that are numerically 2^64 smaller than those unsigned values. But their bit representations are exactly the same as those unsigned values.
02:50andyfingerhutI have not seen 'returning' before. What is that?
02:50danlentzoh
02:51danlentzits analogous to common-lisp's prog1
02:51danlentz(defmacro returning
02:51danlentz "Compute a return value, then execute other forms for side effects.
02:51danlentz Like prog1 in common lisp, or a (do) that returns the first form."
02:51danlentz [value & forms]
02:51danlentz `(let [value# ~value]
02:51danlentz ~@forms
02:51danlentz value#))
02:51andyfingerhutok, familiar with that one.
02:51SegFaultAXdanlentz: Probably easier not to do multi-line paste in the channel.
02:51SegFaultAXrefheap or gist are better options :)
02:52danlentzdunno how you guys live4 w/o it :)
02:52andyfingerhutwill (print (format "%016x" x)) work just as well as the cl-format expression?
02:52danlentzSegFaultAX sorry
02:52andyfingerhutOh, unless you are trying to get out binary.
02:52danlentzy had issues getting binary w/o cl-format iirc
02:53SegFaultAXdanlentz: No problem, just something to keep in mind.
02:54danlentzbtw i really love clojures auto-gensyms or whatever they're called
02:55andyfingerhut(Long/toBinaryString -0x8000000000000000)
02:55danlentzmakes with-unique-names and once-only seem somewhat barbaric
02:55andyfingerhutJava method I just Googled.
02:56danlentzooh. fantastic
02:56andyfingerhutThe cl-format method you showed gave me an error when I tried it with that argument. Probably a bug.
02:58danlentzbut wait the toBinaryString doesnt left-pad 0's
02:58amalloydanlentz: i wrote that `returning` function you pasted, but i can confirm it's pretty easy to do without since most of the time clojure functions are side-effect-free
02:59danlentzstill easily remedieds
03:00danlentzamalloy: y I didn't mean to omit the proper attribution -- just playing fast and loose to convey the idea
03:01amalloyno, i don't mind. just that you said you don't know how we live without it: it's easy if you avoid side effects. i'm pretty sure i haven't used `returning` for months
03:03danlentzamalloy: I copy-pasted it rather than call yours b/c I have a couple of extra tweaks in my utils.clj like an extended "returning-bind" version
03:04danlentzanalogous to the way paul grahams anaphoric aprog1 works without the lexical injection of an 'it binding
03:06danlentzbut "returningf" was a really nice choice of name much more aesthetic and semantically transparent than APROG1 for sure
03:06danlentz"returning" that is
03:08andyfingerhutHmph. I forgot that cl-format with 0-padding is not a good fit for negative numbers.
03:08danlentzi guess returning-bind might be more clojurishly named returning-let to be consistent with when-let, if-let etc... bind is a somewhat common-lisp centric terminology as symbols and bindings work somewhat differently....
03:10mythzHey guys if anyone's interested I've just published a port of C#'s 101 LINQ examples to Clojure at: https://github.com/mythz/clojure-linq-examples - As I'm just starting out myself, any suggestions to improve readability or make the examples more idiomatic is welcomed!
03:11danlentzandyfingerhut: yes, the clojure implementation is unfortunately true to the CL version in that regard
03:11danlentzi really hate format TBH
03:12andyfingerhutJava/Clojure's format is more like C's printf, and fortunately does not have that quirk of CL format / Clojure cl-format
03:12danlentzthe only reason I use it is a profound disgust for all the alternatives....
03:14danlentzbut there is no simple clj.core/format recipie that will handle left-padding the result of (Long/toBinaryString x) with 0's -- or is there?
03:15andyfingerhutNot that I know of. If you want it, probably easiest is to write your own simple 0-padding function on strings.
03:16danlentzy just checkin --- you've been on a roll so I figured I'd ask just in case :)
03:17danlentzi hadnt noticed the cl-format issue before
03:17danlentzi'm sure there is a means of circumventing it
03:18danlentzpeople do really magical things wioth cl-format
03:18danlentz(unfortunately I'm not one of them..)
03:19abaranosky"hey"
03:21abaranoskyegghost:
03:21abaranoskysorry for the spam guys... I'm learning to use IRC via Emacs, and making noob mistakes. :\
03:25sszzqqCloujure could run in JVM & CLR, I think it could run in Perl/Ruby/Python, even Common Lisp.
03:27abaranoskysszzqq: it could!
03:27andyfingerhuttbaldridge (I think) wrote https://github.com/halgari/clojure-py
03:28abaranoskyandyfingerhut: yep, that's by Tim Baldridge, indeed
03:28sszzqqClojure could transfer to Javascript, I think it also could transfer Lua/Ruby/Perl/...
03:28abaranoskyI wonder, is it production quality?
03:28abaranoskymy impression is that only JVM Clojurea nd ClojureScript are indeed production ready
03:29danlentzandyfingerhut: how about https://www.refheap.com/20284
03:29andyfingerhutdanlentz: Your cl-format-fu is certainly stronger than mine :)
03:30SegFaultAXA number of implementations have been started including Python and Lua. I don't think they've seen much work, though.
03:30andyfingerhutabaranosky: tbaldridge is probably the best to comment on production-worthiness of clojure-py. Clojure CLR has a few users, I think, but I've never tried it.
03:30SegFaultAXHopefully Clojure in Clojure will bring down the barrier to entry for new impls.
03:31abaranoskyandyfingerhut: cl-format is a wonder to behold
03:32abaranoskyandyfingerhut: and to be fair, these are only my *impressions*, not actual facts :)
03:32andyfingerhutabaranosky: Yes, every time I see an even slightly complex example of it, I wonder :)
03:32danlentzandyfingerhut: its pretty flimsy actually -- kind of a punt to use cl-format and clj.core/format both like that I think
03:32danlentzbut a punt which works...
03:32SegFaultAXabaranosky: How's Staples?
03:33andyfingerhutdanlentz: yes, it does work. You could simplify its format string to [%016X]" I think.
03:33andyfingerhutdanlentz: Unless you like being explicit about argument position numbers.
03:34SegFaultAXabaranosky: How has the transition been for Runa?
03:34danlentzactually i've discovered that cl-format gives much much more informative error messages than CL format (at least under SBCL and prob most othetrs)
03:34abaranoskySegFaultAX: hey do I know you by real-life name? re: Staples, the acquisition has been really great. We've got ~5 planned machine-learning-based projects to improve conversion rates on the stples online store
03:35abaranoskywe're remodelling the whole office, and in general expanding excitedly
03:35SegFaultAXabaranosky: We met at that prismatic thing a couple weeks ago.
03:35danlentzclojure.pprint/cl-format, correspondingly, is a hell of a lot easier to deal with
03:35SegFaultAXabaranosky: That's awesome! Congratulations again. :)
03:35abaranoskySegFaultAX: as far as transition I'd say it feels mostly the same, but witha transition to a one merchant focus
03:36SegFaultAXI'm always curious to see how little companies transition into big companies, especially via acquisition.
03:36abaranoskySegFaultAX: what's your name again? I met alot of people at the prismatic meetup
03:37abaranoskySegFaultAX: Staples is explicitly keeping us separate from the huge monoithic company structure, so as to give some innovation to pipe back into the mohtership
03:37SegFaultAXabaranosky: Michael-Keith (MK). Same nick on twitter if you're better with faces.
03:38abaranoskyah nice, recognize the face now :)
03:38SegFaultAXabaranosky: Is the Runa group dropping all the branding in favor of the Labs title?
03:39abaranoskyI watched these videos by Tie Baldridge and loved them: http://www.youtube.com/watch?v=R3PZMIwXN_g&amp;noredirect=1
03:39abaranoskyyeah, we're not Runa anymore
03:39abaranoskybut I hate saying Stples Innovation Lab. Too long.
03:39clojurebotexcusez-moi
03:39abaranoskyand SIL isn't very pronouncable
03:40SegFaultAXNo, I don't suppose it is. Haha.
03:40abaranoskySIL is now going to be responsible for creating a variety of services to feed to the website... things like intelligent search, and recommendations engines
03:41SegFaultAXIs the scope pretty open or do you have specific projects?
03:42abaranoskyspecific projects for the first 6 months we've got planned, but as time goes by the scope will expand to more services as the business folks think of more
03:43SegFaultAXThat's pretty great. Plus you probably have massive databases of data to train on.
03:43abaranoskyyeah, and we've got allllllll of staples data too
03:44abaranoskyRight now, we're looking to expand our developer-pool and data scientisit pool a ton. We'll be at Clojure Conj with a tables setup recruiting I'm sure.
03:45SegFaultAXabaranosky: Is Staples all Java on the backend?
03:45SegFaultAXAt least from the web side.
03:46abaranoskyyoumean the mothership right?
03:46abaranoskythey're using WebShpere ... the innovation lab has only a very small few files of Java
03:46abaranosky:D
03:48SegFaultAX"They're" don't you mean "we"? ;)
03:53jared314is there something like doseq without the bindings? i'm code golfing
03:53abaranoskySegFaultAX: "They" referring to the mothership
03:54SegFaultAXIs mothership staples in this instance?
03:54abaranoskyjared314: `dotimes`
03:54llasramjared314: `do`? I'm not sure how the `seq` part would work w/o bindings :-)
03:54abaranoskythe main Staples org... it's not an official term, hehe
03:54llasramjared314: Unless you mean `doall`/`dorun`
03:55abaranoskyllasram, jared314: yeah depends what the code is actually doing
03:55jared314llasram: i need the side effects but not the result
03:55jared314https://www.refheap.com/20285
03:55llasramSounds like `dorun`
03:56jared314llasram: but i need the looping
03:56llasramjared314: OOC, what is that macro doing which it would be difficult to do in a function?
03:56abaranoskyllasram: seems like 'nothing'
03:56llasramjared314: `dorun` walks a lazy seq, forcing all side effects, but discarding the results and not holding the head
03:57llasramIf you actually need to do something with each value, then you do need the bindings
03:57jared314i have to print them
03:58llasramYou could (dorun (map println col)), but `doseq` is about the same length and clearer
03:58abaranoskyjared314: if it were jusst printing I'd say to do something like (apply println (map f s2)) ... but you are also calling read-line
03:58jared314yeah, that is the hard part
03:58abaranoskywhen you have IO peppered in a function, it is hard to avoid this kind of verbose procedural code
03:59jared314abaranosky: and it has to be a macro because doc arguments
04:00abaranoskyyou could do: (apply println (interleave i# (repeat "\n"))) but this is longer and weirder than your implementation :D
04:01jared314previously i was using println string/join, but doseq println is shorter
04:01abaranoskyit is shorter and cleaner
04:02llasramjared314: doc arguments?
04:02SegFaultAXWell presumably if you're golfing, it doesn't matter how weird it is.
04:02SegFaultAXAs long as you're shaving bytes.
04:02SegFaultAXBytes are like yaks, all of them must be shaved.
04:02abaranoskyyeah, I guess I'm not really a golfer in my heart of hearts
04:02llasramOh, calling `doc`
04:03jared314the point of it is to paginate the output of doc
04:03abaranoskywhat type does 'doc' expect
04:03jared314doc is a macro
04:03llasramIt's unfortunately a macro :-/
04:03SegFaultAXLisps don't tend to be the best golfing langs in my experience.
04:03SegFaultAXGolfing is one time where the parens really do bite you.
04:04abaranoskySegFaultAX: they come pregolfed in a sense
04:04jared314then clojure needs more arrows
04:04abaranoskynot golfed like Perl..., but compared to most languages, you don't have much cruft you can pull out
04:05SegFaultAXHeh, well perl golfing is a different level.
04:05abaranoskyif you want to know, a better way to write this is to make doc2 a macro, but then implement sa fn like doc2-fn that implements everything execpt for the (split-at ....) sexp
04:05SegFaultAXThat's Odin-tier golfing, and only because of metavars.
04:06abaranosky... hmmmm , I think I'm too tired to think this through fully, but it looks suspect to need tha tmany lines of macro code
04:06SegFaultAXErr perlvars rather.
04:07abaranoskyPerl really is the only *true* golfing imho
04:07abaranoskyjared314: I found a way to trim your code!!!
04:08SegFaultAXWell and J/K/APL
04:08SegFaultAXBut when you invent your own glyphs, that's sort of cheating isn't it?
04:08jared314abaranosky: ?
04:08abaranoskyadd (let [p# println]) then call p# everywhere instead of println
04:08abaranoskythat saves you a few chars right?
04:09SegFaultAXjared314: Nevermind golfing, convert your macro to swearjure if you want to be truly elite.
04:10abaranoskySegFaultAX: life is not fair
04:10jared314i saw that presentation, it was in line with bf and whitespace
04:10abaranoskytake it easy gents, time for bed :)
04:11SegFaultAXMe too, night.
04:15jared314oh well, i think it is as short as i'm going to get it right now
04:17amalloyjared314: (.. getTerminal getHeight) is shorter as .getTerminal .getHeight
04:18jared314amalloy: not with the extra parens
04:18amalloywhat extra parens?
04:18amalloyjust put in what i wrote
04:18jared314oh using the arrow
04:18jared314true
04:19amalloyand of course your doseq could be a local fn: (let [q# #(doseq [x# %] (p# x))] ...) should save a couple characters
04:23jared314thanks for the help, i'm going to call it a night
04:56algalI notice "lein deps :tree" helpfully warns me that some of my project dependencies don't get along well. It seems like their transitive dependencies are over-riding each other. can anyone point me to a link on how to think about or solve this problem?
04:58beppu(for all the grief javascript gets, the one thing they got very right was the ability to load multiple versions of the same library)
05:02vijaykiranalgal: you can use exclusions to get rid of unwanted depenedencies
05:02vijaykiranalgal: e.g., https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L47
05:02algalbeppu: I take it that we can't do that in JVM-land, that's why leiningen etc need to have a policy to choose just one version of the library, and that's why it gives warning when different project components depend on different versions?
05:04beppualgal: I believe that's the case (but I'm new to Clojure and I don't have much experience w/ JVM langs, so I can't say for sure) </disclaimer> ;)
05:04algalvijaykiran: Is there any documentation on exclusions that is not maven documentation?
05:05vijaykiranalgal: I'm not aware of any OTOH, but dependency management is done via maven deps - so that docs should be helpful
05:05clgvbeppu: algal: well even in theory ths dependency problem seems not solvable as soon as you depend on two incompatible versions of a library and need to pass data between them through the transitive call hierarchy
05:06algalclgv: I would settle for the problem being solvable in practice.
05:06clgvalgal: you just exclude the lib in the dependency that pulls in the undesired version
05:07algalSo (dumb question, maybe) what's the rule of thumb here, when lein deps :tree spits out an alarming cascade of warning about override leading versions ?
05:07clgvalgal: not really on the technical site but on the social site by pushing the maintainer of the lib that transitively pulls in an old version of the conflicting lib to upgrade ;)
05:07algalShould I spend my days lovingly curating a set of exclusion declarations so that the project only pulls the latest and greatest?
05:08clgvalgal: well in practice I have only one or two exclusion statements per project
05:08bepputhe social solution seems to be the best course of action
05:09mindbend`what's the most popular to automate deployment of clojure applications?
05:09clojurebotExcuse me?
05:10mindbend`clojurebot: I'll strangle you now
05:10clojurebotI don't understand.
05:12clgvmindbend`: there is pallet but I don't know about its general popularity
05:12clgvmindbend`: for deployment to several remote machines
05:12algalwhat decides what overrides what? Is it the order of dependencies in my ns form dictating the order of jars which dictates the lookup order in the classpath?
05:12clgvalgal: afaik lein just picks one of the versions
05:13algalat random, each time? Inconceivable. Mr Technomancy is all about repeatability. So there must be a rule that makes it deterministic.
05:13clgvalgal: no, not at random
05:14clgvalgal: you gotta look up what rule is used since I did not care too much for that yet to investigate it
05:15algalclgv: seems like dependency order is driving it, presumably via jar order -> class path order.
05:19clgvalgal: huh? I thought you meant the rule that selects the version of the dependency that is transitively depended on in two different versions
05:19algalclgv: I did.
05:20clgvalgal: so why are you talking about classpath order then?
05:21algalclgv: because I think dependency order is translating into classpath order, and so the dependency order is determining which transitive dependencies are shadowed by earlier items on the classpath.
05:21llasramalgal: Leiningen picks one version of any given dep to put on the classpath, using the same algorithm as Maven.
05:21algalllasram: agreed. what is that algorithm?
05:22clgvalgal: no. there is only one version of the lib on the classpath
05:22llasramOrder by (top-most, earliest)
05:22clgvalgal: everything else would be insane ;)
05:22llasramSo dependencies you specify override transitive deps. Deps directly specified by any of your deps beat further transitive deps, etc
05:22llasramAny conflicts at the same depth are resolved by earliest-first
05:23algalllasram: "earlier" in time? in version number? in what?
05:23llasramEarlier in the dependency list
05:23llasramYeah, wasn't clear :-)
05:23algalllasram: aaah! okay.
05:24algalllasram: thanks,this is enlightening.
05:24algalfeels sort of impossible to understand clojure's tooling without understanding Java's, which is sad.
05:25clgvalgal: thats just wrong since leiningen is clojure tooling
05:25llasramIt's more to take on to really master the ecosystem, but also is part of how much leverage you get with Clojure
05:27algalthanks for the help, chaps. g'night.
06:32nonubywhen in a http-kit (async http client) callback if I want to push a result on a core.async.channel presumably I use the blocking version of 'put' >!! since the http-kit has a seperate threadpool
06:33nonubysince it doesnt make sense to stick the work of pushing onto a channel on to the core.async threadpool ?
06:50andrewmcveighHi, I have a macro 'with-action, and I'd like it to know whether it's called within itself E.G., (with-action :beat-up (some-fn (with-action :kick ...))) - is there a non-awful way for the action :kick to know that it's part of a larger action :beat-up?
06:51andrewmcveighnot a very good example... I know.
06:56llasramandrewmcveigh: Depending on what you're trying to achieve, there's a few different approaches...
06:56llasramDoes `with-action` need to its scope during macro-expansion, or during evaluation?
06:57llasrams,need to,need to know,
06:58andrewmcveighllasram: Well, I'm just toying around. Essentially, I'm trying to transform the body of code passed into it. But I'd like the transformation to be a bit different if it's called within a larger action.
06:58andrewmcveighSo macro-expansion time, I guess?
07:00llasramOk, in which case "within" can only mean "within the lexical scope of the larger action" -- if arguments contain function calls which contain more `with-action` calls, you have no way of impacting them
07:01llasramSo then probably the easiest thing to do is use clojure.walk or one of the libraries specific to code-walking macros and modify the `with-action` calls to contain the full stack of actions within scope
07:02llasramI believe ztellman's is the most complete ATM: https://github.com/ztellman/riddley
07:02llasramNote that if you want this to be something which happens at run time via dynamic scope, it's waaaaay easier :-)
07:05andrewmcveighllasram: Thanks. Not done any code-walking stuff yet. Mostly shyed away from it...
07:06andrewmcveighMaybe it's time to have a look... I have a week off work :)
08:17Jardais there a 'standard' equivalent for the nodejs NODE_ENV variable?
08:32glosoliHey, any ideas what could be wrong with such interop in for https://www.refheap.com/4b0b8a303448d107f745a02d2 I get index out of bounds exception, I am sure it retrieve page object properly
08:44jkkramerglosoli: for is lazy and would be realized after the stream has been closed. wrapping it in (doall) should help
08:45glosolijkkramer: thank sir, you saved me a headache! :)
09:19arrdem3
10:02Jardahi
10:03Jardaif if I have a vector [1 2 3 4 5 6] how can I multiply 1 and 4 by 2, 2 and 5 by 3, 4 and 6 by 4
10:03JardaI tried take-nth but couldn't get it to work as I wanted
10:04Jardashould I use map-indexed and check if index is dividable by 3 etc
10:05ToBeReplacedJarda: i don't understand the algorithm.... can you put a more involved example?
10:06JardaToBeReplaced: the algorithm is the following: starting from left multiply first item by 2, second item by 3, third item by 4, fourth item by 2, fifth by 3, sixth by 4, seventh by 2 ... etc
10:07ToBeReplacedokay, you're down the right path -- you need map-indexed because you require the index
10:09ToBeReplacedthere's a few other cutesie ways that don't involve the division -- ex. partition and map cat +
10:09ToBeReplaced,(doc cycle)
10:09clojurebot"([coll]); Returns a lazy (infinite!) sequence of repetitions of the items in coll."
10:10ToBeReplacedso something like (map + v (cycle [2 3 4])) is prob sufficient
10:11ToBeReplaced,(map + (range 1 7) (cycle [2 3 4]))
10:11clojurebot(3 5 7 6 8 ...)
10:28jcromartieI'm patiently waiting for a paradigm that completel eliminates complexity in information systems.
10:28clgvjcromartie: could there ever be such a thing from a theoretical perspective?
10:33milanjhow to set emacs/nrepl for loading clojure code that is part of java source tree
10:33jcromartieclgv: I don't know. I am becoming increasingly convinced that software is governed by the same laws of entropy as any physical system.
10:34jcromartieI haven't studied any systems engineering, though. My brother did his MS in systems engineering, and has gone on to write big-ball-of-mud software in PHP and Perl so far.
10:34jcromartie(for wall st)
10:35clgvjcromartie: PHP and Perl? *shudders*
10:35jcromartienot exactly HFT or anything, just conservative traders doing modelling
10:35jcromartieI can definitely buy the whole functional over OOP thing for reducing complexity at some level
10:36jcromartiebut I think as an industry we just have no idea what we're doing
10:36clgvjcromartie: good intro to go back to call it "art of computer programming" ;)
10:36jcromartie"There are only two kinds of languages: the ones people complain about and the ones nobody uses."
10:38jcromartieso we have all these high-level many-moving-parts kind of solutions to complexity
10:39jcromartieI like what I'm seeing in dnolen's work with core.async in clojurescript
10:39jcromartiebut there's no silver bullet right
10:39clgvjcromartie: fo mankind's sake I hope PHP will move to the second kind
10:39jcromartiebut you can't argue that people get stuff done
10:40jcromartieand there's really no way to tell, from the outside, if some successful system is written in PHP or Clojure or Brainfuck for that matter
10:40jcromartieas long as we're talking about an opaque system that takes strings and turns them into other strings
10:40clgvjcromartie: but the problem is you can't measure how much money is wasted that way also if you consider security issues
10:44jcromartiehttp://en.wikipedia.org/wiki/No_Silver_Bullet
10:54davHow can I get clojure.pprint/pprint to print recursive hashes on multiple lines and with indent?
10:58devndire looks pretty neat
11:00devnalso, the datomic console -- excited to try that out
11:00mdrogalisdevn: Thanks.
11:03jcromartiethe pretty printer source code is something else
11:03clgvmdrogalis: does dire match exceptions to superclasses yez?
11:03clgv*yet
11:04mdrogalisclgv: Next release, probably 2 weeks away. Need to figure out how to specify priorities
11:04mdrogalisIf you have a subclass, superclass, and predicate, which gets evaled first?
11:05jcromartieit looks a lot like your average mutable Java object design but with another level of indirection
11:05jcromartiehttps://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/pretty_writer.clj
11:05clgvoh nice. I was struggling with that when wanting to use dire for debugging
11:06mdrogalisI frankly just never thought of it until lately. :P
11:06jcromartiea struct with several refs in it :|
11:06mdrogalisI'm emailing with someone who has an idea about it. I can make a GitHub issue for public discussion if you want to weigh in.
11:06jcromartiethere has got to be a better way to make a pretty printer
11:08clgvmdrogalis: wont hierarchies with prefer-statements work?
11:08cmajor7jcromartie: https://github.com/brandonbloom/fipp ?
11:08mdrogalisclgv: Yeah, that is kind of what I was thinking.
11:08mdrogalisSort of how multimethods do it.
11:09jcromartiecmajor7: nice
11:14jtoywhy cant I turn a string into a buffered io stream with (clojure.java.io/input-stream "asdasd")? according to the docs I think that should work?
11:14jtoy,(clojure.java.io/input-stream "asdasd")
11:14clojurebot#<SecurityException java.lang.SecurityException: denied>
11:15cmajor7jtoy: (ByteArrayInputStream. (.getBytes s)) ?
11:16llasramjtoy: Try: ##(-> "example" .getBytes clojure.java.io/input-stream)
11:16lazybot⇒ #<BufferedInputStream java.io.BufferedInputStream@1713e71>
11:17llasramjtoy: The default conversion pathway for strings tries to treat them as filenames
11:17llasramBut byte arrays ^^
11:19jtoycool, testing it out
11:23drorbemetHi, did any body use the 7-Zip-JBinding library http://sevenzipjbind.sourceforge.net/index.html ? Would you be so kind and direct me to som hints on how to use java libraries of this kind in clojure? Untill now I didn't had to deal with java exeptions and the like in clojure code.
11:26joegallohttp://clojure.org/java_interop
11:27joegalloand http://clojure.org/special_forms#Special%20Forms--%28try%20expr*%20catch-clause*%20finally-clause?%29
11:27joegalloyou can translate their example http://sevenzipjbind.sourceforge.net/snippets/GetNumberOfItemsInArchive.java into clojure pretty straightforwardly
11:28joegalloi usually start by pasting the java into a clj buffer, and then editing it into parens...
11:28jtoyllasram: cmajor7: yes, it worked!! thanks: (-> @(httpkit/get url :body .getBytes clojure.java.io/input-stream parse-feed :entries)
11:28joegallothen the .close calls become with-opens, and any assignments become lets
11:28joegallonext thing you know, bam, it's working ;)
11:33drorbemetAh, thanks, slowly I get going, have a nice day :-)
11:35joegalloyou're welcome. if you end up with something that's not quite working, just check back in. you can paste your code using a paste-bin like refheap.com and folks can give you pointers on where you might be going astray
11:35joegallogood luck!
11:37Jardahi
11:37Jardaif I have a number X, how can I find the distance to number Y where Y is the next number with Y % 10 == 0
11:38Jardaso fo 84 I'd like to return 6 (84+6=90)
11:39clgvJarda: integer division by 10, add 1 multiply by 10
11:39jcromartieis this homework?
11:39Jardajcromartie: nope
11:39jcromartie:P
11:39JardaI'm just having hard time with math today
11:39Jardaand thought there would be some 'ceil' function that would have the precision
11:39clgvJarda: I described how to find Y. above
11:40Jardaclgv: yeah thanks
11:40jcromartie(defn next-po10 [n] (* 10 (inc (int (/ n 10)))))
11:40clgv(defn next-po10 [n] (* 10 (inc (quot n 10))))
11:41clgvmore readable as seq of operations (defn next-po10 [n] (-> n (quot 10) inc (* 10)))
11:41Jardathanks
11:41hyPiRionyeah
11:41joegallowhat's the desired answer for 80? 80, or 90?
11:42joegalloi mean, sure 81 -> 90, but what about 80?
11:42clgv6 I guess
11:42Jardajoegallo: actually 80 would be fine
11:42clgvharr good one. he said "next" which I interpreted as greater relation ;)
11:42hyPiRionjoegallo: next number
11:42Jardabut I can special case
11:42joegalloalso, do you want the number (86 -> 90), or do you want the distance (4)?
11:43jcromartieclgv: nice refactor
11:43Jardathe distance actually
11:43joegallo,(- 10 (rem 86 10))
11:43clojurebot4
11:43joegallothere ya go
11:43clgvyeah right distance via modulo is easier ^^
11:43Jardathanks
11:43JardaI knew there's an elegant solution
11:44jcromartieyeah
11:44Jardait's been a while since I last did basic math in uni..
11:44joegallo:)
11:44hyPiRionjoegallo: actually, that should be mod instead of rem if you need to support negative integers
11:45joegallotrue enough
11:45hyPiRion,(map (fn [f] (- 10 (f -12 10)) [rem mod])
11:45clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:45hyPiRion,(map (fn [f] (- 10 (f -12 10))) [rem mod])
11:45clojurebot(12 2)
11:52jcromartiethis is a weird construct: (= (pos? num) (pos? div))
11:52jcromartieisn't that logical nor?
11:52bbloomseems reasonable to me
11:52jcromartiewait no
11:52bbloomassuming it makes sense in context
11:53jcromartieyeah I guess boolean equality is the right operator
11:54bbloomcomparing if two booleans are equal is (comp not xor)
11:55silasdavisHow can I cycle a list: [1 2 3] -> [2 3 1]
11:55silasdavis?
11:55silasdavisor the other way
11:56joegallo,(vec (take 3 (drop 1 (cycle [1 2 3])))
11:56clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:56joegallo,(vec (take 3 (drop 1 (cycle [1 2 3]))))
11:56clojurebot[2 3 1]
11:56llasramsilasdavis: reverse...?
11:56llasramOh, you want to rotate
11:58silasdavisyes
11:59hyPiRion,(let [q (into clojure.lang.PersistentQueue/EMPTY [1 2 3]) elt (peek q)] (-> q pop (conj elt)))
11:59clojurebot#<PersistentQueue clojure.lang.PersistentQueue@7c3f>
11:59hyPiRionIf you need performance, keep it as a queue
12:01sritchie_hey guys, has anyone here used clojurescript for a chatroom-like application?
12:01sritchie_I'm working on an example that uses websockets and redis pubsub behind the scenes to communicate between nodes serving the chat room -
12:02sritchie_most examples keep a map {userID -> websocket} around
12:03sritchie_with multiple chat rooms, I guess the way to go forward would be to keep a nested map of {room -> {id -> websocket}}
12:03silasdavishyPiRion: thanks, why elt?
12:03hyPiRionbecause you need to push the element back in
12:04hyPiRionread as: set elt to the first element in the queue. Then remove the element and conjoin it to the end
12:11silasdavisno sorry I just wondered what elt stood for
12:12silasdaviselement
12:12silasdavisright
12:12silasdavislooks like clojure.contrib.seq-utils has a rotations that would do what I'm after
12:12silasdavisbut I cant' find that on clojars
12:12silasdavisor on the clojure git hub
12:18llasramsilasdavis: it's a dead contrib
12:19ToBeReplacedsritchie: that's an example pedestal app if you google it
12:19llasramsilasdavis: But easy enough to write as a function: ##((fn rotate [n coll] (->> (cycle coll) (drop n) (take (count coll)))) 1 [1 2 3])
12:19lazybot⇒ (2 3 1)
12:23gfredericksdoes kibit suppress unused-argument warnings if the arg starts with _?
12:24silasdavisllasram: better/worse?: (let [x [1 2 3]] (map (fn [n _] (concat (drop n x) (take n x))) (range) x))
12:25silasdavisoh I want all rotations, but is cycle better than concat
12:25llasram`cycle` uses `concat`, so really doesn't matter
12:30jonasengfredericks: not sure what you mean?
12:32sritchie_cemerick, as the resident cljs genius, I have a quick design Q to run past you
12:32sritchie_if you have a second
12:33cemericksritchie_: sure, but LOL, wtf, etc ;-P
12:33sritchie_haha
12:33cemerickI play Curly to dnolen's Moe.
12:34sritchie_I wouldn't be surprised to find out that dnolen is, in addition to being a javascript coder at NYT, cljs committer, also a war journalist, columnist, etc
12:34sritchie_somehow getting all of it done
12:34sritchie_cemerick: it's actually just my question from above, I'm just trying to flatter you to rope you in to answering :) I'm getting my websockets on in cljs,
12:35sritchie_with core.async
12:35sritchie_and the single chat room example that every has, using redis's pubsub to broadcast new chat messages between servers so they can tell the relevant websockets, is pretty clear
12:36sritchie_with a single chat room, each server instance maintains a map of userID -> websocket;
12:36sritchie_my Q is, if I want to tackle multiple chat rooms, is the "right way" to keep a nested map of room -> userid -> websocket?
12:36dnolencemerick: your analysis of 643 looks good, been wanting to clean this up for a while - also it's why we have spurious protocol errors, race condition on namespaces since it's not currently thread safe - it should definitely be dynamically bindable
12:36sritchie_now that I type it out it sounds like that's the only damned way
12:37cemericksritchie_: in {room -> {id -> websocket}}, what's the point of `id`?
12:37cemerickoh, userid....? Is this P2P?
12:38tbaldrid_cemerick: apparently not if he's using redis to route the messages
12:38sritchie_well, I guess I should be specific. What I'm actually trying to do is create a "live results" feature
12:38sritchie_for various athletic events
12:38cemericktbaldrid_: oh, didn't catch that part
12:38sritchie_so, there might be five events going on at some race (men's, women's, 1 man boat, 2 man, etc)
12:38sritchie_and the race organizer is timing the thing and firing new results up to the server
12:39sritchie_so I'm trying to write a page that will allow new results to show up as they're posted for each event
12:39cemerickdnolen: I think we can get back to how e.g. ~1853 worked w.r.t. downstream tools/usage with a minimal set of changes. What are your specific concerns re: namespaces?
12:39dnolencemerick: I don't really have any except that tools should be able to bind it to have thread safe builds
12:39dnolenbut also REPLs
12:40sritchie_cemerick: tbaldridge_: I guess if sockets have proper equality I could keep a map of eventID -> Set[WebSocket]
12:40cemerickdnolen: I think being able to provide a compilation environment will superset that; there's no doubt that namespaces is touched the most of all though.
12:41dnolencemerick: are you talking about some longer term thing - I don't see how the compilation environment fixes thread races on namespaces
12:41NeedMoreDesuCan I do something like this in clojure: start a background thread doing something, and on some part of calculations it executes some code back in main thread? like (future (let [result (heavy-calculations)] (execute-in-main-thread (some-thread-context-fn result))))
12:41cemericksritchie_: If you have a single upstream producer, then why not have a single websocket/SSE source, and merge events it sends down into a top-level model? You can then watch/react on an atom holding that model to disperse bits of data into your view(s).
12:42tbaldridge_sritchie_: and I don't imagine that you would have billions of race results a minute, so why not send all the updates to all the websockets?
12:42clgvNeedMoreDesu: will your main thread be idle until the event?
12:42sritchie_tbaldridge_: and just have them filter the ones they want?
12:42cemericksritchie_: Javelin does this for simple cases, pedestal front-end for more complex models...and CRDTs if you want the superset of 'em.
12:42NeedMoreDesuNope, it'll execute something.
12:43tbaldridge_sritchie_: yep, just do client side filtering
12:43sritchie_that's a good call, actually
12:43sritchie_since, yeah, we're not talking much data here :)
12:43NeedMoreDesuI know I can deref or test if future is finished time to time, but that's not very convinient.
12:44cemerickdnolen: nothing longer-term; each compilation environment would be entirely separate. Races would be nigh-impossible.
12:44clgvNeedMoreDesu: I thought of using a promise either blocking or querying whether it is delivered
12:44sritchie_cemerick: that's a good route, for sure, but I'm more wondering how to do the routing to the right clients
12:45clgvNeedMoreDesu: you'll have to provide more details I guess
12:45sritchie_but tbaldridge_'s solution seems like the right one for now, then fix it in a year when we're at twitter scale and processing 10k races / sec
12:45tbaldridge_sritchie_: that's a whole lotta running :-P
12:45technomancyaren't you at twitter scale already?
12:45sritchie_tautologically, yes
12:46cemericksritchie_: You mean if a client is looking at a subset of races? Yeah, I'd just send everything until it matters, as tbaldridge_ suggests.
12:46silasdavisis pop on a PersistentQueue constant time?
12:46tbaldridge_silasdavis: pretty close
12:46silasdavisbut count wouldn't be?
12:47dnolencemerick: not following at all, what will happen to namespaces? will it be bound around a compilation unit via some map containing a atom provided by the user? your comment is low on details.
12:47tbaldridge_silasdavis: count is a field on the class that's maintained by conj/pop. So yes, that is also constant time.
12:48dnolencemerick: anyways, gotta run for a bit, feel free to update the ticket w/ details.
12:48NeedMoreDesuclgv: Imagine main thread as some gui thread. And gui functions can be used only in main thread. And then we have some heavy calculations, that need to be done in parallel, and just use some main-thread fn's.
12:48clgvNeedMoreDesu: swing? there are a functions/methods in swing to execute something in th GUI thread
12:48cemerickdnolen: the namespaces get swapped into the compilation env atom, as they are now, just under a particular key. One compiler caller's `namespaces` never touches another's.
12:49cemericksure, I'll expand a bit on the ticket
12:51silasdavistbaldridge_: ah so it is, so no point doing (reductions (fn [q _] (rotate-queue q)) queue (pop queue)) over (reductions (fn [q _] (rotate-queue q)) queue (range (- (count queue) 1)))?
12:51NeedMoreDesuclgv: so this is library features, right?
12:53tbaldridge_silasdavis: rotate-queue?
12:55NeedMoreDesuclgv: I'm looking for something like this, actually http://stackoverflow.com/questions/10558019/does-using-dispatch-get-main-queue-mean-that-my-code-will-be-on-the-main-threa
12:55silasdavistbaldridge_: (conj (pop queue) (peek queue)))
12:56kolemannixHey guys I have this function that takes 3 collections (all of the same length), operates on each triple using map, and returns a single collection of the same length
12:56silasdavistbaldridge_: (defn rotate-queue [queue] (conj (pop queue) (peek queue))))
12:56kolemannixsomething like this (defn format-instruction [op locn comm]
12:56kolemannix 90 (str (encode op) \tab locn \tab (pad op) comm))
12:56clgvNeedMoreDesu: yes, in Swing it is e.g. http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingUtilities.html#invokeAndWait%28java.lang.Runnable%29
12:57tbaldridge_silasdavis: ick, that doesn't seem like a good idea. There's got to be a better way of doing whatever you're trying to do.
12:57clgvNeedMoreDesu: or invokeLater
12:57silasdavistbaldridge_: which part?
12:58tbaldridge_silasdavis: if you read the implementation of PersistentQueue.java (it's pretty simple actually) you can see that rotate-queue will use queues in a way they aren't really meant to be used in.
12:59kolemannixWhat's the best way to pass "state" into a function?
12:59kolemannixI have a function that operates on 3 collections, but I need to give it some additional information
12:59NeedMoreDesuclgv: ok, thanks
13:00kolemannixI don't really want to pass in the "state" info as a 4th argument
13:00rasmustokolemannix: I've done something similar with reduce (and a state map as the other argument)
13:00tbaldridge_silasdavis: I mean it works, its just it seems that something like a LinkedList would work better, or even doing nth on a vector.
13:00rasmustokolemannix: why don't you want the 4th arg?
13:01kolemannixI was just wondering if there's a better way to give the state map
13:01kolemannixI guess I can use a 4th arg
13:02dnolencemerick: ok sure like I said above. Do you want to take this patch on?
13:02cemerickdnolen: replied on the ticket.
13:03rasmustokolemannix: this probably isn't 100% what you want, but it shows how I use reduce + a state map https://www.refheap.com/19930
13:03cemerickdnolen: well, it *has* to be done. The `reset` approach is just broken IMO, esp. for REPLs. I'm happy to do the refactor, but I'll need help esp. with testing source maps, since I don't use them at all, and it doesn't look like there's any automated tests around them?
13:04dnolencemerick: writing tests for them is difficult because of unpredictable loss around inlining and dead code elimination
13:05cemerickdnolen: yeah, not faulting the lack of tests, but I suspect you're the only one that has any idea how they should work :-)
13:05dnolencemerick: we could write some for the simpler cases, but I really don't see how you could mess up source maps w/ this change. source maps tracking is per file and not really exposed
13:06dnolencemerick: beyond the compiled-cljs caching
13:06kolemannixrasmusto: Thanks, even though it's not the same thing it helps
13:06cemerickdnolen: Yeah, the refactor is actually a pretty straightforward transformation from (swap! *data-name* assoc ...) to (swap! *compile-env* update-in [:data-name] assoc ...)
13:06cemericknamespaces being maybe a bit different, but we'll see
13:07cemerickthe relation between REPL envs and compilation env is the biggest unknown at the moment.
13:08dnolencemerick: I don't see any obvious issues, the CLJS compiler is REPL centric
13:08dnolencemerick: outside of closure.clj
13:10cemerickdnolen: yeah, agreed
13:12dnolencemerick: one issue is accessing namespaces from macros, with your compilation environment idea it will be different
13:12dnolencemerick: that's the real breaking change
13:14dnolencemerick: could be avoided reading out namespaces and binding it seperately to support old interface
13:14cemerickdnolen: there are macros that look at ana/namespaces directly?
13:15dnolencemerick: that's whole idea, literally since day 1
13:15dnolenpart of the original design since there are no vars
13:17davHow can I get clojure.pprint/pprint to print recursive hashes on multiple lines and with indent?
13:19cemerickdnolen: as long as the usage is read-only, then yeah, ana/namespaces can be updated to mirror the value of the :namespaces slot in the compiler env. Can you point to a macro that looks at ana/namespaces now, though? Looks like extend-type et al. are the only ones in cljs itself?
13:19clgvdav: maybe you can convince "fipp" easier to do that
13:19dnolencemerick: it is the intended use case, Rich said this himself
13:21dnolencemerick: the question is whether we should push the idea further and leave direct namespaces access behind, and provide more utilities like cljs.analyzer/resolve-var to accomplish the same thing.
13:21cemerickdnolen: fine enough, wasn't aware of the word ;-P Any chance the discussion was online?
13:24davclgv: nope that one prints on one line too..
13:27dnolencemerick: can't find anything beyond the source, but it's come up in conversation before when people have complained about lack of vars.
13:27cemerickyah, ok
13:27dnolencemerick: whatever we come up with 643 should support reading namespaces for sure
13:28bbloomdnolen: did you see https://github.com/YaroslavGaponov/node-jvm ?
13:28cemerickdnolen: aside from maintaining the existing "api", shouldn't they just hang off of &env?
13:28dnolencemerick: the namespace isn't in &env
13:29dnolencemerick: &env is just the local environment of the compilation unit
13:29dnolencemerick: I think conflating the two when they aren't conflated in Clojure doesn't make much sense anyhow
13:29davso seriously, there's no canned function for pretty priting nested structures nicely?
13:30dnolenbbiab
13:30cemerickdnolen: Clojure has ambient access to namespaces/vars; seems like binding ana/namespaces into &env makes sense, so that macros would rely upon analyzer impl. details less.
13:31jcromartiedav: did fipp not look good?
13:31bbloomdav: clojure.pprint is included and my fipp is available as an extensible option if you need to build your own pretty printer
13:34davjcromartie / bbloom - I can't seem to get them to print the structure on multiple lines.
13:34davI guess they deem the width to narrow?
13:34bbloomdav: what structure?
13:34dav{:a 1 :b {:c 3 :d 4}}
13:35bbloomyeah, that's pretty narrow :-P both pprint and fipp are targeted at pretty printing for humans. they are not uniform indenters
13:35bbloomyou can force fipp to do something naive for indenting if you just print with {:width 1}
13:35davscore! thanks.
13:37dav*sigh*, it doesn't make [[[[:a :b]]] [[:c :d]] [:e :f]] readable at all :(
13:38bbloomdav: if you know the schema of your data, you can write your own pretty printer with fipp trivially
13:38bbloomlook at https://github.com/brandonbloom/fipp/blob/master/src/fipp/edn.clj
13:38bbloomyou juse use defprinter & you can make a custom pretty printer in a handful of lines of code as pure functions
13:40davbbloom: I just wanted to print some data structure from 4clojure in a readable way
13:41bbloomdav: both pprint and fipp are tuned for making realistic data easy to read. if you're having trouble reading that tiny data structure, i don't know what to do for you other than to suggest you copy paste it in to your editor and turn on brace-matching :-P
13:42bbloomdav: if you want a particular style of indentation, you can achieve whatever you want with fipp and it's seriously both simple AND easy
13:46coventrydav: Do you use paredit-mode in emacs? Put the cursor just after the first [, and C-M-f / C-M-b will move between the top-level elements of the list.
13:47bbloomdav: also, aren't you a haskell convert? how could you possibly think that small list is hard to read? :-)
13:48coventryCome on, parsing a deeply nested structure without automation is tedious and error prone. :-)
13:49bbloomparticularly with associativity :-P
13:53davcoventry: I ended up doing the equivalent in vim
13:53davbbloom: that data structure is invalid in haskell ;-)
13:54davbbloom: (variable depth recursive lists..)
13:54bbloomyup, you'd need to wrap every damn thing in a descriminated union... weeeeee fun times
13:54davbbloom: you just wouldn't ;-)
13:55bitemyappdav: exactly how is it invalid?
13:57davbitemyapp: lists in haskell are lists of some specific type, not lists of "Any". So unless you define a tree structure or use the either type, you can't have a list of "sometimes lists, sometimes things'
13:58bitemyappokay, but when you said that, I was thinking about Either and trees as counterpoints.
13:58bitemyappI wanted to make certain I hadn't missed something.
13:58dnolenbbloom: oh whoa, a JVM bite code interpreter in Node, heh
13:58dnolener byte
13:58bitemyappI would prefer not to think of that Haskell "can't", but rather, Haskell encourages you to keep its type system in the loop on what the fuck is going on.
13:58bitemyappdnolen: hella slow, but amusing.
13:59coventrySomeone should hook it up to js source maps so we can have a real clojure jvm debugger. :-)
13:59shaungilchristhahah!
14:00davbitemyapp: yes. and I wouldn't need the pretty printer in haskell because the type system would tell me exactly what I need to handle ;-)
14:00coventrybitemyapp: I know, I know.
14:03bitemyappdav: that's probably the greatest gift I got from learning Haskell. Thinking in types.
14:03bitemyappMost compressed and efficient way to think about programs I can think of.
14:04tbaldridge_dav: that's probably the greatest gift I got from learning Clojure. Thinking in data. Most compressed and code efficient way to think about programs I can think of. </troll>
14:04tbaldridge_I'm sorry everyone, I couldn't resist.
14:05davI love macros and the access to the JVM libraries, but despite these massive advantages, I'm still quite on the fence.
14:06coventrydav: I'm curious about frege as a jvm-based alternative to haskell. Do you have an opinion about it?
14:07dnolendav: there's always Frege
14:09davcoventry / dnolen - first time I hear of it. Will look into.
14:10bitemyapptbaldridge_: types are about recognizing no data is a special snowflake. Nothing is exempt from categorization or pattern recognition.
14:10bitemyapptbaldridge_: further, types can describe morphisms across huge swaths of the program, data stands alone.
14:11dnolendav: https://github.com/Frege/frege
14:12bbloomgrumble grumble... something something about how types should be optional b/c in theory any data could have multiple interpretations via types.... people conflate types and tags... grumble grumble
14:12tbaldridge_But why would I need any of that? The whole thing with types is that they supposedly provide some sort of way to reason about code. But then you see talks like "The Problem With Types" or "Molog" and you realize types are holding these people back from getting stuff done.
14:13bitemyappwell it's a trade-off, like everything else. But you'll note that I said Haskell's greatest gift (to me) was letting me think in types - day job is Clojure. Clojure was my decision.
14:13bitemyappIt's worth considering that there might be value in the abstract faculty for thinking in types and categories even when somebody uses and prefers Clojure.
14:13davI've found that the times the typesystem is in the way is when writing macros
14:13davEvery other time, the typesystem is incredibly helpful
14:13coventryI thought it was interesting in "The Trouble with Types" that Odersky cited the constraint a type system places on people as a source of good design. Seemed to miss the point at little.
14:14davAnd I've yet to write a program in Haskell that compiles but crashes or produces any eroneous output
14:14tbaldridge_coventry: yeah I have a big problem with that talk. He basically states that good design is finding things that fit into the typesystem well. I remember crazy talk like that from my OOP days.
14:14bitemyappdav: that's easiest to accomplish when you aren't using dynlibs.
14:14davbitemyapp: what is?
14:15bitemyappnon-crashing Haskell programs.
14:15hiredmanI cannot imagine trying to do minikanren with a strong type system
14:15bitemyapphiredman: static*
14:15dnolendav: no erroneous output? you must do a lot of testing.
14:15hiredmanfighting with go's is hard enough
14:15bitemyappClojure is a strong type system.
14:15eric_normandhello!
14:15bitemyapperic_normand: hi!
14:16dnoleneric_normand: yo
14:16eric_normandjvm on heroku is working funny
14:16eric_normand:(
14:16tbaldridge_hiredman: that's what molog is, and yeah it was a interesting talk but boiled down to "we can't do this in Haskell, so I cheated in these ways..."
14:16davbitemyapp: what are dynlibs
14:16bitemyappdynamic libraries yo.
14:16hiredmantbaldridge_: right, he did the clojure west talk
14:16davdnolen: I've never written a test
14:16tbaldridge_hiredman: yeah, I forgot that video was out.
14:16davdnolen: but then again I haven't written that much Haskell..
14:17eric_normandanyone else have trouble with clojure.java.io/resources returning a URL for a directory?
14:17dnolendav: heh, well there's not much more to talk about then.
14:17llasrameric_normand: In what sense?
14:17llasram(of trouble)
14:17dnolendav: nearly every serious Haskell book / person talks about testing. Not testing is only for goofy blog posts.
14:17davdnolen: it's just that when I write clojure (or any other language), I run snippets of code 50 times and they crash until I fix all the little bugs. In haskell it runs from the first time (but i have to try to compile it 50 times)
14:18eric_normandllasram: (clojure.java.io/resource "static/") is returning a url on heroku
14:18tbaldridge_dav: BINGO!
14:18davdnolen: agreed. I never built a large scale app.
14:18tbaldridge_(inc dav)
14:18lazybot⇒ 1
14:18hiredmanx is a logic var, but that logic var may be unified with something else, I dunno of any type system that could deal with that without making everything a union type with lvar
14:18eric_normandllasram: but returns null on my local machine
14:18davtbaldridge_: I'm immutable ;-)
14:18rasmustodav: that's a good point. Does either one of those methods feel more interactive? I tend to prefer seeing erroneous output over compiler errors
14:18bitemyappI find peoples' eager glee at avoiding learning new things disturbing.
14:18eric_normandllasram: is causing ring/wrap-resources to read it as input stream, which doesn't break but is empty
14:18llasrameric_normand: It depends on the class path. io/resource will always return either `nil` or a URL.
14:18llasramAhhh
14:18llasramYeah
14:19eric_normandllasram: seems like new behavior. it was working before!
14:19rasmustos/interactive/productive
14:19llasramThere was a recent change in Leiningen to add directory entries to (uber)jars, as the spec apparently actually requires
14:19eric_normandllasram: I see
14:19llasramBut most versions of ring apparently have issues
14:20eric_normandllasram: let me update leiningen
14:20tbaldridge_bitemyapp: I just don't have time anymore. I can't even bring myself to learn more emacs, let alone a new language.
14:20davrasmusto: when some clojure function expects a list and gets a nil or a number or something and barfs, the errors aren't particularly helpful. Plus if this happens in an untested branch of an if statement, your user may crash an app that would never have compiled in Haskell...
14:20llasrameric_normand: I would more suggest updating ring
14:20bbloomhiredman: there is some recent progress on typing logic vars
14:20llasrameric_normand: Or if that's not an option, downgrading leiningen
14:20justin_smithhlship: regarding the challenge last night, I found M-x javadoc-lookup (provided by the javadoc-lookup package)
14:20bbloomdataflow & logic variables in type sytesm: www.cs.indiana.edu/~sabry/papers/rational.pdf
14:20eric_normandllasram: I don't know if I can downgrade it on leningen
14:20bbloombasically adds fractional and negative types to the notion of sub and product types
14:21bblooms/sub/sum
14:21cmajor7In regards to "Problem With Types": I feel that Scala needs types. Scala can't survive its "implicit" complexity without types. Scala is so far more complex with comparison to something like Haskell or ML, that it must have something to hide behind and hold it together. Clojure has a very strong type system, but it is not leaking out and does not hurt the end user (Clojure developer), where in Scala it always is a battle of something being not "contravariant
14:21hjvbe8hgqt4kjh98Do usa&Israel use chat &facebook 2 spy?!?!?!?
14:21hjvbe8hgqt4kjh98Do they record &analyse everything we type?!?!?!?
14:21hjvbe8hgqt4kjh98Do usa&israel use chat&social communicationprog(facebook&twitter) to collect informations,,,,can we call that spying!!!!
14:21hjvbe8hgqt4kjh98هل تستخدم امريكاواسرئيل الشات والفيس بوك للتجسس!؟!؟!؟!؟!؟!؟!
14:21hjvbe8hgqt4kjh98Do usa&Israel use chat &facebook 2 spy?!?!?!?
14:21hjvbe8hgqt4kjh98Do they record &analyse everything we type?!?!?!?
14:21hjvbe8hgqt4kjh98Do usa&israel use chat&social communicationprog(facebook&twitter) to collect informations,,,,can we call that spying!!!!
14:21hjvbe8hgqt4kjh98هل تستخدم امريكاواسرئيل الشات والفيس بوك للتجسس!؟!؟!؟!؟!؟!؟!
14:21hjvbe8hgqt4kjh98Do usa&Israel use chat &facebook 2 spy?!?!?!?
14:21hjvbe8hgqt4kjh98Do they record &analyse everything we type?!?!?!?
14:21hiredmantechnomancy: !!!!!!
14:21davwtf
14:21eric_normandllasram: thanks. I can now reproduce the problem on my local machine! :)
14:22bitemyappcmajor7: I like to think of types as an opportunity for leverage, especially in situations where a codebase begins getting larger.
14:22llasrameric_normand: np
14:22bbloomdav: it's actually much easier to write a haskell program that segfaults than a java one :-)
14:22bitemyappcmajor7: that Scala mis-uses that leverage to paper over bad complexity is their fault. Haskell and ML do a much better job
14:22bbloomthe word "unsafe" is a scientifically accurate term when you have unsafeIO or whatever
14:22davbbloom: segfault is just one particular kind of crash..
14:23hiredmanbbloom: gross
14:23bbloomright, but the JVM for example enforces safety dynamically
14:23bbloomeven tho Java is statically typed, the runtime enforces safety with dynamic checks
14:23bitemyappYou don't need unsafePerformIO in Haskell any more than you need mutability in Clojure.
14:24bbloomwhere as haskell punts, b/c many of their optimizations rely on a smarter compiler and a dumber runtime
14:24davbbloom: right, that's like saying my computer won't explode when my program segfaults (popping the stack by 1 level)
14:24cmajor7bitemyapp: that's the thing with Clojure.. you very rarely work with a "large" codebase
14:24bitemyappthe practical reality of writing Haskell is that you get an "assistant" as you write your program. It's a pleasant experience.
14:24bbloomwell yeah, you're relying on your operating system's dynamic checks :-P
14:25eric_normandllasram: I hadn't noticed that ring was upgraded. There was a fix for it
14:25bitemyappcmajor7: avoiding the hard work that sometimes needs to be done isn't a win.
14:25eric_normandllasram: thanks a bunch!
14:25rasmustodav: okay, gotcha. Clojure null pointers definitely make me scratch my head
14:25bbloomhiredman: yeah, it's gross, but apparently it actually simlifies signatures for a lot of things that were hard to do in a typed context before.
14:25bitemyappcmajor7: one should of course, avoid attacking problems that don't need to be attacked, but that response is just putting your head in the sand.
14:25bitemyappcmajor7: I've been hurt in my efforts in Clojure for want of type-checking in much smaller programs than you might suspect.
14:25davtime for me to go to bed. good chatting with you all..
14:26bitemyappnot to mention how HORRENDOUSLY painful refactoring dynamically typed programs can be once they become non-trivial.
14:26hlshipknow my pain
14:27cmajor7bitemyapp: refactoring is only a pain if the code wasn't manageable in the first place (bad design). and this is nomatter the languages
14:28tbaldridge_(inc cmajor7)
14:28lazybot⇒ 2
14:28cmajor7bitemyapp: unfortunately I don't know Haskel well (never worked with a large Haskel codebase). but I can tell you that I did with Scala and Clojure. And while Scala has all the types in the world, refactoring was a lot more painful there..
14:28bitemyapptypes have reduced my "time to understand failure" as contrasted with Clojure
14:29bitemyappI got bit really badly by Clojure's dynamic type system at Clojure Dojo and even extra pairs of eyes weren't able to figure it out.
14:29bitemyappit wasn't until I dug in with some deftrace that I was able to figure out that I mis-destructured something.
14:29bbloomthe big problem in scala is the temptation to use the type system to do work for you
14:29bbloomsame with C++ and others
14:29bbloomyou code up things that rely on types to do some metaprogramming or automatic insertion of values
14:29bitemyappznDuff: that's the next step for me.
14:30bbloomand then now you have a hidden, global, cyclic dependency ball of mud
14:30bitemyappcore.typed is pretty expressive, I'm going to start using with Clojure code I actually give a fuck about.
14:30cmajor7bitemyapp: I feel, you are going to experience this less and less, as you do things in a more idiomatic way..
14:30cmajor7bitemyapp: (being bit badly)
14:30bitemyappcmajor7: wrongo.
14:31bitemyappcmajor7: I've been doing Clojure for quite awhile. I was doing my thing in a Clojure idiomatic way.
14:31bitemyappI simply got bit badly.
14:31cmajor7bitemyapp: the thing with Clojure is not types or lack of them. it is really a different dimension of thinking..
14:31technomancygranted my bug was just due to a java lib that used exceptions in an annoying way; wouldn't have been an issue with ex-info
14:31bitemyappcmajor7: please stop talking to me as if I haven't drunk the Clojure kool-aid too.
14:31cmajor7bitemyapp: ok, then maybe I am wrong, since I don't know your particular case. but this is just how I feel.
14:32bitemyappcmajor7: I was structuring a multi-stage predicate application of in terms of data. It was quite nice and declarative. However, a problem that would've been rectified in 5 minutes or less in the presence of type system ended up taking multiple people and sets of eyes 2 HOURS to rectify
14:33cmajor7bitemyapp: what was the problem, can you give an example?
14:34bitemyappcmajor7: This was the program we were refactoring, I chose to do it with a [predicate -> change-fn] pipeline. https://github.com/mjansen401/gilded-rose-clojure
14:34bitemyappcmajor7: I'm not really super interested in nit-picking the specific problem, because once you know what's wrong (I already said waht it was earlier) it naturally seems "easy" or "simple"
14:34bitemyappif you weren't "on the ground" when the problem was still a mystery, you aren't capable of evaluating how difficult or annoying it was.
14:34tbaldridge_"update-quality" what on earth is that?
14:35bitemyapptbaldridge_: the intrinsic value of the item drops as it decays from day to day
14:35mdrogalisHas anyone ever used the Janino microlanguage in app development before?
14:35bitemyapptbaldridge_: it's a discrete algorithm for shifting time one day at a time.
14:35tbaldridge_I know the problem, it's just there has to be a much better way than a 29 mess of Clojure code.
14:35bitemyappcmajor7: do you do Clojure at your day job?
14:35tbaldridge_*29 line
14:35bitemyapptbaldridge_: you...do understand that that's the point right?
14:35bitemyapptbaldridge_: you're supposed to refactor that.
14:36tbaldridge_I wouldn't refactor it, I'd delete it :-P
14:36mdrogalisHah.
14:36bitemyapptbaldridge_: it's an interview exercise, to see how you handle tackling somebody else's complexity budget and how far-sighted and clear-minded you can be about refactoring things you didn't necessarily write
14:36bitemyappI actually think it's a great exercise.
14:37shaungilchrist"todo: write tests later"
14:37technomancyshaungilchrist: https://mobile.twitter.com/GonzoHacker/status/395607991367397376?p=v
14:37cmajor7bitemyapp: yes, I did Scala for a couple of years. I am doing Clojure for about a year and a half now (day job that is)
14:38bitemyappcmajor7: if Scala is your only exposure to advanced type systems, then you are impoverished.
14:38bitemyappI'd reject programming and civilization itself if Scala was my day job, let alone type systems.
14:38bitemyappGo live inna-da-woods.
14:39cmajor7bitemyapp: I also have jobs after the "day" ends you know :)
14:39bitemyappcmajor7: and you've written how much Haskell or ML?
14:39tbaldridge_I'm just saying, that code shouldn't have been written in the first place, so claiming a type system would have helped is a moot point. Now say the same about something like this: https://gist.github.com/davespanton/3848306 and we can start talking.
14:39bitemyapptbaldridge_: you've missed the point.
14:40technomancyheh
14:40bitemyapptbaldridge_: the point is that I've had nice type systems help me understand what I'm doing, wrong or right, faster.
14:41bitemyappI don't care about program verification or any of the other stuff, I simply like having the sanity-assistant compiler tell me what's what.
14:41technomancyno code that should never have been written ever gets written in the real world, am I right?
14:41reiddrapertechnomancy: +1
14:41tbaldridge_sure, if the code is badly written that you can't hold it all in your head.
14:41bitemyapptechnomancy: totes. Clojure programmers only write perfect code, in quantities no greater than 300 LOC per library.
14:42bitemyapptbaldridge_: "if the building is so badly designed that it needs brick instead of straw, it shouldn't be built"
14:42bitemyapptbaldridge_: you are rejecting leverage and knowledge. That is insane.
14:43llasramOh dear. My library is getting close to 6k lines
14:43technomancy~guards
14:43clojurebotSEIZE HIM!
14:43llasramheh
14:43cmajor7bitemyapp: is that an interview? ML/Haskell not much, just for selfeducative purposes.. I mostly did Java/C/Python/Erlang and friends before. However I think that your "misfortune" with Clojure is not because Haskell is great and Clojure is not, but because you had a problem with software and at that day it was Clojure. If it was Pascal we would be talking about it instead.
14:43gfredericksreiddraper: ping
14:44reiddrapergfredericks: pong
14:44TimMcPING
14:44technomancyICMP_ECHO_REPLY
14:44gfredericksreiddraper: curious about a use for simplecheck
14:44TimMc(Player 3 has joined the game.)
14:44reiddrapergfredericks: shoot
14:44gfredericks... are you guys being nerds?
14:44TimMcI would never.
14:45technomancythis sir is calumny
14:45gfredericksreiddraper: I'd like to be able to test a chess-rules thing by playing a random chess game; problem is I therefore need to generate moves interactively, where the available moves at any point are obviously dependent on the previous moves
14:45bitemyappcmajor7: jesus christ dude, that is not what I said.
14:46gfredericksI can imagine a generator that generates an entire game, which just leaves my test to give a thumbs up and assert that no exception was thrown in the process
14:46bitemyappcmajor7: you keep talking to me like I haven't been writing Clojure for years.
14:46gfrederickswhich seems like a weird approach
14:46bitemyappcmajor7: or that I'm somehow dissatisfied with Clojure. I'm expressing that there is a utility to type systems that can help write better code, faster.
14:46hiredmansh/win 21
14:46tbaldridge_bitemyapp: nah, the more correct approach is this: If your building is so complex that it can only be built by having each brick only fit against bricks of the correct types, it shouldn't be built.
14:46bitemyappcmajor7: the practical result for *me* is that it means I'm excited about ambrose's work.
14:47gfredericksreiddraper: so I feel like what I want is to be able to have a (loop [position initial] ...) and be able to do a rand-nth each time through
14:47tbaldridge_bitemyapp: use generic modular bricks (like bricks in real life) and all will be fine :-)
14:47reiddrapergfredericks: yeah, this is defniitely something that comes up in erlang quickcheck,
14:48bitemyappreiddraper: you mean Haskell's?
14:48bitemyappgfredericks: generative testing is great. Have you tried the Clojure library?
14:48reiddrapergfredericks: erlang quickcheck has something called 'statem', which let's you write generates that depend on previously generated values, but it's possible to do this just with 'bind'
14:48reiddraperbitemyapp: nope, i mean erlang quickcheck, EQC
14:48reiddraperbitemyapp: http://www.quviq.com/index.html
14:49bitemyapphaha, they charge for it? jesus.
14:49gfredericksbitemyapp: test.generative you mean?
14:49bitemyappgfredericks: whatever. just use stuff.
14:49cemerickthose g.d. bastards charging money for work! </troll>
14:49reiddraperbitemyapp: it's much more advanced than haskell quickcheck
14:49gfredericksreiddraper: yeah I figured some lower-level mechanism would suffice; so bind is the best approach then?
14:50reiddraperbitemyapp: and written by one of the same original authors of haskell quickcheck, it's _excellent_
14:50reiddrapergfredericks: yeah, so i think what you'd want to do is write something that allows you to take a look at the previously generated moves, and then make a decision about what is 'allowed' based on that history
14:50cmajor7bitemyapp: I guess to each his own. I am not saying that types are crap, or you don't know Clojure well. I just don't see where explicit types would help me in Clojure (in most cases). They do help me in Java, but that's the whole point, right..
14:51bitemyappcmajor7: I didn't understand where types would help me until I got the "Zen" of Haskell and ML either.
14:51cmajor7bitemyapp: ok, maybe you just know something I don't.
14:52bitemyappcmajor7: then once I started taking stock of where my time was going over the course of solving a particular problem, I noticed that I would "net out" on time saved and frustration generated if I had certain faculties and static assurances available to me.
14:52bitemyappI can walk into a Haskell program and modify it with far less knowledge or memory of it and reasonably expect to come out the other side pretty okay.
14:52technomancymaybe cmajor7 knows how to avoid NPEs =)
14:52technomancyplz spill the beans
14:52bitemyapptechnomancy: he must be perfect. The chosen one.
14:52cmajor7bitemyapp: but I am happy with developing my happy Clojure "Zen", since until now it had never let me down (which I can't say about Scala for example)
14:52reiddrapergfredericks: happy to try and hack out something more concrete too, this is a cool, and should be possible use-case
14:53bitemyappcmajor7: you've never done (apply nil [blah lol woot]) eh?
14:53tbaldridge_cmajor7: yep, the best way to shut-up detractors....just build cool stuff.
14:53bitemyappdetractors...seriously?
14:53bitemyappI use Clojure and I'm happy with it. I'm talking about the utility of type systems and why I think core.typed is a good idea.
14:54bitemyapphow does that make me a detractor? absurd.
14:54technomancylook, typed clojure has clojure in the name; therefore it's OK to be a fan of clojure and not dislike it.
14:54gfredericksreiddraper: btw, I hacked together an immutable PRNG lib the other day
14:54technomancynot sure how it could be clearer =)
14:54gfredericksnot sure if that's something you'd consider useful
14:54tbaldridge_bitemyapp: I meant a dynamic typing detractor
14:54bitemyapptbaldridge_: I'm not saying I have a problem with dynamic typing either
14:55gfredericksreiddraper: https://github.com/fredericksgary/four
14:55bitemyappwhich leads me to believe you misunderstood what I was saying even worse than I thought.
14:55bitemyapptbaldridge_: if I had a problem with dynamic typing, I wouldn't be interested in using core.typed.
14:55bitemyappI love dynamic typing and love having it in my day-to-day language.
14:55reiddrapergfredericks: oh really, sweet, so cemerick has a prng that is cljs/clj compatible, might be interesting to trade notes
14:55cmajor7bitemyapp: "(apply nil [blah lol woot])" and what would I do that for? :)
14:55bitemyappcmajor7: k, I can write you off as a smug dude that writes no bugs. Got it.
14:56bitemyappbut for the rest of us mere mortals - take a look at core.typed.
14:56cmajor7bitemyapp: I just have a very good bug spray
14:56bitemyapptbaldridge_: you do understand that using a type system like core.typed doesn't make Clojure *not* dynamically typed, right?
14:56cemerickreiddraper, gfredericks I'm dumbly just wrapping seedrandom.js in pprng
14:56tbaldridge_bitemyapp: but the fact that it's optional is the key part I think. That's why I don't use ML, Haskell, etc. the typing system is non-optional.
14:56gfrederickscemerick: wat is pprng
14:56bitemyapptbaldridge_: why do you think I use Clojure?
14:56gfrederickscemerick: so is it mutation-based then?
14:57cmajor7bitemyapp: and I like the idea of core.typed. but honestly mostly because it is giving Clojure a good marketing
14:57cemerickgfredericks: Clojure/ClojureScript-portable pprng API: https://github.com/cemerick/pprng
14:57cemerickin the process of lifting simple-check on top of it
14:57tbaldridge_bitemyapp: I really haven't a clue....almost every day you complain how it doesn't do X or Y from Haskell. :-P
14:57bitemyapptbaldridge_: pardon me for knowing what's possible.
14:58gfredericksreiddraper: okay so his is mutable; mine's the haskell-style monadic thing
14:58gfredericksagain, not sure if that's actually useful
14:58gfredericksnext-long is probably a confusing name now that I think about it
14:58reiddrapergfredericks: it might be, not having it be the monadic style was definitely interseting in porting from haskell to clojure
14:59gfredericksI wrote it for the sake of being able to serialize an in-process computation
14:59gfrederickshaven't ended up actually using it yet though :)
15:00reiddraperyeah, and it also allows for you to repeat something without having to create a new RNG
15:00reiddraperwhich is handy
15:01gfredericksright
15:01TEttingerare there any random number generators for clojure that alter the behavior of shuffle and rand-nth?
15:02gfrederickscemerick: before reading your README I imagined perhaps it stood for pseudo-pseudo-RNG
15:02muhooregards types, i've noticed that a shit-ton of my functions have {:pre [(string? arg1) (every? number? [arg2 arg3]) (map? arg4)]}, and that tells me it's time to lookin to typed clojure :-/
15:02reiddrapergfredericks: i've also worried about using a mutable RNG if it gets shared between threads, things not being deterministic anymore
15:02cemerickgfredericks: add enough pseudos, and you can build ANYTHING
15:03TEttingerI'm pretty sure my current code uses rand-nth a bunch
15:03hiredmancemerick: doug lea has shown us that
15:03TEttingeralthough I suppose I could define my own...
15:03bitemyappmuhoo: Yep. :)
15:04gfredericksdoes anybody know any good reason for clojure not providing a *rand* underneath its random functions?
15:04hiredmanI was thinking of http://cs.oswego.edu/pipermail/concurrency-interest/2013-July/011579.html and I guess the doug lea remark doesn't make sense without context
15:04bitemyappmuhoo: This is a good way to familiarize: http://nathanic.org/posts/2013/typed-clojure-tour/
15:05cemerickhiredman: even then... :-P
15:08muhooand if i get very many more [{keys [foo bar baz]}] {:pre [(every? (comp not nil?) [foo bar baz])]}, i also should probably be looking at records too instead of maps :-/
15:10muhoostill, clojure lures me into yak shaving like no other language i've used before. not sure if that's just me or the language. but stuff just doesn't "look right" and i spend way too much time making it look right instead of just slapping shit together to make it work. not sure that's a good thing.
15:10reiddrapergfredericks: have you seen any of the papers that the haskell rng is based on?
15:11bitemyappI write better code in Clojure than I did in previous languages, but it's hard to extricate that from simply having programmed longer. I don't find myself yak-shaving Clojure code much.
15:11reiddrapergfredericks: there's at least one referenced here http://hackage.haskell.org/package/random-1.0.0.1/docs/System-Random.html
15:11bitemyappI generally wait for some kind of refactor-ROI trigger to happen.
15:12reiddrapergfredericks: particularly, take a look at the comment in 'split'
15:13tbaldridgemuhoo: it can be that way. Clojure has deftype, reify, defprotocol, multimethods, etc. I've found myself sometimes mucking with those. In Python/C# all I had were Objects...so I didn't have much of a choice.
15:14tbaldridgemuhoo: when there's 20 ways to do things, you can end up shaving yaks more. Unless you completely understand the problem then you may just pick the right primitive the first time.
15:17bitemyapptechnomancy: working on a migration library for Datomic, finished writing a test, ran the test: actual: java.lang.NullPointerException: null
15:17bitemyappclearly I failed to be a proper Clojure ubermenschen.
15:20gfredericksreiddraper: oh that's interesting; I hadn't thought too much about trivial approaches to that not being ideal
15:20gfrederickse.g., take the next two Ints and use those for seeds
15:22seangrovecemerick: Very good points on 643, was interesting reading your notes, thanks for taking the time.
15:23cemerickseangrove: heh, we'll see if it'll end up being worth anything :-) Definitely an area that needs some TLC, in any case.
15:23seangrovetechnomancy: Do you commit the AOT'd uberjar to the git repo when pushing to heroku? It still seems like it trigger compilation anyway.
15:24seangrovecemerick: Well, a lot of the problems are from my keywords/constants-table change, so definitely let me know if I can help
15:24seangroveI like (obviously) making the analyzer/compiler as functional and idempotent as possible
15:27dnolenseangrove: constants-table is a symptom rather than the disease, CLJS was never particularly thread safe and as the compiler has become more sophisticated it's jut more evident now
15:27dnolens/jut/just
15:27cemerickseangrove: No worries, better to keep moving forward than to maybe get stuck fiddling with minutiae. I'm happy to tidy up APIs while people like you and dnolen and Bronsa and bbloom keep pushing the actual compiler bits.
15:27seangrovednolen: Sure, but it's certainly a tractable problem.
15:30cemerickFinally grokking why things have been a bit sideways since 1847 has made me reconsider the subject of default/provided cljs versions in cljsbuild, though. It may be that there's no obviously-correct policy there.
15:32dnolencemerick: I think the problem with pinning has been that we're still kinda moving at alpha speeds here - I do think we're close to something more stable. Source maps that work for everyone and a thread safe compiler would be a solid release to pin to.
15:33seangrovecemerick: Still confused about the default cljs in cljs-build - you already warn if I haven't explicitely stated the cljs version dep in my project.clj, right?
15:34cemerickdnolen: I don't want pinning, people should be able to deviate from the default.
15:35dnolencemerick: sorry yes.
15:35cemerickBut, the dependency-resolution mechanism is simply too narrow to communicate the necessary info to end users, e.g. this version of cljsbuild is known to work with cljs rXXX - rYYY.
15:35dnolenwhich reminds me, somebody should really resubmit the CLJS patch to attach the version so it's inspectable from the source/REPL :)
15:35cemerickI'm contemplating some kind of side-channel for that info that is occasionally checked/cached.
15:35seangrovednolen: Yes, please.
15:37cemerickseangrove: confused that there's a default at all?
15:38seangrovecemerick: Nevermind, after reading your last remark about the narrow-band of potentially compatible cljs releases, it makes more sense
15:42technomancyseangrove: no, committing jars to the repo isn't encouraged. putting :uberjar-name in project.clj should be enough to trigger generating an uberjar at push time
15:42technomancyseangrove: gonna grab lunch but feel free to pm me if you have any questions and I can take a look when I get back
15:42seangrovetechnomancy: But the process is excruciatingly slow on heroku's build servers vs on our build servers - is that just usually just not an issue?
15:42seangroveSure, no worries
15:43technomancythere are other non-git ways to deploy if you want to do your own builds
15:43seangrovetechnomancy: Ah, alright, I'll pm you when you're back then ;)
15:54muhooi'm curious though, if you're using a uberjar, why use heroku? why not just run it on some java container service?
15:54muhoothe main advantage to me of using heroku is being able to run from git instead of having to generate uberjars and running in some apache or google container
15:58bjaYeah, I feel if you're going through the effort of uberjar or war generation, you'd just use a war hosting service like Elastic Beanstalk or CloudBees
16:00xeqicemerick: could you point me to where austin/piggieback passes the options to the cljs compiler?
16:13sritchiegoog.require could not find: clojure.browser.repl
16:13sritchiehave you guys seen that before?
16:14bitemyappsritchie: restart lein cljsbuild?
16:14sritchieyeah, I ran it again
16:14bitemyappsritchie: is the DOM ready when you run that code?
16:14bitemyappclojure.browser.repl needs to be run after DOM ready.
16:14sritchieI was including that in a scripts block down at the bottom
16:14danlentzis it preferred to use (defmulti xyz type) or (defmulti xyz class) ?
16:15sritchiebitemyapp: this is using austin
16:16xeqisritchie: do you have [clojure.browser.repl] in your :require and are not using :optimizations :advanced ?
16:17sritchiexeqi: I DID have it in there before - let me try cleaning
16:17sritchieand nope, not using advanced,
16:17sritchiethis is on a dev build with simple optimizations
16:17sritchietrying a clean
16:18danlentzor am i beimng boneheaded conflating the two (third option...)
16:19sritchiexeqi: bitemyapp doesn't fix it, unfortunately
16:19sritchiebitemyapp: even when the page is loaded,
16:19sritchiewhen I run goog.require('clojure.browser.repl') at the console
16:19sritchieI get an error
16:20sritchieBUT, I'm not referencing it in my code
16:20sritchiemy cljs code
16:20bitemyappsritchie: shut off optimizations completely?
16:20sritchie:optimizations :whitespace
16:20sritchielet me try to say :none
16:20bitemyappbah, yeah that won't do anything.
16:22dnolensritchie: anything except :advanced should work, cemerick would know more about piggieback, are you trying with 1847?
16:22sritchie[org.clojure/clojurescript "0.0-1934"]
16:23sritchiethis worked yesterday, strangely
16:23sritchiednolen: but I cleaned a few times
16:23sritchiednolen: oh, you know what
16:24sritchiednolen: I DID change something - I used to have a "repl.cljs" file that had a browser repl import,
16:24sritchiebut then removed it, since cemerick's code was handling the repl connect call generation for me
16:27sritchiednolen: boom, manually adding that require to any of my cljs files fixes the issue
16:28cemerickxeqi: it mostly doesn't, it reuses cljs.repl/evaluate-form https://github.com/cemerick/piggieback/blob/master/src/cemerick/piggieback.clj#L105
16:30cemericksritchie: you squared away?
16:31sritchiecemerick: sure, but I think that might be something that austin should highlight,
16:31sritchie(cemerick.austin.repls/browser-connected-repl-js)
16:31sritchiethat call won't work unless one of your cljs files has a require for the browser repl file
16:32cemericksritchie: really? What error/behaviour do you get?
16:32cemerickoh, *unless*
16:32sritchieyeah
16:32sritchiethe console shows that the lib doesn't exist
16:32cemerickright
16:33cemericksritchie: maybe you could add a parenthetical list item to the README @ https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample ?
16:33cemerickpointing to the .cljs file therein that has the require, etc
16:33sritchiesure
16:34cemerickor open an issue suggesting the addition, so I don't forget :-)
16:36sritchiecemerick: https://github.com/cemerick/austin/pull/24/files
16:36cemerickawesome, thanks :-)
16:39apricotsin leiningen profiles.clj is there some way to build configuration programatically? e.g. I'm trying to specify a path based on $HOME (str (System/getProperties "user.home") "/datomic-free")
16:40sritchiecemerick: btw
16:40sritchieif I reload a page that austin's connected to
16:40sritchiehttps://gist.github.com/sritchie/66845142f8fc9afceece
16:41cemerickhrmph
16:41cemericksritchie: if you send an expression to eval anyway, does iti sort itself out
16:41cemerick?
16:41sritchieit hangs, even with multiple reloads,
16:41sritchieuntil I manually enter the "connect" call at the console
16:42sritchieI wonder if I'm just putting the repl call too early or something
16:42cemerickhrm, this happened to someone else before....
16:42cemericksritchie: make sure the austin-generated js is the last thing in the page, after your app's js?
16:42sritchieit's in the body, and the only thing after it is some google analytics
16:42sritchiecode
16:43cemerickhrm
16:45cemericksritchie: he was having a similar problem, thus the suggestion https://github.com/cemerick/austin/pull/21
16:45cemericksritchie: if the REPL is hanging, then there's something keeping the browser-repl ns from being required/loaded or the connect call from being executed
16:46sritchieyeah, it's not that particular issue
16:46sritchiebut I had figured that one out on my own yesterday
16:46sritchieI'll see if I can move that call around
16:46sritchieand get some more info
16:47cemericksritchie: or just put a breakpoint on the connect call and make sure it's being hit
16:47sritchieoh, good call
17:02yeoj___i have an old piece of code looking at clojure.contrib.except for :only throwf... where did that go?
17:07llasramyeoj___: Probably didn't make it. What's it do? Name suggests just a function wrapping `throw`
17:08technomancyyeoj___: ex-info is a general replacement for clojure.contrib.except, but throwf has no contemporary analog
17:08technomancyseangrove: what's up
17:08gfrederickswhat did throwf do?
17:09yeoj___looks like it does string formatting, but i'm not sure where the string goes (to logging?)
17:09seangrov`technomancy: The current blog post on how to deploy to heroku didn't mention anything much about AOT, or non-git-deploy methods, etc. Very curious about how you're doing it internally.
17:09technomancythrow+format on the Exception message
17:09llasramAh
17:09yeoj___i found it here: https://github.com/michakurt/clojure-etl/blob/master/etl.clj I guess i can find another way.
17:09technomancyseangrov`: AOT should just always happen. non-git deploys are more experimental.
17:10gfredericksthrowf is fun to pronounce
17:11llasramgfredericks: You must pronounce it differently than I do :-)
17:13gfredericksllasram: in one syllable
17:15hiredmanwin 19
17:23xeqicemerick: ah, no obvious way to plug in a source-map there :/
17:30hiredmangfredericks: win 19 is a private club of which I am a member
17:30mikerodI'm am making a Java interop call of the form (doto <some ArrayList> (.remove (dec <some-num>)))
17:31mikerodAfter some investigation, the .remove is returning False
17:31mikerodthis would indicate that it is calling the ArrayList#remove(Object) method, instead of ArrayList#remove(int)
17:31sritchiecemerick: final error that I'd been seeing
17:31sritchieif I cycle the repl a couple of times
17:31sritchieI get this
17:31sritchieCompilerException java.lang.StackOverflowError, compiling:(form-init8604265301067731997.clj:3:13)
17:32mikerodSo I tried to change it to `(doto <some ArrayList> (.remove (int (dec <some-num>))))` in hopes of making sure it is being passed the primitive int, to match the correct signature
17:33mikerodyet, it still seems to be calling the ArrayList#remove(Object) method instead. Is there a different way to get a primitive int from a Clojure numeric value, which I know are the "boxed" Long type.
17:33hiredmanmikerod: the clojure reflection stuff is always picking the most general method, because it doesn't no the reciever type of .remove
17:33hiredmanso you need to type hint <some ArrayList>
17:33gfrederickshiredman: does (int ...) imply an ^int typehint?
17:34hiredmangfredericks: sure, but the reflector doesn't care
17:34hiredman"oh, look, a remove that takes Object, use that"
17:34mikerodhiredman: the hint fixed it.. (doto ^java.util.List <some ArrayList> (.remove (dec <some-num>))) worked, I didn't even use the `int` call
17:34hiredmanyep
17:35hiredmandec is typed hinted to return a number
17:35technomancyseangrov`: what magnitude of differences are you seeing with your builds?
17:37mikerodThanks, that one had me confused. I guess I haven't had much of a good look at the Clojure reflection code around choosing the method.
17:37pepijndevosWhere should I look if I wanted to implement a toy datalog?
17:37pepijndevos(an plan for world domination afterwards)
17:38justin_smithpepijndevos: bacwn?
17:38justin_smithhttps://github.com/tailrecursion/bacwn
17:38tbaldridgepepijndevos: Pedestal UI has a 200 line implementation of datalog. let me dig it up....
17:38hiredmanmikerod: it is very easy to forget about hinting the reciever of a method call
17:39tbaldridgepepijndevos: correction, it's only 120 lines: https://github.com/pedestal/pedestal/blob/master/app/src/io/pedestal/app/query.clj
17:39pepijndevostbaldridge, whoo
17:39pepijndevosalso, justin_smith whoo
17:39hiredmandamn, mine is 197
17:39pepijndevosI need to figure out what this pedestal thing is anyway...
17:39tyler__I have approx 100 futures that im mapping over, it *appears* that its going about 30 futures at a time before it grabs the next set. I thought future uses an unbounded thread pool. anyone have any ideas?
17:40tyler__s/100/1000/
17:40tbaldridgepepijndevos: from the author's own admission it's not fast, but it works, and it runs on CLJS which was the original goal.
17:40hiredman~map
17:40clojurebotmap is lazy
17:40hiredman~map
17:40clojurebotmap is an evil genius.
17:40tbaldridge~chunked-seq
17:40clojurebotPardon?
17:41hiredmantyler__: map is sequential, the only reason you see an parallelism of your futures at all is this other thing called chunking
17:41danlentzclojurebot: danlentz is an evil dunce
17:41clojurebot'Sea, mhuise.
17:41hiredmanany
17:41hiredmantyler__: most likely you are producing the futures lazily and then derefing them lazyingly, so you need to not product them lazily
17:42justin_smithif you need the return vals, mapv is not lazy, or doall can force it, if you don't need the return there is doseq
17:42danlentzlazybot: what is your relationship to clojurebot?
17:42lazybotIt's AWWWW RIGHT!
17:42hiredman(map deref (for [i (range 10)] (future (+ i i)))) ;; bad
17:42hiredman(map deref (doall (for [i (range 10)] (future (+ i i))))) ;; better
17:43tbaldridgereducers....better
17:43danlentzuncanny, sometimes
17:43tyler__hiredman: the code: (map #(future (oy/request-remote %)) remote-params) (map deref ref-result)
17:43tbaldridgewell I guess unless you want 1000 threads...
17:43hiredmantyler__: see my examples
17:43tyler__hiredman: thanks
17:44technomancy1000 threads is peanuts
17:44justin_smithhiredman: with the (map deref (doall ...)) shouldn't the doall be outside thte map?
17:45hiredmanjustin_smith: it should be where it is
17:46tyler__hiredman: is there a diff between using doseq vs doall and for?
17:47hiredmanread the docs
17:47cemericksritchie: Well, the filename is coming from cider/nrepl.el IIRC
17:47tyler__rgr
17:47bitemyappsritchie: are tagged unions/case classes regarded as a code smell in Scala?
17:47cemericknot sure how to relate it back to austin/piggieback tho, without part of the stack
17:48sritchieyeah, makes sense
17:48sritchiebitemyapp: I don't think so
17:48sritchieI use them, anyway, mostly as a more explicit exception handling mechanism
17:49sritchieEither, for example, right?
17:49brehauttyler__: the docs are two private msgs with clojurebot or lazybot away
17:49pepijndevostbaldridge, how do i even use it? Reading code is hard. Especially tricky code without knowing what it does.
17:49bitemyappsritchie: It's also not clear to me what distinction, if any, is made between Either being a type union vs. a monad one binds values out of
17:50brehautbitemyapp: the monad is just an interface that the union implements
17:50sritchieyeah, the only distinction is that scala has no monad tait
17:50sritchietrait*
17:50bitemyappbrehaut: that makes sense. So in order to access the contents of the union, you bind?
17:51tbaldridgepepijndevos: it's pretty much a rip-off of Datomic's datalog, so: https://github.com/pedestal/pedestal/blob/master/app/test/clj/io/pedestal/test/app.clj#L1168
17:51brehautbitemyapp: thats one way yes
17:51tyler__hiredman: only asking because ostensibly there is no real difference i was wondering if you picekd one way for a specific reason that wasn't apparent to me
17:51pepijndevostbaldridge, is the Datomic one equally short?
17:51tyler__picked*
17:52TEttingertyler__, there's a lot of difference
17:52hiredmantyler__: there is a very real difference, have you looked at the doc strings?
17:52brehautbitemyapp: theres probably also map (functor) and applicative operations for different access to it too
17:52llasramtyler__: If you mean `dorun`, there isn't much effective difference
17:52llasramtyler__: `doall` though, big diff
17:52TEttingerfor and doseq at least are very different
17:52tbaldridgepepijndevos: I don't know (I haven't seen the source), but I guess not. Datomic Datalog is backed by indexes and it also caches queries. This shorter example is very brute force.
17:52pepijndevosI see.
17:52TEttingererr maybe I am exaggerating
17:53TEttingerone returns the seq, one doesn't, so totally different uses
17:53bitemyappbrehaut: I would hope so, yes.
17:53pepijndevosYea, i read datomic uses like 3 indices.
17:53bitemyapppepijndevos: eavt vaet avet and I might be missing one.
17:54bitemyapppepijndevos: oh and aevt.
17:54hiredmanhttps://github.com/sonian/Greenmail/blob/master/src/clj/greenmail/db.clj is a nice little "datalog" that uses core.logic for the actually search, but actually indexes facts(similar to datomic datoms) in memory
17:55bitemyapppepijndevos: would you like an article on how to harness datomic's indexes directly?
17:55pepijndevosbitemyapp, sure.
17:55tyler__hiredman: k thnx
17:55bitemyapppepijndevos: http://www.dotkam.com/2013/05/31/datomic-can-simple-be-also-fast/
18:15mlb-what are the uniqueness guarantees on gensym?
18:15llasrammlb-: You can generate collisions if you try, but probably not if you don't set out to do so
18:19mlb-llasram: is it thread-safe?
18:19llasramtldr yes, but I encourage you to read the implementation :-)
18:20hiredmanmlb-: if you have to ask those questions, the answer is (java.util.UUID/randomUUID)
18:20mlb-I'd love to! Where might I find a javadoc for clojure.lang.RT?
18:20hiredmangensym is just useful enough for generating code, you shouldn't use it for anything else
18:24bitemyappmlb-: a java doc for clojure.lang.RT? Are you serious?
18:27llasrammlb-: No javadoc, but here's the source: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java
18:28mlb-bitemyapp: Entirely serious. Why shouldn't I be?
18:32mlb-llasram: cool, found enough information to satisfy my curiosity
18:32mlb-sad there's no javadoc, though
18:57bitemyappso I just wrote "drop-keys", how did I do? --- (select-keys m (reduce disj (set (keys (target-s))) dropped-keys))
18:57bitemyappproperly: (select-keys m (reduce disj (set (keys m)) dropped-keys)))
19:00bitemyappI'm sure in J it would just be ->!{} ^^ [::]
19:03brehaut,(#([[%&]] (+)) 1 2 3)
19:03clojurebot[(1 2 3)]
19:05hyPiRiondrop-keys is easier than that
19:05hyPiRion(apply dissoc m dropped-keys)
19:07bitemyapphyPiRion: commented my version out and appended ;; for humility. to it.
19:07hyPiRionhaha
19:08hyPiRionit's easy to get lost in the Clojure world
19:11akurilinWhy is it that when I return a file outside of a JAR from a ring app, it's a File object, and when it's in a JAR, it's a BufferedInputStream object.
19:12brehautakurilin: at a guess because when it comes from a jar its pulled out of a zip file on demand
19:13brehautand its not a full 'file'
19:13bitemyappakurilin: why go to the trouble of faking a filesystem inside a jar?
19:14akurilinbrehaut, is that how jar content is usually deal with? It's kept zipped in of the filesystem and then pulled into memory on demand, or are all the contents of a jar automatically cached in memory at java -jar time?
19:15brehautakurilin: i would presume its implementation specific
19:15bjacan lein load clojure source via stdin?
19:16bjanvm
19:16akurilinbrehaut, got it.
19:16akurilinbitemyapp, no reason. Just trying to debug a few quirks I get with MIME types when running the app from a .jar
19:16akurilinled to a fun 3am debugging session.
19:18bitemyappakurilin: if you want fun, let me talk to you about doing migrations with Datomic.
19:20akurilinbitemyapp, I think it'd go over my head at this point :)
19:20akurilinArgh Compojure docs. List the middleware backwards with respect to how they're listed in code in the threading macro
19:33taliosanyone here using Jay Fields expectations testing library at all?
19:35brehautmorning talios
19:35TimMcbja: Not that I'm aware of, but clojure.main accepts an -e containing code to execute.
19:35talios'lo brehaut
19:46bjaif I build a standalone uberjar, will running the jar with java -jar intercept the stdin before my jar gets to it
19:47bjaso doing something like: echo "msg" | java -jar foo-standalone.jar
19:48hyPiRionnot afaik
19:49bitemyappahhhhh fuck I need Fluokitten.
19:50llasramwow
19:52llasrambitemyapp: May I ask what for?
19:54bitemyappllasram: roughly - (group-by :db/id (Either Datomic.List Datomic.Map))
19:54bitemyappa group-by functor for a Datomic transaction category.
19:54llasramhmm
19:54bitemyappso that I don't have to (cond (vector? ...) (map? ...))
19:55bitemyappbecause that is fucking bullshit.
19:55llasramNot just a multimethod or protocol?
19:55bitemyappit doesn't merit reification in that manner.
19:55llasramI see
19:55bitemyappit's also not that simple
19:56bitemyappthe List forms have less data "apiece" than the Map forms.
19:56bitemyappyou can't implement an isomorphic interface to both
19:56bitemyappyou'd have to reduce the List forms into the Map forms to get a complete picture, but the Map forms are less expressive.
19:57llasramI don't know enough datomic to fully grok. Curious to learn how your fluokitten-ing goes though :-)
19:58bitemyappllasram: I'm holding off on the Fluokitten, I'm suffering the schlep for now.
19:58bitemyappbut the ROI is encroaching...
19:58bitemyappwriting this migration toolkit for Datomic is probably the most pissed off I've been in months.
19:59bjaany idea why https://gist.github.com/emidln/7241957 would let me say "lein run < project.clj" but building an uberjar and then saying "java -jar target/edn2json-0.1.0-SNAPSHOT.jar < project.clj" has no output?
19:59bitemyappbja: is that the standalone jar?
19:59bjaerr
19:59bjayeah, meant to be the standalone jar
19:59bjamistyped the question
20:01bjajava -jar target/edn2json-0.1.0-SNAPSHOT-standalone.jar < project.clj
20:07bitemyappllasram: I thought I was the only one that liked Fluokitten.
20:08hoangelosI have some clojure code that calls clojure.java.shell/sh. The (third-party) script being called included a password. I'm trying to make sure the output for that isn't logged.
20:09hoangeloswhen there's an error it seems to log the output and the input including the full script command line args.
20:38yeoj___i'm trying to simply write a large pipe delimited file.... but i'm getting "streamclosed". Can someone take a look at this: (ns metadata.db.table-dump
20:38yeoj___ [:use
20:38yeoj___ [clojure.pprint]
20:38yeoj___ [metadata.db.connections]
20:38yeoj___ [metadata.db.metadata]
20:38yeoj___ [clojure.string :only (join)]
20:38yeoj___ ;[clojure.core.incubator :only [throwf]]
20:38yeoj___ ]
20:38yeoj___ [:require
20:38yeoj___ [taoensso.timbre :as timbre :refer (trace debug info warn error fatal spy with-log-level)]
20:38yeoj___ [clojure.java.io :as io ]
20:38yeoj___ [clojure.java.jdbc :as j ]
20:38yeoj___ [clojure.java.jdbc.sql :as sql]
20:38yeoj___ ]
20:38yeoj___ )
20:38yeoj___(timbre/set-config! [:appenders :spit :enabled?] true)
20:38yeoj___(timbre/set-config! [:shared-appender-config :spit-filename] "log.log")
20:38hyPiRionyeoj___: would be lovely if you put this on a pastebin instead
20:38yeoj___(def sql "select * from comcast_lineup ")
20:38yeoj___(let [
20:38yeoj___ joiner (fn [v] (join "|" v ))
20:38yeoj___ ;results (rest (j/query local-postgres [sql ] :as-arrays? true :row-fn joiner ))
20:38yeoj___ results (rest (j/query local-postgres [sql ] :as-arrays? true :row-fn joiner ))
20:39yeoj___ ]
20:39yeoj___ (with-open [wrtr (io/writer "test.txt")]
20:39yeoj___ (map #(.write wrtr %) results )
20:39yeoj___ ) )
20:39yeoj___opps.
20:39yeoj___sorry
20:39yeoj___i mean't this: https://www.refheap.com/20306
20:39yeoj___hyPiRion: i'm sorry. goofed on a copy paste.
20:40hyPiRionyeah, no worries. It's just easier to read/test on a pastebin, and has the additional bonus of not spamming the channel =)
20:40yeoj___hyPiRion: i understand. i'll be more careful.
20:48amalloy~map
20:48clojurebotmap is lazy
20:50hyPiRionyeah, yeoj___, the problem is that map is lazy. You attempt to write on a closed resource. Try to use mapv, or wrap the map call in a dorun
20:52yeoj___ok, I'm trying to dump massive resultsets... I'm hoping results stays lazy (as it writes) but the doall only effects the vertor for each row
20:53yeoj___also it seems like it returns nil for each row that i .write. but i have the output accurate at this point.
20:58logic_proghow does sessions work in https://github.com/ring-clojure/ring/wiki/Sessions -- can I assume that I can (1) store in a session the user name of an authenticated user and (2) there is no way the suer can change it (since the cookie is encrypted)
21:00Apage43logic_prog: correct, the cookie store should be tamper-proof https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session/cookie.clj
21:01Apage43what you do have to worry about is the fact that a user could *save* their cookie and reset it to an old state later
21:01Apage43so if you want to expire it, you'll need to stick a timestamp in it
21:01logic_prog*thinking*
21:01logic_proglet me skim the cookie.clj file first then raise objections :-)
21:03logic_proghttps://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session/cookie.clj#L92 <-- isn't this dangerous
21:03logic_progi.e. if someone broke AES, they could cause an read-string
21:03logic_progand then use read-macors to do a remote execution
21:03Apage43"if someone broke AES"
21:03logic_progyes
21:03Apage43actually more of a concern is whether someone can break the HMAC
21:04Apage43they don't need to break AES to tamper the cookie, just the HMAC
21:04Apage43but yes
21:04Apage43if you don't trust the HMAC you can't trust cookie store
21:04Apage43you can probably trust it though
21:04logic_progshouldn't there be a (binding [*read-eval* false]) ?
21:04Apage43logic_prog: no. I mean, the data inside the cookie necessarily came from the server
21:04Apage43it's not user data
21:05logic_prognot if someone could forge a MAC
21:05Apage43assume that that is hard
21:06Apage43hn
21:06Apage43*hm
21:06Apage43actually it's using the same key for AES and HMAC
21:06Apage43which you *shouldn't* do
21:06logic_progsomeone should file an issue ticket
21:06logic_progApage43: I've done my part (pointing out the lfaw). I leave the rest to you. :-)
21:06Apage43but... probably won't be what kills you
21:08logic_progthis seems rather bad
21:08logic_progbecause suppose there's some other vulnerability that lets the client guess the AES key
21:08logic_prognow they can do arbitrary code execution
21:10Apage43logic_prog: ..
21:11Apage43really I think if your crypto is busted
21:11Apage43you probably have worse problems
21:11logic_progthat's like saying: "if you have cancer, don't worry about the scraped knee"
21:11Apage43yes
21:11Apage43it is exactly like saying that
21:12Apage43you can probably ignore a scraped knee if you have cancer
21:12RaynesNot really
21:12logic_progwell, actually it's different
21:12logic_progit's more like "here is a scraped knee; which, if you have cancer, will suddenly drain your bank account"
21:12RaynesApage43: That scraped knee could become infected and do away with you much quicker than the cancer.
21:12logic_progit goes from "broken crypt" to "full ownage"
21:12RaynesEven if you've got an expiration date, if it's more than two weeks you should probably go ahead and put some peroxide on that.
21:13RaynesJust saying.
21:13bitemyappah how's that for cool? I think my migration stuff is working now.
21:13logic_progmore accurate is "this is a like a weird gene, where should you one day get cancer, it'll cause you to sponteanously to go into flames"
21:13Apage43i mean
21:13Apage43*the whole point of having crypto here*
21:13Apage43is that you are relying on it for the correctness of your system
21:13Apage43if this crypto is broken
21:14Apage43even if it doesn't give you code execution *there*
21:14bitemyapplogic_prog: there's defense in depth, and then there's realizing there's a line across which you cannot defend your program or your data, period.
21:14Apage43the system is probably severely compromised
21:14bitemyapplogic_prog: if magical gnomes with the ability to read hard disks are inside my colo, I'm fucked regardless. I don't give a damn if they get "root"
21:14bitemyapplogic_prog: concordantly, if they break AES...then *FUCK* it.
21:15Apage43Most folks are going to store "logged in as <user>" in this. if you can just change that to "logged in as admin" (you broke AES).. well you have enough of a foothold you can probably get into the rest of the system
21:15bitemyappApage43: generally what one does is store a UUID4
21:15logic_proglogged in as admin != root shell
21:15bitemyappApage43: this points to an unguessable db-backed session
21:16bitemyappApage43: this prevents cracking of cookie crypto translating into arbitrary user access
21:16Apage43the whole point of using the cookie store is that you don't have a better session store =P
21:16Apage43if you have a db just send a session id and don't use the cookie store
21:16bitemyappApage43: I know, I'm just proffering alternatives.
21:16RaynesIf they break AES then chances are they've earned their prize.
21:16bitemyappbut yeah, if you are stuck with non-db-backed sessions, then the hell with it.
21:16logic_progare you implying that if someone broke AES, instead of hacking my lol-cats site to change their karama, they would hack banks?
21:16bitemyappcrypto is everything with cookie-stores. doesn't fuckin' matter if they crack it.
21:17Apage43logic_prog: well hopefully your app isn't running as root =P
21:17bitemyapplogic_prog: there are two kinds of pedants in this world.
21:17TimMcNo, there are at least 12.
21:17bitemyapplogic_prog: Ones that actually know what they're talking about (amalloy) and then there's those that don't.
21:17RaynesThere is TimMc, TimMc, TimMc, TimMc, and so on up to 12.
21:18bitemyapplogic_prog: you can make yourself less obviously a member of the latter group by dropping the bullshit whine-fest and wasting somebody else's time.
21:18Rayneslol
21:18TimMcOK, I need a filk, stat: "When [...], that's-a monad"
21:18bitemyappIf I got a PR on Github like this I would drop-kick it to Mars and then nuke Mars.
21:18logic_progwhat's PR?
21:19RaynesPull request.
21:19RaynesWhat's a github, bitemyapp?
21:19Rayneso.o
21:20bitemyappRaynes: I just snorted diet coke you little shit
21:20bitemyappnow my nose burns
21:20logic_progactually
21:20logic_progI can just wrap CookieStore
21:20bitemyapplogic_prog: nobody cares
21:21llasrambitemyapp: Let's keep this a friendly community, yes?
21:21RaynesNo.
21:21bitemyappllasram: fine fine. There's been a stream of people like this lately and it's exasperating.
21:21bitemyappWhenever you write any libraries/software that involves web apps, suddenly everybody becomes a fucking expert.
21:22bitemyappthen you get people like Captain Peanut Gallery ^^ up there.
21:22TimMcMore to the point, no one is going to break AES -- but they may break your poor usage of it.
21:22Apage43yep
21:22Apage43but the construction in ring's cookie store is pretty much right
21:22llasrambitemyapp: I agree that the particular topic is probably not going to generate useful discussion, but I think tone is important
21:22Apage43you can feel comfortable using it
21:22TimMcE.g., some people think "Oh I'll ust encrypt it to myself, everything will be fine"
21:23bitemyappllasram: this is really just another reason to use Fluokitten.
21:23Raynesbitemyapp: We need more data pipelining practices.
21:23llasramA dismissive atmosphere makes it easier to accidentally dismiss genuine issues
21:23llasramhaha
21:23RaynesStat!
21:23TimMcand then some clever Ukrainian flips a few bits blindly and gets a valid result
21:23bitemyappllasram: if I use Fluokitten, muggles get scared away and don't make silly comments.
21:23bitemyappRaynes: decomplected data pipelining practices.
21:32TimMc"When a type con-structor has a bind and return... that's-a monad..."
21:32TimMcI'm done, good night.
21:32TimMcI expect to see something better by morning.
21:57logic_progis there a way to tell cljure.tools.namespace.repl/refresh that nameslace Blah.clj no longer needs to be loaded?
22:11l4ushould I use tools.namespace or pomegranate for code reload in REPL?
22:15jcromartiewhy is javagit development using SVN
22:17seangrovejcromartie: Because cvs is horrible, duh.
22:19jcromartiegit log --pretty=format is my new best friend
22:21devnhello all
22:22jcromartiehi
22:45gvickersIs anyone familiar with Quil, the processing library for clojure? In my draw function I am trying to draw a ellipse for all the elements of a vector using (for [x vec] (let [bla bla] (ellipse bla bla bla bla))). Is there something I dont understand about processing, can the draw function only handle 1 new shape at a time? I am getting a nullPointerException on the draw function.
22:50amalloygvickers: i'm not, but a quick look at the quil readme makes me think that draw is side-effectful, and so putting that in a for (as opposed to a doseq) is doomed to fail
23:15uvtcIs there a function to write to stderr, or should I write `(binding [*out* *err*] (println "..."))`?
23:20`cbpuvtc: I guess you could use (.println *err* "foo") but there's no clojure function that i know of
23:21uvtc`cbp, thanks. I was just poking around in the clojure source, and it appears to me so far that `binding` `*out*` is the way it's typically done.
23:25uvtcAh. https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/utilities.clj#L95 (using `binding` as above)
23:30teslanickI'm a clojure newbie, and I'm having a hard time parsing the `for` form.
23:30teslanick(take 10 (for [n (whole-numbers) :when (even? n)] n))
23:30teslanick(From Programming Clojure 1st edition)
23:31teslanickI'm not sure I understand how to map `for` into something I'm more familiar with.
23:31uvtc`for` is a way to generate sequences.
23:32brehautteslanick: what languages are you familiar with (impossible for anyone to make an analogy without that info)
23:32uvtcLike Python's square bracket thingy: `[i for i in range(5) if i % 2 == 0]`
23:32`cbplist comprehension
23:32uvtcRight. That's it. :)
23:32teslanickI'm most familiar with javascript, but I know java-esque languages as well.
23:32brehautuvtc: like generator comprehensions, not list comprehensions
23:32brehautround parens
23:33brehautteslanick: how well do you know jquery's map function?
23:33teslanickYes.
23:33teslanickAll of it. :)
23:34uvtcteslanick, you use `map` and `filter` when you've already got a sequence. You can make new sequences with functions like `range` and `iterate`, or you can custom-make them with `for`.
23:34teslanickI'm actually really familiar with JS's map and reduce functions
23:34brehautteslanick: $.map([1,2,3], function (a) { return [a,a,a]; });
23:34brehaut/=> [1, 1, 1, 2, 2, 2, 3, 3, 3]
23:35brehauts/^\//\/\//
23:35brehautjquery's map is broken, but its useful for analogy
23:35teslanickWhat would that map into in Clojure?
23:36brehautdirectly: mapcat
23:36brehaut,(mapcat (fn [a] [a a a]) [1 2 3])
23:36clojurebot(1 1 1 2 2 ...)
23:36teslanickI get mapcat, map, reduce, etc. I
23:36brehautbut mapcat and for are isomorphic; for is simply a syntax for mapcat
23:36teslanickI'm just having trouble parsing the example code for :when and :while with `for`
23:36coventryteslanick: Programming Clojure probably isn't the best book to be learning from these days.
23:37teslanickIt's the book I have. ;)
23:37teslanickBut what would you recommend?
23:37brehaut,(for [a [1 2 3] generated [a a a]] a)
23:37clojurebot(1 1 1 2 2 ...)
23:37coventryClojure Programming is more recent.
23:37brehaut:when adds a filter
23:37`cbparent they both 1.3?
23:38normalHow do I use the jar from "lein jar"? Or how do I make it find the project dependencies?
23:38coventryteslanick: ##(for [n (take 10 (range))] (* n n))
23:38lazybot⇒ (0 1 4 9 16 25 36 49 64 81)
23:38uvtcteslanick, Oh. `:when` is for when you want to keep going through the rest of the `for`; `:while` is when you want to stop once your predicate says you're done. Have you had a look at http://clojuredocs.org/clojure_core/clojure.core/for ?
23:38brehautso the mapcat version ##(filter odd (mapcat (fn [a] [a a a]) [1 2 3]))
23:38lazybotjava.lang.RuntimeException: Unable to resolve symbol: odd in this context
23:38coventryteslanick: ##(for [n (take 10 (range)) :when even?] (* n n))
23:38lazybot⇒ (0 1 4 9 16 25 36 49 64 81)
23:38brehaut,(filter odd? (mapcat (fn [a] [a a a]) [1 2 3]))
23:38clojurebot(1 1 1 3 3 ...)
23:39coventryteslanick: oops ##(for [n (take 10 (range)) :when (even? n)] (* n n))
23:39lazybot⇒ (0 4 16 36 64)
23:39coventryteslanick: oops ##(for [n (take 10 (range)) m [\a \b \c] :when (even? n)] [(* n n) m])
23:39lazybot⇒ ([0 \a] [0 \b] [0 \c] [4 \a] [4 \b] [4 \c] [16 \a] [16 \b] [16 \c] [36 \a] [36 \b] [36 \c] [64 \a] [64 \b] [64 \c])
23:40brehaut,(for [i (range) :while (< i 3)] i)
23:40clojurebot(0 1 2)
23:40brehautexactly what it says on the tin
23:40brehaut,(for [i (range) :when (odd? i) :while (< i 6)] i)
23:40clojurebot(1 3 5)
23:40brehaut,(range)
23:40clojurebot(0 1 2 3 4 ...)
23:41amalloybrehaut: yes, although people are often surprised by ##(take 20 (for [x (range) y (range) :while (< y 5)] [x y])
23:41amalloy&(take 20 (for [x (range) y (range) :while (< y 5)] [x y]))
23:41lazybot⇒ ([0 0] [0 1] [0 2] [0 3] [0 4] [1 0] [1 1] [1 2] [1 3] [1 4] [2 0] [2 1] [2 2] [2 3] [2 4] [3 0] [3 1] [3 2] [3 3] [3 4])
23:42amalloy:while isn't *exactly* "what it says on the tin", simply because it's hard to realize what is the expected behavior of :while
23:42uvtcbrehaut, Oh. Didn't know clojurebot could handle an ∞ seq. (`,(range)`)
23:42brehautuvtc: its just a flag for the printer
23:43teslanickCan I enable that flag in the repl? I've bumped into that a few times :)
23:43brehautuvtc: http://blog.n01se.net/blog-n01se-net-p-85.html
23:43brehauta chouser classic
23:43uvtcbrehaut, Sorry, don't know what you mean. What magic is clojurebot doing?
23:44brehautuvtc: its doing exactly zero magic. simply setting the *print-length* variable does that automatically
23:44uvtcHeh. That's a pretty exact amount of magic. :) Thanks, and also thanks for the link.
23:44teslanickbrehaut: aww yiss.
23:47TimMc,`[~@(range)]
23:47clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
23:47brehautTimMc: now do it without the alpha characters
23:48TimMchehehe
23:48amalloygfredericks: the way it handles multiple args is insane
23:48TimMcBlow the heap, you mean?
23:48gfredericksamalloy: I remember this from back in the day; apparently I almost never use some-fn in this way
23:48brehautTimMc:
23:48brehautTimMc: yeah
23:48gfredericksbut I can't for the life of me imagine using it the way it was written to be used
23:48TimMcMmm, I don't think I can generate infinite seqs.
23:49amalloygfredericks: right, because the way it was written to be used is easy to emulate with existing functions
23:49davis there a way to tell clojure what to do if destructuring fails to match the mattern?
23:49davpattern
23:49TimMcI could race the stack against the heap and try to allocate too much heap before I use too much stack...
23:49gfredericksamalloy: what on earth is going on with your for example above?
23:49dav((fn ([[x y]] (+ x y))) [4]) -> NullPointerException
23:50gfredericksI can't imagine how :while would be implemented to get that behavior
23:50teslanickThanks for all your help. I'm still making my way out of Plato's proverbial cave over here.
23:50amalloygfredericks: :while only terminates the innermost loop variable
23:50amalloygoes back up a level and starts with the next seq item
23:51gfredericksamalloy: that's what I thought; so why is your result finite?
23:51amalloygfredericks: (take 20)
23:51gfredericksoooh
23:51gfredericksPHEW
23:52gfredericksman for a second there for was pretty dang weird
23:53amalloy(for [x xs y ys :while (f x y)] [x y]) => (mapcat (fn [x] (mapcat (fn [y] [x y]) (take-while (fn [y] (f x y)) ys))) xs), more or less, i think
23:57TimMcdav: You can use :or to put in default values.