#clojure logs

2013-02-27

00:43dcolishalandipert: i have to say i find the similarities between these forms disturbing, but i dont see a nice way to factor them out without adding more complexity elsewhere or with a macro https://gist.github.com/dcolish/c810e10ea928d78c2ca2
00:44dcolishi came up with something close but innermost fn kept receiving the wrong arity for some reason
00:45Raynesalandipert: laser 1.1.1 has xml support.
00:47alandipertRaynes: sweetness, thx!
00:47RaynesI saw the ping and thought you called me sweetness for a second there.
00:47alandipertdcolish: it's kinda tricky too because they start with different classes
00:47alandipertdcolish: if it were me i'd probly leave as is, it's clear now what the differences are imo
00:48alandipertdcolish: and at least for me, a macro would make the situation less clear probly
00:48dcolishyeah its just turning out to be a mess; i guess i'm just not sure how far to push things and what is really idiomatic
00:48alandipertRaynes: na i can't ever visit you if you have a restraining order against me
00:50alandipertdcolish: are you making more than 2 of those functions?
00:50alandipertdcolish: because if you had like 5+ in play i'd say macro time
00:51alandipertRaynes: lol
00:52dcolishalandipert: no there is really only a need for a read and a write builder
00:53dcolishthose are really the only ops you can do against a cube
00:54dcolishits still way better than the raw interop i had before
01:01dcolishis it common to hoist inner java classes/enums into a flatter namespace?
01:05nonubywhats the easiest way to 3000 to $3,000 ? tried clj money backed by org.joda.Money but the only .toString yields "USD 3000.00"
01:07amalloy$google java currency format
01:07lazybot[Java Currency Number format - Stack Overflow] http://stackoverflow.com/questions/2379221/java-currency-number-format
01:07dcolishdid you set it to use grouping?
01:08nonubyyeah :D (.format (NumberFormat/getCurrencyInstance) 3000)
01:12dcolishseems like this would work http://joda-money.sourceforge.net/apidocs/org/joda/money/format/MoneyAmountStyle.html#ASCII_DECIMAL_POINT_GROUP3_COMMA ?
01:18dcolishhmm nope that's only for reading in
01:18dcolishwhat a confusing api
01:20nonubyjust went with java.text.NumberFormat, cant see a need for heavy weight org.joda.Money
01:33lekuhey should I bother trying to get clojure going in Windows, or just run this on a Linux VM?
01:33lekulooks like leiningen might not be as well supported on Win as *nix
01:34rabbit_airstrikeI haven't tried running clojure on windows but I can tell you it's pretty frictionless in an ubuntu VM
01:34lekuyeah i'll just go to that
01:34lekuI wanted to play with the lighttable IDE, maybe I can connect to my project hostd on the ubuntu VM
01:36rabbit_airstrikewhoa, that looks like a pretty IDE :)
01:37lekuah I see you're unaware..
01:37lekuit was all the rage a few months ago I think because of a slashdot post
01:38rabbit_airstrikeyeah I'm kind of new at this community thing
01:39rabbit_airstrikea few months ago I was a research assistant in a cognitive neuroscience lab on the academic track. Then I took a bit of a left turn and became a software developer
01:40lekuhah cool
01:40lekuand you found clojure?
01:40rabbit_airstrikeit's what the company I joined was using, so I picked it up.
01:40lekucool
01:40rabbit_airstrikeI love it so much more than R and Matlab
01:40rabbit_airstrikeand I thought I loved R
01:40lekuinteresting
01:41lekuI was going to do the free codeschool.com class on R, haven't gotten around to it yet
01:41rabbit_airstriketrying to code in R after getting access to real primitive data structure support was tough
01:41rabbit_airstrikenamed lists just aren't the same as maps
01:42lekuhmm.. well i'm gonna get back to this
01:42lekuhttp://www.chris-granger.com/2012/11/09/lighttable-and-the-node-knockout/
01:43rabbit_airstrikeyeah, I'm totally going to look into that too
01:43lekuwerd
01:43lekuenjoy
01:48shriphanihi everyone. I have a question about using a java class with clojure. What is considered the best practice for (require [])'ing a java class ? Should we just do the namespace or is the class ok too ?
01:51leku(ns my-app
01:51leku (:use what.ever)
01:51leku (:require [what.else] :as something]))
01:59shriphanileku: I have another question about a require. I have this maven repo in my project.clj and lein deps runs ok. How do I go and import it (using require) in my project file: http://mvnrepository.com/artifact/org.jwat/jwat-warc
02:00lekui don't even know if i answered your qusetion i'm a clojure noob..
02:00lekui was just looking at some sample 'noir' code
02:00shriphaniah..
02:01lekusorry
02:01shriphaniI find clojure's error msgs quite hard to penetrate else I would've googled around.
02:05Sgeo_use/require is for Clojure code, to mention a Java class smoothly, you need to use import
02:05shriphaniSgeo_: I see.
02:06Sgeo_(ns blah (:import (some.package aclass))
02:06Sgeo_)
02:06Sgeo_I think
02:06Sgeo_(doc import)
02:06clojurebot"([& import-symbols-or-lists]); import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly."
02:06Sgeo_You should also be able to just use the fully qualified name of the class, without import
02:46FrozenlockIf I have two compojure webserver (A and B), would it be possible for A to connect to B, and then for B to become the 'client' while maintaining the connection? My goal here is to to browse A, which is behind a firewall, by using B.
02:50nonubyhiccup code, got a for loop (for [villa (get-villas) [:li (:villaName villa)]) but now I want to include the index so 0 - name1 1 - name2 and so forth, easiest way?
02:52Frozenlocknonuby: Not really the answer you are looking for, but there's now a css property to add count in a list.
02:52Frozenlockbut I don't remember the name... :(
02:52nonubyyeah but this public web facing so I dont think ie8 works.
02:53FrozenlockYou have a bad attitude. The correct attitude is 'fuck IE'.
02:54nonubymy clients is attitude is 'fuck you nonuby, 52% of our visitors are ie (with most being 8)
02:55FrozenlockSad...
02:55nonubyit is indeed
02:55FrozenlockA possible solution could be to use `dotimes'
02:58nonubysure someone will shoot me but what about (for [villa (zipmap (get-villas) (range)] (s-exp))
02:59nonubywith destructing (for [[villa index] (zipmap (get-villas) (range)] (s-exp))
03:04Frozenlock, (let [villas ["a" "b" "c"]] (->> (interleave villas (-> villas count range)) (partition 2)))
03:04clojurebot(("a" 0) ("b" 1) ("c" 2))
03:06efjbossmap-indexed would perhaps be better
03:06nonubyfound I can use (map (fn [villa index] [:p index (:name villa) ]) (get-villas) (iterate inc 1))
03:06nonubydoh map-indexed perfect fit
03:07Frozenlock'must use'
03:08headshot'must-use
03:08shriphanihi. another question about clojure. I have a java function that is to be used like while ((wrec = obj.getNextObject()) != null). Is there a way to wrap around this so that I can map etc in clojure. The while loop looks awkward in clojure.
03:09FrozenlockI'm not very good at reading java, but are you looking for `take-while'?
03:10shriphaniFrozenlock: the object isn't an iterator either.
03:13Frozenlock(take-while true? (enumeration-seq <some-java-enum>))
03:14FrozenlockOr is an iterator the same thing as an enumeration?
03:14Frozenlockarrr.. true? isn't the correct one
03:15shriphaniI could try using repeatedly on the object and wrap a seq that way.
03:15nonuby(take-while identity (repeat #(.getNextObject obj)) ) maybe
03:15shriphaninonuby: identity ?
03:17nonubyshould work (take-while identity [0 1 2 3 nil nil nil 4 5 6])
03:17shriphanioh so a java null is false in clojure ?
03:18shriphaniI'm sorry I am such a noob. I've only used racket in the past as my primary lisp.
03:18nonubynil is java null, and i null and false are the only falsey values in clj - i believe (newb here too)
03:18FrozenlockI don't think null is in clojure...
03:18Frozenlock, null
03:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: null in this context, compiling:(NO_SOURCE_PATH:0:0)>
03:19FrozenlockBut I know nothing of this dirty java :p
03:20shriphanigoogle tells me a clojure nil is a java null.
03:20shriphanishould I trust that ?
03:20nonubyyes
03:21nonubyverify by inversion (.indexOf "abcdef" nil) gives you a null pointer exception
03:24shriphaninonuby: that seems to work. Thank you very much
03:28pwnedwith all the parentheses clojure still looks short https://gist.github.com/anonymous/5046280
03:29shriphanihi. I have another question. I can see that the docs allow something like obj.foo(). How do I do obj.foo.bar() ?
03:29shriphani(foo/bar obj) isn't working.
03:29nonubycould be written (map (partial * 2) [1 2 3]) technically longer but no # or %
03:30Raynesshriphani: Count the parentheses.
03:30shriphaniRaynes: my editor says the parens are balances.
03:30nonubyshirphani (-> (.foo obj) .bar)
03:31shriphaniwow wtf...
03:31pwnednonuby: so partial is lambda ?
03:31RaynesThe Ruby and Python versions both have 4 brackets of varying types. The Clojure version has 6. That means there are merely two more brackets than those other versions.
03:32RaynesThe distance between them isn't that great.
03:32RaynesIt's more about where the parens are in the Clojure code.
03:32pwnedRaynes: yes, for some reason sexpr start and end with parens
03:32pwnedI wish it didn't.
03:32nonubypwned, I would have to google what exactly the formal definition of lambda is, but partial returns a function ready to use, currying I believe its called
03:33RaynesThat isn't currying.
03:33RaynesIt's partial application.
03:33pwnednonuby: can partial take multiple params ?
03:33nonubyshirpani you could do (.bar (.foo obj)) too but in instances like such the -> macro works well
03:33pwnedsay partial * partial [1 2 3] [3 4 5]
03:33pwned[1* 3 2* 4 3* 5]
03:34nonubyyes (map (partial * 2) [1 2 3] [1 2 3])
03:34RaynesClojure's lambda is (fn [args] body) or #(body). In the #() version, args are referred to as % %2 %3 an so on where it is the first, second, and third arg (and so on) respectively.
03:34nonubyyes (map (partial * 2 10) [1 2 3] [1 2 3])
03:34pwnedoh ok
03:34pwnedthat's cool
03:36shriphaninonuby: is there a cleaner way of doing that ?
03:38nonubyin addition to -> macro? Im not sure, still stratching the surface of clojure myself
03:38nonubyscratching
03:41pwnedRaynes: I guess I'm doing it wrong. (map (fn[a](* 2)) [1 2 3]) gives me (2 2 2)
03:42piskettiYou need to use the argument
03:42RaynesYou're doing (* 2).
03:42Raynes&(* 2)
03:42lazybot⇒ 2
03:42nonubypwned if you want to do it that way use (map (fn [a] (* 2 a))
03:42pwnedI know what I'm doing wrong. Clojure isn't QBasic you don't just learn it by guesswork :-)
03:43borkdudepwned you learn a lot by guessing and messing and then turning to the books, and then messing and guessing again
03:43pwnedoh I forgot the operand order
03:43nonubyclojure koans really helped me https://github.com/functional-koans/clojure-koans
03:43pwnedalmost did it with guesswork : D(map (fn [a] (* a 2)) [1 2 3])
03:44pwnedook thanks a lot people
03:45borkdudehmm, using :D as a repl prompt, it might be nice
03:45borkdude:D (+ 1 2 3) ;;=> 6
03:46pwned=> becomes :)
03:46pwnedyou can call this "nice repl"
03:46borkdudepwned the joy of clojure
03:47shriphaninonuby: that take-while solution you gave me doesn't terminate.
03:48shriphaniand doing a first on that seq produces a seq object. Do I need to do something else to get the contained object ?
03:51shriphaninonuby: nvm, I am an idiot.
03:56shriphaninonuby: can I show you some pastebin code. I am doing something stupid but I can't put my finger on it.
04:03shriphanihi. In this http://pastebin.ca/2317378, if I do (first (get-warc-seq stream)), I don't get a record object but a seq object (I think), what is the workaround?
04:07clgvshriphani: workaround? describe your problem and ask a precise question.
04:08shriphaniclgv: so I have a java function .getNextRecord which returns null when it is out of records to return. I turned it into a clojure seq using get-warc-seq. Now that doesn't seem to terminate and I am out of ideas.
04:08clgvshriphani: one first hint, since you seem to aim for side-effects you need to use `repeatedly` instead of `repeat`
04:09shriphaniclgv: I see.
04:09clgvshriphani: yeah thats because of `repeat`. it will return the first object infinitely
04:09shriphanio.
04:10clgvshriphani: if you want to use side-effects there is often a second function in clojure, e.g. `for` vs `doseq`
04:13shriphaniclgv: thanks that was very helpful.
04:13shriphaniAlso, what is the deal with contrib? I see it used a lot on s/overflow questions.
04:14clgvshriphani: there is no single all-in-one contrib lib anymore. instead there are several standalone libs which are hosted on github under the `clojure` group
04:15clgvshriphani: and of course there are a lot of third-party or "non-official" libs for a lot of purposes available
04:33NeedMoreDesuCan I have clojure.lang.DynamicClassLoader in Thread/currentThread.getContextClassLoader, when running uberjar with java -jar?
05:02myewhat is a good way to protect state when reloading files in the REPL eg. a database connection?
05:03myeI tried bound? with refer and a def but that lead to all kinds of pain
05:03nightflydefonce
05:04myenightfly: thx!
05:21lekuhey i'm doing these clojure koans and i noticed something weird
05:21lekuwhats the best way to paste code here?
05:22bmaddygist.github.com works pretty well.
05:22borkdudeleku via refheap
05:22borkdudeleku this pleases Raynes so the chance increases he will help
05:22lekuhaha
05:22lekuok
05:23borkdudeleku also if you paste it via emacs to refheap it will please even more people, although this is a debated topic
05:23lekuwell i'm running this stuff in the repl
05:23bmaddyOh yeah, I forgot about refheap. Use that for Raynes. :)
05:23lekunot in the emacs repl
05:23lekuhttps://www.refheap.com/paste/11866
05:23borkdudeleku never mind, just refheap ;)
05:24lekui need to learn emacs better but one thing at a time (clojure)
05:24lekuso my question is around subvec
05:25lekuwhy is the 3rd vector in the list "and" and not jelly?
05:25katratxo"Returns a persistent vector of the items in vector from
05:26katratxostart (inclusive) to end (exclusive)."
05:26Raynes&(doc subvec)
05:26lazybot⇒ "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."
05:26RaynesOh, right.
05:26Rayneskatratxo beat me to it.
05:26katratxo:p
05:26Raynesborkdude: Yep, and I even got out of bed for this one.
05:26borkdudeRaynes didn't mean to wake you, sorry
05:26RaynesI wasn't asleep. :p
05:26lekuhmm
05:26lekuso i guess it's still a little unclear
05:26borkdudeRaynes please don't give any more details
05:26RaynesI had just laid down. I just heard the beep.
05:27RaynesOh God, no. I was *going* to bed.
05:27Raynes:p
05:27borkdude:)
05:27katratxoRaynes: every time you get mentioned you get a beep?
05:27RaynesA beep from my computer.
05:27RaynesI don't have a pager.
05:27lekupro-tip: don't sleep with a computer nearby
05:27borkdudeRaynes ah, hammock time, I totally get it
05:27RaynesI sleep with netflix going, leku.
05:27lekulol
05:27lekunice
05:27RaynesUsually people don't ping me until after I'm asleep.
05:27Raynes:p
05:28lekunetflix work on linux?
05:28lekui guess with flash eh
05:28RaynesNope, but I have a macbook.
05:28lekuah
05:28RaynesNetflix uses silverlight.
05:28octeforming a question is hard..
05:28lekuisn't microsoft trying to shitcan that?
05:28RaynesDunno.
05:29octei'm trying to understand zippers/xml/zip filters, if i have a zipper made from an xml doc with (xml-zip), i can extract values with zip.xml/xml->, but can i make a partial filtering and later on do more?
05:29octei'll show with code i think
05:29borkdudeI remember silverlight was mentioned in some magazine in 2006 or so, and I thought: maybe it's worth digging into this new thing, but I'm glad I never did ;)
05:30lekulol
05:30RaynesYeah, I wonder if Netflix ever said anything about whether or not it was worth throwing turds at Linux users.
05:30lekulast I heard MSFT was trying to get away from it
05:31octehttps://www.refheap.com/paste/11867
05:31octewhat would i do instead of the rows-object i create?
05:33Raynesborkdude: It was worth getting up for. Your comments made me chuckle. It was like "If you sacrifice your first born child, Raynesgod will make your crops grow far and wide and your wealth be plentiful!"
05:33lekulol
05:34borkdudehehe
05:35leku<3 clojure koans
05:35lekuthese are a neat way to learn a programming language
05:36bmaddyYeah they're a blast. After those 4clojure is a lot of fun too
05:38borkdudegtg
05:41lekuthanks bmaddy
05:41lekuI'll check that out next
05:42bmaddyYou can follow others on there and see how they solved problems. I've learned a lot that way.
05:43octenevermind, i figured it out.
07:09octehttps://www.refheap.com/paste/11869 is that idiomatic?
07:20hyPiRionocte: Actually, I'm not sure. maybe cond-> ?
07:21clgvocte: I think it is a bit confusing
07:21hyPiRionWell, actually, it's not that simple either.
07:23clgvocte: you are not really using a predicate there
07:23clgvocte: it seems you want a shortcut for `cond` to not have to write (string? x), (map? x) and so on
07:27clgvocte: you can write yourself a `condf` macro that does that
07:32octeclgv, yes
07:32octebasically what i want
07:37octethanks
07:37clgvocte: try (defmacro condf [expr & clauses] (let [x (gensym "x")] `(let [~x ~expr] (cond ~@(apply concat (for [[p e] (partition-all 2 clauses)] [(if (keyword? p) p `(~p ~x)) e]))))))
07:37clgvocte: syntax is (condf {} string? "string" map? "map" :else "unknown)
07:38octethat worked, thanks :)
07:40clgvocte: try with macroexpand to see if it expands right. I just wrote it down here without testing ;)
07:51octeclgv, impressive :)
07:51clojure-newbhi guys, how do I filter on this structure : ((:phone "234") ([:phone "123"] [:postcode "abc"])) only getting items which have nested items which include the ':postcode' item ? so I should get : '([:phone "123"] [:postcode "abc"])' returned
07:52clojure-newboh, sorry.. original structure should be : (([:phone "234"]) ([:phone "123"] [:postcode "abc"]))
07:54lekuare you doing some koans?
07:54clgvclojure-newb: are those maps you called `seq` on?
07:54clojure-newbclgv yes
07:55clgvclojure-newb: ##(filter :postcode [{:phone "234"} {:phone "123" :postcode "abc"}])
07:55lazybot⇒ ({:postcode "abc", :phone "123"})
07:55clojure-newbclgv: cool, thanks I'll have a go
07:56clgvclojure-newb: if {:postcode nil} must show up in the result you need to use #(contains? % :postcode) instead...
07:56clojure-newbclgv: no don't need to worry about that
08:06clojure-newbclgv: thanks for the help
08:06clojure-newball working here now
08:32wreckimnakedhey everyone
08:34wreckimnakedI was thinking about participating on gsoc2013 and developing something related to clojurescript seemed like a nice idea.
08:34wreckimnakedNow I'm having a look at the codebase to understand a bit more of its internals. Any tips on that?
08:35pjstadigwreckimnaked: unfortunately i don't know if there is a mentoring org for clojure this year
08:36wreckimnakedpjstadig: I saw something related on the mailing list, I'll look it up.
08:36wreckimnakedhttps://groups.google.com/forum/?fromgroups=#!topic/clojure/vDiha4tYC_s
08:56pjstadigwreckimnaked: oh, right on
09:07augustlis (= (count values) (count (set values))) a sensible way to check if a list contains duplicates?
09:08augustlseems (apply distinct? values) would be another way
09:09hyPiRionaugustl: yeah, that's what I'd use.
09:09augustlmakes more sense too :)
09:09hyPiRionhm
09:10hyPiRion,(apply distinct? nil) ; crashes though
09:10clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$distinct-QMARK->
09:10hyPiRionAnd an empty list doesn't contain dupes, so heh.
09:10augustlah, good to know
09:10hyPiRionYou could bypass it with, hm.
09:10augustlI wonder why it doesn't return true
09:10hyPiRion,(apply distinct? (gensym) nil)
09:11clojurebottrue
09:11hyPiRionthough that's not exactly idiomatic.
09:11augustlI call distinct with the result of a map operation so I'm safe for now ;)
09:18TimMc,(doc distinct?)
09:18clojurebot"([x] [x y] [x y & more]); Returns true if no two of the arguments are ="
09:19TimMcAh, it's an inequality operator, not a collection predicate. THat explains the args.
09:19TimMcThis would be irritating to debug: ##(distinct? [1 1 2 1])
09:19lazybot⇒ true
09:23hyPiRionTimMc: yeah, it's max-key all over again
09:23clgvaugustl: you could create a set while traversing the sequential and stop as soon as you find a double
09:23augustlTimMc: you have any idea why it doesn't have a [] version too, that always returns true?
09:23hyPiRionclgv: that's what distinct? does though
09:24hyPiRion,(distinct? (cycle (range 10)))
09:24clojurebottrue
09:24hyPiRionups
09:24hyPiRion,(apply distinct? (cycle (range 10)))
09:24clgvhyPiRion: ah, that function exists already. I knew only `distinct`
09:24clojurebotfalse
09:24TimMc,(doc distinct)
09:24clojurebot"([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"
09:24TimMcNot confusing at all, nope.
09:25TimMcaugustl: Seems like a bug. Check Jira.
09:25hyPiRionWell wow, that should be fixed
09:26hyPiRionwhen I think of it.
09:26augustlseems related http://dev.clojure.org/jira/browse/JDBC-31
09:26augustl..maybe
09:28AdmiralBumbleBeeman, I haven't been able to use clojure in months :|
09:29AdmiralBumbleBeeit's nice to have time again
09:29hyPiRionaugustl: related, but not exact. I'll pop up an issue and a fix later today.
09:30augustlhyPiRion: great :)
10:04jcromartiecan I not :use or :require a namespace created in a repl?
10:05jcromartiei.e. if I just do (ns foo) (def …) (ns bar (:use foo)) that fails
10:05jcromartiebecause it can't find a class or .clj file
10:36TimMcNullary distinct? should return true, yeah?
10:36TimMcThere are no two = elements.
10:37S11001001TimMc: yep
10:37TimMcAnd it preserves the invariant of (distinct? a b ... y z) implies (distinct? b ... y z).
10:54kittylystAm giving Emacs a spin for Clojure development - followed the instructions here: http://unschooled.org/2011/10/how-to-setup-emacs-for-clojure-on-mac-os-x-lion/
10:54kittylystbut am unable to get a REPL
10:54kittylystSyntax highlighting works, and there were a couple of errors when installing paredit
10:55kittylystAnyone have more up-to-date instructions?
10:55kittylystI am on Mac 10.7, Emacs 24.2
10:55dan_bif you have emacs 24 you can skip step 3 in those instructions I think
10:56znDuffkittylyst: my preferred approach is to use emacs-live, since that provides a single bundle with everything
10:56ivankittylyst: you want nrepl.el, https://github.com/kingtim/nrepl.el
10:56znDuffkittylyst: (and installing it as simple as a git clone)
10:56dan_bkitty: and then yeah, what ivan says
10:57znDuffkittylyst: ''git clone https://github.com/overtone/emacs-live.git ~/.emacs.d'' ...and start emacs, and you're done.
10:57dan_bI've only used nrepl foir about ten minutes but it looks a lot less crufty than swank
10:59kittylystNrepl is complaining about End of buffer: byte-code: End of buffer [3 times]
10:59kittylystAnd I don't seem to have anything which looks like a REPL :(
11:01kittylystInteresting. I'm seeing the ClassCastException I was getting yesterday
11:01kittylystException in thread "main" java.lang.ClassCastException: clojure.tools.nrepl.server.Server cannot be cast to compile__stub.clojure.tools.nrepl.server.Server
11:01kittylystI thought that got fixed after I hosed & reinstalled lein
11:09kittylystOK, weird. For some reason, lein is trying to download older versions of clojure - 1.3.0 & 1.3.0-alpha5
11:09kittylystAnyone seen this before / know if there's a funky default set somewhere?
11:09TimMckittylyst: Perhaps one of your dependencies has a version range?
11:10TimMcVersion ranges can cause some pretty weird behavior.
11:11dcolishSo I am trying to unpack a variable length vector into macro args, but i am finding that apply will not help me because I am using doto, https://gist.github.com/dcolish/5049108
11:12dcolishthere is a finite set of arities, so I could use a helper fn, however I'd like to try and see why the apply doesnt work with doto or if it is possible to unpack the vector as I had hoped
11:15kittylystTimMc: Indeed, it was a dodgy dependency. Thx
11:15llasramdcolish: Not quite following... Do you have an example of what you'd like to be able to do?
11:15TimMcdcolish: You're still trying to use macros inappropriately.
11:16dcolish:(
11:17dcolishso that's just a simplified macro of the one I am actually attempting to write because the real one requires a few depenedencies
11:17znDuffdcolish: What's the reason for using a macro rather than a regular function?
11:18dcolishI have a few functions which have roughly the same form and I wanted to see if they could be done using a macro
11:18dcolishits entirely academic
11:18ohpauleezthat was my comment as well - a function would do fine here
11:18TimMcdcolish: Try doing it as a fn, first.
11:18znDuffdcolish: how about looking at whether they can be done with a higher-order function? :)
11:18ohpauleezahh gotcha
11:18TimMcdcolish: https://gist.github.com/anonymous/5049173
11:19TimMcOh, new is going to be an issue, nvm.
11:19dcolishthat wont work
11:20dcolishoh you got it
11:21TimMcdcolish: OK, then this: https://gist.github.com/anonymous/5049196
11:21gfredericksif I have :omit-default-repositories true in my project.clj and don't mention clojars anywhere, it's not going to accidentally deploy to clojars, correct?
11:21dcolishthis is roughly what i am trying to do https://gist.github.com/dcolish/5049199
11:21dcolishwell yeah, but i wanted to have it instansiate in the fn and not as an arg
11:22dcolishi thought having it as an arg didnt look as nice
11:22TimMcdcolish: Ah, so you want to unpack a set of arguments to a method.
11:22dcolishyup, the (.at)
11:22TimMcdcolish: OK, that may be appropriate for a macro. :-) The first step is to write down a sample invocation and the syntax that the desired macro would emit.
11:22dcolishso i can do (fn [obj# [x# y#]] ..., but thats not general enough
11:23dcolishif you see the two defn above that macro in progess, the (.at x y) or (.at x y z) is what i am attempting to unpack
11:23znDuff...well, it _can_ be done without a macro, but involves reflection.
11:24dcolishznDuff: definitely true
11:25dcolishi guess the goal is to make the java look more like clojure and i felt that having (Class. ) as params everywhere didnt really accomplish that, neither did reflection.
11:25dcolishi can't stress enough that its purely asthetic
11:25dcolishand to see how it could be done
11:26znDuffWaitamoment -- do you control the Java API here?
11:26dcolishyes
11:26znDuffIf you do, and use varargs, then this is all trivial/mooted.
11:26dcolishthats a good idea, unfortunately the argument types are different
11:27znDuff...so it's Object... then
11:27dcolishheh
11:27dcolishtrue
11:27znDuffThere was a link to the Java end of this yesterday, no?
11:27dcolishwell the java API is using generics here and I would probably have my commit access revoked if i pushed code like that
11:28dcolishyeah, here it is https://github.com/urbanairship/datacube/blob/master/src/main/java/com/urbanairship/datacube/WriteBuilder.java
11:28znDuff*shrug*. It's still Object... in the generics case -- just a compiler fiction that pretends otherwise. :)
11:28TimMcdcolish: https://gist.github.com/anonymous/5049270
11:29TimMc(builder (StringBuilder.) .append [1] ["a"])
11:29znDuffdcolish: I don't see how that API would be accepting a list of arguments at all here.
11:29dcolishznDuff: yeah, i know... well i could write a small vararg wrapper in my clojure project
11:29dcolishznDuff: it doesnt, thats why i want to unpack the vectors
11:30znDuff...okay. So this isn't arbitrary-length vectors.
11:30znDuffThis is easy, then. :)
11:30znDuffNo need for a macro if you aren't handling arbitrary argument counts.
11:31dcolishwell sure, i could also use a variable arity helper
11:32TimMcdcolish: Is this what you want? https://gist.github.com/timmc/5049288
11:32dcolishTimMc: i'm checking out that first link you pasted, let me see
11:32TimMcThe second expands on it.
11:33dcolishah yes, that is what I am trying to accomplish
11:33dcolishthere's a lot of new stuff in there, I'll have to study that for a bit
11:33TimMclist* is just apply list
11:34TimMcoh, except it returns a seq, just to confuse you
11:34gfredericksa non-list seq
11:35gfredericks,(map list? ['(1 2) (list* [1 2]) (list* '(1 2)])
11:35clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
11:35gfredericks,(map list? ['(1 2) (list* [1 2]) (list* '(1 2))])
11:35clojurebot(true false true)
11:35gfredericks,(map list? ['(1 2) (list* [1 2]) (list* '(1 2)) (list* 17 '(1 2))])
11:35clojurebot(true false true false)
11:35dcolishoh thats fun
11:35dcolishis that because its the result of an apply?
11:36gfredericks,(type (list* 7 '(1 2)))
11:36clojurebotclojure.lang.Cons
11:36gfredericksa cons is not a list apparently
11:36gfredericksI think this is because lists are supposed to know their length, but list* can't do that without walking a potentially lazy sequence
11:37dcolishis list a protocol?
11:37gfredericks,(nth (list* 1 2 (range)) 20)
11:37clojurebot18
11:37gfredericks,(nth (apply list 1 2 (range)) 20)
11:37clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
11:38dcolishah yes list returns an IPersistentList
11:38gfredericks,(supers (class (list 1 2)))
11:38gfredericks&(supers (class (list 1 2)))
11:38lazybot⇒ #{clojure.lang.Counted clojure.lang.IObj clojure.lang.Sequential java.io.Serializable clojure.lang.IPersistentCollection clojure.lang.Seqable java.lang.Object java.util.List clojure.lang.ISeq clojure.lang.Obj clojure.lang.IPersistentStack java.util.Collection c... https://www.refheap.com/paste/11879
11:38gfredericksjava.util.List is an interface
11:38dcolishTimMc: ok I see why that works, thank you for the help
11:43TimMcdcolish: clojure.template may also be interesting to you.
11:44dcolishoh, that is pretty cool
11:45dcolishalthough, i do worry that i'm not doing things the clojure way
11:49kittylystTimMc: Spoke too soon. Actually looks like it's being caused by running Clojure on OpenJDK 8
11:50TimMcdcolish: I'd not use that builder form myself unless there were at least (I don't know) 6 invocations with the same method in one block.
11:50TimMckittylyst: Oh? That doesn't make sense to me.
11:55kittylystMe neither
11:55kittylystBut it does seem to be the factor
11:56kittylystI reduced my test case to a lein new ; lein repl
11:56kittylystTimMc: Crashes on 8, not on 7
11:57kittylystTimMc: If I can find someone who knows the Clojure internals better, I could help debug from the JDK8 / JVM side
11:57kittylystTimMc: I am not that good at Clojure's innards yet :(
11:58kittylystTimMc: I know that 8 has classloading changes which may be relevant here ...
11:59antares_ohpauleez: hey, do you have a couple of minutes?
12:09degIn Emacs, what keystroke will abort a runaway evaluation in nrepl?
12:11arkxdeg: C-c C-b I think
12:12degarkx: Nope... and I don't see anything yet in the help.
12:12arkxhttps://github.com/kingtim/nrepl.el C-c C-b: Interrupt any pending evaluations. Also bound to C-c C-c.
12:13degYup... did work now... must have just been sluggish to respond.
12:13degThanks... I didn't want to lose the built-up state.
12:14jjl`is lobos the best thing for managing db migrations?
12:20antares_jjl`: lobos is a bit heavyweight, consider trying ragtime first https://github.com/weavejester/ragtime
12:22jjl`what are the tradeoffs?
12:22jjl`heh, named sql files
12:24jjl`okay, given that i'm using postgres and i can have ddl transactions (and thus ensure i only run a given migration once and if anything fails it will rollback), does ragtime actually buy me anything?
12:25dgrnbrgHello Clojurians! Does anyone know which classloader import uses to determine if a class exists?L
12:27znDuffdgrnbrg: Depends. Sometimes it's the thread context classloader, and sometimes it's clojure.lang.Compiler/LOADER
12:27dgrnbrg znDuff: I set the ContextClassLoader to be a GroovyClassLoader chaining to the old ContextClassLoader, which is Clojure's
12:28dgrnbrgbut when I do an (import ...), it fails and the stacktrace indicates it's only looking at the dynamic classloader from clojure
12:28znDuffdgrnbrg: How is *use-context-classloader* set?
12:28dgrnbrgtrue
12:28znDuff(also, to be clear -- while I've fought and bested this problem, that was a substantial while ago, and I've forgotten most of what I learned)
12:28znDuffdgrnbrg: Is this at a REPL? If so, are you using nREPL or Swank?
12:29dgrnbrgI looked at the code that import generates, and it appears to get *ns*, push a "context" enum value defined in compiler.java, then do class.forName on that
12:29dgrnbrgbut I don't understand what's going on--is it calling ns.forName?
12:31dgrnbrgohshoot
12:31technomancyjjl`: lobos vs ragtime doesn't really have anything to do with DDL or whatever; it has to do with finding the right level of abstraction. lobos attempts to offer an abstraction that's impossible to deliver upon.
12:32dgrnbrgI see, it happens becasue clojure.lang.Compiler.LOADER.isBound() == true, which causes it to bypass the contextclassloader
12:32ohpauleezantares_: Here now
12:33znDuffdgrnbrg: ...yup -- so, for instance, in clojure.osgi, we re-bind that: Var.pushThreadBindings(RT.map(Compiler.LOADER, aLoader));
12:34dgrnbrgGot it!
12:34antares_ohpauleez: I am writing an email about making http://clojure-doc.org more visible. Do you think it's a good idea to just ask for a link from clojure.org?
12:34dgrnbrgznDuff: So, should I be rebinding the Compiler.LOADER if I want to include another language's runtime?
12:34dgrnbrgznDuff: or should I set the Thread's contextClassLoader, and rebind the compiler.LOADER?
12:35znDuffdgrnbrg: *shrug*. Not sure. You'd have to go back in time 6-8 months if you wanted to talk to a version of me that had all this in their head. :)
12:35antares_ohpauleez: there is some stuff left to be done that I consider major, but beginners won't have to worry about it for a while (macros, gen-class, implementing clojure.lang.* interfaces for your own data structures, etc)
12:35dgrnbrgznDuff: heh :)
12:35antares_dgrnbrg: ask on the mailing list?
12:36dgrnbrgantares_: which mailing list?
12:36antares_dgrnbrg: clojure?
12:36dgrnbrgI'll give that a shot
12:37ohpauleezantares_: I would just write and say, "The community has worked hard at building up easily digestible documentation. I'd love to see it linked to from high-traffic areas like clojure.org"
12:38ohpauleezIt'd be a good idea to leave all politics out, just ask for the link :)
12:43gfredericksany tips for tracking memory leaks with jvisualvm?
12:43gfredericksjust knowing class names from heap snapshots doesn't seem to help too much
12:45antares_gfredericks: you can generate snapshots with allocation stack traces
12:46antares_gfredericks: http://rejeev.blogspot.ru/2009/04/analyzing-memory-leak-in-java.html
12:46gfredericksantares_: nice, thanks!
12:46jjl`technomancy: sorry, i wasn't clear. i can fake everything ragtime does by using DDL transactions, a migrations table and a trick that will trigger division by zero
12:47technomancyjjl`: I'm saying the advantage of ragtime is that it does *less* than lobos
12:47jjl`i'm inclined to agree with you
12:47technomancylobos tricks you into thinking it's possible to paper over the differences between various DB's DDL the same way it is with SQL
12:47technomancywhich is tempting, but false
12:47jjl`i'm just wondering if it buys me anything over my (admittedly pg-specific) hack
12:48technomancyOTOH even ragtime does to much IMO for some apps
12:48technomancyhttps://github.com/ato/clojars-web/blob/master/src/clojars/db/migrate.clj
12:48technomancyDB migrations can be simple enough not to justify pulling a library for them
12:49jjl`and my one concern from reading the ragtime documentation (at least with the lein plugin) is that changing databases could be a pain since it wants it hardcoding into the file. ideally i'd be able to pass in host and database via command line args
12:49jjl`(though in principle i like the lein plugin)
12:58pjstadigjjl`: you could also checkout http://github.com/pjstadig/migratus
13:07antares_if you care about Clojure documentation, please read this and pass the link on: https://groups.google.com/forum/?fromgroups=#!topic/clojure/3aBMazxVCrk
13:08bbloomsi14: run (source take-while) it should be pretty clear how to extend it to be a take-while-inclusive or whatever
13:09si14bbloom: yeah, I've already done that, thanks. Just had a hope that I'm missing something and this can be done reasonably without duplicating Clojure's code.
13:09bbloomsi14: it's not duplicating, you need a different function :-P
13:10bbloomsi14: don't be afraid to create your own utilities when you need them
13:11si14bbloom: ok :) thank you!
13:19shriphaniHi. I have a question about clojure. I see that the set! operates only on globals. is there any particular reason for this ?
13:20technomancyshriphani: good code doesn't use set!
13:21bbloomshriphani: it also operates on java fields
13:22shriphanitechnomancy: I have a choice of doing (count seq) and then (doall (l seq) (op l)) but is there a way to do it in step without a set ?
13:22joegalloshriphani: to echo technomancy, you might be looking at this and thinking "but i really need set!" and then answer is basically -- no, you don't.
13:23bbloomshriphani: your question isn't super clear, can you provide a paste on refheap ?
13:24Frozenlock,(-> :a str)
13:24Frozenlock... Cmon bot
13:24TimMcslobot
13:24Frozenlock,(-> :a (fn [x] (str x)))
13:24TimMc~ping
13:25bbloom&(-> :a str)
13:25lazybot⇒ ":a"
13:25FrozenlockAnywho, is it normal that the second one doesn't work?
13:25shriphanibbloom: I need to count the no. of items in a seq + do an op per item in seq, any way of doing that in 1 step ?
13:25TimMcFrozenlock: (fn :a [x] ...)
13:25bbloomFrozenlock: use macroexpand
13:25Bronsa&(-> :a ((fn [x] (str x))))
13:25lazybot⇒ ":a"
13:25bbloom&(macroexpand '(-> :a (fn [x] (str x))
13:25lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
13:25bbloom&(macroexpand '(-> :a (fn [x] (str x)))
13:25lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
13:25bbloom&(macroexpand '(-> :a (fn [x] (str x))))
13:25lazybotjava.lang.UnsupportedOperationException: nth not supported on this type: Keyword
13:25shriphaniI could use recursion but clojure doesn't seem to like tail-call-optimization so I am not sure.
13:25bbloomapparently i suck
13:26TimMc&(macroexpand-1 '(-> :a (fn [x] (str x))))
13:26lazybot⇒ (fn :a [x] (str x))
13:26bbloomTimMc: dur, thanks
13:26FrozenlockBronsa: Yeah that's what I'm doing in my code, but the additional paren is bugging me.
13:26Bronsa&(let [f (fn [x] (str x))] (-> :a f))
13:26lazybot⇒ ":a"
13:27Bronsaeither that or this
13:27bbloomFrozenlock: yeah, what Bronsa suggests
13:27BronsaI don't think there's another way to do it otherwise
13:27bbloomshriphani: is your seq expected to be large or of unknown size?
13:27bbloomshriphani: or is it generally going to be small?
13:27TimMc&(((((-> x (fn [] x))))))
13:27lazybot⇒ #<sandbox20321$eval56691$x__56692 sandbox20321$eval56691$x__56692@c986aa>
13:28FrozenlockBronsa: I like that a lot
13:29shriphanibbloom: yes. it is a set of records from a 1gig gzip file.
13:29bbloomshriphani: ok and you want to operate on the entire sequence?
13:29shriphanibbloom: filter about a third of the elements out.
13:29bbloomshriphani: ok, you probably want to use reduce
13:30bbloomyou can use a map as the reduction state with one key for the count, one key for the reduced set, etc
13:30shriphaniah. you're right!
13:30shriphaniis there a reduce quirk (like map has with lazy seqs ?)
13:30bbloom(reduce (fn [state x] ...) {:count 0 :result #{}} big-huge-seq)
13:31bbloomwhat quirk are you referring to?
13:31shriphanibbloom: I had to use doseq as opposed to map.
13:32bbloomshriphani: that's not a "quirk" so much as it was the fact that you need to eliminate laziness
13:32bbloomshriphani: does your operation have any side effects?
13:32bbloomit probably shouldnt....
13:32shriphanibbloom: it does print out stats of the records to a file.
13:33bbloomshriphani: reduce is eager, so it should't be a problem, but before i give you the go-ahead with that design let me ask another question
13:33bbloomshriphani: what is the nature of the stats? are they progress reports during the operation? or just a summary at the end?
13:33bbloomshriphani: are they a constant size? or does their size vary with the number of entries in the input?
13:37shriphanibbloom: records are not constant size, stats are mostly a summary at the end.
13:37bbloomshriphani: so just store your stats inside your reduce state accumulator
13:37bbloommake your reduction function pure
13:37bbloomand you can print the results at the end
13:37shriphaniright that sounds good.
13:37bbloomthis separates your side effects, making your code easier to test and modify
13:38bbloomif you want intermediate results, you can use `reductions` instead of `reduce` to see the intermediate values
13:38bbloom&(reduce + 0 (range 5))
13:38lazybot⇒ 10
13:38bbloom&(reductions + 0 (range 5))
13:38lazybot⇒ (0 0 1 3 6 10)
13:39shriphaniaha! that's pretty neat.
13:40shriphaniso another question. How slow is clojure compared to scala ?
13:40bbloomand you can even get progress reports occasionally!
13:40bbloom(take-nth 50 (reductions + 0 (range 1000)))
13:40bbloom&(take-nth 50 (reductions + 0 (range 1000)))
13:40lazybot⇒ (0 1225 4950 11175 19900 31125 44850 61075 79800 101025 124750 150975 179700 210925 244650 280875 319600 360825 404550 450775 499500)
13:43dnolen_shriphani: typical Clojure is probably compares favorably to a functional Scala style that emphasizes immutability. Clojure has a low-level subset of the language that is pretty zippy but few people write in it.
13:45shriphanidnolen_: ah. So both are about 2x C++ ? And in terms of memory usage ?
13:45rasmustocan anyone foresee problems using pmap with clojure.java.shell?
13:46ohpauleezshriphani: I have yet to write a real piece of production code that wasn't fast enough (or wasn't easily optimized)
13:46dnolen_shriphani: yeah performance of the JVM is the upperbound
13:47znDuff(for instance, choosing to use the map-based abstraction for Esper, with glue for Clojure keyword->value maps, vs using the Object[] abstraction)
13:47ohpauleezshriphani: Depends on what you're doing (if a lot of object allocations are happening and you're making a lot of ephemeral garbage). But like dnolen_ you're only really limited by the JVM
13:48znDuff...and it was actually possible to optimize that to a point where its performance was adequate without changing the abstraction -- but if I want to go much further with it, the library is going to need a rewrite to support that other form.
13:48dnolen_shriphani: programming in a functional style definitely works GC - fortunately the JVM is pretty good.
13:49ohpauleezznDuff: Yes, I guess I should clarify, I've certainly written naive code, that I later when back (either because I knew I had to or because of a profile) and easily adjusted.
13:49Raynescemerick: https://www.refheap.com/paste/11888 Is all I put together last night. It was mostly an observation that what I'm going to do might not be very interesting. One thing I'll point out is that it'd be nice if writing workflows was less densely documented.
13:50ohpauleezto follow on the GC point - I've dialed in both G1 and ParGC with great success, and with more pieces of JRockit moving into the standard JVM, it'll only get better
13:50znDuffohpauleez: *nod*. I wouldn't actually call the initial implementation naive in my project -- it just anticipated different (less performance-sensitive) use cases than the ones it was eventually used for, and knowingly chose to prioritize flexibility over performance for that reason.
13:51ohpauleezahh, just balancing tradeoffs :)
13:51znDuffohpauleez: ...by the way, have any starting points to reference re: GC tuning?
13:52ohpauleezznDuff: Have you done JVM based stuff before?
13:52ohpauleezlike Java or Scala?
13:52ohpauleezthere are a few general tweaking guides and overviews of the GCs
13:52znDuffohpauleez: I've owned Ops in a Java shop before -- actually spent a lot of time working with JRockit's profiling tools in that context.
13:53ohpauleezAhh good news for you then, supposedly all of those tools should be (if not already) available
13:53antares_ohpauleez: this is what I ended up posting, by the way https://groups.google.com/forum/?fromgroups=#!topic/clojure/3aBMazxVCrk
13:53ohpauleezbut it's been my experience each app, once "stable" involves its own round of GC and JVM tweaks
13:53cemerickRaynes: I'm not sure what's going on there. But, "less densely documented"? Like, there's some sweet spot between no docs and comprehensiveness that I'm missing? ;-P
13:54znDuffohpauleez: *nod* -- my current employer has a YourKit license, which is what I used when trying to work on performance in my current project. That said, the work I did was mostly around code changes, as opposed to being effective at tuning GC parameters, hence the question.
13:54cemerickRaynes: FWIW, a WIP: https://friend-demo.herokuapp.com/
13:55ohpauleezznDuff: Let me see if I can pull out some links for you. As I've said, I usually set targets, figure out the best options to adjust, turn one knob, measure, turn another knob, measure… until I hit the target
13:56cemerickRaynes: from what I understand of browserid, then the multi-factor workflow impl might be relevant
13:56Raynescemerick: More like it's a truck with 30 thousand pounds of information trying to drive over a bridge with 10 thousand capacity.
13:56ohpauleezMost of the stuff I need to adjust is latency sensitive, so G1 has been particularly great
13:56TimMc&((->> 5 #(class %&)))
13:56lazybot⇒ 5
13:57cemerickRaynes: I would have wrote a tighter README, but I hadn't the time.
13:57cemericks/wrote/written
13:57cemerickfeh
13:57ohpauleezantares_: That looks awesome
13:57TimMc"I didn't have time to write a short README, so I wrote a long one instead." -- Mark Twain
13:58TimMc(Looks like there are other versions of the quote, and many, many attributions.)
13:58bbloomYeah, that Mark Twain has a sick GitHub profile!
13:58cemerickI had no idea someone had applied it to READMEs before :-P
13:58bbloom:-P
14:01ohpauleezznDuff: It seems most of my favorite articles are listed here: http://www.javaperformancetuning.com/
14:02Raynescemerick: Anyways, the way personas works is: user clicks button on website, enters email; personas comes up with an identity assertion that is posted to your server and then you have to verify this assertion which my function does. If this is okay, user is auth'd. It's simple enough.
14:02cemerickSure, sounds fine
14:04RaynesMy tweet was last night was out of me not being able to see what I gain by integrating with friend over what I've got now. The amount of code that will be removed from refheap will be negligible. My primary motivation was to do it so I could use that new fancy rate limiting middleware that is integrated with friend, but I'd have to write a different workflow for my token-based auth for that anyways.
14:05Raynes- that first 'was'.
14:07cemerickRaynes: Sure. Friend isn't ever going to make things much easier for workflow implementors. The benefit is being able to trivially use multiple workflows and a single authorization regime in your apps.
14:08RaynesMultiple workflows?
14:08RaynesHow often do people use multiple authentication workflows?
14:08RaynesOr am I misunderstanding?
14:08cemerickconstantly
14:08cemericke.g. form-based for humans + HTTPS Basic for an API
14:08RaynesI've never had to log in with a username and password, then auth with openid and click a personas sign in button.
14:09RaynesOh, so separate workflows for different parts of things?
14:09TimMcParallel not series.
14:09RaynesAnd the benefit is that you use the same authentication function in both places?
14:09cemerickRaynes: or the same set of handlers/routes, if they're content-negotiated, etc.
14:09cemerickone piece of middleware, one policy throughout the app
14:10Raynes*shrug*
14:10RaynesI guess friend just isn't for me right now.
14:10cemerick~guards
14:10RaynesI feel like it'd make things wildly more complicated. Maybe it's just this specific scenario.
14:10TimMc$guards
14:10arrdem...
14:10arrdemis clojurebot down?
14:10TimMcWHERE ARE THE GUARDS
14:11arrdem~gourds
14:11arrdemno gourds either... eval someone?
14:11NeedMoreDesuHow can I reload program at runtime? I'm trying to make hot-updates, with program running.
14:11lazybotSEIZE HIM!
14:11cemerickthe bots have let me down
14:11TimMcI guess you're not their... friend.
14:11Raynes~gourds
14:12TimMchiredman: Can you cycle clojurebot? It seems to be down.
14:12TimMcNeedMoreDesu: Start it from the REPL, then use require with :reload as needed.
14:12hiredmanclojurebot: ping?
14:12TimMcNeedMoreDesu: You'll probably want to use defonce for bits of state.
14:13clojureboteval service is offline
14:13clojureboteval service is offline
14:13clojureboteval service is offline
14:13RaynesWe noticed
14:13RaynesWe noticed
14:13RaynesWe noticed
14:13pjstadigsqs backups again?
14:13TimMcAh, the ever-reliable cloud.
14:13pjstadighiredman: did you forget to pay your amazon bill?
14:13hiredmanclojurebot: ping?
14:14TimMcIntroduce latency in new and exciting places!
14:14NeedMoreDesuTimMc: I want to make java -jar runnable uberjar.
14:14arrdemhehehe
14:14TimMcNeedMoreDesu: mumble mumble nREPL drawbridge mumble
14:14hiredmanhmmm
14:14TimMchiredman: lazybot is being quite slow -- possibly coincidence?
14:15arrdemNeedMoreDesu: http://travis-whitton.blogspot.com/2009/09/hot-code-swapping-with-clojure.html
14:15arrdemTimMc: out from under my bridge!
14:16gfredericksdo folk use paredit in they repl buffer?
14:17gfredericksI only use it for editing sexpressions :P
14:18hiredmanTimMc: the irc part of clojurebot only allows 4 threads responding at a time, the eval service oomed, and some how all 4 threads got wedged there
14:18arrdemI mean that's all it's desinge for but I still find it cumbersome.
14:20antares_gfredericks: I do
14:22chronnogfredericks: I like to have it around whenever I'm writing sexps
14:22Raynesgfredericks: I do.
14:23Raynesgfredericks: ninjudd gave me some fancy elisp for using it in the nrepl buffer.
14:23Raynesgfredericks: https://www.refheap.com/paste/11892
14:27NeedMoreDesuTimMc: that code gives me CompilerException java.lang.IllegalArgumentException: More than one matching method found: submit, compiling:(NO_SOURCE_PATH:7) (line 20)
14:29amalloyRaynes: M-u, M-e? are you using ninjudd's keyboard layout too?
14:29Raynesamalloy: No.
14:29TimMcNeedMoreDesu: What code? The thing arrdem sent you?
14:30Raynesamalloy: I don't use those, I just haven't bothered to change them.
14:30arrdemTimMc: I assume so...
14:30arrdemNeedMoreDesu: (full disclosure) I saw that two days ago and haven't tried to run it yet.
14:31arrdemNeedMoreDesu: Imma give it a shot and see if I can duplicate. the post is from 2008 so the bit rot may be strong.
14:31NeedMoreDesuoh uh.~
14:37NeedMoreDesuarrdem: That would be nice, if you'll try. It would be sad if I can't handle that.
14:37arrdemNeedMoreDesu: k gimme a few.
14:43arrdemNeedMoreDesu: error confirmed
14:44NeedMoreDesuhm, what do one do with that error? Is there a way to say which method to use?
14:45arrdemyeah trying to puzzle that out now
15:03devnbest way to make this transformation?
15:03devnhttps://gist.github.com/devn/b356d6186d845ceadad5
15:03arrdemNeedMoreDesu: CHEEVO GET REPL SURGERY
15:04arrdemNeedMoreDesu: okay I got this working...
15:04arrdemit's a raw tty repl with no tab complete or anything so "
15:04arrdemcould use some attention"
15:04ohpauleezdevn: there's a function for that - I've used it, let me dig around
15:05devntree-seq maybe?
15:05devngroup-by?
15:06ohpauleezI think I used group-by, I had a seq of maps
15:09devnhm
15:09devnohpauleez: could you show me what you mean?
15:10ohpauleezdevn: Totally. My data looked similar to the second example on: http://clojuredocs.org/clojure_core/clojure.core/group-by
15:10alandipertdevn: invert? https://gist.github.com/alandipert/4949466
15:11ohpauleezYou could transform your data to have a vector of maps where :date :date1 and :date :date2
15:11ohpauleezthen group-by date or group-by metric
15:12ohpauleezdoes that make sense?
15:13devnohpauleez: i think so, playing with it now
15:14devnmassaging some data
15:14Raynesdevn: How are things?
15:14ohpauleezdevn: Solid - ping me if you stumble up on something, I'll give it a try
15:15devnRaynes: things are good :) and you?
15:15devnohpauleez: thanks
15:15RaynesExcellent.
15:15amalloydevn: https://gist.github.com/amalloy/5051301 ?
15:16amalloyit makes a nested map intead of this weird map-of-lists-of-maps-of-lists-of-maps thing
15:19devnword
15:19devnthanks
15:28gfredericksI upgraded to the new clojure-mode and now my RET doesn't automatically tab
15:28hiredman:(
15:28technomancygfredericks: someone pointed out that clojure-mode's behaviour was wrong
15:28hiredmannever upgrade
15:28technomancysupposedly C-j is the "correct" way to do that
15:29gfrederickstechnomancy: sweet, that works; thanks
15:29gfredericksnice to have two options
15:29technomancyI just rebound RET in my own dotfiles because I think it's dumb, but whatever
15:32amalloyi actually use C-j for the times i want to avoid clojure-mode's RET behavior (which is normally what i want)
15:33gfrederickstechnomancy: oh man yeah it's awful for pasting code
15:34hyPiRionhiredman: rebind RET to newline-and-indent then
15:34hiredmanhyPiRion: nope, never upgrade
15:34hyPiRionheh
16:04tyler_is there a way to switch threading order midway through? e.g.
16:04tyler_(->> (util/build-url "/v1/twitter/status" {:user-id 9429332 :par "user-id"}) (sh "curl") :out (json/decode true) pprint)
16:05tyler_i need the output to be first threaded not last thread on json/decode
16:22devnznDuff: I've heard spotty things about zookeeper
16:23znDuffdevn: Our ops team has had issues with it under heavy load, but the currently envisioned use case doesn't involve heavy load.
16:25hiredmanhttp://stackoverflow.com/questions/1479442/real-world-use-of-zookeeper
16:26hiredmanit is everywhere
16:26hiredmandatomic's ability to use riak for storage uses zookeeper
16:27joegalloi used it once to punish some misbehaving children, i made them watch the whole thing http://www.imdb.com/title/tt1222817/
16:28brianwongyeah that was a bad movie
16:32bbloomzookeeper is needlessly complex and provides an extremely poor programming model, but it can be forced to behave with enough blunt force
16:32bbloomnetflix has all the code you need: https://github.com/netflix
16:33bbloomhttps://github.com/Netflix/curator and https://github.com/Netflix/exhibitor
16:44heizHi! Tell me please why clojure evaluates special forms before looking up in scope.
16:48dnolen_heiz: because that's the way it is, you can't override specials.
16:48winkhmm, I'm just playing around with Racket and xexpr totally reminds me of hiccup
16:49nopromptoccasionally i'll get an java.io.FileNotFoundException when using macros with cljs and ring, any idea why this happens?
16:50nopromptonce i refresh it disappears though.
16:51hiredmannoprompt: you are using some kind of cljsautobuild and some kind of auto referesh for ring
16:52noprompthiredman: i'm using cljsbuild auto yes.
16:52hiredmanautobuild deletes the file before writing a new one, and your auto refresher hits the middle
16:53noprompthiredman: ah, yes that makes sense.
16:53hiredmaneither that or you are seeing the FileNotFoundException from your browser looking for a favicon
16:58patchwork,(take 2 "yellow")
16:58clojurebot(\y \e)
16:59patchwork,(str (take 2 "yellow"))
16:59clojurebot"clojure.lang.LazySeq@12cd"
16:59patchwork,(str (doall (take 2 "yellow")))
16:59clojurebot"clojure.lang.LazySeq@12cd"
16:59patchworkAnyone know how to get the first two letter from a string in a better way than that?
16:59patchwork*letters
16:59patchworkIt keeps printing "clojure.lang.LazySeq"
16:59patchworkeven with a doall
16:59patchwork?
17:00katox,(.substring "yellow" 0 2)
17:00clojurebot"ye"
17:01patchworkAh, java!
17:01patchworkno clojure way to do it?
17:01patchworkI can use java if necessary, was looking for a pure clojure approach
17:01frenchyp(apply str (doall (take 2 "yellow")))
17:02amalloy&(clojure.string/subs "yellow" 0 2)
17:02lazybotjava.lang.RuntimeException: No such var: clojure.string/subs
17:02amalloy&(subs "yellow" 0 2)
17:02lazybot⇒ "ye"
17:02patchworksweet, thanks!
17:05katoxcould anyone point me to some docs or blog how to get a reasonable workflow in cljs?
17:05katoxclojurescriptone looked promising but it's broken atm
17:05katoxI looked around and found only relying on cljsbuild auto to recompile and browser refresh
17:06katoxthis tutorial is quite nice https://github.com/magomimmo/modern-cljs/
17:06katoxbut the presented workflow is not very appealing
17:08pbostromkatox: might want to check out https://github.com/cemerick/piggieback too
17:10katoxpbostrom: thanks, will do
17:11katoxi didn't know there is a clojure-tools google group, another good hint there
17:11katox+ the first post I've seen is the guy from a clojure users group here in town ;)
17:22jasonbraycljs interop: If you need to pass a js fn into a js library you're consuming, how do you go about it?
17:22dnolen_jasonbray: just pass it in
17:22jasonbraypass the cljs fn?
17:23amalloycljs functions are just javascript functions
17:23amalloywell, "just". they're probably some other stuff as well
17:25jcromartieI just added a command to nrepl.el to speak the doc for the symbol under the point
17:25jcromartie:P
17:25jcromartieC-c C-p
17:25jcromartieno way to stop it though
17:25jcromartiethat will come later :P
17:25dnolen_amalloy: they really are just JS fns w/ some extra properties tacked on - which is a pretty normal pattern in JS land
17:27jasonbrayI suppose I'm surprised since we use clj->js for data structures, but that's great - thanks
17:28amalloyjasonbray: clj data structures can't be just js data structures, because theirs need to mutate and ours need not to. but functions can just be functions
17:28dnolen_jasonbray: there may be some performance arguments for doing things differently, but the convenience of being able to pass CLJS functions as JS fns is pretty high.
17:29jasonbraythanks fellas, interesting
17:32cemerickdnolen_: there are some subtleties that I haven't entirely grokked. e.g. with-meta yields a value that is fn?, but isn't goog.isFunction.
17:35dnolen_cemerick: oh right, because we add meta via reification, don't have a solution in mind for that.
17:36ravsterhey all
18:09katoxinteresting that cljs fns are just js functions
18:10katoxwhy is that if I have an event like onclick and a listener function (which is cljs) why does it stay the same on redefinition?
18:10katoxwhat's the intent
18:11dnolenkatox: because you assigned a value not reference.
18:12dnolenkatox: no way around that really - you can circumvent that in Clojure you have the indirection of vars.
18:12katoxdnolen: I noticed that cljs code reflects the change
18:13katoxso I guess there is a map but to js it's just a value then
18:13dnolenkatox: because you're using the name (a reference)
18:13katoxwell, I used domina.event/listen! so it was a bit opaque ;)
18:31shriphanihi everyone. I am trying to open a file (and append if it exists) in a specified directory. I am unable to find any path joining function in clojure.java.io. Where should I be looking ?
18:32shriphaniessentially, the python version to open(os.path.join(dirname, filename), 'a+')
18:32technomancyshriphani: clojure.java.io/file does that
18:48katoxdo I need clojurescript sources to run piggieback?
18:49katoxcljsbuild worked fine but piggieback complains that cljs.repl.rhino.RhinoEnv is missing
18:52Frozenlocksaperlipopette
18:52FrozenlockI successfully loaded a uberjared project into another one.
18:54shriphanihttps://www.refheap.com/paste/11905 Hi everyone. I am doing something stupid here. I am trying to create a csv file and write to it but I get a Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.Keyword . Can someone point out my mistake to me ?
19:05katoxbah, probably resolved
19:05katoxpiggieback needs a newer clojurescript version
19:06katox0.0-1424 just failed, it seems to work with an extra dependency set to 0.0-1586
19:07katoxthe older one came as a transitive dependency of domina 1.0.0, for the record
19:15amalloyshriphani: the args you're passing to io/file look bogus, as you'd expect from that error message
19:16amalloyon line 26
19:16shriphaniamalloy: I fixed that. Now it terminates silently but I don't see a csv file anywhere on the filesystem
19:17shriphaniamalloy: does :append expect the file to exist ?
19:55johnmn3what is the equivalent javascript: "var output = [];" in clojurescript? do I need to do something like as-array?
19:55dnolen(def output (array))
19:58johnmn3dnolen: thanks
20:12johnmn3when I have: "document.getElementById('list').innerHTML = 'blah' " would I use aset on that?
20:12johnmn3(aset (.innerHTML ...) "blah")
20:13dnolenjohnmn3: use (set! (.-innerHTML ...) "blah")
20:13johnmn3dnolen: Thank you sir!
20:13nopromptdnolen: i was curious about that. what's the difference?
20:14dnolennoprompt: aset is really for arrays, but can be used to mutate arrays or objects since it gets compiled down to foo["bar"] = baz;
20:15dnolenonly recommended for interop
20:15nopromptis there a place where stuff like aset, oset, etc. are documented?
20:15dnolenthere is no oset
20:15nopromptthe cljs book doesn't make mention of them.
20:16amalloydoesn't (.-innerHTML x) get munged/minified by the compiler, dnolen? i would have thought this is the kind of thing you want aset for
20:16noprompti saw oset! here https://gist.github.com/lynaghk/3856153
20:16noprompti'm guessing that might be outdated
20:16dnolenaset happens to have a dual use - but it's really intended to be used as it's used in Clojure
20:17dnolennoprompt: he's defined his own oset! at the top
20:17dnolenamalloy: Closure knows about common DOM symbols.
20:18nopromptomg. i think i need to take a break. :)
20:18nopromptcaught a cold over the weekend. :(
20:21johnmn3where do I read up on what the hyphen is for "(.-innerHTML ..." in all the cljs I see?
20:23nopromptjohnmn3: it's for property access
20:23johnmn3so only use hyphen if it is a property... and a property is... something that stores data...?
20:24nopromptjohnmn3: if you leave the - off it's a function/method call
20:24johnmn3k
20:25dnolenjohnmn3: on the JVM the distinction is not necessary, since the JVM knows whether something is a field or a method
20:25nopromptdnolen: beat me too it!
20:25dnolenjohnmn3: there are no methods really in JS, just properties. thus the need for a distinction.
20:26johnmn3k. So this: var files = evt.target.files; would be (def files (.-files (.target evt))) ???
20:26lazybotjohnmn3: Yes, 100% for sure.
20:26johnmn3thanks lazybot
20:26dnolenjohnmn3: no
20:26noprompt(def files (.-files (.-target evt)))
20:27dnolenor (def files (.. evt -target -files))
20:27nopromptlove that macro
20:27johnmn3oy vey.. I'm having trouble discerning between methods and properties
20:27nopromptjohnmn3: you're familiar with js?
20:27johnmn3no
20:28johnmn3first time here
20:28johnmn3do you have to be familiar with the object to know whether it is a property or method?
20:29nopromptjohnmn3: objects in js are fairly simple
20:29nopromptjohnmn3: var obj = {prop: "value"}
20:29johnmn3k
20:29nopromptjohnmn3: var obj = {prop: function(x) { return x }}
20:30nopromptso if i say obj.prop in the first case i'll get "value"
20:30johnmn3k, where "function(x) { return x}" is the value
20:30nopromptin the second case i'll get back the function
20:31nopromptif i wanted to call the function it'd just be a matter of obj.prop(1)
20:31johnmn3k, but if you want to return the function..
20:31johnmn3?
20:32nopromptin cljs you could still use .- to get the function
20:32johnmn3ok
20:32nopromptbut if you want to call it simple .
20:32johnmn3ok
20:32noprompts/simple/simply
20:34johnmn3so for var files = evt.target.files; why would it be: (def files (.-files (.-target evt))) ??? what makes you think they want to assign the function to files rather than the value?
20:34nopromptsince (funcname args …) is a function call in clj, cljs has to make a distinction between property access and "method" calls
20:34nopromptotherwise you'd end up trying to call a string or something and get complaints
20:34nopromptdnolen: did i explain that right?
20:34nopromptsometimes i feel like i suck at explaining things
20:35johnmn3its making a lot of sense.
20:35nopromptsince functions are first class citizens in js it's quite common to use them as property values
20:36bbloomprobably a good idea to have some javascript experience before digging into clojurescript
20:36nopromptjohnmn3: i tend to agree with bbloom in this instance
20:36johnmn3hmmm
20:36bbloomunfortunately, clojurescript inherints warts from both clojure and clojurescript, so you should probably be comfortable with each
20:37nopromptjohnmn3: js is fairly easy to pick up, it has some nasty gotchas though
20:37bbloomyou shouldn't need to be an expert in either, just basic debugging skills will help
20:37nopromptbbloom: +1
20:37johnmn3I'm pretty good with clj
20:37johnmn3better than with java, but I know java well enough
20:37nopromptjohnmn3: take a few days to play with javascript
20:38nopromptjohnmn3: it's pretty easy to use the browser console, or node js for that sort of thing
20:38johnmn3yea, I oughta do those online interactive courses
20:39nopromptjohnmn3: the js knowledge will be handy when you intended to use js libs from cljs
20:40nopromptunderstanding the semantics is a bit important if you want to be able to translate examples, etc.
20:40johnmn3if I'm not passing in a parameter, can I assume it is a property access?
20:42nopromptobj.foo is property access obj.foo() is a call
20:42nopromptbut i'm with bbloom on this one, pick up some js. it'll make more sense.
20:43dnolenjohnmn3: David Herman's Effective JavaScript looks good or Marijn Haverbeke's http://eloquentjavascript.net
20:43nopromptyeah that's a great free book
20:44johnmn3I'm on it folks... Thanks for the guidance!
20:44ryanfeloquent javascript is good
20:55tyler_what are thoughts on using if to test if value is set?
20:55tyler_should i do (if (not= nil search)
20:55tyler_or (if search
20:55bbloomtyler_: "set" depends on a bunch of things
20:56bbloomthere is a nil? predicate
20:56tyler_bbloom: checking existence
20:56bbloomand if-not
20:56bbloomso you can do (if-not (nil? search) ...)
20:56tyler_ah
20:56bbloomthere is also when-not
20:56tyler_bbloom: thnx
20:56bbloombut if you know for a fact search won't be a boolean, it's totally reasonable to just (if search ...) or (when search ...)
20:57tyler_search is a string
20:57bbloomtyler_: yeah, so just go with (if search ...)
20:57tyler_i feel dirty when i use if to check non booleans
20:58bbloomtyler_: *shrug* no reason, there are exactly two falsey values in clojure: nil and false
20:58bbloomthat's an intentional design
20:58tyler_i feel like they took that from ruby, and i feel dirty doing it in ruby as well
20:58tyler_heh
20:59hiredmanfeh, it certainly predates ruby
20:59bbloomtyler_: unlikely, considering "nil punning" is a very old idea
20:59tyler_ok
20:59tyler_ruby didn't influence clojure
21:01johnmn3okay, I think I have a question that is worthy of the present audience, with or without js knowledge... how do you map across a js object and/or array?
21:02tyler_(map js-object array)
21:02johnmn3so map just works then...
21:03tyler_i was tongue-in-cheek
21:03tyler_how to map over an array in javascript?
21:03johnmn3yea
21:04tyler_arr.map(function(element){ return element.foo })
21:04johnmn3k
21:04bbloomyou can't rely on that across browsers
21:05tyler_oh browser javascript?
21:05bbloomthat's why people use things like $.each in jQuery
21:05tyler_i don't touch that
21:05bbloomor underscore's _.map
21:05tyler_prolly underscore
21:05johnmn3well, I have a "for ..." construct in some example js...
21:05johnmn3can I replace that with a map, is what I'm wondering
21:06tyler_most if not all fors can be replaced with map
21:06bbloomjohnmn3: the behavior of "for" in javascript has a giant bag of caveats
21:06johnmn3and the specific object is: var files = evt.target.files; // FileList object
21:06tyler_why not ask in #javascript?
21:07johnmn3because I'm translating it to clojurescript
21:07brehaut"the behavior of javascript has a giant bag of caveats" FTFY bbloom
21:07bbloombrehaut: true story
21:07bbloomjohnmn3: clojure's protocols are extended to javascript arrays in some cases
21:08bbloomjohnmn3: same as with JVM clojure:
21:08johnmn3thats what I figured
21:08bbloom(map inc (array 1 2 3))
21:08johnmn3right
21:08bbloom,(map inc (array 1 2 3))
21:08clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: array in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:09johnmn3to-array?
21:09bbloomer, 'array is a function in cljs
21:09bbloomnott clj
21:09bbloomanyway, you get a seq when you map, not an array
21:09johnmn3k
21:09bbloomso you need to (to-array (map inc (array 1 2 3)))
21:10bbloomwhich is significantly less efficient since it's going to create a lazy sequence just to be mapped back to an array eagerly
21:10bbloomso, if you need perf or interop, consider using functions from Google Closure
21:10bbloomthat's what it's there for!
21:11bbloomgoog.array/map, for example
21:12nopromptthat's news to me. good to know.
21:12bbloomthink of Google Closure like the JVM Base Class Library
21:16nopromptwhere do clj->js, array, js-obj, and the like come from?
21:20FrozenlockHow does one test compojure in a repl? (handler "some-url") ?
21:25amalloy$google clojure ring spec
21:25lazybot[ring/SPEC at master · mmcgrana/ring · GitHub] https://github.com/mmcgrana/ring/blob/master/SPEC
21:27amalloyFrozenlock: ^
21:34Frozenlockamalloy: Thanks!
21:55tommo_,(* 1700 17)
21:55clojurebot28900
22:33xeqiis there a keybinding for clojure-mode to pretty print an sexp?
22:39FrozenlockSo many java errors.. Is there something about static methods that makes them not working with normal interop?
22:39Frozenlock(.method-name java-object args)
22:39gfredericksFrozenlock: you have to call them with (Class/method ...)
22:40Frozenlocko_O
22:40gfredericks,(Math/pow 3 4)
22:40FrozenlockI'll be back..
22:40clojurebot81.0
22:41FrozenlockWell that worked. Thanks :)
22:41FrozenlockNow I must remember that a method is not the same thing as a static method.
22:43Raynesgfredericks: You should write this Personas workflow for friend for me.
22:44Raynesimo
22:46gfrederickso_O I don't even know what that means
22:46brehautraynes is personas the thing you use for auth in refheap?
22:46Raynesbrehaut: Yes.
23:14mindbender1how do i troubleshoot a ring server that is giving me http error 503.
23:19mindbender1what is the default version of jetty in ring-jetty. Is there a way to specify a version?
23:20eggheadmindbender1: https://clojars.org/org.clojars.mmcgrana/ring-jetty-adapter
23:22eggheadmy mistake mindbender1: https://clojars.org/ring/ring-jetty-adapter/versions/1.2.0-SNAPSHOT
23:39johnmn3Okay, so with lein trampoline cljsbuild listen-repl ... What if I want to fire up the page on another computer to see how it interacts? The other machine attempts to reach back to "localhost:9000" and it ends up breaking the js on the page.
23:41johnmn3I'm thinking about putting in some kind of conditional, like "if a service is listening on localhost:9000, attempt to connect" but I don't think that can be done in js/cljs
23:41johnmn3oh, but I could do a try catch thing