#clojure logs

2015-07-06

00:17turbofailman. figwheel is pretty awesome
04:12singa2015hi
05:01wombawombaI'm having a hard time splitting a vector of numbers into sequential parts (i.e. [1 2 3 5 6 8] -> [[1 2 3] [5 6] [8]])
05:01wombawombaWhat's a good way of doing this?
05:10namra(doc partition)
05:10clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
05:11TEttinger,(doc partition-by)
05:11clojurebot"([f] [f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions. Returns a stateful transducer when no collection is provided."
05:11namracool even better
05:11justin_smith, (partition-by (partial apply -) (partition 2 1 [1 2 3 5 6 8]))
05:12clojurebot(((1 2) (2 3)) ((3 5)) ((5 6)) ((6 8)))
05:12TEttinger,(reductions #(= % (dec %2)) [1 2 3 5 6 8])
05:12clojurebot(1 true false false false ...)
05:12justin_smithnot the full answer, but close...
05:12TEttinger,(reductions #(= % (dec %2)) 0 [1 2 3 5 6 8])
05:12clojurebot(0 true false false false ...)
05:12TEttingerhm
05:12justin_smithTEttinger: that reductions is comparing true or false to a number
05:12TEttingerright
05:13TEttinger,(reductions #(- % (dec %2)) 0 [1 2 3 5 6 8])
05:13clojurebot(0 0 -1 -3 -7 ...)
05:13TEttinger,(reductions #(- % (dec %2)) [1 2 3 5 6 8])
05:13clojurebot(1 0 -2 -6 -11 ...)
05:13TEttingerhm
05:14TEttinger,(map - [1 2 3 5 6 8] [2 3 5 6 8])
05:14clojurebot(-1 -1 -2 -1 -2)
05:16TEttinger,(let [base [1 2 3 5 6 8]] (map - base (drop (cycle base))))
05:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$drop$fn__4606>
05:17TEttinger(doc drop)
05:17clojurebot"([n] [n coll]); Returns a lazy sequence of all but the first n items in coll. Returns a stateful transducer when no collection is provided."
05:17justin_smith,(#(apply conj (reduce (fn [[runs part] i] (if (= i (inc (peek part))) [runs (conj part i)] [(conj runs part) [i]])) [[] [(first %)]] (rest %))) [1 2 3 5 6 8])
05:17clojurebot[[1 2 3] [5 6] [8]]
05:17TEttinger,(let [base [1 2 3 5 6 8]] (map - base (drop 1 (cycle base))))
05:17clojurebot(-1 -1 -2 -1 -2 ...)
05:17TEttingernice justin_smith!
05:17TEttinger(inc justin_smith)
05:17lazybot⇒ 270
05:18justin_smithTEttinger: fundamentally that algorithm needs two accumulators, and that's easiest to do with a reduce or loop
05:18justin_smitha simple lazy stream doesn't carry two states as easily
05:19justin_smith(though you could use lazy-seq by hand I think? Not easily though)
05:21amalloyjustin_smith: it doesn't seem particularly hard to do lazily
05:21justin_smithOK
05:21amalloyyou just have a recursive function with two arguments
05:22wombawombaI managed to solve it, but it seems there should be a neater approach: https://gist.github.com/aeriksson/b6f5e29a1e55fe83aa18
05:27rritochWhat's the normal naming convention for a clojure "hello world" application? Would it be clj-mytech-helloworld or clj-mytech-hello-world ?
05:28oddcullyisn't the "clj" prefix only used if you wrap something with the same name?
05:29justin_smithwombawomba: I think a lazy-seq version is doable (I am trying), but I think my reduce is beats that
05:30wombawombajustin_smith: yeah seems like it :)
05:32rritochoddcully: The clj prefix just helps me visually isolate clojure apps from other apps. Anyhow, the only hello world I could find used hello-world so I guess that's what I'll use. It just looks like it's a bit too wordy that way.
05:37justin_smithwombawomba: my lazy version, does not fit in a one liner nicely https://www.refheap.com/105337
05:37justin_smithwombawomba: it works, and may be shortenable
05:40justin_smithwombawomba: just edited and removed some duplicated logic, still works, still too verbose https://www.refheap.com/105337
05:43oddcullyand somewhere else the battle rages on whether to indent with tabs or spaces...
05:51namrayea what is actually the prefered indentation for clojure (tabs/spaces and how many)
05:52justin_smithnamra: two spaces
05:53namrak using that
05:53oddcullythis was targeted on the creative use of `,` to indent
05:53namra^
05:53justin_smithoddcully: haha, yeah, total hack
05:53oddcullythe problem: my brain read `..`
05:53oddcullyand gone, what?! why?!
05:54justin_smithoddcully: I promise I didn't invent using ,, in cond
05:59wombawombajustin_smith: cool, thanks!
05:59TEttingergaaaaah
05:59TEttinger,(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (conj (last stack) a) (conj (conj (last stack) a) [[b]]))) [[]] (partition 2 1 base)))
06:00clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IPersistentCollection"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IPersistentCollection"\n :at [clojure.core$conj__4114 invoke "core.clj" 82]}]\n :trace\n [[clojure.core$conj__4114 invoke "core.clj" 82]\n [sandbox$eval389$fn__391 invoke "NO_SOURCE_FILE" 0]\n [clojure....
06:00TEttingerthere's no conj-in
06:00TEttingerso I don't know how to append to an inner element in a nested vector
06:00TEttingerand get back the whole vector
06:00justin_smithTEttinger: update-in v [idx] conj foo
06:00justin_smith?
06:01TEttingerneeds to be past the end
06:01TEttingerend can change
06:01TEttingeroh!
06:01hyPiRionor just (update v idx conj foo) with 1.7
06:01hyPiRionyay update
06:02TEttinger,(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (update stack (dec (count stack)) conj a) (conj (update stack (dec (count stack)) conj a) [b]))) [[]] (partition 2 1 base)))
06:02clojurebot[[1 2 3] [5 5 6] [8]]
06:02TEttingerodd!
06:03TEttinger,(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (update stack (dec (count stack)) conj a) (conj (update stack (dec (count stack)) conj a) []))) [[]] (partition 2 1 base)))
06:03clojurebot[[1 2 3] [5 6] []]
06:03TEttingerhm
06:05justin_smith(update stack (dec (count stack)) conj a) is (conj (pop stack) (conj (peek stack) a))
06:05justin_smithdunno, I kind of like the latter better
06:14vlvxgday
06:15vlvxwhat os do you girls use?
06:16wasamasavlvx: /join ##windows
06:20vlvxoksu
06:26oddcullyoh goody, clojuretv got updated
06:53dstockto1last week oddcully, still waiting for day 2
06:59oddcullydstockto1: seems i didn't got the memo. well cron ftw
07:28tdammerslibrary/tooling question here
07:29tdammersI'm looking for a mocking library or framework that allows me to mock an SQL database at the query level
07:29tdammersis there a go-to thing for that?
07:42rritochWhats the best way to load a clojure namespace from java? I called Namespace.findOrCreate(someNamespace) && then called invoke on Clojure.var(namespace,ifn) but I'm getting an illegal state exception because the function (namespace) was never loaded, though it should be available in the currentContextClassloader
07:45rritochI believe I'm looking for the java equivalent of (require 'some-namespace)
08:06puredangerhttp://clojure.github.io/clojure/javadoc/clojure/java/api/Clojure.html
08:11rritochpuredanger: Thanks, but that's what I am using. I'm going to try "invoke
08:24rritochYay! It worked.
08:28rritochhttps://github.com/rritoch/clj-osgi-namespaces > is now successfully calling a clojure "loader" by specifying the namespace in the bundle "Clojure-Activator" header, the activator must have start [ctx] and stop [ctx] functions similar to a regular java activator or else there will be some problems.
08:29rritochNo way to know yet if the "Clojure-Imports" and "Clojure-Exports" headers are working yet though.
08:33TimMc$mail arohner In your post "Why Clojure Is Awesome, Without Using the L-Word" I do think this line is a bit silly: "A person has identity, because they have a name." -- people's names change too. :-)
08:33lazybotMessage saved.
08:39rritochI uploaded the hello world app to > https://github.com/rritoch/clj-osgi-namespaces-hello-world which is 100% java free and executes with the help of the clj-osgi-namespaces bundle
09:04aztakwrong channel probably - but I'll try.. anyone using Spacemacs to hack Clojure and have the cider-debug stuff working? :)
09:05aztakI can instrument a method, but I can't act using the n,i,c etc. keys when a break-point gets activated. I suspect it's related to evil-bindings in Spacemacs.
09:06luxbockaztak: yeah you have to switch to emacs-state to use it
09:07aztakluxbock: really? you know if it's something that will be fixed or if it's something that can't be changed because of how cider is implemented?
09:07luxbockaztak: I believe there is an issue for it
09:07luxbockalthough it is for emacs lisp
09:08aztakluxbock: thanks for the info - I'll give it a try :)
09:08luxbockit is rather annoying so I've almost got my hands dirty a few times but everytime I get that itch I'm usually working on something else so never got around to it
09:08aztakC-z to enter emacs-state, and then ?? to switch back? :)
09:09wasamasaC-z again
09:10aztakah, there's '\' to execute on cmd in emacs-state.
09:10aztakwasamasa: thanks!
09:10wasamasaaztak: spacemacs has a gitter channel for support
09:10wasamasaaztak: what you were asking for is part of evil as is, so I've answered it
09:11aztakwasamasa: I know - I posted the same question there an hour ago, but everyone seems to be sleeping right now *grin*
09:11wasamasaaztak: as for the specific issue with keys, perhaps you can make use of one my tweaks for edebug (which is what the cider debugger is modeled after)
09:11wasamasaaztak: https://github.com/wasamasa/dotemacs/blob/master/init.org#keymap-hacking
09:13aztakwasamasa: wow, that's a lot of good stuff there.. I'll bookmark that page - thanks :)
09:13aztakand the emacs-state switcharoo solved the issue with cider-debug. Thanks guys!
09:24wasamasaaztak: well, that's my emacs config
09:24wasamasaaztak: feel free to favourite it
10:06rritochaztak: There are lots of updates to the osgi system I'm working on @ https://github.com/rritoch/clj-osgi-namespaces , The hello world app is functional, my next stage of development is to test the import/export functionality by using the exports of hello world in a hello-world-user bundle.
10:06rritochHmm, seems he's gone.
10:08rritochIs it ok if I lazybot mail him?
10:32rritochAnyhow, the imports and exports do seem to be working, it's time to send this off to the clojure mailing list so others can use (break) it. I'm sure the tickets will pile up on this one since OSGI itself isn't easy to use.
11:18crocketIs clojure ok for a command line utility that's executed every 5 minutes?
11:18crocketNot sure how I would write a command line utility with clojure.
11:19justin_smithcrocket: -main will get any args provided to your uberjar
11:20justin_smithand stdin and stdout are straightforward enough (via *in* and *out*)
11:20justin_smiththough for a repeated task you may want to consider just leaving the clj process running with a timed task
11:25crocketjustin_smith, Does JVM not use a lot of memory for a simple DDNS client that updates DNS entires every 5 minutes?
11:26crocketIt would consume at least 128MB after optimization.
11:27justin_smithcrocket: the memory usage is another consideration. Just a nitpick: the memory usage is not the JVM's fault. It's 100% clojure's fault.
11:27crocketOn the other hand, Gogs, written in Go, consumes 32MB of OS memory.
11:27crocketGogs is ridiculously light.
11:27justin_smithClojure is not optimized for memory usage, at all
11:28crocketI'd consider using pixie, but it is not mature enough yet.
11:28crocketIt's not even ready for a simple DDNS client for home.
11:28crocketI'm stuck with a nodejs DDNS client I wrote a year ago.
11:29crocketjustin_smith, What is clojure optimized for?
11:29crocketA large web application?
11:29justin_smithcrocket: correctness, speed
11:29justin_smiththose things are good for large web apps, sure.
11:29crocketFor clojure to suit CLI apps, it needs to consume little memory and start up fast.
11:30crocketpixie fills that niche.
11:30justin_smithright, and clojure is not good at either of those things
11:30crocketDo you know pixie?
11:30justin_smithyes, I've played with it quite a bit
11:31crocketI plan to pick up Racket for that...
11:31justin_smithcrocket: if you want a functional language that starts up fast and uses little RAM, OCaml is probably your best bet.
11:31justin_smithunless you start using the janestreet libs, but you don't need those
11:31crocketJanestreet is known for OCaml.
11:32justin_smithyes, and their libs are amazingly huge
11:32crocketIt reflects their organizational structure.
11:32crocketWhat was the relevant law?
11:33crocketRight, conway's law
11:33crockethuge, slow, etc...
11:34crocketjustin_smith, I wonder what I'll use clojure for in the future.
11:34crocketProbably some AIs
11:35wasamasalol
11:35wasamasawork, really
11:37rritochcrocket: Why would you want to relaunch a java/clojure app at a certain interval? There is a lot of overhead to starting the JVM and you can just leave it running, in this case instead of a cron you would probably use a ExecutorService
11:40crocketrritoch, As I said above, a simple DDNS client in clojure would consume at least 128MB.
11:40crocketGogs consumes 32MB.
11:41justin_smithcrocket: sure, but none of us here are going to be able to fix that any time soon, and I don't think the heap usage is even on the agenda for the clojure.core dev team as something that needs fixing.
11:42rritochcrocket: 128MB is nothing, considering Firefox uses anywhere from 1GB to 2GB
11:42crocketrritoch, Except it's a simple DDNS client that should occupy less than 2MB.
11:43crocketMy server doesn't run firefox.
11:43justin_smithif that's your constraint, then of course you can't use clojure, (unless maybe you port your node version to cljs?)
11:44markmmAre you running on embedded device or some memory constraint environment?
11:44rritochcrocket: Are you using leiningen?
11:44crocketrritoch, I usually do
11:44crocketmarkmm, no
11:45crocketBut, I appreciate little memory usage.
11:45justin_smithcrocket: lein should not be used at runtime, it's a dev/build tool
11:45crocketI appreciate how little memory Gogs consumes.
11:45justin_smithand not using it will reduce your ram usage and startup time quite a bit
11:45wasamasamarkmm: he's in the trolling environment
11:45crocketIt is fast and light.
11:45crocketjustin_smith, I won't use lein in production.
11:45rritochcrocket: So try setting :jvm-opts ["-Xms:2m"] that should reduce JVM down to 2m on startup
11:46justin_smithbut clojure simply doesn't fit in 2m
11:46markmmcrocket: ok I see, try C then
11:46rritochjustin_smith: That's assuming your using all of clojure
11:46wasamasamarkmm: to satisfy all of its constraints you must present a fast, functional, memory-cautious and elegant language which ideally spits out binary executables that start up fast and comes with loads of libraries and a wonderful community
11:46rritochjustin_smith: Either way, starting at 2m which is his goal, it will expand up if clojure really needs more space.
11:47justin_smithrritoch: if you are willing to accept the huge perf hit of the lazy-loading branch, you can do that I guess
11:47wasamasamarkmm: I did get pretty close to that, but then they started an offtopic comment how they dislike design by committee
11:47wasamasamarkmm: so I'm pretty sure it's just a troll
11:47rritochjustin_smith: I'm perfectly happy with a 128MB footprint, it's crocket who's looking for a micro-environment, and changing java options is one way to do that.
11:48justin_smithrritoch: but the way clojure operates (always loading it's full lang / compiler) undo any benefit that setting would give. Unless you use the lazy-loading branch and accept the degraded performance that goes with that.
11:49markmmwasamasa: Ah has this been going on a while
11:49wasamasamarkmm: yeah, in other channels as well
11:50wasamasamarkmm: including #emacs and #scheme
11:56crocketwasamasa, Are you a troll that trolls other trolls?
11:59TimMccrocket: The only solution is to write your own language.
11:59crocketIt's weird
11:59crocketIf I point out weakness of clojure in #clojure, it's considered trolling.
12:00TimMcThis *is* how new languages get created, you know.
12:00crocketIf I point out weakness of something in #something, it's also considered trolling.
12:00crocketTimMc, That's how pixie is being created as far as I know.
12:00justin_smithcrocket: you can point out the weakness, then we acknowledge it... it's weird when the conversation is expected to continue? I mean what can we offer other than other languages you could use?
12:00wasamasacrocket: you could, like, accept that no language is perfect?
12:00crocketI know that no langauge is perfect.
12:01crocketI was just following through the conversation.
12:01wasamasathen just stop, it's getting tiring
12:02crocketThe problem is that pointing out weakness of something seems to invalidate people's ego.
12:02rritochjustin_smith: Well, starting with "-Xms2m" my repl still uses 94M to 104M
12:03justin_smithrritoch: yeah, that was kind of what I meant. The small Xms is just going to slow startup, not prevent the repl from using more RAM. Is that a lein repl or a clojure.main repl btw?
12:03wasamasacrocket: it's like you've got nothing better to discuss than weaknesses of languages
12:03rritochjustin_smith: lein repl
12:04crocketwasamasa, That's your perception, but not my intention.
12:04wasamasacrocket: I have logs of you doing this for weeks
12:04wasamasacrocket: so, nope
12:04crocketwasamasa, What do you talk about on IRC?
12:04rritochBah
12:04rritochNEVER trust the garbage collector!
12:05crocketThe JVM garbage collector doesn't return memory to OS.
12:05wasamasa...
12:05rritochMemory usage before garbage collection, 94M, after 101M, wtf
12:05rritochThat was running (System/gc)
12:06wasamasacrocket: why don't you just lurk and observe
12:06wasamasacrocket: like, most people on IRC
12:06crocketwasamasa, I do not commute to IRC to observe.
12:07crocketI observe when there are clearly things to learn.
12:07justin_smithrritoch: crocket: 75m for a non-lein clojure.core 1.7 repl
12:08crocketwasamasa, I think you're over-reacting.
12:08rritochjustin_smith: And after (System/gc)? lol
12:09justin_smithrritoch: also, remember that "lein repl" creates two processes, and you should be counting them both
12:09justin_smithrritoch: 93m after gc :)
12:10crocketAgain, the garbage collector cleans up garbages inside JVM.
12:10rritochjustin_smith: Yeah, I'll never trust the garbage collector again.
12:10crocketJVM itself doesn't return memory to OS.
12:10justin_smithrritoch: the gc is optimized for runtim perf by default, not neccessarily minimizing heap usage
12:10justin_smithrritoch: it reorganizes things in memory so that future processing happens faster
12:10justin_smitheven if that means using more RAM
12:10crocketIf you want a runtime environment that returns memory to OS, JVM is not it, yet.
12:11justin_smithcrocket: likely never will be. It's not a community proirity for the JVM or for Clojure.
12:11crocketI think server markets were the priority for Oracle.
12:13crocketwasamasa, I just wonder what you would get by observing conversations in any IRC channel for extended periods of time.
12:13crocketThe profit lies in bidirectional communication.
12:14justin_smithcrocket: well, Oracle is only the most recent owner of Java, but yeah, the Java project has been run by various companies that sell and support large complex systems with a lot of resources, and for a long time has been optimized for these sorts of environments
12:14justin_smithcrocket: they are optimizing for the very common case where RAM chips are cheaper than the lost perf from using less RAM
12:14crocketI guess I'll keep learning languages.
12:15justin_smithas I mentioned before, OCaml does a great job of doing awesome perf, with low heap usage, in a sane functional language
12:15crocketjustin_smith, That makes sense if your program always uses a lot of RAM most of the time.
12:15wasamasajustin_smith: that might be the case, but it's not enough to satisfy crocket
12:16justin_smithcrocket: the point is that there are generic methods to speed up performance by using more RAM. The JVM exploits these
12:17justin_smithcrocket: there are other methods that get speed by using less RAM, OCaml takes that approach more often
12:17crocketI think performance is more than just speed.
12:18justin_smithcrocket: do tell
12:18crocketperformance metrics include memory usage, speed, etc...
12:19crocketI think Racket and OCaml will just do fine for my small CLI scripts.
12:19justin_smithracket's pretty slow, but that likely doesn't matter for your use case, yeah.
12:20crocketRacket's still noticeably faster then python 3.
12:20crocketSo, it still satisfies my performance requirements.
12:22puredangerit's almost like a single language can't satisfy every possible application
12:22wasamasaunbelievable, is it
12:22chouserpuredanger: yet
12:22puredangerYET
12:22chouser:-)
12:22wasamasanot every language can look like clojure either
12:22TimMccrocket: You should use gherkin.
12:22justin_smithcrocket: for comparison, I'm working on a corparate app that does large scale data crunching (working on the parallelizing / multi host part right now, using onyx). We really don't care how much RAM is used, but if we can make a task take only an hour instead of 7 hours to do a computation, that would be awesome.
12:22crocketTimMc, Why?
12:22TimMcFast + parens.
12:22wasamasalol
12:23crocketTimMc, Parens themselves do not interest me much.
12:23TimMchttps://github.com/alandipert/gherkin
12:23TimMcYou know what I mean.
12:23wasamasaTimMc: please don't troll back
12:23markmmcrocket: You looked at Rust?
12:23TimMcActually, I have no idea if it's fast, but it compiles to bash and that's not too shabby. :-P
12:24crocketmarkmm, yes
12:24justin_smithTimMc: depends what "fast" means - low startup time, sure, any sort of perf speed? not likely
12:24markmmcrocket: It's supposed to be as fast as C++ and has nice modern features
12:25markmmcrocket: I didn't like all the pointery stuff
12:25crocketmarkmm, I wouldn't use it over pixie.
12:25crocketI'm acutually waiting for pixie to satisfy my quick scripting needs.
12:25justin_smithcrocket: what's pixie lacking then?
12:25TimMcWaiting is a good strategy.
12:26crocketjustin_smith, pixie is still very experimental.
12:26crocketIt doesn't even have a proper documentation.
12:26crocketIt is a new language.
12:26justin_smithsounds like OCaml or Racket are you best bets then, yeah
12:26crocketI think it'll take 1-2 years for pixie to become useable for average programmers.
12:26wasamasalol
12:27crocketUntil then, pixie is for pioneers.
12:27wasamasadoes it even have libraries?
12:27wasamasaor interop abilities with python?
12:27justin_smithwasamasa: it can use C libs directly
12:27justin_smithwasamasa: no, no python interop, only C / system interop
12:27wasamasawell then
12:27justin_smiththere is no python at pixie runtime, it's only used to generate the vm
12:28crocketRPython was used to bootstrap pixie.
12:28justin_smithstill is
12:28justin_smithunless pixie started self-hosting while I wasn't looking
12:28crocketWill pixie start self-hosting?
12:29justin_smithI doubt it
12:29justin_smithit's not on their list of goals at least
12:29crocketThe main dev seemed to be fond of RPython.
12:29wasamasahttps://github.com/pixie-lang/pixie/issues/338
12:29wasamasawhy doesn't this surprise me at all
12:30crocketI still think PyPy tool chain is better than bootstraping on C.
12:30crocketor LLVM
12:30crocketwasamasa, You're very good at tracking other people's lives.
12:30crocketI dare you to be better than tracking my life.
12:31crocketwasamasa, You say I'm a troll, but your behaviors are more problematic than you think I am.
12:31wasamasacrocket: I click its issue tracker and see a ticket by you at the very top
12:32xemdetiathat is an awful bug title
12:32wasamasainorite
12:32xemdetiaI have threatened physical violence at people for less
12:32crocketwasamasa, Is talking about personal behaviors your main topic on IRC?
12:33crocketissue is more than a list of bugs.
12:33TimMcMan, I'm just going to ignore the both of you. Don't care if you're trolls, just not interested.
12:34crocketwasamasa, If you keep pointing out my personal behaviors at every opportunity, I'll have to ignore you.
12:34xemdetiaforgive me TimMc I am in a release stretch
12:34xemdetiamy temper is about as cool as a volcano
12:37wasamasa\o/
12:37uris77is there a way to copy an sexp in emacs?
12:38uris77a keybinding?
12:38TimMcxemdetia: Haha, no worries! Smite away.
12:51amalloyuris77: you can select a sexp with C-M-SPC
12:51amalloyand then copy as usual with M-w
12:52BronsaTimMc: ha, me too
12:52BronsaI do C-M-k C-y
12:53TimMcC-y? I do C-/
12:53TimMc(it puts me back where I started)
12:54Bronsaoh, nice
12:54TimMcbut really I should learn how to package this up into a single keybinding
12:57uris77amalloy: thank you
12:58uris77Bronsa: I don't want to cut-paste, but thank you. That is also handy :)
13:02wasamasauris77: you could mark the sexp at point, then use M-w
13:03TimMcuris77: It's the same number of keystrokes. :-P
13:05uris77TinMc: yes
13:05uris77but I really wanted to copy, didn't want to cut
13:05uris77but thank you, I'll need to cut-paste too :)
13:05justin_smithuris77: in evil mode I can do it with "y%"
13:05justin_smith(inc evil)
13:05lazybot⇒ 0
13:05justin_smithhaha
13:05TimMcIt ends up on your clipboard either way... and it doesn't result in your buffer being any different afterwards...
13:06uris77TimMc: yes, you are right.
13:06justin_smithI think evil, as usual, wins the keybinding golf contest
13:07uris77it comes down to muscle memory. I'm trying to do it the 'Emacs Way' as much as possible. (I am a long time vim user)
13:07justin_smithuris77: long time emacser here, evil saves my wrists so much pain
13:08wasamasauris77: the emacs way is writing your own crappy command for it
13:08wasamasauris77: or rather, customizing generally (which includes using some other way of inputting it than a vanilla install would, including evil)
13:10justin_smithwasamasa: evil isn't crappy :P
13:10wasamasajustin_smith: I didn't write that
13:11justin_smithwasamasa: perhaps I was over-applying some transitive logic to your statements
13:11wasamasajustin_smith: tune down the aggressiveness of your inferer?
13:11justin_smithyeah, probably :)
13:11uris77your type inference is buggy
13:11justin_smithhaha
13:11xemdetiaI just abuse emacs keybindings to my function keys
13:12xemdetiaso I can program like it's 1974
13:12justin_smithxemdetia: as if emacs was brand new, and vi doesn't exist yet, and most people are using line editors?
13:12xemdetiajustin_smith, yes
13:13xemdetiabut really I don't know why people don't use function keys for that class of moderately used commands
13:13xemdetiathings like f10 for hide-show-toggle
13:13xemdetiais really nice
13:14justin_smithxemdetia: because they are so far from the home row (that's my excuse at least)
13:14justin_smithperhaps if my fingers were longer...
13:14TimMcYou just need longer tentacles: http://fc04.deviantart.net/fs71/i/2011/029/8/3/emacs_user_at_work_by_earlcolour-d38aj2x.jpg
13:14xemdetiato be fair my hands are massive
13:15justin_smith(inc TimMc)
13:15lazybot⇒ 100
13:15xemdetiaI have an external keyboard in front of my laptop and I can use the touchpad with the heels of my palms resting on the external keyboard below the space bar
13:15TimMchha wow
13:16xemdetiaI do have a slim external though compared to most
13:16justin_smithxemdetia: kinesis freestyle 2 (the one that's split in half) with a trackball in the middle of the two halves, with the two halves of the keyboard tented
13:17xemdetiajustin_smith, belkin $10 special straight from a dumpster, glazed with two unique spills of coffee
13:17justin_smithTimMc: it's funny that the caption says emacs user, but the mug has a blender logo
13:17justin_smithxemdetia: sweet
13:19xemdetiabut yeah I love my function keys
13:19justin_smithxemdetia: I have a half-baked 1/4 completed project that ties a midi controller to emacs
13:19xemdetiaf3 for grep-find, f4 for neotree, f6 for magit status and f10 for hs
13:19xemdetiathat I remember off the top of my head
13:20justin_smithxemdetia: so I can use things like my foot pedal board, or a drum pad controller for functions...
13:20bjaI eventually gave up on function keys for space and space space as leader/localleader
13:20xemdetiajustin_smith, I always hear of people trying to use foot pedals for things but I just can't figure out what key I would put on it
13:20justin_smithxemdetia: one example - a rocker pedal as absolute mode scroll bar
13:21xemdetiayeah but generally at that point I shift back to coffee/mouse interface and scroll
13:21justin_smithfor evil, a footpad for escape, and another for :
13:21justin_smithxemdetia: foot pedals for control / alt / shift
13:21justin_smithlike a clutch for emacs
13:22justin_smiththis is all theoretical for now, maybe it's totally unusable :P
13:22xemdetiayeah but honestly compared to some people I really don't use that many extended key chords that not just using a finger to do it wouldn't be adequate
13:22xemdetiathat's the use case I've struggled with
13:22justin_smithone of those "it's the weekend and I had way too much coffee and wouldn't this be neat" kind of things
13:22xemdetiayeah
13:22xemdetiaI mean you have things like C-x v l for source control log
13:23xemdetiaso you just hit the pedal for one key press?
13:23xemdetiamy brain can't do that
13:25blakewAnyone using Wildfly? Or just me. =P
13:25xemdetiaI feel like rigging up some sort of external pad for extra functions to slap and maybe a large lever for save would be more effective than a pedal and more appealing
13:26justin_smithI often talk about how awesome component is, but I just found another way it is awesome. I am adding onyx to my webapp, and by defining an alternate (optional) main namespace, I can use the same uberjar as used for the http server, with a different set of components, reusing the shared functionality and config. Win!
13:26bjablakew. I'm using undertow
13:26bjanot full on wildfly though
13:27justin_smithxemdetia: sure, the midi thing would work the same with floor or table devices, the rest is just wiring up the bindings.
13:28blakewbja: Hmmm. I might check it out. I'm trying to debug a Widlfly situation and finding my Clojure WAR, when I deploy it, ends up with Wildfly routing 8080->8443 (and not working). Just trying to tease out what the problem is. (I've been deploying for a while.)
13:29justin_smithblakew: is this via immutant?
13:29bjablakew, I've been meaning to move to this: http://immutant.org/documentation/2.0.0-beta1/apidoc/immutant.web.html but am currently running via https://github.com/piranha/ring-undertow-adapter
13:30blakewjustin_smith: Nah. I just lein ring uberwar my compojure app.
13:30blakewbja: Yeah, I'm planning to switch to immutant.
13:30justin_smithahh, so just using it like it was any other app container, interesting
13:30bjafwiw, ring-undertow-adapter does seem to work well, but I'm deploying an uberjar proxied behind nginx
13:30blakewbja: Good to know.
13:31blakewjustin_smith: Yeah, it's been working fine. But I've got an issue and have been trying to rollback to a working situation, and realize I don't know enough about Wildfly to know how to debug.
13:32justin_smithblakew: I never really got tomcat working reliably with hotswaps, and just gave in and restarted the app when redeploying. It felt like a defeat, but it worked.
13:32justin_smithnot that immutant has the same issues, and for all I know the fix might have been simple but something I haven't tried yet
13:33bjaheh, just checking my codebase and noticed my new-web-server constructor for my wildfly component has a docstring of "Creates an HTTP-Kit component with an injectable ring handler"
13:33justin_smith~comments
13:33clojurebotcomments is http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/commenting.html
13:33justin_smithclojurebot: broken link, yo
13:33clojurebotexcusez-moi
13:33blakewheh
13:34blakewjustin_smith: We've been live-swapping with Wildfly for months without trouble.
13:35justin_smithnice!
13:36jcrossley3blakew: are you seeing the problem on a vanilla WF install? what version?
13:36TimMcjustin_smith: Hmm, you think it was originally a joke about Blender?
13:37blakewjcrossley3: I was using clean Wildfly 8.2, then I tried 9. I'm not 100% sure what I'm using on my other servers.
13:37justin_smithTimMc: they do have crazy keybindings... but blender is also a tool that would be used to create an image like that regardless of the target of its mockery...
13:37TimMchaha
13:37justin_smith~blender |is| the emacs of 3d
13:37clojurebotIk begrijp
13:37TimMcOr it could be... "OK, I need to put something on the mug, need a logo... here we go."
13:38justin_smithyeah
13:39xemdetiablender really is the emacs of 3d though
13:39xemdetiaso much python doing all sorts of magic
13:39justin_smithand the wacky keybindings (though more chaining than chording I guess)
13:39jcrossley3blakew: not sure off the top of my head, but do you by chance have a security-constraint in your war's web.xml that might be triggering the reroute?
13:42blakewjcrossley3: Maybe. It's root and it looks like root ends up covered by the default.
13:43blakewWait...could this be an upgraded lein thing?
13:44jcrossley3blakew: not sure, but maybe a later version is adding the security constraint to the web.xml it produces?
13:56blakewjcrossley3: Yeah, I think that's gotta be it.
13:56jcrossley3blakew: easy enough to check. remove the <security-constraint> :)
13:57blakewjcrossley3: Heh. Can I do that inside the WAR?
13:58jcrossley3blakew: well, unpack it, edit web.xml and repack. emacs makes that trivial, if you're using it.
13:59blakewjcrossley3: Dammit. If it's that, then how come I get it on old versions? They're all using the project.cljs used to create them previously, so they should work.
13:59blakewI guess the real question is what creates that web.xml?
14:01jcrossley3lein-ring, but it doesn't appear to add a security-constraint: https://github.com/weavejester/lein-ring/blob/master/src/leiningen/ring/war.clj#L103
14:02jcrossley3blakew: i would start by confirming you actually have one in your web.xml
14:02blakewjcrossley3: I do. And I've taken out and am trying to redploy.
14:06blakewWelp, that fixed it. So...now I just gotta figure out how I'm putting it in there.
14:07clojer_A Reagent app with :optimizations :advanced produces a 446Kb file containing React 13 minified but the Reagent code isn't minified. Are there any other settings I need to get the file size down?
14:18justin_smithclojer_: you may get a better answer on #clojurescript
14:21dnolenclojer_: doesn't really sounds plausible, what build tool?
14:59seangroveAnyone have a lobsters invite?
15:04blakewjcrossley3-away: OK, my web.xml is the thing with the security constraint. I've been using the same one for 5 months but now it's a problem. :-/
15:25joschkaTL;DR can you look at my first clojure code and tell me what you think? http://sprunge.us/FLgK Hi there, I just began learning clojure and started by solving an easy to solve problem in clojure. I wrote most of the functions in a recursive manner, trying to stick to the functional coding style as close as possible. My question is: should I do this everywhere in clojure? Does this benefit performance or is it
15:25joschkagenerally better to write in a 'procedural' style?
15:27amalloycfleming: the cursive plugin is refusing to load, saying the version i'm using has expired and i should download a new one. this seems like a crazy policy for a plugin to have, but i'm fairly sure you are not crazy so i would love it if you could tell me why this happens
15:29justin_smithjoschka: in general we don't often write recursive code in clojure, we have nice higher level functions that wrap that sort of thing (reduce, map, iterate)
15:29justin_smithjoschka: in particular, most code that is recursive and takes the rest of some seq at each step can likely be expressed as a map or reduce
15:30amalloyyou also have this pattern repeated twice: (if x true (if y false z)), which is better written as (or x (and (not y) z))
15:30joschkathank you this kind of advice actually helps me a lot
15:31justin_smithjoschka: additionally, the rare code that needs to be directly recursive should, if possible, use recur instead of self calls, clojure does not do self tail call optimization automatically, but only when explicitly invoked with recur
15:31joschkacan you point me to any well written, easy to entry clojure project that could teach me a couple of good techniques?
15:32amalloyhere is some code you should probably never write: (if (= 0 (count seq)) ...). if you are counting a seq, you can't process it lazily; and if you're counting it N times you are turning an O(N) algorithm into an O(N^2) one
15:32justin_smithjoschka: 4clojure exercises introduce a bunch of good basics, and if you follow some of the more active users you will see good solutions
15:33justin_smithamalloy: joschka: yeah, in the same paste you have (empty? sq) which is the right way to do it
15:33joschkajustin_smith: yeah, I probably recognized this myself later on in the process :P
15:36blakewSo, I'm getting warnings because I defined a database namespace with an "update" command. Actually, I get two: The first apparently because I'm using monger.collection, and it has its own "update" function, then in myown.mongo, because it has an "update" function, too.
15:37blakewThoughts? Bad form? OK because for everyone who uses them, it's always "alias/update"?
15:38amalloyit's a little tacky to share a name with a core function, but not a big problem. you should do so in a way that doesn't produce a warning, though, by managing your (ns) better
15:38Bronsablakew: exclude update from :refer-clojure and don't refer to monger.collection
15:39blakewBronsa: Is ":refer-clojure" implicit?
15:40blakewBronsa: Also, I only refer to monger.collection with an alias. I mean, I do need the functionality, so I have "monger.collection :as mc" in a require. No :refer.
15:40Bronsablakew: all of clojure.core is implicitly refer'ed, to avoid referring to one of its sym you have to use :refer-clojure, like so: (ns my-ns (:refer-clojure :exclude [update]))
15:41justin_smithblakew: you'll get that warning if monger.collection gets loaded. If you make a replacement that doesn't define "update" or at least uses an :exclude in the ns form I would use it :P
15:41Bronsablakew: then it's possible that the warning comes from monger.collection itself, it probably defines update but doesn't exclude it from clojure.core.
15:42Bronsablakew: update was added to clojure.core in 1.7, many libs defined their own without any need to exclude it, nothing you can do about it unfortunately
15:42justin_smithBronsa: yeah, that is definitely the case (get the same warning in our app right now)
15:43blakewBronsa, justin_smith: Aha...thanks.
15:46blakewI am finding some odd stuff with 1.7.
15:54puredangerif you're the first to find the duck wearing a hat, you get a star
16:26blakewI'd like a star.
16:28blakewI lost one when our chef died.
16:28seangrove"#clojure - where the chat is indistinguishable from markov bot chatter"
16:28dmitrig01justin_smith: instead of (def queen-indicator (first (seq "*"))) you can do just (def queen-indicator \*)
16:30dmitrig01justin_smith: also for valid?, you can do (defn valid? [[head & tail]] …), that way you save yourself from manually parsing that out
16:31justin_smithdmitrig01: you probably meant to direct those to joschka
16:31dmitrig01ack, you’re right :-)
16:31dmitrig01joschka: ^
16:31joschkadmitrig01: thanks :P
16:32dmitrig01(+ 1 x) is shorter as (inc x)
16:33dmitrig01(if (= 0 (count seq)) nil (col seq 0)) can be more concisely expressed as (when-not (empty? seq) (col seq 0))
16:33joschkadmitrig01: yes amalloy told me about that one :P
16:34dmitrig01empty? yes - but i’m pointing you to when-not as well :-)
16:34amalloydmitrig01: that is much better written as (when (seq xs) (col xs 0))
16:34amalloycombining not and empty? is a sin
16:35dmitrig01ah, you’re right
16:35dmitrig01joschka: also for your (cond) inside pair-diag?, you can just use (or (= y1 y2) (= x1 x2) (= 1 (/ (abs (- x2 x1)) (abs (- y2 y1))))
16:36joschkayes probably better
16:40Mongey_1hey, am I supposed to require something to use rename-keys ?
16:40dmitrig01joschka: overall - nice work!
16:40rasmusto_Mongey_1: isn't it in clojure.set?
16:40Mongey_1I'm getting 'Unable to resolve symbol: rename-keys in this context'
16:40rasmusto_(for some strange reason)
16:41dmitrig01joschka: also an algorithmic question - colrow and rowcol end up with the same result, right?
16:41joschkadmitrig01: yes
16:41dmitrig01joschka: i might just pick one and stick to it then, no need to allow both :-) but that’s more of a personal pref, depends on yoru goals
16:43dmitrig01joschka: also any reason to use (list) instead of a vector?
16:43joschkayeah this happened during the process and was needed for some other steps that were deleted during the process
16:43Mongey_1I guess I'm just requiring it incorrectly
16:44joschkano reason at all, a purely naive choice :D
16:44dmitrig01ah. it’s almost always recommended to use vectors instead of lists
16:44joschkaokay
16:44dmitrig01also! your addr-seq function can be expressed more concisely as just a map over the line-seq
16:44dmitrig01as far as i understand
16:45dmitrig01i know they were takling about that earlier :-)
16:45dmitrig01but it looks like a pretty textbook map to me
16:45joschkayes they did :>
16:46joschkaIn the future I am probably going to avoid writing recursive functions for every single problem and look at reduce, map iterate
16:47amalloyrecursion is pretty standard for n-queens though, isn't it
16:52joschkasneaky 4clojure, teaching me the recursion again :> https://www.4clojure.com/problem/57
16:53justin_smithjoschka: it gets to the other fun stuff too :)
16:53justin_smithjoschka: also, after the first bunch, the difficulty isn't always in order
18:58eriktjacobsenAny ideas on why something like: (pmap (partial foo (first id-list) :param) array-list) works fine but (map #(pmap (partial foo % :param) array-list) id-list) just hangs, never goes into the fn and just sits there forever until ctrl-c?
18:59justin_smitheriktjacobsen: is id-list infinite?
18:59eriktjacobsenNope, just 8 items, already realized / computed
19:00eriktjacobseneach of the 8 is about 200 strings with max length 40 char… (so pretty small)
19:01amalloyeriktjacobsen: are you typing exactly this expression into the repl, or using it in some larger expression? are you using the results of this map, or just doing it for side effects?
19:02eriktjacobsenExactly this expression, so the results of the map should go into repl. the function “foo” hits a web REST api, so I am looking for it actually hit that. And the former (without the extra map) does hit just fine and runs all the results into the repl
19:03eriktjacobsenNot sure if it matters, but the function foo does exectute 6 separate request all in futures that are realized in the result.
19:03eriktjacobsenbut doing the function foo in the pmap works fine one at a time, I just can’t get repl to iterate over it
19:09monstaDoes anyone here had work with JavaFx8, I would like to know how can reload a scene after a make some change in the repl
19:16justin_smitheriktjacobsen: so instead of printing the result of the map, the repl just hangs?
19:16justin_smitheriktjacobsen: you could try running jstack on the jvm to see what all your threads are trying to do
19:24eriktjacobsenjustin_smith: right. I have a println for instance as the first line in “foo”, and it never prints anything. doesn’t seem to be even running the inner map
19:26eriktjacobsenjustin_smith: thanks will look into that. If have any guides on how to see what repl threads are trying to do that would be helpful, normally it takes a lot of effort to run jvm profilers including using jar directly (no repl) and some pause statements to get anything meaningful out, because otherwise its a bunch of clojure internals that dont seem to mean anything
20:11joschkawhy is ({:a 4 :b 5} :a) a function (PersistentArrayMap) and how may I find the documentation of that form?
20:17tyler569For some reason I'm struggling to find documentation for you, but essentially you can call things like maps as functions, pass a key as argument, and get the value at that key
20:17tyler569it just ends up being more convenient
20:18tyler569if your keys are keywords it works the other way too
20:18tyler569(:a {:a 5 :b 6}) will return 5
20:19joschkatyler569: nice, thank you!
20:20joschkain clojure there seem to be a lot of those convenient features :P
20:21tyler569it also works for maps ([3 8 2] 1) -> 8, sets (#{:a :b} :a) -> :a, while (#{:a :b} :c) -> nil
20:21tyler569and any seqable as far as I know
20:21icedpWhy does partition-by doesn't work here instead of filter and remove? https://gist.github.com/9129621df3037383e8b8
20:49justin_smithicedp: ##(partition-by even? (range 10))
20:49lazybot⇒ ((0) (1) (2) (3) (4) (5) (6) (7) (8) (9))
20:49justin_smithicedp: that's different from filter/remove isn't it?
20:50Cr8,(partition-by #(quot % 3) (range 10))
20:51clojurebot((0 1 2) (3 4 5) (6 7 8) (9))
20:51Cr8,(partition-by identity "leeeerooooy")
20:51clojurebot((\l) (\e \e \e \e) (\r) (\o \o \o \o) (\y))
20:53Cr8icedp I think what you wanted was split-with?
20:53Cr8,(split-with #(< % 6) (range 10))
20:53clojurebot[(0 1 2 3 4 ...) (6 7 8 9)]
20:53justin_smith,(split-with even? (range 10))
20:53clojurebot[(0) (1 2 3 4 5 ...)]
20:53justin_smithCr8: only works if the subseq is sorted already
20:54justin_smithand if it's sorted already, you're done :P
20:54Cr8ah, prolly *aaaactually* wanted split-at then
20:54justin_smithCr8: there's no builtin that does what he wants
20:54Cr8,(split-at 6 (range 10))
20:54clojurebot[(0 1 2 3 4 ...) (6 7 8 9)]
20:54icedp,(let [f #(< % 5), xs (range 15)] (partition-by f xs))
20:54clojurebot((0 1 2 3 4) (5 6 7 8 9 ...))
20:54justin_smithCr8: once again, only makes sense with a partially sorted input
20:55icedp,(let [f #(< % 5), xs (range 15)] (list (filter f xs) (remove f xs)))
20:55clojurebot((0 1 2 3 4) (5 6 7 8 9 ...))
20:55Cr8split-at doesn't look at the values at all -- which is what you actually want, i think?
20:55justin_smithicedp: ##(let [f #(< % 5), xs (shuffle (range 15))] (partition-by f xs)) ;; breaks on unsorted inputs
20:55lazybot⇒ ((8 9 14 12) (2 3) (7 6) (4) (10 11 5) (0 1) (13))
20:55Cr8its a qsort impl?
20:55justin_smithicedp: just use filter/remove
20:56icedpCr8: yes
20:56icedpjustin_smith: I just wonder why it doesn't work. maybe partition-by doesn't support some lazy-cat 'stuff'
20:56justin_smith,((juxt filter remove) (partial < 5) (shuffle (range 10)))
20:56clojurebot[(9 6 7 8) (3 4 5 1 2 ...)]
20:56justin_smithicedp: that's not how partition-by is meant to work
20:57justin_smith(juxt filter remove) is likely the most elegant result you'll get
20:57icedpinteresting
20:57justin_smithicedp: partition-by splits the input at each change in value, but never re-orders input elements
20:58icedpah, now I got it
20:59icedp,(partition-by (partial > 5) [1 2 3 2 1])
20:59clojurebot((1 2 3 2 1))
20:59icedp,(partition-by (partial > 5) [1 2 3 6 1 ])
20:59clojurebot((1 2 3) (6) (1))
21:03icedp,(vals (group-by (partial > 5) [1 2 3 6 1 ]))
21:03clojurebot([1 2 3 1] [6])
21:04Cr8the order those come out in could be either though
21:07icedpthen I guess group-by and two get's. It's supposed to be faster then filtering two times filter + remove, right?
21:10Cr8,(let [p 5 in (shuffle (range 10))] (reduce (fn [[l g] i] (if (< i p) [(conj l i) g] [l (conj g i)])) [[] []] in))
21:10clojurebot[[0 1 2 3 4] [7 9 6 5 8]]
21:11Cr8not really using any clever built-in seq stuff, but if you want a single pass split-filter
21:14icedpI see, great
21:16justin_smithyeah, lazy-sort doesn't make a whole lot of sense anyway
21:26weavejesterDoes anyone happen to know why alter-var-root doesn't work with vars defined as part of a protocol, unless you explicitly use them as vars?
21:27amalloyweavejester: protocols do some nasty stuff to their vars
21:27justin_smithweavejester: when would alter-var-root work on something that isn't explicitly a var?
21:27justin_smithamalloy: oh, interesting, for the method slot logic I guess?
21:28amalloyi don't really know what you mean by method slot logic
21:28amalloybut it keeps information about implementations of the protocol function inside the var's metadata
21:28justin_smithamalloy: the protocol is backed by an interface that needs methods backed by the protocol methods, right?
21:28amalloywell it doesn't *need* them. you can choose to never use that interface
21:29amalloyweavejester: if the compiler detects that you are calling a function which is a protocol function, it emits code that, instead of calling the thing in the var, fiddles around with its metadata
21:29weavejesteramalloy: I was afraid it would do something like that :)
21:32dnolenBronsa: with the all various optimizations, cljs.tools.reader is within 3X of the JVM version under JavaScriptCore
21:33dnolen~130ms to read cljs.core on my desktop machine, not too shabby :)
21:33clojurebotGabh mo leithscéal?
21:37Bronsadnolen: wow, impressive. didn't know js performances were this close to jvm
21:38dnolenBronsa: can probably get w/in 2X with some more work