#clojure logs

2014-05-05

01:03rhg135Any preferred way to do io in a swap! once?
01:08rhg135I was thinking a deftype to hold state and an io fn comparing only the state but that feels hackish
01:40Viestihmm, looking for memory sensitive caching (soft/weak reference)
01:42Viestisaw that core.memoize had one (Release 0.5.1 on 2011.12.13 Removed SoftCache memoization) and the current (0.5.6) release note mentions softcache again in Plans section (SoftCache backed memoization)
01:44rhg135It's extensible, I'd write one
01:58Viestirhg135: that did occur to me also, was wondering if one is in the works, so that I don't code in the bugs :)
01:59rhg135Ic, I forget who wrote it
02:14tickingis there a way to check if a channel is still open except for reading it? I need this information for a debug log.
02:15tickings/channel/core.async/chan
02:16gunsticking: clojure.core.async.impl.protocols/closed?
02:16gunsAlthough I'm not sure if that's just an implementation detail
02:17tickingguns: a thanks, that's why it doesn't show up in the api ^^
02:17tickingguns: I'll use it with care ^^
03:11waynris it possible to copy a directory from a project's resources or does it have to be done file-by-file
03:13crispinhi there peeps!
03:13crispinIm pulling my hair out with gen-class!
03:14gunswaynr: only file-by-file if you care about resources from jars
03:14TEttingercrispin, that's something I'm familiar with, kinda
03:14crispinI know its something to do with AOT... but I just cant get it working
03:14crispinI keep getting ClassNotFoundException
03:14crispinany definitive document on this?
03:15crispinhow do I _find_ my class?
03:15crispin(I wish proxy could create new methods, not just subclass :P )
03:16TEttingercrispin, uh some code would help. the file with the ns you are trying to gen-class and the project.clj , on gist would be easiest?
03:17crispinok. I'm using (gen-class... not :gen-class
03:17waynrguns: would it be possible to get a list of files in <dir> within the jar using clojure.java.io or something like it?
03:17crispinwill gist it up
03:17TEttingerthanks
03:17sm0ke,(let [{:keys [x y]} {:rs/x 1 :rx/y 2}] (prn x y))
03:17clojurebotnil nil\n
03:17gunswaynr: of course
03:17sm0ke,(let [{:keys [x y]} {:rs/x 1 :rs/y 2}] (prn x y))
03:17clojurebotnil nil\n
03:18sm0kehow do i destrucutre those keywords?
03:18sm0ke,(let [{:keys [rs/x rs/y]} {:rs/x 1 :rs/y 2}] (prn x y))
03:18clojurebot1 2\n
03:18sm0kewhoa!
03:19sm0kethis must be a joke! doesnt work on my repl
03:20TEttingerI'm surprised you can have symbols with / in them
03:20TEttinger,://
03:20clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: ://>
03:20TEttinger,:oh//
03:20clojurebot:oh//
03:20gunsUsing said symbols is another matter
03:21sm0kethat gives valid error on my repl, Can't let qualified name: rs/y
03:21sm0kehow the hell it worked here
03:21sm0ke,(let [{:keys [rs/x rs/y]} {:rs/x 1 :rs/y 2}] (prn x y))
03:21clojurebot1 2\n
03:21TEttingerprobably because there's sandboxes and such
03:21gunssm0ke: the behavior changed in 1.6.0
03:21TEttingeror that!
03:21sm0keanyway to handle this pre 1.6?
03:22crispinhttps://www.refheap.com/85128
03:22TEttinger,(print *clojure-version*)
03:22clojurebot{:major 1, :minor 6, :incremental 0, :qualifier nil}
03:22gunssm0ke: ,(let [{x :rs/x} {:rs/x 1}] x)
03:22crispinTEttinger: not sure if this is even the right approach. But I can't seem to get the class foiund no matter how I arrange it
03:22amalloyTEttinger: oh// reads as "the symbol named / in the namespace oh"
03:22TEttingertaking a look, crispin
03:23sm0keugh, keep on forgetting the basic
03:23sm0kethanks guns
03:24sm0ke(inc guns)
03:24lazybot⇒ 2
03:24TEttingercrispin, does "lein compile" throw any errors, from the command line
03:24crispinTEttinger: no
03:25crispinthe app runs fine too
03:25TEttingerI'm guessing it has to do with the ns not matching the class name
03:26waynris there a simple way to preserver directory structure when copying directories from the classpath?
03:26crispinwhich ns? com.signiq.jwsapp.download?
03:26gunswaynr: I should have mentioned that you don't generally want to search the classpath for resources
03:26TEttingercheck the compiled .class files, crispin? if there isn't a com/signiq/jwsapp/download folder, then we know something's up
03:26gunsthe usual approach is to keep a static list
03:27crispinyes!
03:27crispintheres no download.class
03:28TEttingerthere's no folder called download, with a class called Connection in it?
03:28crispinno folder.
03:28crispinjust all core classes
03:29TEttingeroh that's interesting
03:29TEttingerit doesn't have any of your ns segments as folders?
03:30crispinit has classes/com/signiq/jwsapp/
03:30crispinthen in that, core.class, core__init.class, core....
03:30TEttingerright
03:30crispinlots of core classes
03:30TEttingerthat's the result of AOT compiling your core.clj
03:31crispinright
03:31crispincan I tell AOT to compile the download.clj into a class?
03:31TEttingerI would like to see that project.clj if you can paste it
03:31TEttingerit might be a simple fix
03:31crispinhttps://www.refheap.com/85129
03:34TEttingeryou need in there, before or after ":main com.signiq.jwsapp.core", :aot [com.signiq.jwsapp.download] I think
03:34crispinaaahhh. let me try
03:35crispinI figured it may have been aot related
03:35crispinaa-ha. lein compile now reports: Compiling com.signiq.jwsapp.download
03:35crispinTEttinger: awesome! you're a legend
03:36crispinit finds the class now! Theres another error, lol
03:36TEttingerhooray!
03:36crispinbut it finds the class!
03:36crispinsweet!
03:36waynrguns: okay, well i have template files that i want to be deployed by the project to the current directory
03:36crispinthanks a bunch
03:36TEttingeryou can add more classes to that :aot vector if you need more gen-class classes
03:36crispinok.
03:36crispinand it will compile all the gen-classes in a file?
03:36crispinso if I have a few with different prefixes?
03:36TEttingerin their own files I think
03:37crispinok. man I love clojure, but java sucks :P
03:37crispinits always the dealing with java bits that hurts
03:37TEttingera single Java class has one .class file, the clojure equivalent is a .class file for the ns that calls a bunch of similarly-named .class files
03:37crispinright
03:37gunswaynr: Your templates are packaged in your jar, so you know them beforehand right? Or you can spit the list of templates to a file in a build hook, then read from that at runtime
03:39waynrthe templates are in "./resources/templates" and all i want to do is copy that directory from the jar to local directory
03:42gunswaynr: You're free to scan the classpath for all files matching the prefix templates/, but it might be slow, and it might include files from other jars
03:43waynrmaybe i'll give it a project-specific prefix
03:43crispinok, FYI. multiple (gen-class... classes get compiled into multiple.class files in the class directory. So if I have two gen-classes in a .clj file I get two output .class files
03:43TEttingeryes
04:25martinklepsch (with-open [z (java.util.zip.ZipFile. fileName) e (find-xml z) r (.getInputStream z e)]
04:25wadeany one have a best solution for the 2048 game in Clojure?
04:26martinklepschI have something like this and thought that way I could get the contents of the xml file but the .getInputStream method returns a ZipEntry? (which is not closeable
04:27TEttingerwade: I thought there was a random element to 2048?
04:30clgvwade: what game? (link?)
04:32clgvmartinklepsch: the result of `find-xml` is probably not closeable either. so just use a `let? inside the `with-open`
04:33TEttingerclgv: http://gabrielecirulli.github.io/2048/
04:33TEttingerit's an excellent idle time waster
04:34martinklepschclgv, turns out that error was because I renamed the function but executed the same snippet I had in light table again and again
04:34TEttingeralso once you've played that, there's the marginally harder http://doge2048.com/
04:35Morgawrmm.. I was playing around memoizing some functions in my (single-threaded) code, it's very CPU-intensive code and adding memoization doesn't help (I always have different values) but I don't understand why when I add memoization to my function the CPU usage goes to 100% on all cores
04:35Morgawrdoes memoize use multithreading? I can't seem to find any multithreading done in the implementation but all my cores go to 100% CPU
04:36Morgawrusing visualvm it seems that most of the time is spent in clojure.lang.Util.dohasheq() and clojure.lang.PersistentHashMap$ArrayNode.find()
04:36MorgawrArrayNode.find() doesn't seem to be doing any multithreading and I doubt dohasheq() does that either
04:37clgvMorgawr: probably the Garbage Collector using all available cores
04:37Morgawrclgv: ah, good point
04:37Morgawrthat makes sense
04:37clgvMorgawr: does VisualVM have a view for GC? Yourkit has
04:38Morgawryeah
04:39Morgawryeah it seems to be the GC
04:39Morgawrthe used heap goes up and then suddenly all my cores go to 100% and it goes down again
04:39clgvTEttinger: ah. right. maybe tractable via machine learning to find ratings for good moves
04:40clgvMorgawr: maybe you have to rethink the granularity of your memoization
04:40Morgawrclgv: yeah yeah, I already know it wasn't a good idea to memoize that function, it was just a test
04:40clgvMorgawr: what types are the arguments of the function you memoize?
04:40Morgawrthey are records
04:40Morgawrthat hold doubles
04:40Morgawrso it makes no sense to use memoization in the first place
04:40Morgawrbecause the double values are going to be different most of the time
04:41Morgawrit was just a test
04:41martinklepschhaving an InputStream, whats the easiest way to make that a string?
04:42penthief(.readLine (java.io.BufferedReader. (java.io.InputStreamReader. is)))
04:43gunsCan't you slurp an InputStream?
04:43clgvMorgawr: yeah. if you know upfront that all invocations will very likely have different values dont bother trying memoization ;)
04:44Morgawrclgv: yup :P
04:44llasramguns, martinklepsch, penthief: yes, `slurp`
04:44penthiefThanks!
04:44gunsclojure.java.io/Coercions is very convenient
04:45llasramIndeedy. Extra so since as a protocol it is open to extension to additional types
04:45martinklepschllasram, guns, penthief, that indeed seems to work
04:46martinklepschguns, haha that was highlighted as a link. kinda funny where it gets you
04:46wadewhois TEttinger
04:48hennryHello i want to reload the repl from the code there is any way Actually i want to refresh the page
04:49TEttingerwho is TEttinger, really... what is TEttinger...
04:49clgv$karma TEttinger
04:49lazybotTEttinger has karma 17.
04:49sm0kehennry: you need to explain it better
04:49clgvsomeone with karma 17 it seems ;)
04:49TEttinger$karma clgv
04:49lazybotclgv has karma 16.
04:49TEttinger(inc clgv)
04:49lazybot⇒ 17
04:49clgvlol :P
04:50Morgawr$karma Morgawr
04:50lazybotMorgawr has karma 1.
04:50Morgawr:D
04:50sm0ke(dec clgv)
04:50TEttinger(inc Morgawr)
04:50lazybot⇒ 2
04:50lazybot⇒ 16
04:50clgvnow we are indistinguishable with respect to that "metric" ;)
04:50Morgawrwoo
04:50sm0kewhoa!
04:50clgvor not...
04:50sm0kesorry about that
04:50sm0ke(inc clgv)
04:50lazybot⇒ 17
04:50TEttingergood ol' karma
04:50TEttinger$karma technomancy
04:50lazybottechnomancy has karma 107.
04:50Morgawrturning good people into terrible popularity slaves
04:51Morgawr$karma rhickey
04:51lazybotrhickey has karma 2.
04:51Morgawrwe are one!
04:51Morgawr$karma Morgawr
04:51lazybotMorgawr has karma 2.
04:51TEttingerhaha
04:52clgvit should decrease karma to add it to often to others ;)
04:52hennry<sm0ke> i want to refresh the page there are many ways in ajax and jquery but i want to do this from clojure there is any process, i think this is happened by reload the repl in clojure
04:52TEttingerclojure or clojurescript, to refresh a page, hennry?
04:53hennryclojure
04:53hennry<TEttinger> by clojure
04:54sm0kesorry i am unable to comprehend
05:00penthiefhennry: "by clojure" implies this code is executing on the server. There is no sensible way for a server to refresh a client whether using clojure or not.
05:21clgvhenry: you need to describe you problem technically more exact. it often helps to post a minimal example of your problem code on refheap.com
05:35martinklepschis there a way to handle an open input stream to another function or reopen it?
05:36llasrammartinklepsch: What are you trying to accomplish at a slightly higher level?
05:37martinklepschllasram, pass a large input stream from an xml file to a function that splits it into a chunks. that split function previously took a file as argument but I refactored things and now I'd like to pass the input stream directly
05:37martinklepsch(the input stream comes from a zip file so referencing the file directly didn't work anymore
05:38llasramWhat's preventing you from passing the input stream like any other argument?
05:38martinklepschllasram, here's some code: https://www.refheap.com/85131
05:38llasramOh, is the function closing the entry stream -> closes the overall file?
05:39martinklepschyeah, it uses with-open and this closes the input stream
05:39martinklepschI think that's the problem — maybe putting both things into one with-open clause would fix it but thats more of a compromise than a solution
05:40llasramYeah, this is a general problem with Java I/O interfaces. Apache Commons IO has a CloseShieldInputStream which lets you prevent callees from closing the stream you pass in
05:46martinklepschllasram, this seems to be an acceptable workaround
05:46martinklepschhttps://www.refheap.com/85132
05:47llasrammartinklepsch: Well, except that closing a Reader will close the underlying InputStream too
05:48martinklepschyeah, but in that case I'm done anyways. the splitting is hopefully all IO work necessary
05:49visofhow can i set the paths of dependencies at project.clj if it's at local file system?
05:49llasramOh, I see. I'm obviously not awake yet :-) I was thinking about an issue on the output side of the Java stdlib ZIP interfaces
05:51llasramvisof: (a) You don't. See https://github.com/technomancy/leiningen/wiki/Repeatability
05:52llasramvisof: (b) There are ways to refer to local JAR files, but they are hacks, so first make sure something is actually preventing you from doing it right
05:52visofllasram: i'm using buggy lib which i need to patch it then test again, what do you suggest to do this?
05:53llasramvisof: Is the buggy lib also a Clojure project using Leiningen?
05:53visofllasram: yep
05:53llasramvisof: Checkout dependencies: https://github.com/technomancy/leiningen/wiki/Repeatability
05:53llasramooops, wrong link
05:54llasramhttps://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
05:54llasramThere we go
05:57visofllasram: so i should put the patched jars at checkouts dir at my root project?
05:57llasramUm, no
05:58llasramYou symlink to the root of your checkout of the source for the other project
05:58visofllasram: symlink to the directory of the other projects not jar?
05:59llasramYes. No JARs. Generally if you are directly handling JAR files, then you're fighting against the grain
06:02visofllasram: okay thanks
06:35clgvvisof: you could also "lein install" the buggy lib provided it is a lein project
06:47visofclgv: can you help me to make jirpah working please?
06:47clgvvisof: I don't even know what that is ;)
06:48visofclgv: https://github.com/ninjudd/jiraph
06:48visofclgv: just want to make the sample in this page work
06:48visofclgv: can you try at your owns?
06:51clgvvisof: well just check it out. maybe rename the version (e.g. 0.12.3.1-SNAPSHOT) in project.clj too avoid accidental problems later and then "lein install". after that you can add it as normal dependency to your other project on that same development machine
06:51clgvbut checkout dependency would work as well
06:52visofclgv: can you do the just the basic stuff for it at your own?
06:52clgvvisof: no. no time for that
06:52visofokay
06:54visofclgv: https://www.refheap.com/85110
06:54visofclgv: that's the error i got
06:55clgvvisof: well an error without a description what you were trying to do does not help much
06:55TEttinger,(doc applied)
06:55clojurebotExcuse me?
06:55TEttinger(doc applied)
06:55clojurebotexcusez-moi
06:56TEttingerwell that could be part of it?
06:56clgv~applied
06:56clojurebotCool story bro.
06:56TEttinger##(doc applied)
06:56lazybotjava.lang.RuntimeException: Unable to resolve var: applied in this context
06:56TEttingerah
06:56clgvTEttinger: what are you looking for?
06:56TEttingerit definitely is something it thinks should exist but doesn't, which is probably not in clojure.core...
06:56TEttingerthat refheap, second error
06:57TEttingerException in thread "main" java.lang.IllegalAccessError: applied does not exist
06:57clgvah. never heard that symbol before
06:58clgv,(apropos "applied")
06:58clojurebot()
06:58clgv$apropos "applied"
06:58clgvok that does not exist..
06:58visofclgv: https://www.refheap.com/85134 core.clj
06:59visofclgv: https://www.refheap.com/85135 project.clj
06:59visofclgv: https://www.refheap.com/85110 error
07:01clgvvisof: assuming these versions mean anything why don't you just try 0.12.2
07:01clgv?
07:02visof0.12.2-alpha1
07:02visof?
07:02clgvno. the idea is to use something without "alpha" or "beta" in the version to check whether that works ;)
07:04visofclgv: works but the same error i got
07:05clgvvisof: does "lein check" in the jiraph project work without errors?
07:06visofclgv: That's not a task. Use "lein help" to list all tasks.
07:06clgvvisof: upgrade ;) $ lein help check => "Check syntax and warn on reflection."
07:07visofupgrade lein?
07:07clgvyes
07:07visofokay
07:08f3ewHow do I do the equivalent of if (/^pattern/) { (undef, $foo, bar) =~ /(pattern)\.(data)\.(other.data)/ } ?
07:08f3ewThe regex documentation isn't particularly helpful for this
07:09clgvf3ew: clojure.string/replace?
07:10f3ewI'm just trying to capture matched patterns
07:11f3ewNo, I only want to match the pattern, capture some data if the string matches and then do other processing on the data
07:11clgvre-find? re-matches?
07:12f3ewre-matches is what I've been looking at
07:13TEttingerf3ew, was that snippet perl?
07:13f3ewHmmm, I wonder if I should just assign (re-matches #"^pattern) to a variable, and then apply variable <actual string>
07:13f3ewTEttinger: yes
07:13TEttingerI have no idea quite what it does...
07:14TEttingerI usually use http://www.regular-expressions.info/brackets.html for when I have regex questions
07:14f3ewif (match pattern) { capture three values , assign them to three variables }
07:14f3ewThis isn't a regex question :)
07:15TEttingerlikely re-matches or re-seq ?
07:15TEttinger(doc re-seq)
07:15clojurebot"([re s]); Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-groups."
07:15f3ewYeah, my question was about applying those
07:17TEttingerso you're trying to get out of a string, "a.b.c" a, say, vector, of 3 elements, here "a", "b", and "c"
07:17clgv,(let [s "12 3 456"](when-let [[_ a b c] (seq (re-find #"(\d+) (\d+) (\d+)" s))] [a b c]))
07:17clojurebot["12" "3" "456"]
07:17clgvf3ew: something like that? ^^
07:17f3ewthat looks useful, thanks
07:17TEttingerthat looks about right to me
07:17f3ewExcept I don't know s yet
07:18TEttingersure, you can use an arg in its place
07:18clgvf3ew: yeah that is included for the example as constant ;)
07:19TEttinger,((fn [s](when-let [[_ a b c] (seq (re-find #"(\d+)\.(\d+)\.(\d+)" s))] [a b c])) "alpha.beta.com") ; you'd use what's in the fn as a defn more likely
07:19clojurebotnil
07:19TEttingeroh right
07:19TEttinger,((fn [s](when-let [[_ a b c] (seq (re-find #"(\w+)\.(\w+)\.(\w+)" s))] [a b c])) "alpha.beta.com") ; you'd use what's in the fn as a defn more likely
07:19clojurebot["alpha" "beta" "com"]
07:21clgvf3ew: TEttinger: if you write a function you won't destructure the result just to reassemble it to a vector again ;)
07:22TEttingerhaha fair point, I didn't read it very carefully
07:22agarman,((fn [s] (when-let [[a b c] (re-seq #"\w+" s)] [a b c])) "alpha.beta.com")
07:22clojurebot["alpha" "beta" "com"]
07:22TEttingeralthough I can't quite think of a better way
07:23TEttingeragarman I think can!
07:23TEttingerthat's nice
07:23TEttinger(inc agarman)
07:23lazybot⇒ 1
07:23TEttinger(inc clgv)
07:23lazybot⇒ 18
07:24visofclgv: https://www.refheap.com/85137 result of lein check
07:27clgvvisof: great. you are sure that you want to use that library?
07:28visofclgv: what do you mean
07:28visofi have added flatland/useful to project.clj
07:42clgvvisof: I mean that it is probably not a good idea to start using a library that causes so much trouble just from referencing it in you own project
07:43clgvvisof: if there is really no alternative I'd get in touch with its developers/maintainers to get the problems fixed
07:43visofclgv: i'm forced to use it to check the performance with other libs
07:43visofclgv: someone here told it's not a user-friendly
07:44clgvvisof: well, amalloy might be around here later today. maybe you can catch him
07:44visofclgv: one of its dev
07:44visofclgv: amalloy who told this
07:44visofamalloy told it's not user friendly and suggest to not use it
07:44clgvvisof: from what I saw of you error messages it is not usable at all...
07:45visofclgv: what do you mean?
07:46clgvvisof: requiring a namespace of a library should not result in any exceptions. I'd say that's a minimum requirement for a "usable" library ;)
07:46visofclgv: all i want if you can help just copy/paste the project.clj and core.clj and try at your own and you are going to get some more sight on this
07:47clgvvisof: I have seen enough. I wouldnt touch a library like that for the above reason
07:49agarmanit's jiraph, not useful that's failing?
07:50clgvagarman: yes, jiraph
10:04coventryvisof: Might be a dependency conflict, which "lein deps :tree" might help you to determine.
10:07sritchieany lein-voom users here?
10:07sritchiebmabey: are you using lein-voom?
10:07TEttingerwhat's lein-voom?
10:07clgvsounds explosive :O
10:08TEttingerthat's neat sritchie. does it work?
10:08sritchiethe voom plugin?
10:08sritchiewell, that's what I'm working on, figuring out the right workflow for it
10:09TEttingerclgv, it's named after something explosive https://github.com/LonoCloud/lein-voom
10:09clgvTEttinger: :P
10:10clgvthe readme doesnt tell anything about configuration...
10:11clgvsritchie: do you use leiningen checkouts?
10:11sritchienot really - I did when I was developing on Cascalog more
10:11sritchiefor the shared util libraries, etc
10:12bmabeysritchie: no, not yet, but it is on my TODO list
10:12sritchiesaw your pull req, thought you might have some insight
10:12sritchieI'm just watching Aaron's clojure/west talk now, we'll see how it goes
10:13bmabeysritchie: I've had some conversations with Aaron about it and saw his talk at ClojureWest
10:13bmabeysritchie: what isn't documented, and I don't fully understand yet, is the box part
10:13sritchieI haven't seen the box thing
10:13sritchiebmabey: I'm going to start writing some batch jobs that need to share my database and utility code, and figured I'd try to do things right from the start
10:14sritchieand not get into the whole dependency mess that haunted me with the Twitter open source projects
10:14sritchievoom seems like a nice approach
10:14bmabeysritchie: also, the CI daemon for continuous freshening isn't done yet (last I heard).. so it is just up to the devs to run freshen (or batch scripts)
10:14clgvwith only the readme I have no idea how to use lein-voom...
10:14sritchieclgv: :)
10:14bmabeyyeah, the approach is solid and they have put a lot of time and effort into it so I think it is worth adopting
10:14bmabeyit is either that or use maven, etc
10:15clgvyou can add that quote to an issue about the docs if you should create one ;)
10:15sritchieclgv: sounds like you should create one
10:15sritchiebmabey: well, maven's still involved, I guess - I'm going the s3-private-wagon road for now
10:16clgvsritchie: well the point is I don't even see what it provides ...
10:16bmabeysritchie: true, but the whole snapshotting thing can be solved if you go into pure pom land
10:16bmabeyfrom what I understand at least... I'd like to stay with lein so I'm glad len-voom exists :)
10:17sritchieah, I see what you mean
10:17bmabeyclgv: if you work on a large project comprsied of several independent projects each moving quickly lein-voom automates the process of making commit-level releases so that the projects are always using the latest deps but don't have to rely on dangerouse SNAPSHOTs
10:17sritchiebmabey: yeah dude, do NOT go that route
10:17sritchiewhat a nightmare
10:18bmabeysritchie: B
10:18bmabeysritchie: BTW, I used your om-timer the other day to explore om and react, pretty cool stuff. thanks for sharing :)
10:18sritchiebmabey: the question I had, the reason I pinged, was that I've been seeing examples in the github issues on that project that include metadata on the various voom dependencies
10:18sritchienice!
10:18clgvhm ok found a project.clj on github using it.
10:18sritchieclgv: link?
10:19tbaldridgeIs staying at the latest release on everything really that important? What projects move that quickly?
10:19clgvseems like you just define the git repo via metadata on the dep right?
10:19clgvsritchie: https://github.com/vlacs/galleon/blob/d329e2498a13840aa638305cc2d7a1feb07fa7fa/project.clj
10:20sritchietbaldridge: it's really annoying when you modify a util library to go doa whole release, bump the deps, submit a bunch of pull reqs...
10:20sritchietbaldridge: so what happens is you just stick the code in whatever project you're currently working on
10:20sritchietbaldridge: and then later, do some big refactor of all your projects to get the code back where it belongs
10:20tbaldridgeor use lein checkouts?
10:20sritchieyeah, that's great if it's just you
10:20sritchiebut then someone else on your team gets on to code, and nothing builds because you forgot to push the util lib,
10:21sritchieor they need to go restart their lein processes,
10:21sritchieand then the pressure of how annoying this is just forces you into a single repo
10:21sritchieand you do what twitter did, and actually create an ENORMOUS MONO REPO
10:22sritchiebut you still want to open source stuff, because you like open source, so you write tools that carve out specific namespaces, bundle them up and release those as specific artifacts… but then you accidentally include the same namespace in multiple artifacts, and someone includes both, but with different versions,
10:23sritchieand they spend hellish hours trying to debug problems that result from two versions of a clj file on the classpath, one with the bugfix, one without, so SOMETIMES the depending project manifests the bug, sometimes not,
10:23sritchietbaldridge: and then, oh my god, you write a bunch of build tooling to detect diamond dependencies within your mono repo… and on and on
10:23bmabeyyeah, util libs that are shared among several of our projects are the main use case. We want them to be up to date as soon as possible to catch integration problems ASAP
10:23sritchieyup
10:24sritchieI have a nice async stripe lib that uses schema that I want to be able to release
10:24sritchieand quickly integrate changes
10:24sritchiebmabey: once a project is released using voom, do you just peg it to some arbitrary version and use voom for all release?
10:24sritchiereleases?
10:25sritchiebmabey: what's not clear is how to interleave true releases into the voom flow, for open source work
10:26bmabeysritchie: I think for true releases you would just bump the version deps manually in the project.clj, make a releases, and then switch back to voom.. just like you would with a regular release->SNAPSHOT cycle
10:26Glenjaminbmabey: can't you just depend on a semver range of your util lib, then cut a series of stable releases?
10:26tbaldridgeIs this really that this big of a problem though? Every large codebase I've worked on either used larger modules (so less coupling between modules), or more regulated releases.
10:26Glenjamintbaldridge: if the tools supported it, do you think you'd go for smaller modules?
10:27sritchie tbaldridge how did you regulate releases?
10:27sritchieGlenjamin: I don't think that leiningen has good support for semver ranges
10:27sritchieand if you don't have good tooling for actually detecting semver bumps,
10:27sritchiewhich is REALLY hard in a non-typed lang,
10:28bmabeyGlenjamin: yes, I think that approach works well and that is what we've been doing but having SNAPSHOT still seems scary
10:28tbaldridgeOne project I worked on had a "owner" for each project. You would submit a PR, and in about a day it would be released as a new lib version.
10:29sritchietbaldridge: that sounds really nice :)
10:29Glenjamintbaldridge: in theory, if your modules are small enough most of them don't change much
10:29Glenjaminor the number of breaking changes is very small
10:29sritchietbaldridge: but then a module has to be big enough that a person can make a fulltime job out of it
10:30tbaldridgeI think some of the problems you're hitting is that they are too small. Having problems with diamond deps is a big code smell IMO.
10:30sritchiebmabey: for adding a voom proj for the first time, I guess you just go look up the voom version and add it manually
10:30Glenjaminthe main one for me is "utility" libraries
10:30tbaldridgeactually scratch that, I was thinking "circular deps" when I heard diamond deps.
10:31sritchieyeah, diamond deps just happen
10:31sritchietbaldridge: the clojure lib being a huge example :)
10:31foofoobarHi. Is there some online clojure tutorial/book you can recommend? Like learn you a haskell, just for clojure :)
10:31Glenjaminwe can't just keep putting all the useful stuff in core, and we can't require every project to bump their dependencies when a new version of a lib comes out
10:31bmabeyfoofoobar: I haven't read it but this looks similar in spirit: http://www.braveclojure.com/
10:32sritchiebmabey: do you know what's going on with the metadata on different project deps?
10:32Glenjamini'm a fan of the approach taken by http://aphyr.com/tags/Clojure-from-the-ground-up
10:32sritchiebmabey: just checking, then I'll watch the video :) and write something up when I figure it out
10:32Glenjamini think the rules for dependencies should be different if you're building an app vs a lib - at the mo lein doesn't distinguish afaik
10:32bmabeysritchie: sorry, it has been a while since I investigated it so I don't recall the details. I remember that I was able to get it to work without much hassle
10:33foofoobarthanks!
10:33bmabeysritchie: bug @0x1B on twitter if you can't figure it out
10:33sritchienice, thanks
10:35bmabeysritchie: BTW, OT, but did you get into the Wasatch 100?
10:36sritchiebmabey: nope! nor the hardrock
10:36sritchienow I have to do another one of these damned 100s to apply again
10:36sritchiekeep me on the list for running adventures :)
10:36bmabeysritchie: uhh.. sorry! sure thing
10:36sritchielet me know if you make it out to Boulder, or if you want to come visit
10:37sritchiethere's a bunch of fun stuff to do off in rocky mountain
10:37sritchieback soon, dog part time
10:37sritchiepark*
10:37sritchiecolorado life ftw
10:38bmabeycool, I'll have to check out the list of boulder races
10:39tbaldridgesrcerer: you're in Boulder?
10:39tbaldridgesritchie: you're in Boulder?
10:40foofoobarSo I'm following http://www.braveclojure.com/getting-started/ and just created an project with "lein new projectname"
10:41foofoobarI'm inside this folder now and run "lein run", but the only thing I get is No :main namespace specified in project.clj.
10:44technomancyfoofoobar: do lein new app projectname if you want to have an entry point defined
10:46foofoobartechnomancy, I just read in the comments that I need to updae my lein to 2.X
10:48hyPiRionfoofoobar: yeah, that's a good idea too
11:05clgvfoofoobar: otherwise just use "lein repl" and play with the REPL ;)
11:13MorgawrI have a record defined in a namespace and I try to use its constructor from another namespace and it doesn't work, it says class not found
11:13Morgawrif I import that namespace+record I still get the same problem, am I missing something?
11:14clgvMorgawr: if you import the class correctly you can use the constructor
11:14clgvMorgawr: but you could also use the generated function (->MyRecord 1 2 3)
11:15clgvthen you need no class import
11:16Morgawrclgv: ah.. I didn't know about ->MyRecord
11:16Morgawrthanks!
11:16clgvMorgawr: there is also a function map->MyRecord to convert maps to records
11:18Morgawrclgv: awesome
11:21yedidoes github user ptaoussanis hang out here?
12:09yedii have this middleware: https://www.refheap.com/85143
12:10yedican someone explain to me why the mid uid: <different random number> is getting printed over 80 times?
12:10yediwhy would that line of code be continually getting called
12:13gtrakbecause.. you're making a lot of requests?
12:13gtrakmore than you think?
12:19yediheh yea, wtf...
12:19yedioh maybe it's for all the static assets
12:22paulfedorowyedi: check the network tab in firebug or chrome dev tools, to see which requests are sent to the server
12:23yediyea, it was the static assets i'm guessing... just forgot those were a thing
12:24yedii guess i could change the middleware to only trigger on certain types of GETs based off the url resource it's getting
12:29Morgawris there a map-indexed in parallel like pmap?
12:32Glenjaminit's lazy, so you should be able to combine them?
12:44TEttingerMorgawr: map-indexed isn't needed since you can do ##(print (map-indexed + (repeat 5 10)) " or " (map + (range) (repeat 5 10)))
12:44lazybot⇒ (10 11 12 13 14) or (10 11 12 13 14)nil
12:49Glenjamin,(pmap + (repeat 5 10) (range))
12:49clojurebot#<SecurityException java.lang.SecurityException: no threads please>
12:49Glenjaminheh, fair enough
12:54shoepieany ideas why my .nrepl-port wouldn't be created when running "lein repl"?
12:54technomancyshoepie: older leiningen version?
12:55shoepietechnomancy: on 2.2.0
12:55technomancytry upgrading
12:56shoepietechnomancy: ah, that was it. gracias
12:56technomancynp
13:00shoepietrying to get fireplace.vim and cljs to play nicely
13:11rasmustoshoepie: iirc fireplace + cljs is still a bit new
13:12rasmustoshoepie: oh, you're using :Piggieback ?
13:13cbpHow can I delete a project on clojars_
13:13cbp?
13:15technomancycbp: unless sensitive material was leaked we like to keep clojars immutable
13:15technomancybut I can delete something if it's important.
13:16cbpNot really I just changed groupId for 2 projects
13:16technomancybetter to leave it, I think
13:16technomancyif we ever have to do a security review, having fewer discrepancies makes it more likely that we'd spot a change that came from an actual attack
13:16cbpOkies
13:16technomancys/if/when/
13:18dbaschtechnomancy: how often do you reindex clojars? I uploaded something two weeks ago and it doesn’t show up in search results
13:21technomancydbasch: indexing happens upon deploy, but sometimes there are boogs
13:23dbaschtechnomancy: what are you using for indexing / searching?
13:24technomancyI'll initiate a reindex
13:26cbpIs it a big issue if pom/jar files are not signed?
13:27dbaschok, now it shows up
13:27technoma`cbp: it means it's impossible for anyone using your lib to verify their build.
13:28technoma`it's kinda crappy, but it depends on the context, who's going to be using it, etc.
13:28technoma`right now verifying your build is not very common, which sucks
13:28cbpit's a bunch of compiled protocol buffers
13:28cbpwhich i separated from the actual library that uses them
13:28technoma`I guess a better question is why it's not signed
13:29cbpthe library is signed though
13:31technoma`doesn't really matter; one unsigned library is as bad an ten from an attack surface area perspective.
13:31nDuffcbp, I'd suggest signing it if you can. The Java-ecosystem world is already quite good about that -- things don't get into Central unless signed -- and the more folks do likewise on the Clojars front, the easier it'll be to catch up.
13:32cbpHmm. I guess I'll figure out signing once i push a new version
13:32technoma`basically my hope is that a few years down the line having unsigned jars will be like having libs that depended on monolithic contrib was a few years ago
13:32nDuffcbp, *nod*. Having a GPG key published and out on the keyservers will be necessary if you ever want to get something into Central as opposed to Clojars anyhow, and I really do hope that Clojars will make it mandatory in the not-too-distant future as well.
13:33technoma`something that may have sort of made sense at the time even though you knew it was technically a bad idea, and now it's pretty annoying to have to deal with the fallout of peoples' laziness.
13:33shoepierasmusto: I haven't tried :Piggieback yet
13:34rasmustoshoepie: was reading this issue: https://github.com/tpope/vim-fireplace/issues/14
13:36shoepierasmusto: yeah, that that this morning, too. Just now tried :Piggieback with no luck
13:36shoepieCannot read property "pr_str" from undefined
13:37shoepiejust calling (range 100)
13:39nDuff...tried cider.el+piggieback, but it just got flaky too often. Might have been something I could fix (such as completion built for JVM-hosted Clojure trying to activate on CLJS), but LT has the advantage of providing an environment that Just Works, even if it's not all there yet as an editor.
13:49gfredericks2I thought that (clj-http.client/post "..." {:body {} :as :json}) was supposed to work
13:49gfredericks2am I misremembering?
13:49gfredericks2(it *will* work if I manually convert the data to json first)
13:59VinzentWhat logging library can be used on both clojure and clojurescript sides?
14:10SegFaultAXVinzent: Logging in js-land is pretty different from logging server-side.
14:13nullptr`goog.log is pretty similar to the jvm-side logging libs
14:18VinzentSegFaultAX, I understand that.
14:18Vinzentnullptr, I mean same API, so I could use cljx to share code which uses logging.
14:29nullptrVinzent: not sure how much https://github.com/clojure/tools.logging is used "in the wild", but seems to have a simple logging surface and different back end implementations
14:29nullptrcould probably extend that to goog.log without massive effort
14:46Vinzentnullptr, as far as I see from the source, its interface is implemented with macros, which means I can't extend and use it directly; anyway, it's a good starting point for writing a port I guess
15:04amalloyi guess vinzent is gone, but c.t.logging isn't based on macros. it has a few primitive functions, and then a bunch of macros that wrap those
15:26sdegutisAha! Apparently my methods aren't being reloaded at runtime because they're methods on a long-lived object.
15:26sdegutisI should really stop using (deftype).
15:28coventry`What are you working on these days, sdegutis?
15:28sdegutis(runtime = development time using ring's reload-when-changed middleware, whatever it's called)
15:28sdegutiscoventry`: like, for fun or work?
15:29coventry`Where ever the deftype issue is coming up, I guess. Just curious.
15:29sdegutiscoventry`: Ah that's work.. it's a Clojure web app (cleancoders.com)
15:31coventry`Fun.
15:31sdegutisExcessively so.
15:35dbaschthis is a mildly interesting article, but the code itself could be much better http://blog.shriphani.com/2014/05/01/consistent-hashing-in-clojure/
15:35dbaschthat random-take function, ugh
15:43sdegutisdbasch: how would you do it?
15:44dbaschsdegutis: for one, it only works with unique elements
15:44dbaschsdegutis: I wouldn’t force the collection into a set
15:45cbpI haven't the slightest clue what the appstore is downloading it but its happily going over 2 gb now
15:45sdegutiscbp: wrong channel?
15:45cbpyes,,
15:45sdegutis#clojure-social?
15:45cbpsorry :-(
15:46sdegutisJust wondering.
15:46sdegutisI haven't been to #clojure in a while, I just don't know what the rules are these-days on off-topic discussions.
15:47technomancyinstant beheading
15:47technomancyclojurebot got an upgrade while you were gone
15:48joegalloah, yes, well, the rules have gotten a little harsher. the punishment for off topic conversations is scaphism.
15:49sdegutistechnomancy: is he now able to join other channels, ie #clojure-social?
15:49nullptr(def behead (partial drop 1))
15:49jdeisenbergjoegallo: that sounds a bit harsh.
15:49coventry`That wikipedia page needs a not-safe-for-children warning.
15:49technomancynullptr: hah!
15:49technomancysdegutis: not sure what the protocol is there
15:50joegallocoventry`: history generally isn't
15:52cbpany instances where IllegalArgumentException Key must be integer might occur?
15:52cbpbesides ##([] :a)
15:52lazybotjava.lang.IllegalArgumentException: Key must be integer
15:52dbaschsdegutis: here’s a (slightly) better random-take https://www.refheap.com/85148
15:53dbaschsdegutis: at least it works for collections with repeated items
15:57coventry`The right way is probably to sample from the n-partitions of a roughly (count coll)-size set, and pull all the elements out at once.
15:57meliponehello friends!
15:57meliponeHow do i get the process wrapped in a future statement?
15:58meliponeI am bringing up a server through Jetty and I want to stop it
15:58dbaschcoventry`: not sure I follow
15:59amalloydbasch: i'm not sure i would call that random-take better. it's awful in a different way
16:00llasramIs the goal just to sample without replacement?
16:00amalloyhttps://github.com/flatland/useful/blob/develop/src/flatland/useful/seq.clj#L149 is a good solution, imo, although if i could go back i'd write it as (lazy-shuffle coll) instead of (take-shuffled n coll)
16:00dbaschamalloy: for that particular case, I’d just to (take n (shuffle coll))
16:01coventry`Oh, yeah, that's a better awy.
16:03llasramThere's also reservoir sampling, which has the benefit of not holding the head of the input sequence: https://www.refheap.com/85150
16:03llasram(although the sequence does still need to be finite)
16:04amalloyllasram: i don't see why that's eager. the reduce could easily be reductions, or just a recursive lazy-seq
16:05dbaschamalloy: that code counts coll twice
16:05amalloydbasch: counting a vector is free
16:06dbaschamalloy: yes, just not lazy
16:06amalloyof course not. neither is yours
16:07amalloythe output is lazy, but you have to be strict/eager in consuming the input
16:07llasramamalloy: I'm not sure I see the benefit... You could take a sample from a sub-sequence of length `n` by taking the `n`th `reductions` result?
16:08dbaschamalloy: anyway, I was just trying to get it to work. The original one was trivially broken.
16:08amalloyllasram: looking at it again, reductions isn't much of an answer. but just manual recursion is much better than the reduce
16:08llasramamalloy: How so?
16:09llasramOh, you just think it would be clearer?
16:09amalloyllasram: say i have a million items, and want to sample a thousand of them. your reservoir-sampling means you don't hold the head of the million items, but you do hold the head of a thousand
16:09amalloy(it's also clearer)
16:10dbaschif you had a million items, the most efficient way would be to do a limited in-place shuffle of the array until you get to N
16:10llasramI'll buy the clearer, but the algorithm needs to hold the entire sample in memory, so that any member of the sample-thus-far is eligible for replacement
16:11amalloyyeah, i guess i'm not reading the algorithm very well
16:11amalloyyou soak up the first N items from the input, and then for anything left you decide randomly whether to replace one of those originally-selected items
16:12amalloyso you need them all
16:12dbaschamalloy: I mean fisher-yates, except you stop at 1000 or whatever
16:13amalloydbasch: that's what my take-shuffled does
16:14dbaschamalloy: as far as I can tell, you’re not doing anything in-place
16:15amalloyi'm assoc'ing the input vector, which is as in-place as anything functional is
16:15dbaschamalloy: but then it’s not fisher-yates, which obviously is not functional and more efficient for large collections :P
16:16amalloydbasch: i disagree that it's not fisher-yates
16:16amalloyjust because it's often implemented with mutation doesn't mean the algorithm is innately mutation-based
16:18amalloyeg, the wikipedia page says "exchange a[i] and a[j]". who says that means mutating an array?
16:18jdeisenbergThe original algorithm (as described in Wikipedia) appears to use an original list and a new list.
16:18amalloyindeed
16:18jdeisenbergThat lends itself a bit more to a functional approach, yes?
16:18dbaschamalloy: I mean that the most efficient way is to mutate an array, obviously
16:19amalloydbasch: so why are you using clojure? c is more efficient. we make tradeoffs all the time
16:19amalloyjdeisenberg: it does. i hadn't read that version before just now, but that's an interesting way to look at how my vector version works
16:19dbaschamalloy: I had to solve this exact problem for billions of urls years ago, and I did it in c
16:20r00kAnyone ever seen some weirdness with ring & wrap-params where sometimes integers submitted through a form come in as chars?
16:20amalloyr00k: they're coming in as strings, and you're seq'ing over them somehow
16:21r00kamalloy: That does seem the likeliest thing...
16:21jdeisenbergI wrote a solution in Erlang using that algorithm; http://chimera.labs.oreilly.com/books/1234000000726/apa.html#_literal_cards_erl_literal_2
16:21r00kI'll double-check that.
16:22jdeisenbergor rather, added comments to the source from Literate Programs
16:22coventry`dbasch: amalloy: Could take-shuffled be sped up with transients? If not, actually seems like a good candidate for bashing a local array.
16:27juliobarrosAny know if there is a Quill like library for drawing on a browser canvas?
16:33r00kamalloy: You were totally right. Thanks!
16:35r00kIs there a more idiomatic way to accomplish (defn fooify [xs] (if (coll? xs) (map bar xs) (bar xs))) where xs can be strings?
16:35r00kMore specifically, where xs can be either ["baz"] or "baz"
16:36jcromartier00k: I've written something like this a few times
16:36amalloyr00k: make it always be a list, and then always use map on it
16:36jcromartier00k: (defn foo [x] (if (coll? x) x (seq x)))
16:36jcromartieerr
16:36jcromartieno
16:36jcromarties/seq/list/
16:37amalloythere's not much use propagating the "string or list of strings" dichotomy to more code who will have to cope with it
16:37r00kamalloy: Is there a handy fn to make something a list but only if it isn't one already? (won't increase nesting I mean)
16:37jcromartiebut it's probably a bad pattern
16:37llasram(inc amalloy)
16:37lazybot⇒ 105
16:37llasramThat pattern has only ever caused me pain
16:37r00kamalloy: Also, my example was wrong. I am always returning a list. The else branch was (vector (bar xs)).
16:37amalloyyes. it's a shame compojure's param middleware does that, but on the other hand it's much more convenient than the alternative
16:47technomancyHTTP headers being case-insensitive multimaps is a weird design to begin with
16:48jdeisenbergjuliobarros: see http://www.chris-granger.com/projects/cljs/ specifically, "monet" -- this is a clojureScript thing.
16:49amalloytechnomancy: i don't think it's the headers that are at issue, so much as the query-params
16:49jdeisenbergjuliobarros: followed it to https://github.com/rm-hull/monet
16:49technomancyamalloy: oh, gotcha
16:50juliobarrosjdeisenberg: Cool. Thanks. I'll take a look at that.
16:50amalloyare headers really multimaps? i can't think of an example
16:50jdeisenbergDoesn't seem very quil-ish, though :(
16:50technomancyjdeisenberg: quil is pretty imperative; I wouldn't necessarily hold it up as a paragon of functional api design.
16:51jdeisenbergtechnomancy: Is there a good functional-graphics-with-ease-of-Processing type module for Clojure?
16:52technomancyjdeisenberg: the best functional graphics API I know of is Racket's. I don't know of any in Clojure that I'd recommend.
16:52technomancythat is, I would recommend *using* Quil, but I wouldn't recommend copying it's design.
16:53jdeisenbergAh, OK. Thanks. I teach Processing as intro to programming, and was thinking of moving over to Quil.
16:54technomancyit's definitely lots of fun
16:54technomancya lot more fun than Processing sounds =)
17:01TerranceWarriorhow would your normally handle error passing up the stack chain in clojure?
17:01TerranceWarrioralso every thing is passed by referene?
17:07coventry`I handle it by reading the resulting stack trace and squashing the bug. :-) Things are passed by reference, but that doesn't make much difference for most objects, since they tend to be immutable.
17:11TerranceWarriorcoventry`: ah ok. how do you 'read' it. with 'try'?
17:26`szxjdeisenberg: canvas API is pretty easy, as easy as processing IMO
17:26scape_does loop-recur work similar to trampoline?
17:27`szxTerranceWarrior: i think coventry` was talking about debugging stack traces, not exception handling which i think was what you were asking about?
17:27amalloyscape_: errrr. trampoline is implemented via loop/recur. it's not clear what your question wants to know
17:27scape_just how/if theyre related
17:27scape_thx, that explains it
17:32TerranceWarrior`szx: i am asking about how to handle errors in code and whether to pass them up the call chain.
17:32sdegutisI am about to use (partial) to solve a problem.
17:32sdegutisThis would be impossible in a lesser language.
17:32TerranceWarriorTEttinger3: thanks.
17:32`szxTerranceWarrior: you could return nil, or throw an exception and catch it
17:33coventry`,(try (throw (Exception. "I'm an exception")) (catch Exception e (throw e)))
17:33clojurebotcoventry`: Pardon?
17:33`szxheh
17:38sdegutisNever mind, partial alone will not solve it.
17:39TerranceWarrior`szx: right ok. but i know that handling exceptions you pay hevily in performance.
17:41amalloypartial is at best a partial solution, sdegutis
17:41sdegutisamalloy: Very good joke.
17:42`szxTerranceWarrior: not sure what's the current state of the JVM in regards to that, but i'm pretty sure that the common wisdom is that exceptions are there for exceptional cases only, and therefore shouldn't have a significant impact on performance
17:42`szxi.e. you shouldn't use exceptions for control flow
17:43TerranceWarrior`szx: AFAIK there is a call check and possibly more within each function of a try block.
17:44`szxTerranceWarrior: https://groups.google.com/forum/#!topic/clojure/kOrg9XCYklQ for Rich Hickey's take
17:56sdegutisShould be used (partial f arg1) or #(apply f arg1 %&) ?
17:56Bronsasdegutis: go with partial
17:57sdegutisI will test it in the REPL to ensure that it respects dynamic changes in the applied function's source code.
18:01sdegutisAww, no! It does not work. When I do (partial) it captures the definition of the function at this time. I will perhaps use sharpquine to capture the var instead.
18:02sdegutisThis works better. But now I will test it with %&
18:03sdegutisWith (apply %&) I do not have to use sharpquine, it captures the fresh var at each call.
18:03sdegutisThis is a trade-off.
18:04gtrakit's not apply that's the issue, it's #(apply f ..)
18:04gtraksame effect #((partial f ...) %&)
18:05DerGuteMoritzshouldn't (partial #'f) work? in case f is a var, that is
18:05amalloyyes, DerGuteMoritz
18:05sdegutisgtrak: I don't understand what you said.
18:05gtraksdegutis: the deref happens when the anon-function is run.
18:06sdegutisgtrak: I have done (partial #'myfunc state) and #(apply myfunc state %&) and both work.
18:06gtrakpartial derefs the var when it evals its args, like any normal function.
18:06PigDudeis there something besides map for iterating two collections in parallel? other things like for and doseq create cross-products
18:06fowlslegsWhat is the best way to test whether one piece of code or another works faster? My immediate thought is to run the task #'repeatedly, say a few hundred times, with randomized input variables, wrapping both of the snippets in #'time, and taking the better. I'm not very knowledgeable on how Clojure/ Java handles memory allocation, garbage collection, etc. though, so I'm not sure if this is the best way to go about doing this.
18:06PigDudeer, is there a `domap`, so to speak
18:07sdegutisgtrak: so what are you saying, that I should use partial?
18:07gtrakI'd try to find a way to avoid depending on the timing of var-capture :-), I guess, is the point, that doesn't have to be a visible tradeoff in most cases.
18:07gtrakI don't know what your code is doing.. so I'm just generalizing.
18:08gtrakI think partial's prettier than #(..) when it's straight-forward.
18:08dbaschfowlslegs: criterium
18:09dbaschfowlslegs: https://github.com/hugoduncan/criterium
18:09sdegutisgtrak: I have a few functions that I want to act on some state, and I want them all to reload when I reload my file while developing live.
18:09fowlslegsThanks dbasch!
18:10TerranceWarriorPigDude: Did you see Lando's Fan on utube?
18:10TerranceWarrior`szx: Setting a 'dynamic' variable? Ha, thats the kind of hack Python uses, global vars.
18:12sdegutisLook: https://gist.github.com/sdegutis/7c4aa63d7abb5180caf2
18:13sdegutisI just want it so that when I change one of those first two functions, anyone who already called (create-names-fns-map) and stored the result, they can have their state remain the same, yet the function differs.
18:14sdegutisSay someone stores (create-names-fns-map) into 'foo, now when they do ((:add-name foo) "gtrak") I wish for that to continue working, even after they add some code to (add-name) and reload the file it lives in.
18:14sdegutisYes, Now you see my question clearly.
18:14gtraksdegutis: ah, I get it.. but.. why?
18:15PigDudeTerranceWarrior: hm? what's that
18:15gtrakit looks suspiciously like an object.
18:15sdegutisgtrak: You see, I want to make sure that when I reload my files, my new functions are used with conjunction with the old state.
18:15sdegutisgtrak: I have some state that is setup one-time with ring's "init" feature and that state I don't want to reload at every file-reload.
18:16gtrakwell, that can be solved by defonce.
18:16TerranceWarriorPigDude: A Key and Peel sketch with reference to 'PigDude' in a tiny Star Wars spoof.
18:16`szxTerranceWarrior: keep in mind this post is from 2008, a lot has changed since so current thinking might be different
18:17sdegutisgtrak: that seems irrelevant in this case.
18:17sdegutisgtrak: For you see, the state must be stored at the same time the functions are defined. And the functions may be swapped out for "mock" functions during a test-suite-run.
18:17gtraksdegutis: I'd just pass the state around and have folks call the functions. destructuring a map to get functions is something I've considered many times before and thrown out.
18:18gtrakor define a protocol on the service, and have people call into that using an impl of the service.
18:18sdegutisgtrak: that was my initial solution, using a protocol and deftype for each implementation.
18:19sdegutisBut you see, they have the very same problem. The new functions aren't used whenever you reload the file where they're defined!
18:19sdegutisThis makes sense, because the instance isn't going to change just because the factory function (the deftype body) that created it has changed.
18:20sdegutisIt's not loosely coupled, it's tightly coupled to the body.
18:20gtrakI'd rather have an extra convenience function to take care of this than change an api for dev-use convenience.
18:20gtrakrip the state out of the record, call the new record constructor with it.
18:20gtrakafter its redefined.
18:20gtrakit's.
18:21gtrakor, don't inline the function definitions, extend-type doesn't have this problem.
18:21gtrakthat's probably your best bet.
18:22gtrakknow what I mean?
18:23gtrakre-evaling an extend-type/protocol form will redefine the global map of impls, should work for old instances.
18:24gtrakthe tiniest bit slower than inlining it
18:25sdegutisThat sounds great.
18:25gtrakphew :-)
18:25sdegutisBut still, I think this should be redesigned to just use plain old functions.
18:25gtrakbut.. then you're writing javascript.
18:26gtrakor you mean not the map-of-functions, but ns-functions.
18:26sdegutisI don't know how I plan to distribute the functions yet.
18:44sdegutisOh no, I cannot just pass the namespace that contains the functions.
18:44sdegutisThey are not first-class things. Although I can pass the symbol.
19:48upwardindexIs it possible to set the name of the thread created by a future (so that jstack are clearer)?
19:50amalloyupwardindex: no. future doesn't even guarantee to create a thread; it may reuse one it finds lying around
19:50amalloyif you want more control, create the thread yourself
19:50AWizzArdand there you can use setName
19:50upwardindexamalloy: ok, thanks!
19:50AWizzArdhttp://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html
20:01danneuhttps://news.ycombinator.com/item?id=7700638
20:02stormehaha nice
20:02tufthaha
20:18PigDude! i'm calling (ns/f) from within same-named function 'f' in another ns, but i get bad arity, as if it's calling local fn?
20:19amalloy&((fn inc [] (clojure.core/inc 1)))
20:19lazybot⇒ 2
20:19amalloyseems to me like it works fine, PigDude. do you have an example you can put on refheap or something?
20:26PigDudeamalloy: it feels like anything could be broken w/ some of these error messages, i guess it was not that
20:27amalloyPigDude: i bet if you put your stacktrace on refheap, someone could tell you what's wrong
20:31amalloyughhhh, i was looking through the source of a library i was evaluating, and i see here (distinct (vec (flatten (map keys ...))))
20:33hiredman:(
20:33hiredmanit's like people don't even care
20:36PigDudewhy does this happen?
20:36hiredmanhttps://github.com/search?q=%22%28distinct+%28vec+%28flatten+%28map+keys%22&amp;type=Code&amp;ref=searchresults
20:36PigDude&(filter (partial > 4) (iterate (partial * 2) 1))
20:36lazybotjava.lang.ArithmeticException: integer overflow
20:37PigDudei expected this to be [1 2]
20:37amalloyPigDude: well, you tried to print an infinitely long list
20:37PigDudebut i have filtered the list
20:37amalloyyou've filtered it, but you haven't *stopped* it. clojure doesn't know for sure that the millionth item in the list is 3
20:38amalloythat is, it doesn't know the numbers are increasing and your predicate will never go back to returning true
20:38PigDudeso is there a form for this or do i have to recur?
20:38amalloy&(doc take-while)
20:38lazybot⇒ "([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."
20:38PigDudeah, thanks
20:56yeoj___hi, is there anyway in emacs to automatically create test files with the correct namespace stub/etc? does cider/clojure mode would have provided that somewhere?
20:58amalloydo you create test files so often that having the ns form provided would be a substantial win? i mean, time-saving features are nice, but i sure don't do it often enough that i'd have thought to ask
20:58yeoj___amalloy: i'm just rethinking my workflow, and as i'm interacting with a function i'm defining i'm constantly jumping back and forth to the test file
20:59yeoj___amalloy: maybe i should be spending more time at a repl instead of the test file
21:01gfredericksyeoj___: jumping back and forth isn't the same thing as creating a new file
21:01gfredericksjumping back and forth is supported in cider for the *-test naming convention
21:02yeoj___gfredericks: ok sounds good. i was just thinking something would write the namespace/etc for me because it's pretty much always the same, and refer/use the stuff i'm testing, etc.
21:02yeoj___gfredericks: i thought emacs live did that for me but i don't remember, maybe not.
21:06cespareThoughts about carmine? Anyone use other clients (maybe just jedis?)
21:10lvhHi
21:10lvhI'm trying to wrap my head around Korma, and I'm not seeing where the column definitions would go
21:10lvhnone of the defentities seem to define, say, that there exists a thing called a "username" and that it is a string and a user has one
21:11lvhwhich I guess is fine as long as korma never tries to produce DDL statements?
21:12kenrestivoyou might want to try honeysql or the other alternatives
21:18lvhSorry, got disconnected.
21:18lvhDid anyone say something in the mean while?
21:23akurilinDo we have any libraries in clojure that do fuzzy string matching? e.g. make sure that every character in the search-term is present in the string in that specific order?
21:24akurilinor actually, I think we have a couple. Is there one you guys are happy with?
21:46akurilinNvm didn't find what I was looking for, just wrote it myself.
22:13mgaarelvh: korma is somewhat high in magic. I've been playing with sqlingvo lately and I would recommend giving it a look
22:27lvhby the way, I was walking through the datomic tutorial and saw expressions like these: @(d/transact conn data-tx)
22:27lvhI know @ means "deref" but what is the point of derefing the result of the transact call? does it have some kind of side effect?
22:27lvh(it's not assigned to anything or whatever)
22:30amalloyit probably returns to you a promise or delay or something, representing the plan to eventually transact
22:30amalloynot that i know a lot about datomic
22:30AWizzArdPerhaps the returned object is indeed a promise and will signal you that the transaction has finished, if you care.
22:31dbaschtransact does return a future http://docs.datomic.com/clojure/#datomic.api/transact
22:32lvhoh, cool. thanks :)
22:33AWizzArdAh yes, we got it.
22:33AWizzArdThat way you can blockwait in your thread until the tx has finished.
22:37KeithPMGood evening clojurists. Can someone explain to me the significance of the '- 'in (set! (.-x point) 15) the following gist? kpmaynard / gist:43500393959b3615a3fe … Thanks
22:40dbaschKeithPM: I can’t see the gist, but “-“ is used in clojurescript to access js properties
22:41AWizzArdclass Point { int x, y } => then you have a (def my-point (Point. 10 20)) Now (.-x my-point) ==> 10
22:41dbasch“.-“ actually
22:41KeithPMOh OK… This property was a java instance variable
22:41AWizzArdJavaScript maybe. I guess your code snippet is a ClojureScript one.
22:42KeithPMNo actually it was clojure..
22:44KeithPM-https://gist.github.com/kpmaynard/43500393959b3615a3fe Gist is here, sorry.
22:46AWizzArdWell okay, it still looks like a field accessor.
22:46AWizzArda place
22:47TEttingeris it accessing a variable called _x ?
22:47TEttingerno, nvm
22:47KeithPMNo x
22:49beamsothe code in the gist worked for me :/
22:49AWizzArdWhich beamso? The first or second?
22:49AWizzArdStrange that this operator isn’t listed at http://clojure.org/java_interop
22:49KeithPMThe first one fails
22:50beamsoAWizzArd: the code in the gist looks identical to me in both cases
22:51AWizzArdbeamso: on my computer the version at the bottom is different
22:51AWizzArdit is rendered .-x vs. .x
22:51KeithPMNo just the '-' is the only difference… see the commented line
22:51beamsooh, the .-x
22:51beamsothe top one worked
22:51KeithPMReally?
22:51AWizzArdIn Clojure I would have expected the top one to work.
22:52AWizzArdcljs however indeed has this .- accessor
22:52beamsoi'd never seen set! used in that manner but i haven't done interop with public fields in java yet
22:53KeithPMFound it in Fogus' book.
22:53AWizzArdI can’t remember to have ever seen it for Clojure before, but maybe it was indeed introduced in some version.
22:57KeithPMOK. I think I upgraded to 1.6 tonight because I could not find set! in light table
23:33amalloyAWizzArd: .-x was added to clojure when it was added to cljs, which i think was 1.3, maybe 1.4
23:34amalloythose should both work in any non-cljs version of clojure i know of, though
23:35amalloy,(.x (java.awt.Point. 1 2))
23:35clojurebot1
23:36amalloy,(set! (.x (java.awt.Point. 1 2)) 3)
23:36clojurebot3
23:38KeithPMHmmm… Maybe it is not working with the bound value 'origin'? Let me try your suggestion amalloy
23:40KeithPMWorks fine anonymously but fails once the point is assigned to a named value
23:45TEttingerMorgawr: how's cloister coming along?
23:59amalloy,(let [p (identity (java.awt.Point. 1 2))] (set! (.x p) 3))
23:59clojurebot3
23:59amalloystill works fine, KeithPM
23:59amalloymaybe you don't actually have a Point anymore