#clojure logs

2014-02-11

00:01dobry-denWhat database would yall use to log pageviews (just ip, referer, and destination)
00:04technomancydobry-den: that sounds like a canonical redis use case
00:06technomancyor like ... flat files?
00:06arrdem(inc flat-files)
00:06lazybot⇒ 1
00:06technomancyobligatory http://www.brandonbloom.name/blog/2013/06/26/slurp-and-spit/
00:07Wild_CatI'm thinking sqlite would do the job nicely too
00:07Wild_Cat(or whatever the JVM equivalent is)
00:07technomancyWild_Cat: from any other language, sure
00:07dobry-dentechnomancy: generally speaking, if you were just tracking unique IPs that hit each page, do you generally log everything naively and then post-process to find uniques. or would you just do the uniq check as you go?
00:07technomancythe jdbc bindings to sqlite are rubbish though
00:07Wild_Cattechnomancy: HSQL then, maybe?
00:07bob2then you have (inc n) problems?
00:09technomancyWild_Cat: if it fits on a single server I'd just use a file and an atom in memory
00:09Wild_Cattechnomancy: sure.
00:10dobry-denoh duh. that's what i'll do for now
00:10dobry-denwell, that atom would fill up fast
00:11Wild_Catdobry-den: actually, do you even need to access the data from the process that writes it?
00:12Wild_Catdobry-den: if not, just open a text file and keep appending lines to it.
00:12dobry-denWild_Cat: all the main process really needs is access to a "Unique Views" counter that's computed elsewhere
00:13dobry-denWild_Cat: cool, that's good enough for now
00:13Wild_CatI'd probably log naively and postprocess later.
00:13dobry-denyeah, logging everything would give me insight into actual activity
00:13dobry-denthanks
00:14dobry-denWild_Cat: I guess you'd do the write in a future
00:14Wild_Catdobry-den: not even.
00:15dobry-denoh, is it thread safe?
00:15dobry-dento just write?
00:15dobry-den(not that a future would fix it)
00:15Wild_Catdobry-den: if you use a line-buffered output stream, yeah, it is
00:16arrdemWild_Cat: linebuffered is synchronized by default? til....
00:17dobry-denWild_Cat: do i need to do something special for that?
00:17Wild_Catarrdem: I'm actually uncertain what the situation is on the JVM.
00:17arrdemdobry-den: worst case, just have a work queue atom and a worker thread that does all the writes...
00:18arrdemmessage passing FTW
00:19dobry-denin fact i'm already using core.async just for (go-loop [] (<! (timeout (* 1000 60 5))) (flush-cache))
00:19dobry-deni'll get a channel set up
00:20dobry-denwhen do you know to use a thread vs go block for something like this?
00:22Wild_Catdobry-den: all java.io.Writer subclasses have a lock attribute, but Writer doesn't specify how or if it should be used.
00:22Wild_Cat...and then none of the subclasses document how it's used.
00:23dobry-denWild_Cat: exactly. i'll just push views onto an async channel that consumes it on another thread
00:24Wild_Catdobry-den: fair enough. I mean, if you're all-async in the first place, that can't hurt.
00:24arrdemthat kinda synchronized main print queue is sitll something I want to put in my OS...
00:24Wild_Catman, this is reminding me of how bad the Java I/O class hierarchy is.
00:25Wild_Cat(yay manual buffering and then accidental buffering of buffered buffered buffered buffers >.< )
00:30arrdem:D
00:30arrdemyo dawg I heard u like buffers....
00:36Wild_Catarrdem: class XzibitOutputStream...
00:38sdegutisWriting ClojureCLR and it's pretty fun :)
00:55TolstoyThis OM component state management thing is confusing. At least for big lists of widgets.
01:08sm0kehow do i convert a trasient back to immutable?
01:08TEttingersm0ke: persistent!
01:09TEttinger,(doc persistent!)
01:09clojurebot"([coll]); Returns a new, persistent version of the transient collection, in constant time. The transient collection cannot be used after this call, any such use will throw an exception."
01:09sm0keTEttinger: thanks!
01:09sm0ke(inc TEttinger)
01:09lazybot⇒ 14
01:09TEttingernp, transients are neat but you do need to be careful of what functions support them
01:10sm0keyep, i see they normally have ! suffixed function counterparts
01:10sm0keassoc!, dissoc!
01:10TEttingerindeed, but there aren't counterparts for most "read" operations. nth and get work on transients, not much else
01:11sm0keah yea, good one
01:11sm0kei was using get without thinking about it
01:11amalloyseq can't work on transients, especially
01:41systemfaultIf I use emacs as my editor, should I spend time learning paredit?
01:42sdegutisWoo.
01:44eggheadyes systemfault
01:44eggheadparedit is great in every lang
01:44systemfaultReally? I thought it was some cool LISP-only thing
01:45sdegutissystemfault: yes.
01:46eggheadsystemfault: it balances syntax like ', ", [, {, (, etc, all langs need those things matched
01:46eggheadbut yes it makes programming w/ parens blissful
01:46systemfaultHmm, cider already does that
01:46eggheadnot all langs, not apl
01:47TEttingerheh, J. [ has no need to be matched!
01:49Tolstoysystemfault: The fun with paredit is the other editing stuff. Like "kill to end of line" is remapped to erase everything up to the next balancer paren.
01:49Tolstoybalanced. ;)
01:50systemfaultAh, I see :)
02:43sdegutisYay, it's done-ish.
02:43sdegutishttps://github.com/sdegutis/ZephSharp
02:48sdegutisUses ClojureCLR for scripting :)
02:50TEttingerneat sdegutis
02:51sdegutisThanks TEttinger.
03:07sm0kehmm ok i swear i have something like (when ... (assoc! n [i j] k) (prn i j k)) ... i can see 1 2 3 printed but ..its not present in the final map!
03:08sm0ken is transient, and i did a prersistent! for the final map
03:08sm0ketrue story.
03:21sm0keok i replace transient with an atom, and things work!
03:32sm0ke,(let [t (transient {})] (doseq [i (range 20) j (range 20) k (range 20)] (assoc! t [j k] i)) (persistent! t))
03:32clojurebot{[0 0] 19, [0 1] 19, [0 2] 19, [0 3] 19, [0 4] 19, ...}
03:32sm0ke,(let [t (atom {})] (doseq [i (range 20) j (range 20) k (range 20)] (swap! t assoc [j k] i)) @t)
03:32clojurebot{[2 1] 19, [3 2] 19, [4 3] 19, [5 4] 19, [6 5] 19, ...}
03:33sm0kecan you guys try this in your repls?
03:33sm0kewhy is transient has loss of writes?
03:33sm0kedoes*
04:03pyrtsasm0ke: Curiously, it's because you shouldn't actually think transient assoc! works (entirely) in-place. Looks like every 8 items inserted, it creates a new return value. Thus, instead of doseq, use reduce.
04:04pyrtsaOr actually, it's not the transient assoc! but the way transient maps are implemented.
04:05sm0kewhatever it is i dont know whats it good for
04:06sm0kei am using a HashMap, ftw
04:06pyrtsasm0ke: Did you read what I just said?
04:07pyrtsaTransients are pretty much only good for optimizing the construction of a collection, single-threaded. They could be more but they aren't.
04:08pyrtsaFor an example, see (source into)
04:14pyrtsaThe documentation of ##(doc assoc!) is slightly off.
04:14lazybot⇒ "([coll key val] [coll key val & kvs]); Alpha - subject to change. When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets the val at index. Note - index must be <= (count vector). Returns coll."
04:14pyrtsaIt doesn't always return `coll`.
04:46bob2Expected: (clojure.lang.IPersistentMap clojure.lang.Symbol java.lang.String)
04:46bob2Actual: (IPersistentMap (U Symbol (Value :dark-feature-value)) String)
04:46bob2shouldn't they match?
05:01ivanbob2: :dark-feature-value is a Keyword, no?
05:02ivan(note I don't know core.typed so I'm guessing what that means, sorry)
05:10borkdudeWhat is that irc client that is always connected, starting with a z?
05:11borkdudesomehow I only remember first letters of things
05:11algernonznc?
05:11borkdudeyes, tnx
05:11Anderken1in all fairness, znc is a prettty hard name to remember
05:11Anderken1what does it stand for?
05:13borkdudeI have no clue
05:13borkdudeI think it is a play on bnc, which means bouncer
05:14Anderken1yeah, that'd fit
05:56AeroNotixDoes Ring work with Clojurescript?
05:57AeroNotixor portions of it
05:57dsrxwhat do you mean by that?
05:57AeroNotixI just saw this: http://clojurescriptone.com/documentation.html
05:57Anderkentyeah, there's also some middleware that lets you recompile scripts on every request while developing etc.
05:57AeroNotixhuh
06:10d11wtqI grapple with this. Do you reckon if you've written (and tested) a convenience function for pulling something from a data store (for example), you should be able to use that function in assertions in other tests?
06:11d11wtqIf you use it, you get more readable tests, but on the other hand, if you at some point introduce a regression that breaks the convenience function, you get a cascade of failures through your test suite, making it hard to identity the root cause.
06:11d11wtqs/identity/identify/
06:11AeroNotixYes.
06:12AeroNotixBecause you're testing the convenience function so you tests should fail in a predictable manner.
06:13Anderkentd11wtq: that's fine; another approach is to mock the conveniance function for other tests. Depending on how common it is through your code it might or might not be worth the effort
06:14d11wtqAeroNotix: Yeah, but if the convenience function test failures are buried in a sea of thousands of other failures, it might not be obvious that it is the cause. I suppose this is entirely academic in practice.
06:14d11wtqI've been bitten by it once or twice in a 10 year career, not much.
06:14Anderkentyeah, it's a minor inconveniance; I'd guess if you went to mocking it you'd be just as likely to have an error in your mock than in the original function :P
06:14d11wtqAnderkent: I tend to agree.
06:15d11wtqWas just thinking out loud in here as I was about to go down this path :)
06:15d11wtqThanks for the input!
06:16AeroNotixYou need to fix your error reporting if you get lost
07:01bob2ivan`, oh, you're totally right - thanks!
08:39mdrogaliscemerick: ping once more :) Sorry
08:43cemerickmdrogalis: go for it
08:43mdrogaliscemerick: Heh. Philly ETE, yeah?
08:43mdrogalisSaw your tweet yesterday.
08:44cemerickmdrogalis: I don't remember what I tweeted an hour ago :-P
08:45mdrogaliscemerick: Haha, fair. Your talk just sounded interesting.
08:46cemerickmdrogalis: ah, right. Yeah, I hope so
08:46cemerickI certainly think so :-)
08:47mdrogalisI live in Philly if you want to get drinks after and geek out. Stalking ambrosebs too. :P
08:47cemerickI hope the organizers aren't aggro'd; I think they thought I'd be talking about Clojure
08:47cemerickOh, sure, I'm sure all the Clojure folk will rove about in unison.
08:47mdrogalisHm. Yeah, not sure how they'll react to that.
08:48mdrogalisCool.
08:48cemerickThey gave me carte blanche, so I'm not going to worry so much.
08:48cemerickI just hope I don't get slotted opposite Jeff Hodges or something. :-P
08:49mdrogalisThat wouldn't feel so great.
08:49mdrogalisread: That won't feel great for whoever gets it.
09:03cmiles7416:11 *** LLKCKfan QUIT Excess Flood
09:11effyis there something analog to ML pattern matching in clojure (outside of multimethod) more like a "cond-ish" thing ?
09:12Anderkenteffy: I'm not sure what ML pattern matching is, but maybe core.match?
09:13effyAnderkent: sweet, i think you pointed just in the middle :)
09:16mathwyes, core.match is rather like ML-ish pattern matching
09:16mathwat least as far as I've used it
09:32krlanyone know a channel for datastructures?
09:33chousercore.async provides channels for data structures. <rimshot />
09:35AimHerekrl, ##programming will be a general CS/programming channel, where datastructures will be on topic
09:38krlAimHere: thanx
09:39ambrosebs$200 bounty to build an Emacs plugin for Typed Clojure https://www.bountysource.com/issues/1406536-emacs-plugin-for-typed-clojure
09:50pcnIs there documentation on what thatwould mean?
09:51ambrosebspcn: for the emacs plugin? rough notes here, get in touch with me if you're considering it and we can talk http://dev.clojure.org/jira/browse/CTYP-103
09:52ambrosebsnot looking for much
10:06pcnI've got no skillz for that, but I'd be interested in trying it out - maybe chipping in a few bucks if I understand what's going on there.
10:12ambrosebspcn: cool. Right now Typed Clojure just spews out type errors, it would be nice if they were hyperlinked to the sources. And just some bindings that type check specific forms and do some refactorings.
10:12ambrosebsThat's all I'm really after
10:12ambrosebsI implemented the hyperlinking for vim in about 150 lines of viml
10:13ambrosebsto give an idea of the scope
10:17ohcibihi, is there something like map, but like that it also replaces the values if f returns a trueish value?
10:18teslanickCan you provide an example of the transformation you're looking for?
10:18Anderkentohcibi: to make it clearer, do you want to replace every value x for which (f x) is true with (g x), and otherwise leave x unchanged?
10:19Anderkentthe simplest way to do that is just (map (fn [x] (if (f x) (g x) x)) xs)
10:19ohcibi(magic-map #(when (= 1 %) "hello") [0 1 2]) --> [0 "hello" 2]
10:20ohcibilike replacing only one value that matches a predicate
10:20Anderkentooh, only one?
10:20ohcibiuhm
10:20ohcibilemme think if it must be limited to one...
10:20Anderkentif it's all values that match, see my post above
10:20carkhow about (map #(if (=1 %) "hello" %) ... )
10:21carkoh only one
10:22Anderkentif it must be just the first, I think you have to do first split-with to find the first occurence, then replace the single element, then concat
10:25pcnambrosebs: yeah, the update to the jira makes it clearer what you're asking for
10:26ambrosebspcn: ok
10:26ohcibihm okay.. the solution with (if) would replace the values that should not be changed with the same values (thus leaving them unchanged) is there no way that would just only touch the ones that should be replaced?
10:26sdegutisI wrote a window manager for Windows that's scriptable in ClojureCLR! So excited :)
10:27chousersdegutis: wow, that sounds powerful.
10:27sdegutishttps://github.com/sdegutis/ZephSharp
10:27sdegutisIt's API is a little limited compared to Zephyros, because it's only a few days old. But the plan is to get there soon.
10:27Anderkentohcibi: well, you have to look at every value to decide if it matches the condition anyway; returning it unchanged or not touching it are the pretty much equivalent
10:28sdegutischouser: :)
10:37ohcibilets say I have a map that contains a vector, like {:myvector [1 2 3]} with (assoc-in mymap [myvector 3] 4), I would append a 4 to this vector... is this possible by appending (i.e. without needing to specify the 3 as index?)
10:39mikerod,(update-in {:myvector [1 2 3]} [:myvector] conj 4)
10:39clojurebot{:myvector [1 2 3 4]}
10:39mikerodohcibi: How's that
10:40ohcibimikerod: sweet... thanks
10:42mikerodohcibi: `update-in` is intended to let you make an "update" to the map that is a function of what is already there (or nil if missing). `conj` on a vector returns a vector with the args appended to the end (the efficient end for a vector).
10:43ohcibiyep... basically I wanted to ask for a function that would "somehow work with conj" but I didn't know how to explain it, so I asked for the basecase 8-))
10:44mikerodohcibi: I see
10:44mikerodif you were unsure of the map having a vector already at that key, and you wanted to have the value be a vector, you could have it like:
10:44mikerod,(update-in {:myvector [1 2 3]} [:myvector] (fnil conj []) 4)
10:44clojurebot{:myvector [1 2 3 4]}
10:44mikerod,(update-in {:myvector nil} [:myvector] (fnil conj []) 4)
10:44clojurebot{:myvector [4]}
10:45mikerod,(update-in {} [:myvector] (fnil conj []) 4)
10:45clojurebot{:myvector [4]}
10:48ben-obyte and/or byte-array question: how can I select the first n bytes of a byte-array? Thanks.
10:49llasram,(let [ba (byte-array (map byte [1 2 3 4]))] [ba (take 5 ba)])
10:49clojurebot[#<byte[] [B@1b8d481> (1 2 3 4)]
10:50ben-o@llasram-let me give that a quick try- thanks!
10:51llasramben-o: np. And FYI, the convention on IRC is to just refer to someone's handle directly -- no '@'-prefix
10:51ben-ooh ok
10:52sdegutisCouldn't figure out the syntax for accessing enumeration values in ClojureCLR.
11:01dobry-denHow do you decide between a core.async `go` block and a dedicated `thread`?
11:02AeroNotixcoin flip
11:02CookedGryphondobry-den: things like whether there are any blocking operations happening
11:02CookedGryphonif you are using an api which blocks for a while for example, use a thread, otherwise you will interfere with the thread pool that gets used for go blocks
11:02CookedGryphonthere's probably other considerations too
11:04dobry-denCookedGryphon: Honestly I thought the point of a go block was that you could do something that would otherwise block the flow of execution.
11:04teslanickdobry-den: The go block only protects you from channel blocking, if you're using an API that does other blocking, go blocks can't help you.
11:05dobry-denOhh.
11:05teslanickAt least, that's my understanding.
11:05teslanick"Blocking" in channels actually parks the go, and frees up the thread for other code to run.
11:06dobry-denSo `go` is really for servicing channels
11:07Anderkentyeah; for interacting with external event-based or blocking interfaces the common thing to do is to have a very simple poller / thread that just reads from the external interface and puts stuff into channels (or the other way around)
11:07Anderkentso your business logic can live in go blocks and service only channels
11:09dobry-denWhat kind of benefits do you lose if you naively use `thread` instead of a `go` block for servicing a channel?
11:10Anderkentwell, every read / write will actually block the thread; you can have many more go routines than threads
11:11dobry-denAnderkent: i guess my problem is that i read that, and i can nod along, but i don't really grasp it. what kind of resources should i check out to get a better mental model of how threads work?
11:11dobry-deni've read java's docs on threads/concurrency, but they don't really answer those questions.
11:11dobry-denthey just explain the API
11:11Anderkenteach thread is an actual OS threads; they have their own stacks, related data structures etc.
11:12Anderkentit's basically about the memory cost
11:12dobry-denfor example, I don't understand why read/write "blocks" a thread (or what that means) and why go can ameliorate that
11:12Anderkentoh
11:12Anderkentwell, in a (go) routine if your code tries to read from an empty channel
11:12Anderkentit'll just 'park', which means it will stop execution, save the current state and let another goroutine run on the same machine thread
11:12Anderkentwhereas if a (thread) tries to read from an empty channel
11:13Anderkentit will 'block' the machine thread - i.e. this thread will not do anything until the channel can produce a value
11:13pbostromdobry-den: this is a pretty good read: http://martintrojer.github.io/clojure/2013/07/07/coreasync-and-blocking-io/
11:13dobry-denoh, so that's what it means when there's a "pool of special go threads" - they just take turns on the same OS thread
11:13Anderkentyeah
11:14teslanickYou can configure it to use any Java thread pool (IIRC, I've never fooled with it)
11:14Anderkentnow it sometimes makes sense to have a lot of blocked threads
11:14dobry-denpbostrom: thanks, that looks awesome. i'll check that out
11:14Anderkentfor example if you only have the old fashioned io interfaces, you don't want to be polling from hundreds of sockets; you want to make a thread for each and let them block
11:15Anderkentotherwise if all the sockets are empty you'll just waste cpu spinning around
11:15Anderkent(of course this is all irrelevant if you have an event based io interface)
11:15Anderkentbut in general, tens of thousands of go routines shouldn't be a problem
11:15Anderkentwhereas tens of thousands of threads can be onew
11:16Anderkent(since each thread has its own allocated stack space - I think 128k minimum)
11:16Anderkent(so a thousand threads uses 128M of memory ; ten thousand brings you into gigabytes *just* for the stack space)
11:16Anderkent(and linux threads used to be notoriously expensive; I heard it's better now)
11:17dobry-denAnderkent: where did you learn about OS-level things like IO and threads? Do you have a background in lower level languages like C?
11:18Anderkentcollege :P
11:18Anderkentthe details are fuzzy but I remember the general idea
11:18dobry-deni got into programming 75% of the way through a finance degree.
11:18teslanickYeah, that's totally a thing they stomp into you in a CS program. THREADS HARD, THREADS EXPENSIVE :)
11:18dobry-dendidn't even teach us cobol :(
11:19cleatomaYour smiley is the wrong way around there.
11:19AnderkentD:
11:20dobry-denwhat language did yall predominantly use in your CS programs?
11:20teslanickEh. It kept me away from it for ten years. When I first learned programming, it didn't make sense to parallelize because everything was single-core. Now it doesn't make sense not to, and the abstractions have gotten pretty good.
11:21Anderkentdobry-den: AFAIR it went haskell -> java -> c (total of 1 week) -> x86 assembly (another 1 week) -> C++ (2 weeks) -> java
11:21teslanickThe first language anyone taught me was C. Before that I taught myself (terrible terrible) JS, which is how I snuck into college with terrible grades. After C was C++ and then finally Java.
11:21Anderkentbut honestly for everything after hte first year it was fairly language agnostic
11:22Anderkentyou'd learn stuff like compilers or software engineering practices or maths (lots of maths) or type theory
11:22sdegutisdobry-den: VB.NET
11:22Anderkentpracticals in language of choice, which for some ment java, some c#, and for some vimscript (once.)
11:22teslanickYeah. It becomes less about what you write and how you write it, and how you should think about it.
11:22Anderkentseriously, don't do vimscript.
11:22dobry-denwell i switched to emacs like an adult
11:23dobry-deni realized that my vimrc rested precariously on the productivity of tpope
11:23Anderkenthaha
11:24AnderkentI've been thinking of moving to evil for like 2 years now
11:24sdegutisIt's a trap.
11:24Anderkentno time to really do it
11:24dobry-denAnderkent: were you previous a vim user in your life
11:24AnderkentI'm a vim user right now
11:25sdegutisAnderkent: There's never time, you just have to make time for it.
11:25sdegutisAnderkent: And that's only worth it if you're convinced that you'll actually be more productive after learning it.
11:25dobry-deni was all vim and a fulltime ruby developer when i decided to jump in to clojure + emacs + evil + nrepl all at once.
11:26sdegutisI'm now convinced I'm more productive in emacs than vim. I still hate emacs though.
11:26Anderkentyeah, I guess I haven't yet
11:26AimHereYou tried one of emacs vi emulation modes yet?
11:26sdegutisI'm pretty sure text editors are a practical joke that computer scientists play on programmer communities at large just for fun.
11:26Anderkentno, as I said, I'd be switching to one of these
11:26sdegutisIt's kind of mean-spirited of them if you think about it.
11:26Anderkentbut it's everything *around* the core comands that I'd have to learn
11:27dobry-denevil is almost perfect. in fact, once you install emacs + evil, it's pretty much vim once you open a file
11:27Anderkentnow, given, I've been withdrawing from my vim plugins recently, so it might be an opportunity
11:27Anderkentbut still, I rarely sit down with vim when not trying to get something done; switching the editor would cause me to take much more time to get it done
11:27Anderkentfor any value of it
11:28Anderkentand I'm not putting enough time into cloverage as-is :(
11:28Anderkentthough, I suppose, if someone has a nice evil emacs setup for clojure that they'd like to share
11:28AnderkentI'm listening :P
11:28dobry-denhttps://gist.github.com/danneu/7185465
11:29AnderkentI've tried emacs live once, but it was a bit too much; and I think the keys conflicted with evil in some parts
11:29dobry-denyeah it's way too much
11:34Anderkentwhee, second 'external' pull request for cloverage! I'm getting so popular.
12:06technomancy"don't get cocky, kid." - Han Solo
12:06sdegutisAnyone wanna upvote this sucker? https://news.ycombinator.com/item?id=7218521
12:07sdegutisI love popularity contests!
12:07`cbpupvoted
12:08sdegutis:)
12:08sdegutisThanks you two!
12:08`cbpAlso will try next time I'm forced to use windows
12:08sdegutis:D
12:09Anderkentneeds screenshots in the readme :P
12:10sdegutisAnderkent: It's the kind of window manager where you write a Clojure script that registers callback functions for global hot keys, which move/resize windows according to your likes.
12:10sdegutisThus the closest thing to a screenshot is an example config. Which it has :)
12:10Anderkentyeah; so write a couple simple scripts and show what results they produce
12:10sdegutisOoh, a screencast!
12:11Anderkentyeah, or the written form - text with screenshots / gifs :P
12:11sdegutisHmm, that sounds easier.
12:12Anderkentjust a couple examples like how to script a 2 column layout, 3 column, etc. (can it access multiple windows or just the active one?)
12:12Anderkentis there like a stack of recently opened windows on windows?
12:12justin_smith,(apply str (map (comp char inc int) "gdkkn"))
12:12clojurebot"hello"
12:13Anderkenthm, no 'get-nth-active-window' in the api, so I gues not
12:13sdegutisAnderkent: Dunno about recent ones, but (get-all-windows) works.
12:14Anderkentmhm
12:14Anderkentwell, from my experience trying to interact with the winapi windows api (goddamnit, microsoft) it's usually really painful
12:14Anderkentlike, I remember tring to bring a window to front
12:14sdegutisAnderkent: Meh, it's actually pretty easy these days.
12:15Anderkentthere's bringWindowToFront function, but it doesn't bring the window to the front unless a number of preconditions is met
12:15sdegutisAnderkent: See https://github.com/sdegutis/ZephSharp/blob/master/Zephyros/Window.cs
12:15sdegutisOh maybe we just ran into different things.
12:16andyfBronsa: ping
12:16Bronsaandyf: hi
12:16andyfBronsa: Howdy. I guess you can tell I am back to testing Eastwood again :-)
12:17Bronsaheh, yeah I noticed :P
12:18andyfThere is an exception during analyzing a namespace in core.async because it refers to a constant in another namespace that was defined with an ^int type hint. Older t.a(.jvm) didn't throw an exception for this case, but the newest one does.
12:18andyfThe exception goes away if I delete the ^int type hint. I guess file a JIRA ticket and let you take a closer look?
12:19Bronsaandyf: yeah, definitely a bug
12:19andyfOK. Filing ...
12:20Anderkentandyf: wouldnt it be http://dev.clojure.org/jira/browse/TANAL-24 though ?
12:20Anderkentor is that a different pass
12:21Anderkentwait, that's your bug
12:21andyfAnderkent: I honestly don't know. I file bugs on the symptoms, not the causes :-)
12:22andyfBronsa is cool that way
12:22Anderkentyeah, I suppose you'd know if the symptops are the same; I didn't notice the old one was also reported by you and thus figured it might be the same symptom
12:22Anderkent(it does look similar - exception on tag that is a primitive)
12:23Bronsayeah, there's no point in making andyf figure out the cause of the bug since I can do that way faster.
12:23Bronsaif it turns out that it's the same bug it takes ~2 seconds to close as duplicate.
12:24Anderkenti suppose :)
12:31Bronsaandyf: Anderkent yeah, it's indeed a duplicate of #24 and thus a bug in core.async
12:31andyfBronsa: OK, so just not caught by earlier t.a(.jvm) versions?
12:31Bronsaandyf: looks like so
12:32andyfBronsa: You interested in filing a ticket for core.async?
12:33andyfThe suggested patch is trivial enough -- it is the precise explanation of why that you are much better at than I am :)
12:34Bronsaandyf: heh, opening the ticket now
12:40seangroveDoes anyone have a link that talks about the performance characteristics of clojure's persistent data structures?
12:48dnolen_seangrove: pretty sure Rich covers this in his early talks?
13:11Anderkentwhee, merging pull requests is fun
13:20gtrakdoes anyone know any interesting, surprising, or heinous ways to mess with jruby from clojure?
13:21technomancygtrak: there was a talk on that at the first clojure/west
13:21gtrakoh ha
13:21gtrakI see it
13:22dobry-denive interoped with JRuby once when I was too lazy to read Javadocs for the java bindings of a lib
13:22technomancytl;dr: you can do this, but you really shouldn't
13:22technomancyiirc
13:22gtrakI'm just going to start with trying to get a jruby proc to work in reducers
13:22gtrak'jruby for performance-sensitive-code'
13:22dobry-denopt-in to mutability for perf
13:22dobry-denduh
13:23technomancyhehe
13:28dobry-denCan you really not copy the value of a cookie from Chrome's inspector?
13:28dobry-denwhat a boondoggle
13:34SegFaultAXdobry-den: Allow me to blow your mind: http://www.charlesproxy.com/
13:34SegFaultAXAlso, you can copy and paste from the network tab.
13:35teslanickCharles Proxy is one of those tools you don't always use, but when you need it, it's the perfect tool for the job.
13:37dobry-deni hear good things. thanks
13:38blackrose_Hey guys, i'm new to irc and clojure
13:38blackrose_:)
13:38technomancytwo of my favourite things
13:39dobry-dennice, this might be my chance to answer a question
13:39blackrose_Yeah
13:39dobry-deni'm deep in an ask deficit
13:39AimHereI didn't know someone was keeping a score
13:40TimMcAimHere: Yes, we are, and you'll be sent to Collections soon. o\__/o
13:40dobry-denlazybot keeps score
13:41TimMcwhere you will be forced to answer Yahoo! Answers questions for a minimum of 40 minutes.
13:44blackrose_I have a project. My boss ask to use clojure for server side
13:44Wild_CatTimMc: is that the special-special hell for people too evil for the regular special hell?
13:45blackrose_Can you guys suggest where i should start ?
13:45blackrose_dobry-den
13:45blackrose_?
13:45SegFaultAXblackrose_: What kind of project?
13:45SegFaultAXWe need more details to set you on the right direction.
13:46SegFaultAX(Also, you have an awesome boss)
13:46AimHereMaybe it's a different kind of bad boss. Maybe three weeks ago, he demanded a server written in Scala, and before that haskell
13:46SegFaultAXAimHere: How could weighing all the options be a bad thing? :)
13:47AimHereThere's weighing all the options, and then there's implementing all the options!
13:47blackrose_SegFaultAX It's to develop a tracking system
13:47SegFaultAXblackrose_: Go on...
13:47SegFaultAXAimHere: Heyooo!
13:47blackrose_base on ruuvitracker
13:48S11001001Learned something interesting today. Leiningen uses a *modified* EPL.
13:48SegFaultAXIs this backend thing a web service?
13:49S11001001Ironically, the paragraph that has been changed comes right after the paragraph that states that modifying its text is forbidden.
13:51blackrose_SegFaultAX yes.
13:52pbostromblackrose_: are you asking how to run this: https://github.com/RuuviTracker/ruuvitracker_server
13:53blackrose_pbostrom yes, that's right.
13:54pbostromyou will need to lein: https://github.com/technomancy/leiningen
13:54blackrose_I'm trying
13:57SegFaultAXblackrose_: Are you on OSX?
13:57TimMcS11001001: I'll submit a PR to tweak that paragraph as well. ^_^
13:57S11001001TimMc: that'll do it :)
13:57blackrose_pbostrom I'm installing it
13:58blackrose_SegFaultAX I'm in ubuntu.
13:58S11001001In seriousness, I think, as a result, leiningen should not claim "Distributed under the Eclipse Public License, the same as Clojure uses." Because it *isn't* the same.
13:58SegFaultAXblackrose_: Ok, nevermind.
13:59TimMcS11001001: You should definitely file an issue, in any event.
13:59S11001001TimMc: Yeah, later :)
13:59pbostromblackrose_: run 'lein version' when it's installed to make sure you are at the latest, sometimes the distro repos do not have the latest
14:12blackrose_<SegFaultAX> <pbostrom> I'm following the instruction in https://github.com/RuuviTracker/ruuvitracker_web
14:13blackrose_If there would be any problem, i will ask you later, ok?
14:13sdegutisHomogenous collections are dumb.
14:13sdegutisSorry I meant heterogenous
14:17bbloomsdegutis: um, why?
14:18sdegutisCollections with different types. I used to love the idea, now it just seems like a useless/dangerous novelty.
14:20sdegutisI can't remember ever dealing with a collection that has more than one type in it (excluding nil).
14:20technomancysdegutis: maps included?
14:21justin_smithhow about maps mixed with records? arraymaps mixed with hashmaps?
14:21justin_smithfunctions mixed with maps even
14:21sdegutisNot for maps. They sometimes have number keys, sometimes string keys. Working with one right now (Datomic) that has both actually.
14:21justin_smith(both being applied on the same type args0
14:21sdegutisSo I guess I meant linear collections.
14:21technomancyyeah, I'll buy that
14:21bbloomsdegutis: what about using collections as paths?
14:21bbloom[:users 5]
14:22justin_smithlongs mixed with doubles?
14:22sdegutisHmm, that sounds useful. Although I'd mentally consider it a specialized struct with ordinal keys, rather than a vector, despite its implementation.
14:22sdegutisjustin_smith: Heresy!
14:22technomancyalso mapentry is technically sequential, but that's fairly pedantic
14:22sdegutisActually wait bbloom, you're totally right.
14:23bbloomsdegutis: except that "specialized" implies taking something generic, and intentionally eliminating the universal nature of it in order to benefit from particular aspects of a particular instantiation of it
14:23sdegutisEach element in [:users 5] is typically grabbed as a sequence to reduce a tree into a value.
14:23bbloomsdegutis: technically, those collections *are* homogenous
14:23bbloomthey are vectors of Object
14:24justin_smiththis is also mixed type - [[0 1 2] '(3 4 5) [6 7 8]] - and due to how clojure coerces sequences, not at all hard to end up with
14:24justin_smithbut also not hard to use
14:24sdegutis,(reduce get {:users [10 11 12]} [:users 2])
14:24clojurebot12
14:24sdegutisNeat.
14:25justin_smithsdegutis: looks a lot like get-in :)
14:25sdegutisbbloom: But when I think of homogeneous vs heterogeneous, I'm assuming stronger types than a void* equiv.
14:25SegFaultAXThat's basically exactly get-in
14:25sdegutisCool, I just invented get-in.
14:25sdegutisYay me.
14:26sdegutis,(source get-in)
14:26clojurebot#<SecurityException java.lang.SecurityException: denied>
14:27amalloy~def get-in
14:27bbloomsdegutis: the problem is that homogenous vs heterogenous isn't a useful distinction of any kind
14:27sdegutisShut up your face clojurebot.
14:27justin_smithyours is basically identical to the version with no not-found
14:27justin_smith(reduce1 / reduce)
14:27sdegutisbbloom: Fine point indeed.
14:27amalloyjustin_smith: it's also very wasteful for (reduce get {} (range 100))
14:27sdegutisI was mostly thinking about C#'s generic collections compared to ObjC's dumb old NSArray.
14:27amalloythe one in clojure.core short-circuits
14:27bbloomsdegutis: all collections are always homogenous, since you must always lift several types to a sum (or union) type
14:28sdegutisAnd how much cooler C#'s VS integration is than Xcode's with ObjC arrays.
14:28bbloomsdegutis: the question is whether you feel it's a good or bad idea to have a universal union type
14:28bbloomsdegutis: and if you decide yes, you want a universal union type (which i believe in, and most lispers / dynlang do) then supporting "heterogenous" collections is a no brainer
14:29justin_smithamalloy: only for the case with an explicit not-found though?
14:29amalloyno?
14:29clojurebotno is tufflax: there was a question somewhere in there, the answer
14:29amalloy&(get {} (range))
14:29lazybot⇒ nil
14:29sdegutisbbloom: Wow you're obviously pretty educated on language design and/or type system design.
14:29justin_smithamalloy: I don't see that in the source linked above at all
14:29amalloy&(get-in {} (range))
14:29amalloyreally? wow, i had no idea
14:29amalloythat's terrible
14:29lazybotExecution Timed Out!
14:29SegFaultAXOr if your language happens to have sub-type polymorphism with covariant sequences.
14:30justin_smithamalloy: see the link from clojurebot above
14:30sdegutisBy the way, that line of reduce/get code was meant to show that a path is accessed as a sequence or linear collection.
14:30justin_smithmoral: provide a not-found value to get-in I guess
14:30sdegutis,(range)
14:30clojurebot(0 1 2 3 4 ...)
14:30dobry-denwhat's the simplest way to split a vector into equal parts?
14:30sdegutisNeat. Replacing (iterating inc 0) from now on with (range).
14:31insamniacpartition?
14:31clojurebotpartition is probably not what you want; see partition-all.
14:31justin_smithdobry-den: partition?
14:31SegFaultAXdobry-den: partition and its cousins.
14:31justin_smithif "equal" is a hard req, partition, otherwise partition-all
14:31insamniac,(partition-all 4 (range 9))
14:31clojurebot((0 1 2 3) (4 5 6 7) (8))
14:31ToBeReplacedi've got a deep directory structure i've inherited of non-source code, and i want to create a file explaining it that can generate READMEs down the tree saying what the directory is and what its children are -- anyone know of a project that does that or something similar?
14:31bbloomsdegutis: the more i study type systems, the more i believe that sum types are a bad idea :-P
14:32sdegutisGood to know that I can draw out half the channel by just throwing out a controversial language design argument.
14:32sdegutis:)
14:32sdegutisbbloom: Why?
14:32bbloomsdegutis: b/c it is anti-reuse
14:32dobry-deni meant "Split this vector of arbitrary size into 4 equal parts". I ended up just doing partition-all and dividing count by 4
14:33sdegutisbbloom: related to m:n problem?
14:33justin_smithbbloom: isn't clojure effectively unityped with a huge sum type? or at least mostly so?
14:33amalloybbloom: you don't like sum types, but you argue for a super-sum union-everything type?
14:33bbloomjustin_smith: it's a union type, not a sum type
14:33justin_smithahh
14:34bbloomamalloy: i don't like sum types b/c if you can't reuse constructors between the types
14:34justin_smithbbloom: I am fairly ignorant, but wikipedia describes sum types as being a safer alternative to union types
14:34amalloyjustin_smith: by the way, the link clojurebot gave was to a four-years-old snapshot of the code
14:34bbloomjustin_smith: that's just propaganda the static typing people want you to believe :-P
14:34sdegutisThe biggest challenge I'm facing in my Clojure code these days is how to turn implicit system contracts into explicit verifiable safe contracts.
14:34amalloyit's still just as bad, but it might have been out of date
14:35sdegutisWhat library solves this problem completely for us?
14:35justin_smithamalloy: my 1.5 gives a similar function though
14:35bbloomsdegutis: no library will solve that problem for you completely
14:35sdegutisbbloom: In Haskell it does :P
14:35bbloomsdegutis: most, if not all, interesting properties of real problems can not be proven
14:35sdegutis(joking!)
14:35sdegutisbbloom: Maybe through machine learning they can?
14:36bbloomsdegutis: statically insignificant risk of incorrectness is different than "proven"
14:36sdegutisI think using clojure.typed with explicit interfaces may be a good start, if I put much of the contracts in message passing.
14:36bbloomsdegutis: i'm a big believer that the former is A-OK, but logisticians don't necessarily see it that way
14:36bbloomsdegutis: you'll note that core.typed works with union types
14:37bbloomie (U Integer Nil) can share the Nil constructor with (U Map Nil)
14:37sdegutisActually no wait, there's another solution that's kind of escaping me, that I want in Clojure.
14:37bbloomjustin_smith: amalloy: that ^^ is the distinction between sum and union types
14:37sdegutisAh yes, Sing#'s contracts!
14:37thearthurI have always used pallet in async mode, and now im trying to figure out the proper way to check for success on the result of a syncronous call to converge
14:38sdegutisIt's basically a verifiable state machine for execution flow.
14:38sdegutisIt focuses all the risk of an incorrectly specified system into central locations (the contracts).
14:38amalloy,(get (hash-map 1 2) (range)) ;; a bit of silliness i just realized
14:39clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
14:39sdegutisYou still have to be diligent to design the state machine properly, but as long as you have, then you have much more confidence that your system works as expected.
14:40bbloomsdegutis: the MSR folks do some seriously cool verification research
14:40bbloomsdegutis: people don't realize, but MSR invented all kinds of new static analysis techniques between Windows XP SP1 and SP2
14:40sdegutisWow.
14:41bbloomsdegutis: the entire windows code base is crazy advanced in terms of static verification
14:41sdegutisIs there a similar system for Clojure yet? That'd be neat.
14:41sdegutisbbloom: Probably how they got their OS so stable lately.
14:41sdegutis*in
14:41bbloomsdegutis: http://msdn.microsoft.com/en-us/library/windows/hardware/hh454825(v=vs.85).aspx
14:42bbloomsome of the tools are available to windows developers, like that one ^^ the static driver verifier
14:42bbloomit analyses things like correct sequencing of system calls
14:43gfredericksamalloy: what's interesting about that? the fact that another way you can easily realize the key isn't in the map?
14:45amalloygfredericks: it introduces a lot of non-obvious danger points when using lazy sequences
14:45amalloyand you won't even notice them in testing, because ##(get {1 2} (range)) works fine for array-maps
14:45lazybot⇒ nil
14:46amalloyfor example, if i can control the args to a memoized function in your program, i can run you out of memory
14:46amalloy(this is sorta true *anyway* with memoized functions, but that was the first obvious example of using hash-maps i could think of)
14:47gfredericksamalloy: iiiinteresting
14:47gfredericksprobably highly unlikely that user input could ever create a (range) without that being expected
14:48gfredericksthat programmer deserves her OOM
14:48AeroNotix,(range)
14:48clojurebot(0 1 2 3 4 ...)
14:50gfredericksclojurebot: clojurebot is highly unlikely
14:50clojurebotAlles klar
14:50gfredericksactually that example sort of proves the point of it being expected :)
14:52sdegutisI think I'm going to make use of assertions in my code to verify system contracts. For example an episode must be part of a series. That way there's no cheating in the integration tests by creating an episode and omitting its series, which is not a correct state of the system.
14:52sdegutisBut I'd love it if there was a more centralized way to specify/assert system contracts than pre/post-conditions inside scattered Clojure functions.
14:52stuartsierraCheck out core.contracts
14:53sdegutisSeeking.
14:53sdegutishttps://github.com/clojure/core.contracts#example-usage
14:54sdegutisWhen is Clojure gonna move to codeplex already?
14:55technomancynot sure why it's on github TBH
14:55sdegutistechnomancy: What would you recommend?
14:55technomancyTrac
14:55sdegutisstuartsierra: Looks neat. Seems to have the same isolation problem of pre-conditions though.
14:55sdegutistechnomancy: Okay now you're just trololing.
14:56technomancysdegutis: what I meant was there hasn't really been any practical difference since moving from assembla
14:57stuartsierrasdegutis: Also Prismatic Schema, Herbert, and core.typed :)
14:58sdegutisWow, So picture, Such trendy: https://github.com/miner/herbert
14:58technomancyI mean I know why it's on github: because everyone kept bugging rich to move it. but they were actually asking for "move to github and actually start using github's features", which never happened.
14:59sdegutistechnomancy: yeah, I submitted a pull request to rename it to Lava (Lisp in jAVA) and they never even looked at it
14:59sdegutis:(
14:59stuartsierrasdegutis: That was you! :)
14:59technomancyshame
14:59sdegutistechnomancy: yeah, totally cooler name, oh well
14:59mdrogalissdegutis: Dire :)
14:59sdegutisstuartsierra: shh don't tell!
15:00sdegutisstuartsierra: All of these libraries focus on a per-function basis it seems.
15:01fogus|awaysdegutis: The core.contracts code also allows other ways to attach contracts besides in that basic example.
15:01sdegutisThat's great, but I'd like a macro (vs micro) approach too, which specifies interactions between functions.
15:01mdrogalisAn overhead flying Fogus! Duck!
15:01`fogussdegutis: What would that look like?
15:01sdegutisfogICantAutoCompleteYourNick: hmm I'll look into that more. Might send a pull request to put an example in the readme.
15:02mdrogalissdegutis: https://github.com/MichaelDrogalis/dire#preconditions
15:03mdrogalisIt has the 'centralized' bit, but not the 'function interaction' piece.
15:03sdegutis`fogus: I have no idea, I'm just dreaming. The inspiration came from Sing#'s contracts. (page 3 of http://research.microsoft.com/pubs/69431/osr2007_rethinkingsoftwarestack.pdf )
15:03sdegutismdrogalis: Hmm, will look into it.
15:06`fogussdegutis: Thanks for the link. I've not seen that paper before
15:06eraserhdSay I wanted to load a jar off clojars at runtime. Where would the code to do that live? In leiningen?
15:06sdegutis`fogus: I imagine in Clojure it would have to be implemented as (1) a state-machine that (2) exercises all the functions it specifies, (3) using generated data based on the contracts.
15:07sdegutisI think #3 could be done based on Stuart Halloway's test.generative maybe.
15:08hyPiRionsdegutis: or core.check
15:08hyPiRion(or is it test.check?)
15:08sdegutis`fogus: Sure thing. It's an exciting idea, although it implies a reliance on a third party (presumably Microsoft) to verify your app for security before it can be fully trusted by the end-user. Which puts us in the same place as Apple's and MS's app store.
15:09`fogussdegutis: Part of my goal with c.contracts is to provide the substrate for something like what you describe, but yeah that would be a sweet library.
15:09sdegutisAlthough maybe with clojure.analyzer et al. it might even be possible at compile-time rather than run-time.
15:10sdegutisEr, tools.analyzer I guess?
15:10sdegutis(It changed its name a few times and I'm not sure what the latest one is, but I basically mean CinC.)
15:11bbloomsdegutis: you should also look in to substructural types
15:11sdegutistechnomancy: https://www.assembla.com/home WHOA GIANT TEXT BOX
15:11`fogusWell, runtime would have to occur to run the checks, but you could have a contracts checking phase that happens at dev time.
15:12sdegutisHmm right.
15:13technomancyeraserhd: look at pomegranate
15:14logic_proganyone have an APL of interprter written in clojure/cljs ?
15:14dnolen_sdegutis: `fogus: this also got me thinking - Microsoft has done some really interesting work with CodeContracts - seems like abstract interpretation for compile time verification of contracts is pretty promising.
15:14dnolen_now that the Clojure(Script) analyzer story is improving - it would be nice to see this type of literature implemented
15:15bbloomdnolen_: abstract interpretation isn't just "pretty" promising, it's, in my opinion, already far more useful than type systems at verifying real world code
15:15`fogusdnolen_: Have a favorite paper?
15:15bbloom`fogus: good starting point: http://research.microsoft.com/en-us/people/tball/tball_30yai_text.pdf
15:16`fogusbbloom: Thanks!
15:16bbloom`fogus: talks about the history a bit, so you can go dig in to the literature
15:16dnolen_`fogus: bunch of stuff behind ACM - but this is available http://research.microsoft.com/pubs/138696/main.pdf
15:16sdegutisYay! A transcription of a talk, so I don't have to sit through the whole thing!
15:16sdegutisMy ADHD thanks whoever transcribed that page.
15:18bbloomone of the things i most like about abstract interpretation is that it's "functional" in the sense that the flow of analysis matches the data flow of the program, rather than being "relational" in the sense that you have to run a solver over the type annotation of a program
15:19escherizehello, may I ask a compojure question
15:20escherizeI'm a little confused about how to allow the http OPTIONS method
15:20bbloomalso, abstract interpretation is naturally extensible. you can always add more abstract interpreters and run them in parallel over your program
15:21bbloomif you add to your abstract interpretation, you don't break properties of your existing analysis, which you do if you try to extend a type system
15:21bbloomwhenever you add a new feature to your type system, you need to go back and make sure it plays nice with every other aspect of your system
15:22bbloombut with abstract interpretation, you just add a domain with monotonic operations. analysis is always monotonic and never codependent with previous analysis
15:22sdegutisWelp, my job here is done. Got the smart people talking about a fun problem they can probably solve. Back to my grunt work :)
15:27gfredericksare vectors the only persistent data structure that work well with reducers?
15:27bbloomgfredericks: maps & sets should work just fine too
15:28pbostromescherize: isn't it just (OPTIONS "/some-path" [] "some response")
15:28bbloomgfredericks: plus, reducers are still useful for seqs if you can compose your processing pipeline up front. even if you put a lazy seq in and get a lazy seq out, you save all the allocations of the intermediate objects in the middle
15:28mikeyg6754Does anybody know of a good way of validating POSTS with Liberator? For example when a user submits an image upload form I'd like to be able to make sure they are actually uploading an image file.
15:29mikeyg6754I can't seem to cancel the :post! from within the handler function.
15:29gfredericksbbloom: I think sets in particular don't work
15:29gfredericksor at least aren't nearly as fast as a vector
15:30seangrovetechnomancy: Any idea if the faster deploy on heroku should significantly affect clojure deploy times?
15:30gfredericksbbloom: there parallelism in particular is what I'm after at the moment
15:30gfredericksthe*
15:31bbloom,(let [s (set (range 100000))] (time (clojure.core.reducers/reduce + 0 s)))
15:31clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.core.reducers, compiling:(NO_SOURCE_PATH:0:0)>
15:31bbloom(require 'clojure.core.reducers)
15:31bbloom,(require 'clojure.core.reducers)
15:31clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/core/reducers__init.class or clojure/core/reducers.clj on classpath: >
15:31bbloom&(require 'clojure.core.reducers)
15:31lazybotjava.io.FileNotFoundException: Could not locate clojure/core/reducers__init.class or clojure/core/reducers.clj on classpath:
15:31bbloomwtf?
15:31bbloom,*clojure-version*
15:31clojurebot{:interim true, :major 1, :minor 6, :incremental 0, :qualifier "master"}
15:32bbloom:-(
15:32bbloomwell there's that one and:
15:32bbloom(let [v (vec (range 100000))] (time (clojure.core.reducers/reduce + 0 v)))
15:32bbloomi got 30ms and 6ms
15:32gfredericksso that's supporting my assertion about sets, right?
15:33gfrederickswait don't you have to use fold to get parallelization?
15:33bbloomah right, duh
15:34mikeyg6754Anyone have experience with liberator?
15:35bbloomgfredericks: yeah (let [x (set (range 1000000))] (time (r/fold (r/monoid + (constantly 0)) + x))) seems non parallel
15:35klokbaskehi there! i cljs, how do I re-evaluate a (ns ..) form from my ide (lighttable in this case) without getting an exception?
15:36gfredericksbbloom: (r/monoid + (constantly 0)) is just +, eh?
15:36dnolen_klokbaske: I don't know of a good way to avoid that, might want to ask on the Light Table mailing list or channel
15:37bbloomgfredericks: yes, but i had already typed that out before i realized that fold was using a function rather than some data structure with two keys :-P
15:37klokbaskednolen_: alright - was actually going through your om tutorial and got that problem.
15:37pbostromklokbaske: I usually refresh my page when I change the ns
15:38klokbaskepbostrom: tried that - didn't work for some reason. seems odd to me, how the state can be kept alive in the browser ...
15:39pbostromklokbaske: are you also running cljsbuild auto?
15:43klokbaskepbostrom: now I am - but it does not seem to make a difference?
15:44pbostromwhen you save the file it should trigger an recompile, then refresh the compiled js in your browser and whatever you added to your ns should be available
15:45klokbaskeit does trigger a recompile when I save
15:45klokbaskeso maybe I just shouldn't re-evaluate then?
15:45pbostromright, no need to re-evaluate the ns
15:45klokbaskealright
15:49stuartsierraYou can't really "evaluate" anything in ClojureScript. It has to be compiled and loaded into a JavaScript runtime like a browser.
15:50sdegutisJust like Ruby!
15:51stuartsierraUm. No.
15:51dan`Hi, does anybody know about the Clojure GSoC projects? I'd love to work on one, but I'm not sure I have the experience..
15:51xnilahahha
15:52sdegutisstuartsierra: I meant like how you'd run a .js file in 'node', you'd run a .rb file in 'ruby'. Extra step is that you'd have to compile the .cljs file to .js
15:52pbostromstuartsierra: Lighttable handles the compile/load via a browser connection so it feels like it's evaluating; but doesn't seem to work for changing the ns form
15:53klokbaskepbostrom: seems I have to re-evaluate the (ns) form in order to evaluate from Lighttable any expressions that use the updated ns
15:54klokbaskerefreshing the browser doesn't do it
15:54klokbaskeand I do make sure that the source is recompiled before I refresh
15:54klokbaskeit's not that big a problem, it just puzzles me l-)
15:56sdegutisI feel like ClojureCLR opens up a whole new host of side income via windows apps possibilities.
16:15jconnollyquestion about using gen-class to implement a java interface and override a method...
16:16jconnollywhen I use :methods, I'm definining the methods I'm overriding?
16:17llasramjconnolly: No -- :methods are additional
16:17jconnollyah i had it backwards
16:17gfredericksA non head-holding version of rand-nth: #(->> % (map (juxt (fn [_] (rand)) identity)) (apply max-key first) (second))
16:17llasramjconnolly: I personally advise against using gen-class at all. What's your use-case?
16:18jconnollymy god, how long do you have?
16:18jconnollyi need to register a class a a JAXBContext resolver
16:18llasramReference for context?
16:18jconnollyi started with reify, then on to proxy, finally to gen-class
16:19jconnollyyes, basically https://jersey.java.net/nonav/apidocs/1.4/jersey/com/sun/jersey/api/client/config/DefaultClientConfig.html
16:19jconnollyadding a .class to .getClasses mutable set of context resolver
16:20jconnollyi've done it in java dozens of times, I was basically tansliterating from java to clojure without much success
16:20jconnollyso down the https://github.com/cemerick/clojure-type-selection-flowchart flowchart i went
16:20llasramAh, annotation-based dependency injection?
16:21jconnollyexactly
16:22llasramYeah -- I found even w/ the general issue I have w/ gen-class, annotations make it worse. In particular, I do not believe you can attached an annotation to a gen-class'd constructor
16:23jconnollyso I've come to conclude... it's okay, using jaxb was the wrong way to do this anyway
16:23jconnollyi thought it might have been the path of least resistence since most of the java code was written already, i'd just need some clojure wrappers around interop...
16:23llasramTwo options: (a) if you just need one or two specific classes, and can inject your specific logic via normal Clojure methods (passing in an IFn etc), then you can just write some tiny stub classes in Java which call the Clojure API
16:24llasramYeah, so just tiny wrappers, only in the other direction :-)
16:24jconnollyi had a hunch. i'm still getting acquainted with clojure so this was quite the journey down the rabbithole
16:24jconnollylearned a lot though
16:24jconnollythanks llasram
16:25llasramnp
16:25llasramAnd the other option, although is probably too crazy for your use case
16:25llasram(b) use ASM to dynamically generate stub classes w/ the interface you need
16:25borkdudeI am trying some clojurescript in lighttable and external browser connection á la the nom tutorial
16:25llasramIt isn't as bad as you might think -- https://github.com/llasram/esfj
16:26borkdudebut I keep getting "Namespace already declared"
16:26borkdudeeven when I refresh the page
16:26borkdudeand 'chan' can't be eval-ed, because I can't reload a new namespace definition
16:33BobSchackborkdude I've had a similar problem. I had to put the core.aysnc requires in the core / main file.
16:34borkdudeBobSchack I'm using only one file
16:35BobSchackdo you mean you are working with only one file?
16:36sdegutisI am in a black hole of regular-expression-based migrations.
16:36BobSchackI had a foo/core and foo/rules and tried evaling the foo/rules ns but kept on getting errors
16:37sdegutisFortunately it's at least in Clojure.
16:37BobSchackwhen I put the requires in foo/core that solved the problem. I tried it after reading this thread (https://groups.google.com/forum/#!msg/light-table-discussion/I1vFNuCm5zo/bFpGNARwOGEJ)
16:38borkdudeI also have Uncaught Error: Invariant Violation: prepareEnvironmentForDOM(...): Target container is not a DOM element errors in my console log
16:41BobSchackthat would be a question for dnolen_
16:42borkdudeI can evaluate each form without errors
16:42borkdudebut the browser thinks differently
16:42dnolen_borkdude: it's a known LT issue you can't evaluate the namespace form more than once.
16:43borkdudednolen_ ah ok, I restarted LT already
16:43dnolen_borkdude: the error doesn't really affect anything
16:44borkdudednolen_ ok
16:44BobSchackdnolen_ have you tried using any cljx projects from lighttable?
16:44dnolen_BobSchack: nope, never used cljx ever
16:45dnolen_BobSchack: but I'm sure there's gotta be people here or in #lighttable who have
16:46BobSchackOk thanks
16:49dnolen_BobSchack: also #clojurescript, also might want to hit up the ClojureScript mailing list as well if you don't get a response from someone on IRC
16:49kevinfishwhat happened to pedistal's site?
16:50BobSchackdnolen from what I can tell it tries loading clj namespaces not cljs ones.
16:51BobSchackI get js namespace not found
16:53bbloomkevinfish: React.js
16:53dsrxis there a special clojurescript mailing list?
16:53bbloomkevinfish: https://groups.google.com/forum/m/?utm_content=buffer1e113&amp;utm_medium=social&amp;utm_source=twitter.com&amp;utm_campaign=buffer#!topic/pedestal-users/jODwmJUIUcg /cc dnolen, if you didn't see it
16:53dsrxah, nice
16:53bbloomdnolen_ ^^
16:54arrdem~next
16:55dnolen_bbloom: yeah I saw the post when it came out
16:56dnolen_BobSchack: I don't know if LT can understand cljx, cljx is a build phase thing. perhaps cemerick knows something more
16:58cemerickBobSchack: there's a Leiningen plugin for cljx, and nREPL integration/support. I don't know anything about LightTable.
16:58DomKMI've been unable to get it to work in LT
16:59DomKMworks fine through lein repl or cider
17:00DomKMI asked about it on the mailing list (https://groups.google.com/forum/#!topic/light-table-discussion/g54WJuz36ws) but no one replied
17:01dnolen_DomKM: people also have problems with setting CLJS Node REPLs - so I suspect this is just a broader problem with LT at the moment.
17:01BobSchackThanks for all the info dnolen_ DomKM looks like I'll be looking at emacs for the time being.
17:02effyi dont know how to take a proper memory footprint but looking at a htop while running a `lein repl` i can see ~540M of RAM vanish, i was wondering how small a clojure daemon memory footprint could be (is there a chance that i could make them run on very small vps (ec2 micro-instance style)?)
17:04DomKMdnolen_: I'd be happy with only the clj side of cljx for now. It fails because it tries to read #+clj literally, even when connected to an external headless nrepl
17:04DomKMdnolen_: Seems to me like LT is ignoring the cljx middleware, but idk
17:13sdegutisDoes anyone use https://github.com/sdegutis/clojuredocs/wiki , or can I delete it?
17:14arrdemkill it.
17:15sdegutisk.
17:15arrdemhttp://brainsyndicate.files.wordpress.com/2010/10/892cap012.jpg
17:16sdegutisWhat's a less dumb way of doing this? ((fnil #(Long/parseLong %) "0") (re-find #"\d+" "looking 4 the number four BUT IT MIGHT NOT BE THERE"))
17:18sdegutisarrdem: killd
17:18seangrovesdegutis: Probably an if-let
17:18sdegutisOh right.
17:19seangrove(if-let [number (re-find #"\d+" "looking 4 the number four BUT IT MIGHT NOT BE THERE")] (Long/parseLong number) 0)
17:20sdegutisMuch better.
17:20sdegutisThanks seangrove.
17:20seangroveNo worries
17:20seangrove(dec everyone-but-me)
17:20lazybot⇒ -1
17:20sdegutisHa.
17:32sdegutisI'm totally solving a problem with regular expressions!
17:33oskarkvI'm using tools.namespace. If I have namespace A and B, and in B do (eval `(var ~(symbol "A/func"))), and refresh, that works. But if I make a change to A, refresh, so that only A refreshes, then that expression gives "Cannot resolve var: A/func in this context", even though A/func exists. Why?
17:34sdegutisarrdem, llasram: Just realized you both have double-consonants in your nicks.
17:34sdegutisTwins?
17:35AimHereWell given one is 'l' and the other is 'r', I expect them to be mirror images of each other, at best
17:35arrdem,(bit-xor (int \r) (int \l))
17:35clojurebot30
17:36sdegutisOh man, I think it's worth changing some data in production to get rid of this outlier in my regular expression inputs.
17:37sdegutisEvil, or best plan ever?
17:37llasramOne bit off from nemeses!
17:37arrdem1d2
17:37clojurebot1
17:37arrdemtotally evil
17:37arrdemllasram: haha
17:42sdegutisThis is the data set I'm working with in my migration: https://gist.github.com/sdegutis/97bf0b3ac610cb5405ad
17:42sdegutisI've got two options. Cheat and manually normalize data in production, or use some awesome regular expressions.
17:42sdegutisI think it's a no-brainer, amirite?
17:44carkmaybe use some regexes to normalize the data =D
17:45sdegutisOh man, yes totally!
17:46carkor go pro and use instaparse
17:47mvzinkprobably won't be the first time someone's written a CFG for episode titles...
17:47arrdemhaha
17:47sdegutisI really hate the idea of manually normalizing the data. It just feels like I'd be giving up.
17:48arrdemautomated migrations fwt!
17:48sdegutisAt the same time, just look at all those different ways of specifying Part N!
17:48arrdemsdegutis: jnltk is that way...
17:48sdegutiseps 6, 11, 19, in the title...
17:51RaynesInstaparse is pretty pro
17:51mvzinkinstaparse++
17:53sdegutis(inc instaparse)
17:53lazybot⇒ 1
17:53sdegutis(inc Instaparse)
17:53lazybot⇒ 2
17:54sdegutis(inc instaparse)
17:54lazybot⇒ 3
17:54sdegutisoh.
17:54justin_smith$karma instaparse
17:54lazybotinstaparse has karma 3.
17:54veron(inc instaparse)
17:54lazybot⇒ 4
17:54veronoh sweet, there's a repl here?
17:54justin_smith(inc instaparsE)
17:54lazybot⇒ 5
17:54justin_smithkinda
17:54justin_smithinc is special
17:55justin_smith,(+ 1 1) ; this is more general
17:55clojurebot2
17:55veron(* 2 4)
17:55clojurebot*suffusion of yellow*
17:55justin_smith#(+ 1 1) ; or this
17:55veron,(* 2 4)
17:55clojurebot8
17:55veronwhy do I need a comma
17:55justin_smithbecause clojurebot has to know which things to interpret
17:55veroncan I break out to shell?
17:56justin_smith##(int \a) ; or this, I mean
17:56lazybot⇒ 97
17:56veronI don't know enough clojure for exec
17:56justin_smithvenron hope not
17:56justin_smithit has a sandbox
17:56veronhaha
17:56sdegutisI DID IT!
17:56veron,(use '[clojure.java.shell :only [sh]])
17:56clojurebotnil
17:56veron,(sh "free")
17:56clojurebot#<SecurityException java.lang.SecurityException: denied>
17:57veronhahahahahhaa
17:57sdegutishttps://gist.github.com/sdegutis/97bf0b3ac610cb5405ad
17:57justin_smith,(slurp "http://goatse.cx&quot;)
17:57clojurebot#<SecurityException java.lang.SecurityException: denied>
17:57sdegutisI cheated by doing four different regexes for the different ways parts are specified in the title.
17:58llasramsdegutis: Oh, that's nothing. I thought you were doing something like implementing a 100-line parser in a regular expression
17:58sdegutisNah, I'm not that pro.
17:58llasramI'd actually call what you have there "completely reasonable"
17:59sdegutisThen you sir are a crazy person.
18:00llasramI'm going to call that an orthogonal concern :-)
18:00veronyou should run that clojurebot inside an lxc container :P
18:00veronso even if they "break out" of both the jvm sandbox and clojail, they're only on a container system
18:01veronhttp://docker.io
18:06arkh_ping ztellman
18:06ztellmanarkh_: sup
18:07arkh_ztellman: hello sir - I was using byte-streams and found that this still appends (transfer "asdf" (java.io.File. "/home/user/temp") {:append? false})
18:08arkh_I wish I could send you a pull request but I haven't been able to figure it out yet
18:08ztellmanjust a sec, let me check out the code
18:09arkh_I'm using 0.1.9
18:10ztellmanhmm, I see how it *should* be working
18:10ztellmancan you open an issue? I'll look at it later today
18:10oskarkvDoes anyone know what's wrong here? http://stackoverflow.com/questions/21714704/my-logging-with-robert-hooke-does-not-work-properly-with-tools-namespace-refre
18:11arkh_will do - thanks
18:20patchworkAny reason ring's wrap-content-type defaults to application/octet-stream rather than text/plain?
18:20patchworkIt seems that will be the default content type more often by far
18:20technomancypatchwork: you can turn bytes into text reliably but not vice versa
18:20sdegutisyeah huh, using utf8
18:21patchworkWell, not every stream of bytes is valid utf8
18:21sdegutisalso you pronounced vice versa incorrectly
18:21technomancypatchwork: right; the set of valid octet-streams is a superset of text/plain
18:21sdegutisI'm hoping one day I'll have enough HN karma to become king of the world
18:21patchworktechnomancy: Hmm… but it triggers a file download rather than just displaying the text
18:22amalloypatchwork: i wouldn't expect text/plain to be right more often than octet-steam
18:22technomancypatchwork: yes, but it's lossless
18:22technomancytext is lossy
18:22amalloymost files that you're serving as files are things you actually want to download and use for something else; if you wanted to display text frmo your webserver, you'd have used html, not plaintext :P
18:22weavejesterBasically everything technomancy says is right
18:23technomancywhoa, can I quote you on that?
18:23hyPiRionhaha
18:23technomancycompletely out of context, I mean?
18:23patchworkOkay, so every response should specifically set the [:headers "Content-Type"]
18:23patchworkjust seems clumsy for simple tasks, but I see the reasoning
18:23weavejestertechnomancy: Be my guest ;)
18:24weavejesterpatchwork: Sure, but you can automate it.
18:24weavejesterpatchwork: You can just add some middleware to give a set of routes a fixed content type if you want.
18:25patchworkweavejester: Sure, but not all of them are the same content type, some actually are files or whatever else
18:26patchworkBasically I will just rewrite wrap-content-type to use text/plain as the default
18:26patchworkit is a simple enough function
18:30fowlslegsI am having troubles understanding how MVCC works. I played with the example on http://clojure.org/refs, switching alter w/ commute and noticed that commute will end up with less distinct values.
18:30patchworkOr rather, "text/html;charset=utf8"
18:31fowlslegsIs this because alter will restart the transaction, recording a new in-transaction value if another function commits to one of the values the original transactions doblock is acting on?
18:32fowlslegsWhile commit will go ahead and use the original in-transaction value, even if another function has commited to it changing it.
18:32fowlslegsSorry, while *commute* will go ahead...
18:33fowlslegsWhat exactly is the difference between an end-of-transaction value and a commit?
18:34hyPiRionfowlslegs: well, you can only use commute when the applied function is commutative
18:35hyPiRionnot sure if that answers your question, but setting or replacing values certainly isn't commutative
18:36fowlslegsI am trying to make sense of the following "the last in-transaction value you see from a commute will not always match the end-og-transaction value of a ref, because of reordering. If another transaction sneaks in and alters a ref that you are trying rocmmute the STM will not restart your transaction. Instead, it will simpll run your commute functionatain, out of order. Your transaction will never even see the ref value that commute ran a
18:37fowlslegshyPirion: I get what you are saying, I'm just trying to understand the details of how alter and commute work in the clojure mvcc implementation.
18:37fowlslegsrocmute should be to commute
18:38fowlslegsfunctionatain should be function again
18:38fowlslegssorry for the typos
18:39carkcommute is for those cases where it isn't important to o the updatein order
18:39carklike adding a constant to an accumulator
18:40carklet's say you have a bank
18:40fowlslegscark: I get when to use them, I'm just trying to understand the internals of the clojurebot
18:40carkand you want ot count the total number of transactions
18:40carkok
18:42carkwhy don't you take a look at the source then ?
18:42hyPiRionfowlslegs: so if my-ref is a ref with value 0 when `(dosync (commute my-ref inc) (deref my-ref))` is started, then the return of the dosync will be 1 regardless. But if another transaction updates the value before the original transaction has been "commited", the actual update will be with the latest value.
18:42hyPiRion(doc commute) explains it rather well I think.
18:42clojurebot"([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref. At the commit point of the transaction, sets the value of ref to be: (apply fun most-recently-committed-value-of-ref args) Thus fun should be commutative, or, failing that, you must accept last-one-in-wins behavior. commute allows for m
18:46fowlslegspublic Object commute(IFn fn, ISeq args) { return LockingTransaction.getEx().doCommute(this, fn, args);
18:52teslanickom question: is it possible to insert html as a string using the builtin om dom api?
18:52teslanicki.e. (dom/div nil "<i>this is italics!</i>")
18:57ivanteslanick: maybe (dom/div #js {:dangerouslySetInnerHTML #js{:__html "<i>this is italics!</i>"}})
18:58ivanthat's more om than I expected https://github.com/search?l=clojure&amp;q=dangerouslySetInnerHTML&amp;ref=searchresults&amp;type=Code
19:01teslanickThat appears to do it, thanks
19:15teslanickThat doesn't actually meet my need. Let's change topics:
19:15teslanickWhat's the advantage over letfn and let?
19:15teslanick*of letfn over let
19:17amalloywell, it communicates that you'll be creating just functions, no other locals; and it allows mutually recursive functions, which let doesn't
19:17AimHereIt sugars the process of assigning names to temporary functions
19:17dbelldoes anyone use types/protocols for polymorphic dispatch in recursive functions?
19:18AimHeredbell > I do something like that if I want to spit out JSON
19:18AimHereActually no, I don't; I just use a multimethod. Ignore me
19:18dbelli've got a function recursively dividing a tree, and it checks whether the leaves are a string or a seq; having the coll? check feels inefficient, but types feel like overkill
19:19AimHereWould a multimethod triggered on the type help?
19:19dbellidk; I guess I'm asking for stylistic intuition more than anything else
19:20dbella type-based multi would work too; it's really the choice between different strategies, all of which work
19:20dbellanyway ty aimhere
19:38amalloydbell: well, dispatching on something like coll? doesn't work very well in the general case. it will work on a tree of strings, but surely you want your generic tree-splitter to also be able to handle a tree of lists, for example
19:39amalloya common solution in clojure is to have each node in the tree be a map like {:value x, :children [...]}, and then there's no confusion about whether you've gotten to a leaf or not
19:40amalloy(which is a problem that you can't really resolve, if your tree is just a list of lists of lists of...and then eventually something at the bottom which might or might not be a list)
19:42dbellamalloy: this is a good point. I'm writing my first decision tree which just happens to be composed of all strings, so i've known ahead of time what the raw materials are. but going more generic would probably be good
20:29btcNeverSleeps,(.bitLength (biginteger "1"))
20:29clojurebot1
20:29btcNeverSleeps,(.modPow (biginteger "1") (biginteger "1"))
20:29clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: modPow for class java.math.BigInteger>
20:30btcNeverSleepsI'm probably a Java noob but how comes modPow doesn't work here?
20:30btcNeverSleepsJava's BigInteger class has a: public BigInteger modPow(BigInteger exponent, BigInteger m) {...} method
20:30S11001001TimMc: NB: #4 https://github.com/technomancy/leiningen/issues/1446
20:31brehautbtcNeverSleeps: looks like a static method?
20:31btcNeverSleepsbrehaut: no, it's not static
20:32BronsabtcNeverSleeps: looks like it takes 2 args, not one
20:33btcNeverSleepsBronsa: ooooh, gotcha, silly me!
20:33btcNeverSleeps,(.modPow (biginteger "1") (biginteger "1") (biginteger "1")
20:33clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
20:33btcNeverSleepspfffft, paredit mode not on in erc-mode
20:55muhoobtc sleeps plenty, actually. at least for the moment.
20:56muhoountil they fix the malleable tx problem, at least, and deal with the somewhat janky way most wallets calculate and show balances :-P
20:56sajHas anyone used clojure.tools.namespace?
20:57sajI'm have a problem where using refresh actually unloads clojure.tools.namespace itself
20:59muhoois stuart still using c.t.n? or has he moved on to his new reloaded workflow?
21:00muhooah, i see, it's built on c.t.n
21:01sajnevermind, got around it by adding c.t.n.r to my ns header
21:09dacchave a school team project and trying to convince my teammates to let me use clojure for my bit
21:09dacctough going, they have some weird scheme and prolog nightmares
21:28teslanickWhat's the clojure idiomatic way to walk over each character in a string?
21:29dnolen_,(seq "hello")
21:29clojurebot(\h \e \l \l \o)
21:29dnolen_teslanick: strings are seqable
21:30teslanickI realized that almost immediately after I asked the question. : /
21:30logic_progin building a webpap, is it better to do (1) cljs client side + clj server side or (2) cljs client side + erlang server side ?
21:31teslanickcljs client / clj server would theoretically let you share logic client/server, as long as it was pure-clojure.
21:31teslanickAnd doesn't crash into one of those clj/cljs differences.
21:32logic_progyeah, the _entire_ app is currently written in cjx
21:32logic_progerr, clj
21:32logic_progerr, cljx
21:32logic_progyet, the more Ithink about the more I'm convinced erlang should be a better server side solution
21:32logic_progbut then I lose edn/read-string + pr-str
22:29RMacyso, just slightly curious.. why is map-invert in clojure.set? Is it because of the way it handles clashing values?
22:44technomancyRMacy: I think clojure.set is more about set theory than set data structures
22:45RMacythat makes sense
23:37hiredmanthe reverse
23:39teslanickis the gear with the little R next to it
23:40hiredmanclojure.set is terrible for set theory
23:40hiredmanclojure.set is about clojure sets, with some relational algebra type bits throw in
23:41hiredmanthrown