#clojure log - Aug 05 2013

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 Raynes: And we have a programming language designed to do everything else.

0:00 callen: xeqi: what?

0:00 xeqi: no, this is me being lazy and writing a lein plugin for something stupid.

0:00 Raynes: You could write a parser to parse a subset of bash and turn it into conch code or something, but… bash already does that without the conch part. :p

0:03 xeqi: callen: I was just suprised to see a manual ssh to clojars

0:03 given `lein deploy clojars` is builtin.

0:03 callen: this is quickly becoming monstrous.

0:04 xeqi: does that do the pom and the jar too?

0:04 thank you for telling me that existed.

0:05 (scp "pom.xml" (str "/home/callen/code/trajectile/target/provided/" (last (clojure.string/split (last (filter #(re-find #"\.jar" %) (clojure.string/split (ls "-ltr" "/home/callen/code/trajectile/target/provided/") #"\n"))) #" "))) "clojars@clojars.org:")

0:05 there, shriek in horror you bastards.

0:05 see what you made me do?

0:05 * xeqi is sad

0:05 callen: xeqi: you shouldn't be, you're the one that told me about lein deploy.

0:06 I asked about this yesterday and it was *crickets*

0:07 well alright then, I can nuke this then.

0:10 * Raynes shrieks at callen

0:42 bja: if I'm looking to good-faith attempt an operation (say send monitoring data to graphite), but I don't particularly care if it fails, what would be the recommended construct for making that action happen outside the main thread?

0:43 Raynes: Well, you can do it inside a future with (future ..yourcode..). If an exception occurs in that it'll never bubble up unless you try to deref the future.

0:51 technomancy: muhoo: can you get that in the issue tracker please?

2:39 xsyn: Is there anyway to give an index to the items in a lazy-seq?

2:41 TEttinger: xsyn, there

2:42 xsyn: hi

2:42 TEttinger: there's always ##(vec (map inc [1 2 3 4]))

2:42 lazybot: ⇒ [2 3 4 5]

2:42 xsyn: awesome, thank you

2:42 TEttinger: it only makes sense for finite seqs

2:42 xsyn: I'll take a look

2:42 TEttinger: if you do it on, say, ##(vec (repeat 5))

2:43 that will be an execution timeout

2:43 lazybot: Execution Timed Out!

2:43 xsyn: :)

2:43 TEttinger: because repeat 5 is an infinite sequence

2:43 xsyn: it's a finite seq, so should be good

2:43 I've been breaking my brain on some of these things. Absolute n00b

2:43 TEttinger: vecs may have different conj order if you conj on them, compared to lazyseqs

2:44 ,[(conj (map inc [2 3 4 5]) 7) (conj [3 4 5 6] 7)]

2:44 clojurebot: [(7 3 4 5 6) [3 4 5 6 7]]

2:45 TEttinger: yeah, you can see there, map returns a lazyseq, and conj'ing on it attaches at the beginning, but the vec attaches at the end

2:46 xsyn: uhm

2:47 I'm not sure I understand

2:47 seancorfield: (map vec my-lazy-seq (range)) ??

2:47 lazybot: seancorfield: Definitely not.

2:47 seancorfield: gee, thanx lazybot :)

2:48 ##(take 6 (map (iterate #(* 2 %) 2) (range)))

2:48 lazybot: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn

2:48 seancorfield: bah... too late for this stuff

2:49 oh, ##(take 6 (map vec (iterate #(* 2 %) 2) (range)))

2:49 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: core$vec

2:49 TEttinger: xsyn, uh hm. map returns a lazyseq, as you've probably run into by now (my biggest beginner mistakes revolved around laziness)

2:49 seancorfield: ##(take 6 (map vector (iterate #(* 2 %) 2) (range)))

2:49 lazybot: ⇒ ([2 0] [4 1] [8 2] [16 3] [32 4] [64 5])

2:49 seancorfield: i knew i'd get there eventually :)

2:50 TEttinger: these days I try to only deal with finite sequences, and vec them whenever possible to get more stuff I can do with them

2:50 like indexes

2:50 seancorfield: and there's always map-indexed right? :)

2:50 TEttinger: does that work on seqs?

2:50 ,(doc map-indexed)

2:50 clojurebot: "([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."

2:51 seancorfield: all depends what xsyn really wants

2:51 TEttinger: looks like it

2:51 xsyn: TEttinger: I'm busy pulling a data obj via congomongo, which comes back as a bunch of maps in a lazy seq

2:51 zeroem: alternatively, you could also manage the loop yourself and just pass an incrementing value along with everything else

2:51 TEttinger: I've used congomongo a bit

2:51 * seancorfield maintains congomongo

2:51 xsyn: what I want to do is to be able to pull a specific map out of that based on it's index

2:52 seancorfield: nth?

2:52 clojurebot: monad labyrinth is http://oglaf.com/labyrinth/ (SFW, but has NSFW links)

2:52 xsyn: *looks*

2:52 seancorfield: ,(doc nth)

2:52 clojurebot: "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

2:52 seancorfield: ,(nth (range) 25)

2:52 clojurebot: 25

2:53 xsyn: hah, that looks promising.

2:53 TEttinger: zeroem, loop may be a bit complex for beginners. I would say I was a beginner before I started this project and 4clojure stuff, now I'm early-middle of knowledge I guess. I have had intense trouble with loop

2:53 I mean I get it now

2:53 seancorfield: although why would you be pulling anything much beyond first of that sequence? other than just iterating thru the whole result?

2:54 TEttinger: my current code generates an array with two consecutive loops laying down tiles in a herringbone pattern, it's the most complex code I have written in any language, and I'm kinda proud of it

2:55 seancorfield: generally, with congomongo, i find i'm either (doall (map f some-congo-result)) or (doseq [row some-congo-result] ... row ...)

2:56 TEttinger: my favorite line is (aget ^doubles initial (+ (* 10 ow) -10 (* 20 (quot i wide)) (- i (dec wide) (* 2 (quot i wide))))) , which I could explain but it would take until tomorrow

2:56 that one line took me about an hour to write

2:57 it's array indexing code

2:57 in a section that was a speed bottleneck

2:57 xsyn: nth may well work

2:58 seancorfield: don't have to explain it to me... but i'm off to bed anyways...

2:58 xsyn: thank you all

2:58 seangone: xsyn: glad we could help...

2:58 xsyn: me too :)

2:58 nice community

2:58 TEttinger: xsyn, I learned something too, I thought nth only worked on numbered index colls

2:58 thanks seangone

2:59 zeroem: TEttinger: if you have a set, then maybe this? http://clojuredocs.org/clojure_core/clojure.set/index

3:00 assuming that by "indexing" you mean the database/fast look up kind of indexign

3:00 TEttinger: not really, literally finding the index that lines up in a large array to a subset of a smaller array, all 1D emulating 2D

3:03 zeroem, I haven't been using sets enough, that could be really handy

3:05 zeroem: oh my, look at the time

3:09 xsyn: hmm, I actually need the reverse of n

3:09 nth*

3:10 so from a k v pair, what is the index in the se

3:10 seq*

3:13 TEttinger: xsyn, ah, but v could repeat

3:13 xsyn: it's unique

3:13 TEttinger: so you really want the first that satisfies (= v what-I-want), which will also work for unique

3:13 xsyn: but I understand the abstration

3:14 well, I want to know where it is in the seq

3:14 not the actual value of it

3:14 samrat: in clojure.java.jdbc is it possible to insert! with a `where` condition? I want to avoid adding duplicate columns.

3:15 xsyn: I need a break

3:15 bbiab

3:17 TEttinger: ,(keep-indexed (fn [idx elem] (if (= elem :search-target) idx)) (repeatedly (fn [] {(rand-int 10000) (if (= (rand-int 4) 0) :search-target :not-correct)})))

3:17 clojurebot: Execution Timed Out

3:19 samrat: this is what I want to do(with java.jdbc) https://www.refheap.com/17238 . Is that possible?

3:20 muhoo: technomancy: done.

3:20 samrat: I'm doing a separate query to check for duplicity

3:26 TEttinger: xsyn, you can actually treat a map entry as a 2-item vector, with the key as (first kv) and the value as (second kv), if kv was gathered by going over a hashmap with a function like map. so {:key "value" :key2 "value2"} can be used like [[:key "value"] [:key2 "value2"]]

3:26 and if you just want the key, that might be... key

3:26 (that's not technically true, but map entries act like 2-element vectors)

3:28 oh nvm, you wanted the index in the seq, not the map

3:31 (loop [idx] (if (= :what-I-want (nth seq-of-maps idx)) idx (recur (inc idx))) ;; substitute the name of your seq of maps and the value you want. not guaranteed to work if you search for a non-present entry (in that case it will throw some out-of-bounds exception, which you can catch)

3:32 worst case is linear time, best case is the first entry is what you want

3:32 actually nth on a seq is linear, so O(n^2)

3:39 shdwprince: provide one more argument to nth (like nil) to receive that value if not found and avoid out of bounds

3:56 TEttinger: http://www.reddit.com/r/technology/comments/1jk1gz/sourceforge_starts_using_enhanced_adware/ uh oh...

4:07 bja: does ns's :require support [library :only [something :as other-name]]?

4:07 err, that question is awful, nvm

4:10 muhoo: who the hell uses sourceforge anymore?

4:11 it's not 2001 anymore

4:13 bja: sf still exists?

4:13 do they support git?

4:13 muhoo: http://24.media.tumblr.com/tumblr_llpyemJT3v1qjfdudo1_500.gif

4:15 katratxo: bja: http://sourceforge.net/p/forge/documentation/Git/

5:18 dotemacs: I guess you'd use SF just retro kudos

5:59 xsyn: I'm trying to use congomongo's distinct-values, as found here: https://github.com/aboekhoff/congomongo/blob/master/src/somnium/congomongo.clj

5:59 but I'm getting a: No matching method found: distinct for class com.mongodb.DBApiLayer$MyCollection

5:59 does anybody have any ideas why?

6:15 mccraig: looking for a clojure parser combinator lib : anyone got good/bad experiences to report ?

6:18 hyPiRion: mccraig: if you want to parse small pieces of data (less than 500 kb), then Instaparse is great. It's not really a parser combinator library, but it's a good parser library

6:18 TEttinger: xsyn: well, are you calling distinct or distinct-values?

6:18 hyPiRion: then there's parsatron, but I've not used it so I can't comment on its quality

6:19 xsyn: TEttinger: I'm calling distict-values

6:19 TEttinger: xsyn, also, your MyCollection you're passing in, it must not be coerceable to DBCollection

6:20 err, or it doesn't have a getColl?

6:20 get-coll I mean

6:20 xsyn: hmm

6:20 it seems ok

6:20 TEttinger: not knowing what MyCollection is, I can't comment

6:20 xsyn: :) that's a clue

6:21 I don't know what my collection is

6:21 which means, that the collection is probably the isse

6:21 the collection I'm passing it should just be a users collection

6:23 mccraig: hyPiRion : i've got a few gigs of fixed-field data, which has a format which is itself defined by a bunch of TSV… both formats need parser : too much for instaparse ?

6:24 TEttinger: TSV is easy to parse

6:26 ,(clojure.string/split "alpha\tbeta\tgamma" #"\t")

6:26 clojurebot: ["alpha" "beta" "gamma"]

6:26 mccraig: well, yes : fixed-field is easy to parse too

6:26 TEttinger: the few gigs is the hard part

6:27 you probably want to split the file if possible

6:27 unix split is handy

6:27 mccraig: it's fixed-field, so a lazy sequence of records is straightforward

6:33 h0bbit_: dark_element, hello :D

7:14 hyPiRion: mccraig: yeah, that's too much for instaparse, but a hand-written one should suffice really

7:15 mccraig: hyPiRion: sure, i', just trying to minimise the code i have to write

8:03 lgs0pht: Is this channel also about datomic?

8:05 cmdrdats: lgs0pht: you probably want to ask at #datomic

8:18 xsyn: TEttinger: it was a semantic thing I didn't expect it wanted a string for the collection, rather than the :symbol

8:18 TEttinger: oh weird

8:19 glad you figured it out

8:21 xsyn: Thanks for your help today, I finally broke through 10 lines of code that have been keeping me up at night

8:23 ro_st: xsyn: are you Guy?

8:23 xsyn: Hey Rob

8:24 Yeah :)

8:24 TEttinger: xsyn, I know how it is

8:24 ro_st: hey :-)

8:24 TEttinger: I've been dreaming in code lately

8:24 ro_st: glad to see you in clojure land!

8:24 TEttinger: hey ro_st

8:24 xsyn: ro_st: I'm about to put my first bit of Clojure into production :)

8:24 ro_st: o/ TEttinger

8:24 TEttinger: cool!

8:24 ro_st: xsyn: that rocks, man!

8:25 clojurebot: clojurebot is a time-capsule for snark

8:25 xsyn: ro_st: I saw some of your stuff the other day, it's looking great

8:25 ro_st: which stuff is that?

8:25 xsyn: The Cognician stuff

8:25 ro_st: oh, our actual app?

8:25 xsyn: *nod*

8:25 it's come a long way

8:25 ro_st: heh, thanks

8:26 yeah. going to go a helluva lot further, too :-)

8:26 so many plans.

8:26 xsyn: good :)

8:27 ro_st: feel free to hit me up on the twitters if ever you want some help

8:27 getting quite serious about the whole clojure thing here in SA!

8:28 TEttinger: san antonio?

8:28 ro_st: south africa :-)

8:28 TEttinger: woah, way off

8:28 cool

8:30 xsyn: ro_st: Thanks man, I will. I think my biggest fear at the moment is I'm not sure it's entirely idiomatic

8:30 but I'm slowly getting my head around that

8:31 ro_st: that's the sort of thing that sinks in

8:31 xsyn: I'd also be interested to chat about workflow

8:31 ro_st: quicker'n you'd think

8:31 for sure!

8:31 xsyn: how's the cpt clojure user group?

8:31 ro_st: we're meeting again on the 17th

8:32 doing an install day. bring your machine, we get you set up with clj/cljs, emacs, and show how to do the basics with all three

8:32 if no newbs show up we'll probably just end up yakking

8:33 i've got my head around Pedestal for the most part now, so i might show some of that too

8:33 xsyn: was just about to ask about that

8:33 I want to spend some time on that tut

8:33 apparently it's about 8 hours worth of learning

8:33 ro_st: way more than that

8:34 the tut is excellent. highly recommended. i've been through it a couple times. lightly at first and then really spent time going through each bit

8:37 xsyn: Well hopefully I'll be able to put the sweat in after this goes lives

8:41 ro_st: awesome :-) be keen to hear what you think

9:19 cmajor7: what's the good way to handle system wide properties that come from an external file, the path to which can be passed via "-D"? So far I am thinking on having them in EDN in "xyz-conf.clj". what I wonder about is the "state". do I create a single "conf" namespace that will read all these properties, and then other namespaces can use it?

9:23 ro_st: cmajor7: we use (System/getenv "key") and we have a config ns that just fetches many of these into CAPITALISED-THINGS

9:23 where a default is suitable, we do (def SOME-THING (or (System/getenv "SOME_THING") :a-default-value))

9:23 shdwprince: cmajor7: or you can store config in hash map and use (read-string "data...") to get it

9:24 ro_st: we also make these vars ^:dynamic so that they can be rebound in test runs

9:24 cmajor7: fyi, http://12factor.net/config

9:27 cmajor7: ro_st: yep, was thinking about using ^:dynamic for profiles, but it seems a bit strangle to use ENV properties for app properties

9:27 shdwprince: yes, hence EDN, store them as map and use reader to get them

9:28 ro_st: by putting it outside the code, you make it possible to run the code in different configs without having to version control those files

9:28 which is what that link i pasted basically says

9:28 allows you to treat the whole git repo as a unit with consistent semantics, rather than the whole lot except for this one config file

9:29 cmajor7: ro_st: not sure I follow: "without having to version control those files" vs. "whole lot except for this one config file"

9:30 ro_st: if you run your code in more than one environment eg production and test

9:30 s/test/staging

9:30 cmajor7: ro_st: I do want them versioned controlled, at least their sensible defaults

9:31 ro_st: right, so why use System/env vs. EDN ?

9:31 ro_st: to configure for staging, you'd have to include the notion of staging in your config file. you end up with a map of env -> [key val]. this means your code has to know about all the possible deployments. by using env vars, you avoid having to include these notions in your code

9:32 you can use edn as well, but env vars are universal

9:32 cmajor7: but can't you just run with -Dprofile=qa, and have your code to read by profile vs. to "know about all possible deployments"

9:33 ro_st: you could :-) but then your code has to know all the profiles

9:33 sbinq: Hi, I have maybe a silly question - recently read this post http://swannodette.github.io/2013/08/02/100000-processes/ - and still cannot understand - why it is saying about 10k processes: I see only 2 there (one in render-loop and another within last let clause) - do I misunderstand smth?

9:34 ro_st: in our situation, we have all of our devops scripted. how to configure server components, and how to compose them to create servers. we have such configs for ec2 prod, ec2 load-testing and for our staging vpses. each one has a slightly different set of env var values

9:34 dnolen: over to you :-) /cc sbinq

9:35 cmajor7: only the "conf.clj" though, which can actually benefit from it.. What I don't yet have a solid opinion on is how to manage this global state for all namespaces.. create a "conf" namespace, or dedicate certain props to certain namespaces..

9:35 ro_st: cmajor7: you could totally do the edn thing. but it's complecting your app behaviour with your app configuration.

9:36 we created a config ns with everything in it. we've got about 20 different things in ther enow

9:36 aws creds, datomic, various enable-thing flags

9:36 nirrub: Hi - I have a troublng issue. I'm trying to load a resource as a Java File object. I'm getting the resource url via (clojure.java,io/resource "resource_name") but then, when I try to create a File object by using (clojure.java.io/file url) on the url of the result, I'm getting a "java.lang.IllegalArgumentException: Not a file: jar:file:/....!/{my_resource_name}"

9:36 cmajor7: ro_st: is it really complecting? how do you represent a nested map using System/env?

9:36 nirrub: This only happend when I run the uberjar via a regular java -jar command

9:37 ro_st: cmajor7: we don't

9:37 we use scalars

9:37 cmajor7: you might like http://github.com/weavejester/environ

9:38 stuartsierra1: nirrub: Your resource is inside a JAR file, so you can't get it as an ordinary File.

9:39 cmajor7: ro_st: interesiting.. "environ.core/env" is right in the middle of what you are doing and what I am thinking, since it does allow the structure, at the same time it's env

9:39 TEttinger: sbinq, 100 wide, 100 high?

9:39 ro_st: there you go, then :-)

9:39 TEttinger: and the async code might generate a process for every cell in that 100 * 100 block

9:39 nirrub: @stuartsierra1: So if I have an api whoch requires me to use a File object, my only option is to give it a well known address?

9:39 sbinq: TEttinger: but it is not a number of go "processes" - it is size of greed, correct? Or I do not see them launched somewhere?

9:40 stuartsierra1: nirrub: I don't understand your question. If you need a java.io.File, you can't get it out of a JAR.

9:40 nirrub: stuartsierra1: Ok, thanks a bunch!

9:40 sbinq: TEttinger: s/greed/grid, sorry

9:40 TEttinger: sbinq, heh I was confused

9:41 yeah, I think it loops 10000 times, and creates an async process with >! in each

9:41 cmajor7: ro_st: still not convinced to use ENV for APP properties.. smell a lot of name clashes. for example, in case of "environ", "AWS_ACCESS_KEY" is not app specific, and it is global...

9:42 sbinq: TEttinger: m. isn't >! just writing to a channel - not creating a process?..

9:42 ro_st: cmajor7: we prefix all our env vars

9:42 cmajor7: right, that is how you cheat the proper structure :)

9:43 ro_st: -grin- yes :-)

9:46 dnolen: sbinq: there 10,000 concurrent running go blocks, each go block is in an infinite loop.

9:48 jonasen: dnolen: did you test the reader optimizations for anything other than V8?

9:48 sbinq: dnolen: sorry for stupid question, but where they are launched (maybe line of code or function or smth like this)? source code there is complete, correct?

9:48 dnolen: jonasen: not really why?

9:48 sbinq: they are launched by writing "go"

9:50 kmicu: bREPL is now called "bionic REPL" https://github.com/cemerick/austin

9:50 sbinq: dnolen: yes - and I see it only two times: "(go (while true...." and "(go (loop [refresh (timeout rate) queue []]...." - each of them executed once.. I'm making some very stupid mistake here?..

9:50 jonasen: dnolen: I don't have spidermonkey or jsc installed so I was just wondering if you saw similar numbers

9:51 dnolen: sbinq: oh oops that's just a typo

9:52 sbinq: dnolen: oh thanks, I was having many doubts about my sanity already ;) what should be the correct version?

9:53 ro_st: cemerick: thanks for austin! definitely going to try it out

9:54 cemerick: ro_st: sure :-) Knocking together a quickie demo vid right now.

9:55 kmicu: You already have good demo vid in README ;]

9:55 dnolen: sbinq: updating now

9:55 ro_st: video, awesome. clojure community could certainly do with more videos!

9:56 sbinq: dnolen: thank you, will check updated post

9:56 dnolen: sbinq: I'll be including the code for all the posts into the blog repo over the next week or so

9:56 kmicu: yep, more clojure porn

9:56 ro_st: dnolen: when do you start campaigning to use cljs at the NYT? :-)

9:56 hyPiRion: ro_st: honestly, I think the Clojure community has many videos (presentations?) already. But I would love to have more, of course.

9:57 ro_st: hyPiRion: it has lots. but it can always do with more. i've watched everything already.

9:57 even the koan walkthroughs

10:00 it'd be great to see some more Datomic videos. plenty of topics in the docs that could benefit

10:05 dnolen: sbinq: post updated

10:05 sbinq: dnolen: thank you!

10:06 dnolen: sbinq: thx for pointing it out

10:09 TEttinger: sbinq, sorry, I don't know how the async works, I guess my answer was misleading

10:10 sbinq: TEttinger: it's ok, thanks for trying to help :)

10:20 deg: Are there any parser generators that work in clojurescript? Something bison-like would be great, but even recursive-descent would be good enough for my needs.

10:20 dnolen: sbinq: TEttinger: I've added the full source of that post to the repo http://github.com/swannodette/swannodette.github.com/blob/master/code/blog/src/blog/processes/core.cljs

10:23 stuartsierra1: can we do another CLJS release?

10:23 stuartsierra1: dnolen: suer

10:23 *sure

10:23 dnolen: stuartsierra1: thx!

10:23 stuartsierra1: It's cookin.

10:24 http://build.clojure.org/job/clojurescript-release/30/

10:44 jonasen: dnolen: so CLJS-565 didn't make it into this release?

10:45 dnolen: jonasen: no, but releases are quite easy now, pretty much automated

10:45 jonasen: dnolen: ok, no problem.

10:51 isomorFFF: Hello, I need help :) I have an atom with clojure.java.io/writer inside. I want to write with .write method on the atom in a function. But I obtain No matching method found: write for class java.io.BufferedWriter. I don't understand the problem.

10:52 I think it's because of number of arguments

10:54 kmicu: o_O

10:56 stuartsierra1: isomorFFF: Check the javadoc for java.io.BufferedWriter: you're probably calling it with the wrong number or wrong type of arguments.

11:20 Anderkent: is there a lein thing that warns you about unused imports/uses/requires?

11:26 kmicu: maybe eastwood, bikeshed, kibit...

11:29 clgv: Anderkent: slamhound can rebuild your ns form

11:29 Anderkent: clgv: yeah but not if you `use` stuff

11:30 (i know, i know, use is evil, but I don't feel like refactoring 10 files not to use use for a minor rearrangement)

11:31 squidz: what's a good way to make structures in clojure like Month Week Day etc. where the relationship between them is comparable by their granularity. For example Year < Day : because there are more many days in one year

11:32 or Hour > Week because there are many hours in a week

11:32 clgv: squidz: keywords and a function to compare by granularity

11:32 squidz: clgv: what do you mean?

11:34 clgv: squidz: well I dont know whether there is more than just the comparison. but if it's only the comparison you can hardwire it in a function and us :month :year ...

11:37 squidz: btw there are libs for using units in clojure. maybe one of these already implemented the comparison

11:38 squidz: what i'm trying to do is given two javascript dates, I want want to determine a granularity for example if the input is [01-01-2011 01-01-2014] then I want the granularity year if it is [01-01-2011 01-12-2011] I want to return the granularity of month etc. Then given that returned granularity i want to get the next level up, so if month is determined, the next up would be year. If week is determined, the next would b

11:40 So i'm not sure what would be a good way with clojure(clojurescript)

11:41 for the granularity determination I figured I would just get a date number and pass that number through conditions to determine which granularity it belongs to. I was maybe skipping ahead and asking how I should use the date for the next step for finding the next level up in granularity

11:43 the data structure that is

11:50 konr: Are there other clojure conferences besides clj/conj and clj/west?

11:50 nDuff: konr: LambdaJam has a lot of Clojure folks, though it isn't a Clojure conference as such.

11:51 konr: nDuff: interesting!

11:51 tim_: EuroClojure

11:52 zerokarmaleft: strangeloop brings a lot of clojure folks also

12:05 clgv: what knowledge is there about multiple data_readers.clj files?

12:06 e.g. when a library has one and the project using it wants to have one as well?

12:07 gfredericks: clgv: looks like they get merged together

12:07 if there's a conflict it throws at clojure-load-time

12:08 clgv: gfredericks: but in a uberjar scenario one would replace the other in a non-specified way?

12:08 gfredericks: that's an interesting question

12:08 I'm gonna go try it.

12:11 clgv: that is indeed the case

12:11 I was able to clobber a lib's file by supplying my own

12:11 and confirmed the value was missing at runtime from the repl

12:11 I wonder if this is something leiningen should be worried about

12:12 clgv: gfredericks: humm than it's probably better not to include that file in a lib

12:12 gfredericks: I've done that at least twice

12:12 it's kind of a lame limitation

12:13 hmmm

12:13 I could see an argument the other way though

12:13 certainly a lib that does reading internally can just set it at runtime

12:17 clgv: gfredericks: I thought of including it to not have to tell every user to write that file in their project

12:18 TimMc: gfredericks: Clobber the entire file, or just one reader entry?

12:19 xeqi: any files of the same name will have this problem for an uberjar

12:19 gfredericks: TimMc: the whole file

12:20 apparently if you have two files in two libs with the same absolute name, `lein uberjar` will silently pick one

12:20 technomancy: I think there's an open ticket for :uberjar-merge-with

12:20 clgv: xeqi: yes, there are namespaces therefore but data_readers.clj needs to be top-level so it is *special* ;)

12:20 gfredericks: I was just heading to the githubs to check

12:20 technomancy: https://github.com/technomancy/leiningen/issues/973

12:22 still time to get it into 2.3.0 if anyone cares enough to implement it =)

12:24 clgv: technomancy: my question was more directed in the direction of tagged literals best practices related to data_readers.clj

12:25 gfredericks: technomancy: I was having trouble testing https://github.com/technomancy/leiningen/issues/1276

12:26 technomancy: pray tell

12:27 clgv: should a library have its own data_readers.clj for easier setup in projects?

12:27 that was about it^^

12:34 huh, in CCW data_readers.clj seems not to be loaded? I thought that is no leiningen business but clojure runtime business

12:35 TimMc: gfredericks: Oh, that makes sense for uberjars. I mean, in a mechanical sense, not in a design sense.

12:35 I just avoid data readers. :-P

12:35 clgv: I have a DSL where they would be pretty useful for bootstrapping

12:37 oops. repl in wrong project ;)

12:37 gfredericks: I've been using a timeless date library

12:37 nice to have data readers there for literals

12:39 clgv: humm, the namespace of the function in the data_readers.clj gets not loaded automatically?

12:39 gfredericks: technomancy: I was trying to call resolve-and-apply from inside the test, and kept getting a "suppressed exit" exception

12:39 technomancy: which I thought made sense when I was calling -main prior

12:40 but then it kept doing it

12:40 even after switching to resolve-and-apply

12:40 technomancy: gfredericks: apply-task calls abort in the case of an arity mismatch

12:40 line 187

12:43 cmajor7: what is an idiomatic way to make (loop/recur) or (while true) span multiple cores? the data is streaming in. ["loop/recur" and "while true" are using a single core..]

12:43 tbaldridge: cmajor7: well that question doesn't really make sense, but look into reducers

12:43 cmajor7: tbaldridge: why does not it make sense?

12:43 tbaldridge: cmajor7: http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html

12:44 cmajor7: I know about redicers

12:44 tbaldridge: the question is "how do I loop, but make the loop use multiple cores".

12:44 cmajor7: but here the data is streaming in

12:44 tbaldridge: over what?

12:44 cmajor7: yes, the loop _can_ use multiple cores

12:44 tbaldridge: what is the streaming system

12:44 cmajor7: tcp/ip

12:45 think socket

12:45 it does not matter really

12:45 tbaldridge: cmajor7: so you can use future to kick off a different thread for each iteration of the loop, but that probably isn't what you want.

12:45 Java queues will allow you to enqueue data from one thread and read it from another.

12:46 Or clojure.core.async will allow you to do this with "fibers" or micro-threads like Erlang/Go

12:47 but the actual definition of a loop is a single thread of execution returning to a previous location to process more data, it is not a concurrency construct.

12:47 cmajor7: tbaldridge: yes, I am using a queue, and I did use a pool to submit things there, but all these are not core deterministic (e.g. will jump around the CPU sockets).

12:47 tbaldridge: yep

12:48 technomancy: cmajor7: if you can reframe your problem in terms of seqs it's a lot more tractable

12:48 cmajor7: tbaldridge: I guess what I am wondering if there are clojure reducers for streams

12:48 tbaldridge: so you're asking for thread affinity?

12:48 technomancy: loop/recur isn't really a good fit for application-level code

12:49 cmajor7: tbaldridge: not yet, affinity will come next.. I am asking if there is a way to make a looping construct that reads form a stream and "does" using multiple cores

12:49 tbaldridge: cmajor7: so what's the problem with jumping around the CPU sockets?

12:49 cmajor7: technomancy: right, does not have to be loop/recur

12:50 tbaldridge: cache lines are not reused, performance is jumpy, but again, this is not the problem I am looking for a solution to

12:51 tbaldridge: "looping construct that reads form a stream and "does" using multiple cores" is

12:52 tbaldridge: cmajor7: if you're worried about cache lines and the like, those are going to be utterly screwed by immutable data structures anyways, that is, if you're making new ones.

12:53 cmajor7: tbaldridge: I am not

12:53 tbaldridge: cmajor7: but back to the question you did ask about. I'd reach for core.async, have a Java thread for each socket, and then spin up as many go blocks as needed for processing.

12:54 build it right, them build it fast. Queues and threads is what you want, either from core.async or custom-built from Java.

12:54 *then build it fast

12:55 squidz: is core.async a good candidate for loading large resources in the background while a user is on a page?

12:55 tbaldridge: or seqs as technomancy said, but those aren't really concurrency constructs.

12:55 squidz: yes

12:55 clgv: squidz: thats a job for `future

12:56 imho ;)

12:56 cmajor7: tbaldridge: yea, I am using a simple thread pool, which works just fine. hence asked about idiomatic way to do it, but I guess there is none. or core.async, which might include a certain overhead with wrappers and a state machine.., but a good thing to try in any case

12:56 tbaldridge: squidz: clgv: it depends on the number of resources. Load 10,000 resources at once and you'll crash your jvm

12:57 clgv: core.async will allow you to queue up thousands of resources that are load balanced over a smaller number of loaders

12:57 ddellacosta: I feel like I've done this before, but I cannot for the life of me remember how to tell Clojure to cast the arguments to a Java instance method into a subclass of the object I'm trying to pass…anyone tell me how to do this?

12:58 clgv: tbaldridge: I mentioned `future` to him to prevent him from breaking a nut with a sledgehammer ;)

12:58 ddellacosta: not finding it on the Java interop page (http://clojure.org/java_interop)

12:58 squidz: I mean load one large resource like a json file from a server without locking the page

12:58 for clojurescript

12:58 tbaldridge: squidz: oooh

12:59 ddellacosta: ah, I see, there is a cast function. Nevermind.

12:59 tbaldridge: it depends what you mean by "loading". you can abuse core.async to allow you to "yield" back to the browser.

12:59 squidz: is core.async a good application for that

12:59 tbaldridge: squidz: it's about the only way, aside from a custom solution, for an example see this: http://swannodette.github.io/2013/08/02/100000-dom-updates/

13:00 squidz: i mean if my page needs to a large file from the server is it possible to let the user browse the page freely while it loads

13:00 tbaldridge: squidz: that's the job of the browser, unless your CLJS code is doing post-processing after it loads

13:01 for instance, loading a massive 20MB image won't lock my browser while its loading

13:02 squidz: tbaldridge: what do you mean by post-processing?

13:03 xeqi: cemerick: austin looks neat, will have to try it out this evening

13:03 cemerick: xeqi: sure, let me know where it breaks :-)

13:04 tbaldridge: squidz: loading a resource shouldn't lock your browser, now if you're parsing or processing that file via CLJS, that may lock the browser a bit.

13:04 cemerick: Been using it for quite a while, so it shouldn't be too rough

13:04 tbaldridge: squidz: loading a resource shouldn't lock your browser, now if you're parsing or processing that file via CLJS, that may lock the browser a bit.

13:04 squidz: okay I see

13:04 maharj: cemerick: Thanks for the Austin package, I just cloned the repo, and tried to run the example, but it fails to start the repl saying: FileNotFoundException Could not locate cemerick/austin/repls__init.class or cemerick/austin/repls.clj on classpath: clojure.lang.RT.load (RT.java:443)

13:06 cemerick: mharju: this in the browser-connected-repl-sample?

13:06 mharju: cemerick: yeah

13:06 squidz: because I wwant to analyze some data with clojurescript and display it to the user so I wanted to load smaller version of the data to display something to the user while the bigger dataset loads in the background

13:06 that shouldn't be a problem?

13:07 tbaldridge: nope

13:08 cemerick: mharju: That's pretty weird....I just cloned it fresh, moved my existing ~/.m2/repository out of the way, and `lein repl` and `(cemerick.austin.repls/exec)` work as expected in there.

13:09 mharju: what version of leiningen are you using?

13:10 mharju: cemerick: oh, Leiningen 2.0.0-preview7 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM

13:10 quite old. it seems I've not updated this machine

13:10 cemerick: mharju: yeah, I'd twiddle that first

13:11 mharju: cemerick: yeah, I'll try, thanks :)

13:14 cemerick: that was it. I was quite sure I updated leiningen last week but.. :)

13:14 cemerick: mharju: sounds good :-)

13:33 gtrak: baltimore clojure meetup, take 2 :-), in a couple weeks.

13:36 mharju: is there a guide on how to connect a cljs repl to fireplace?

13:41 It says " (do

13:41 (def repl-env (reset! cemerick.austin.repls/browser-repl-env (cemerick.austin/repl-env)))

13:41 (cemerick.austin.repls/cljs-repl repl-env)))

13:41 argh

13:41 cemerick: ??

13:41 lazybot: cemerick: Definitely not.

13:41 callen: mharju: upgrade your leiningen.

13:41 mharju: that was an accidental paste

13:42 cemerick: ah

13:42 mharju: Just connect to an nREPL endpoint with fireplace, then use austin

13:42 mharju: I tried to put the message that the browser repl is waiting on http

13:42 cemerick: okay, basically what I pasted was what I tried to eval with the nrepl connection

13:42 but it was not correct :)

13:43 dark_element: cemerick hey i hardcoded the generated browser repl url after running "(austin-exec)" in my cljs code.

13:43 cemerick: the URL it prints out is one you can paste into e.g. a browser, and have it service the browser-repl

13:44 dark_element: cemerick i just wanted to try it out quickly before moving to a better setup with templating

13:44 cemerick I see the repl xhrs being made in browser but still the evaluation doesn't complete

13:45 mharju: cemerick: okay, I'm running the browser-sample now. It serves the localhost:8080-page, is that enough?

13:45 wakeup: hi

13:45 cemerick: mharju: once you have an env reset!'ed into that atom, yes

13:45 dark_element: you invoked something exec-related in cljs code? Not possible (it's a Clojure function).

13:46 wakeup: I am coming from CL (used to MAKE-HASH-TABLE), how the hell do I

13:46 append a key/value pair to a HASH-MAP?

13:46 dark_element: cemerick ohh no. I ran (austin-exec) in repl and harcoded the generated url in cljs.

13:46 mharju: cemerick: yeah, so first env reset!, then localohost:8080 and then eval? (cemerick.austin.repls/cljs-repl repl-env) and it should work?

13:46 cemerick: wakeup: &(assoc {} :a :b)

13:47 dark_element: oh, I see; that's the /start URL?

13:47 mharju: yes

13:47 dark_element: cemerick yup

13:47 wakeup: cemerick: (assoc (hash-set "foo" "bar") "baz" "boom")

13:47 ClassCastException clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative clojure.lang.RT.assoc (RT.java:702)

13:48 jaju: Need some advice/help with a configuration approach for an app.

13:48 Bronsa: wakeup: a hash-set is not a hash-map

13:48 wakeup: Bronsa: true, may bad

13:48 dark_element: cemerick cljs code looks something like this right now "(repl/connect "http://localhost:65384/1810/repl/start")"

13:48 cemerick: dark_element: yeah, that's meant to be pasted straight into a browser. Just clip off the /start for use in a cljs (connect ...) call

13:48 dark_element: cemerick ahh ok

13:49 cemerick yes works

13:49 cemerick: the /start resource is basically a shim HTML file that does what your template would do

13:49 I guess I should make the message, etc. more clear...

13:49 mharju: cemerick: okay, it spits out the type ":cljs/quit" -stuff so I guess it went fine. However, when I try to eval anything it just spits out an exception about an unused Var cemerick...Exception and the traceback contains stuff from goog

13:50 cemerick: mharju: could you paste the full interaction/exception somewhere?

13:50 dark_element: cemerick generating shim js would be a lot more helpful in my opinion, so that i can place it in html as a script tag

13:51 cemerick: dark_element: There's a fn for that in cemerick.austin.repls

13:51 jaju: I would like to have, say, a var which is initialized with some default value. But when the app starts, and user supplies another value, that value over-rides.

13:51 cemerick: dark_element: second part of step #3 @ https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample

13:51 jaju: How would one go about such a setup?

13:52 mharju: cemerick: https://www.refheap.com/adba008cd790b2db49daed7b0

13:53 cemerick: mharju: yuck

13:53 dark_element: cemerick ok

13:54 cemerick: mharju: Not that you should get an exception like that in any case, but FYI you do need to reset! the atom *before* loading the page. Though, if you do it in the other order, you should see nothing, not an error.

13:54 mharju: cemerick: yes, I do reset! it before loading

13:54 dark_element: cemerick i should get the templating in place to understand it better

13:54 mharju: the comment about loading was in the wrong place, sorry :)

13:55 cemerick: dark_element: The sample app is ~10 lines :-)

13:55 mharju: this is running out of the sample project?

13:55 mharju: cemerick: yes, plain vanilla

13:55 functionform: I feel like this chart should be somewhere on the clojure cheat sheet: http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html

13:55 its very helpful

13:56 mharju: cemerick: The only thing I added was that (comment ...) section on the top of the bcrepl_sample.clj

13:56 dark_element: cemerick heh :). Just that I am trying to get it working with a project i am working on.

13:56 cemerick: mharju: what browser?

13:57 mharju: cemerick: chrome 28.0.1500.95

13:57 It works if I do it on lein repl

13:57 cemerick: was hoping for IE 5 or something :-P

13:57 mharju: but not if I eval it from fireplace

13:58 cemerick: mharju: oh, this is only via fireplace?

13:58 mharju: yes

13:58 cemerick: hrm

13:59 its nREPL support is a bit idiosyncratic, but I hadn't expected this

13:59 mharju: maybe you could open an issue. I'll see if I can replicate and run a bug up for fireplace if the problem is actually there.

13:59 konr: is anybody using Finagle or something similar on clojure?

14:00 cemerick: Works nicely in my fireplace fork, for all the good that does anyone. :-P

14:00 quackv4: h

14:00 dark_element: cemerick, great intro video to the project by the way.

14:02 mharju: cemerick: okay, I'll open an issue, thanks :)

14:02 cemerick: dark_element: thanks, which one ;-)

14:04 dark_element: cemerick heh

14:04 wakeup: Can anyone point me to the documentation of fn's parameter specification? e.g. keyword parms, arbitrary arity, optional parameters

14:06 rasmusto: wakeup: this isn't function-specific, but I found it to be a useful page: http://blog.jayfields.com/2010/07/clojure-destructuring.html

14:13 mharju: cemerick: I posted the issue, hopefully it's clear enough

14:16 justin_smith: we have an artifact on clojars that shouldn't be used - how do I go about deleting it?

14:17 technomancy: justin_smith: redeploy with "delete me" in the description and give me a ping

14:17 futile: I love you guys.

14:17 You're all so humble and patient.

14:17 justin_smith: technomancy: thanks

14:18 futile: Awesome channel to be in.

14:18 * futile was just in some channels that were not so humble, and it gave some perspective

14:18 squidz: futile: which channel?

14:19 futile: That wouldn't be so polite to say.

14:19 Let it suffice to say that you guys are great.

14:19 And don't change :)

14:19 * TimMc preens

14:22 dark_element: cemerick, ok setup done. But switching to a namespace didn't work right away and after while i got a hanged repl.

14:23 cemerick: hrmph

14:23 dark_element: what does "didn't work right away" mean?

14:23 dark_element: cemerick ok now it's intermittently working and need to refresh to get the repl working again.

14:24 cemerick ohh ok let me explain. I tried changing the package and after that repl hung up for a while.

14:25 cemerick so i tried to interrupt evaluation which gave me couple of these messages "java.lang.ThreadDeath" and "java.lang.InterruptedException"

14:25 cemerick: dark_element: for how long? If it was the first time you required a particular namespace, then the compiler needs to do its business before the prompt will return

14:25 dark_element: cemerick and after that the namespace switched

14:26 cemerick let me try again with a new repl

14:26 cemerick: dark_element: yeah, the ThreadDeath exception print-out is expected under piggieback, it's an open issue (see end of the section @ https://github.com/cemerick/piggieback#rhino-clojurescript-environment-default)

14:27 dark_element: cemerick yes it happened to me few times on ThreadDeath but mostly because i was trying out something crazy on repl.

14:28 Raynes: Excellent. Oracle's documentation site is down.

14:29 dark_element: cemerick i am trying to switch to a namespace that is already compiled in the output js.

14:29 antares_: Raynes: http://docs.oracle.com/javase/7/docs/ is up for me. Also, I downloaded a copy a while ago just in case.

14:29 cemerick: dark_element: ok; that _should_ be snappy

14:29 Raynes: Yeah, looks like nothing is working for me.

14:29 gfredericks: technomancy: oh I bet that's the issue (calling abort); thx!

14:31 Raynes: There we go.

14:31 dark_element: cemerick hmm right now even a simple eval like "(+ 1 2)" is not working.

14:32 cemerick: dark_element: sounds wonky. Maybe a lein clean is in order, just for kicks?

14:32 dark_element: cemerick all right on it.

14:32 cemerick: and ditch ./out and ./.repl too

14:37 dark_element: cemerick all right

14:40 cemerick ran #3 and #4 from https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample

14:41 cemerick all right figured it out i had two tabs running

14:45 cemerick: dark_element: ah

14:45 yeah, that's trouble

14:45 dark_element: cemerick sorry about that.

14:45 cemerick: it's possible that a browser-REPL env could detect that multiple browsers are tag-teaming it (thus likely producing crazy behaviour), but that's a TODO

14:45 dark_element: maybe file an issue for that?

14:46 dark_element: cemerick, is there any way i can switch back to clj repl from piggieback ?

14:46 cemerick: dark_element: :cljs/quit to just get back on the same session; or, connect via nREPL, clone the first session, use one for cljs, one for Clojure

14:46 justin_smith: technomancy: hmm... we may have projects still erroneously using the artifact - in that case does deleting and redeploying with the same version number but added "DO NOT USE THIS" messages make sense, or is there a more sensible course of action with deprecation without complete removal?

14:46 dark_element: cemerick, all right even better i'll send a pull request.

14:47 cemerick, but ill file it first so that we don't loose track of it

14:47 cemerick: dark_element: If you can put it together, great! It might be a sticky wicket.

14:48 dark_element: cemerick ok

14:49 technomancy: justin_smith: you need to use a new version to redeploy, but that sounds reasonable

14:49 anyone coming across it via the web will see the latest with the warning

14:51 justin_smith: technomancy: thanks

14:55 wakeup: How to I convert a string to a utf-8 encoded byte array?

14:56 e.g. usable with clojure.data.codec.base64

14:56 justin_smith: wakeup: maybe (.getBytes string)

14:56 I don't know if that is utf8 always, or how to ensure that though

14:58 wakeup: justin_smith: well the problem is, if you don't know what you are going to encode...

14:58 justin_smith: ,(.getBytes "hello world" "utf8")

14:58 clojurebot: #<byte[] [B@1621157>

14:58 justin_smith: the second arg is the encoding

14:58 wakeup: thanks

14:59 justin_smith: I don't know what all encodings it accepts, by trial and error utf8 and utf16 are in there

14:59 and utf32

14:59 wakeup: what do I have to require in order to get .getByte?

15:00 justin_smith: there is an s on it

15:00 .getBytes

15:00 it is a native jvm method on strings

15:00 wakeup: ah cool thanks

15:00 whats the reverse?

15:01 ztellman: ,(keys (java.nio.charset.Charset/availableCharsets))

15:01 clojurebot: #<SecurityException java.lang.SecurityException: denied>

15:01 technomancy: ,(= "hello" (String. (.getBytes "hello"))) ; <- wakeup

15:01 clojurebot: true

15:01 ztellman: ok, well, that's how you'd get all the avaiable charsets

15:02 available*

15:02 justin_smith: ztellman: cool, thanks

15:02 technomancy: and thanks for that trick too, I didn't know that one

15:02 wakeup: Not to start a flamewar, but coming from CL, and having a client that wants me to write Clojure...

15:03 this "language" is madness

15:03 I'm cool with all the concepts and so forth

15:03 agree with some designd decisions

15:03 but basically I have to know Java to use clojure

15:03 justin_smith: wakeup: it definetly took me a while to adjust, but it grows on you (except for the startup time)

15:03 wakeup: I don't have a real repl

15:03 there is no debugger

15:04 technomancy: yeah, it really missed the boat by not putting VAX filesystem support in the core language.

15:04 wakeup: I get java stack traces as errors

15:04 nDuff: wakeup: re: debugger, have you looked at ritz?

15:04 wakeup: technomancy: are you hating on PATHNAME ? you use strings for filenames...

15:05 nDuff: wakeup: you're very much right that the compromises made for platform support are significant, but well, they're exactly that. Personally I consider them worth it.

15:05 justin_smith: wakeup: I agree that the existing debuggers don't compare to cl at all - but what would clojure need to have a "real repl" by your standards?

15:06 wakeup: justin_smith: I have to restart the repl all the time to make it see new libs

15:06 nDuff: wakeup: ...inasmuch as that platform support makes Clojure a competitor in spaces where CL isn't, _because_ of its failure to interoperate with the larger ecosystem. If I'm at a shop that spent a decade building libraries that run on the JVM, there is no other option.

15:06 justin_smith: yeah, the classpath thing is annoying

15:06 wakeup: nDuff: There is ABCL

15:06 nDuff: wakeup: you don't _have_ to restart the JVM to get new libs; you can use pomegranate.

15:07 mnemnion: Is there a tagged element in EDN which is defined to be a syntax error? So that if I type #n{} into an EDN file it is required to discard it?

15:07 wakeup: nDuff: The platform is also the reason while Clojure will never be a real language

15:07 mnemnion: I specifically can't use #_

15:07 nDuff: wakeup: *shrug*. You can keep your "real language" definition. I'll keep my ability to grab real marketshare.

15:07 ztellman: wakeup: for someone who doesn't want to start a flamewar, you're doing a fine approximation of someone who does

15:08 wakeup: nDuff: basically, if anybody would try implementing a standalone clojure, he would be like "damn, this all really really sucks by design around the jvm"

15:08 nDuff: wakeup: you realize there already _are_ non-JVM-targeting implementations?

15:08 wakeup: ...and that Clojure's core team is building software that runs across them?

15:08 technomancy: why not use abcl then?

15:09 wakeup: like I said, clients choice

15:09 I will recommend it to him

15:09 mnemnion: the Clojure ecosystem will gain a lot of clarity by having a compiler with an intermediate representation that's broadly compatible with C. Something like an LLVM front end.

15:09 technomancy: heh

15:09 wakeup: but it's his choice

15:09 mnemnion: there are projects in the works. It's a matter of time, like most kinds of maturity.

15:10 technomancy: I hope the client has read http://home.pipeline.com/~hbaker1/ObjectIdentity.html

15:10 gtrak: wakeup: just be happy for lisp getting more popular :-)

15:10 justin_smith: wakeup: I also am using clojure because of client concerns. It is this or ruby or php or java, as "best of evils" it is actually really nice once you get used to it

15:10 wakeup: clojure != lisp

15:10 please

15:10 nDuff: wakeup: clojure is certainly a LISP. It's not Common LISP, but the definition is broader than that.

15:10 wakeup: I respect clojure but not as a lisp, and I don't mean that in an offense

15:10 technomancy: clojurebot: no *true* scotsman uses clojure

15:11 wakeup: :)

15:11 clojurebot: clojure is a very attractive hammer with a nice heft to it

15:11 wakeup: also I don't benefit from any language families popularity

15:11 dnolen: wakeup: as as I understand such would not be McCarthy's stance, there is no archetypal Lisp. And thank god for that.

15:12 wakeup: I don't want to go too deep into what defines a lisp

15:13 dark_element: cemerick, i just got java.lang.OutOfMemoryError.

15:13 dnolen: wakeup: and there's no need since you would only express your opinion which doesn't hold a candle to what McCarthy gave us.

15:13 wakeup: dnolen: exactly

15:13 or whatever

15:13 as I said no flame war intended

15:13 tbaldridge: (inc dnolen)

15:13 lazybot: ⇒ 11

15:14 wakeup: Who came up with WITH-OUT-STR?

15:14 tbaldridge: "no flame war intended" said the man who splashed gasoline around the room and started smoking a cigar....

15:14 wakeup: oh come on

15:14 technomancy: ~gentlemen

15:14 clojurebot: You can't fight in here. This is the war room.

15:15 rasmusto: with-out-str is really useful, but yeah, the first hyphen is pretty important to understand what it does

15:15 dark_element: cemerick, interestingly the cljs repl server is still running.

15:15 wakeup: Why with-out-str instead of something more similar to with-output-to-string?

15:15 gtrak: wakeup: curious what you could have against that

15:15 wakeup: honest questions

15:16 cemerick: dark_element: yeah, I wouldn't run a Clojure/ClojureScript app with default heap settings, etc

15:16 gtrak: out is clearer than output because of *out*

15:16 wakeup: gtrak: it's a crippled version of CL's w-o-t-s with a really bad name

15:16 technomancy: wakeup: why nconc?

15:16 wakeup: no way in hell I would have guessed it

15:16 technomancy: rplacd

15:16 wakeup: technomancy: well it's not like clojure has a lot of historic baggage does it?

15:16 gtrak: why is it crippled?

15:17 honestly curious, I don't know anything about CL

15:17 wakeup: gtrak: as I understand it cannot bind arbitrary names but instead alsways binds *out*?

15:17 CL: (with-output-to-string (out) (print 'foo out))

15:17 gtrak: yea, you can bind other things though, what else would you want to bind?

15:17 kmicu: programming or guessing, who cares?!

15:18 dark_element: cemerick all right

15:18 Greg-: clojure not implementing tail recursion isn't a JVM limitation is it? because scala does it

15:18 tbaldridge: wakeup: if you want to bind to something else you can use binding.

15:18 technomancy: Greg-: tail recursion, no. full TCO, yes.

15:18 wakeup: gtrak: well this way you can meaningfully nest calls, eg, have an string for *out* and a string for *err* in case you want to capure an IO function.

15:18 justin_smith: Greg-: design decision: if you use recur it can throw an error if not in tail position

15:19 Greg-: anything in the pipeline for java 8 to help with that?

15:19 gtrak: hmm, I've never wanted to capture *err*, but it would be a trivial macro.

15:19 cemerick: Greg-: Last I knew, Scala does a CPS transform when it can; when it can't, I think you silently get stack consumption

15:19 justin_smith: Greg-: the ugly part being that you cannot do generalized recursion that way, you end up needing trampoline for that

15:19 jwpalmer: ll

15:19 sorry! wt

15:20 Greg-: ok

15:20 justin_smith: s/generalized recursion/generalized tail calls/

15:24 wakeup: So pathnames are strings right? How do I ensure a directory exists?

15:24 Greg-: that looks like a vim command in a room full of emacs users *get 'im!*

15:24 wakeup: Greg-: acually thats vi unrelated

15:24 ztellman: wakeup: http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html#exists()

15:24 gtrak: wakeup: http://docs.oracle.com/javase/7/docs/api/java/io/File.html#exists() and clojure.java.io

15:25 wakeup: Greg-: it's more like unixy

15:25 gtrak: ztellman wins :-)

15:25 ztellman: photo finish, folks

15:25 justin_smith: wakeup: ,(.exists (java.io.File. "/home/justin"))

15:26 Greg-: ah ok

15:26 gtrak: and don't you start complaining about java apis being everywhere, I'd get upset if everything was duplicated

15:27 justin_smith: more clojury (-> "/home/justin/" clojure.java.io/file .exists)

15:27 Raynes: I much prefer the first example.

15:27 I'm very sad that people are beginning to interpret "MOAR ARROWS!" as more clojury.

15:28 gtrak: lure them in with the arrows... then yell at them.

15:28 Raynes: -> in general exists to improve clarity in pieces of code that are lacking it. This isn't one of them.

15:29 hyPiRion: (-> Raynes inc)

15:30 ztellman: haha

15:31 * Raynes beats hyPiRion over the head with a ><>

15:31 hyPiRion: I'd probably do something like (:import (java.io File)) and then do (.exists (File. "/home/justin")).

15:31 oh no, the ascii fish strikes again

15:32 gtrak: clojure.java.io has a file function for that though

15:32 wakeup: ztellman: What do I have to require to use File. etc.

15:32 ?

15:32 gtrak: polymorphic

15:32 ztellman: wakeup: import, not require

15:32 see hyPiRion's example

15:34 gtrak: works on URL's, Strings and handles nulls: https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/io.clj#L40

15:34 Raynes: An observation: everything you say to wakeup sounds like you're way too excited about what you're saying. "Wake up, man! Import not require!!!!!"

15:35 dnolen: I would just use io, (ns foo (:require [clojure.java.io :as io])) (.exists (io/file "/path/to/file"))

15:44 chrisrossi: another dumb question: in order for a record to have methods, you must also define at least one protocol, right?

15:45 dnolen: chrisrossi: you can implement interfaces too

15:46 chrisrossi: sure, but I can't for example, just have methods on the record that aren't declared elsewhere, in a protocol or a an interface.

15:46 like, there's no way to say this record type is its own protocol and spare having to declare methods twice?

15:47 gtrak: chrisrossi: why do you need a protocol, then?

15:48 just to spare yourself having to use accessors?

15:48 dnolen: chrisrossi: yes you have to declare things somewhere, ClojureScript is a bit more flexible in this regard, but even there you have to say that you're implementing Object methods.

15:48 tbaldridge: gtrak: Not that, because you can always use get and assoc as accessors

15:48 vraid: i'm trying to use a java library that requires me to do "public class A extends B{ public A(C c) {}}"

15:48 hiredman: chrisrossi: don't thing about it that way

15:49 chrisrossi: a record is just a container for data (a map)

15:49 gtrak: tbaldridge: I meant only the convenience of defining methods within the scope of a record definition, instead of by themselves in a namespace

15:49 hiredman: chrisrossi: you can extend protocols to them either in line or via the extend* functions/macros

15:49 vraid: i tried doing it by (proxy [B] []), but i get no matching constructor and can't manage to solve it

15:49 hiredman: chrisrossi: they don't have "methods"

15:49 gtrak: those symbols are available to the impls.. not sure why else you'd want to do it

15:50 chrisrossi: well, the O'Reilly book calls them methods.

15:50 hiredman: so?

15:51 gtrak: chrisrossi: protocols are for polymorphism, that was the point I was leading up to.. you can use pure functions otherwise.

15:51 cemerick: chrisrossi: hopefully only in the context of the corresponding generated interface, and/or inline implementations of those methods

15:51 chrisrossi: but, yeah, so if i don't need a protocol, per se, i just don't declare the (not) methods in the scope of defrecord, i just make functions that operate on record instances. is that more or less the standard way?

15:51 hiredman: chrisrossi: that sounds good

15:52 chrisrossi: next consider, do you even need a record? why not just use a map?

15:53 vraid: what would be the right way to extend a java class in clojure?

15:53 dnolen: chrisrossi: exactly, if a function doesn't need to be polymorphic, no need for it to be a part of the record.

15:53 shdwprince: vraid: proxy in common

15:53 chrisrossi: hiredman: i probably don't. ;)

15:53 gtrak: vraid: let me dig up cemerick's awesome flowchart

15:53 http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

15:53 vraid: shdwprince: i couldn't get it to work for "public class A extends B { public A (C c) {} }"

15:54 chrisrossi: i don't become literate in something unless i use it, though, and i wanted to become literate in records.

15:54 shdwprince: (proxy A [instance-of-C] (method1 [this] ...)) should work

15:54 chrisrossi: and i still have some OO wiring that likes the organizational grouping of functions to structs (ie classes)

15:55 gtrak: chrisrossi: just imagine 'this' as your (now explicit) first arg, and always return one.

15:56 dnolen: chrisrossi: records are not common, people try to avoid them.

15:56 vraid: shdwprince: not (proxy [A] ..?

15:56 chrisrossi: yeah, i understand the pattern. it's really for legibility that i wanted to combine them into the same form. more than anything else.

15:56 hiredman: chrisrossi: becoming literate in records by using them badly seems pretty silly to me

15:57 shdwprince: &(doc proxy)

15:57 lazybot: ⇒ "Macro ([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which cre... https://www.refheap.com/17274

15:57 hiredman: chrisrossi: the first step is determing how to decide if a record is appropriate, and we just did that little exercise

15:57 shdwprince: (proxy Class [constructor_params] ...)

15:57 chrisrossi: that's why i came here. the cognitive dissonance detector in my brain was going off.

15:57 thanks.

15:58 shdwprince: Result of proxy is new anonymous class extending passed and with super(params) in constuctor

15:59 *extending class, passed in first argument

15:59 chrisrossi: the nice thing about clojure is refactoring between records and maps is pretty easy.

16:00 shdwprince: How can I pass parameter-declaration vector into macro? For example (my-macro [a b c]), clojure tries to find defn's of a, b, c.

16:02 gtrak: shdwprince: what?

16:03 shdwprince: (defmacro my-macro [name params] `(defn ~name ~params (prn 1)))

16:03 gtrak: oh, you're looking for an 'apply' sort of thing?

16:03 or... what

16:04 futile: Raynes: might wanna disable the Submit button on refheap once its been pressed, so we dont accidentally double post

16:04 shdwprince: gtrak: my real macro is much complex

16:04 Raynes: futile: Like you just did? :P

16:04 gtrak: what's wrong with the above?

16:04 shdwprince: (my-macro abc [a b c]) extends to (defn abc [a b c] (prn 1)), but not evaluates

16:05 futile: Raynes: yes

16:05 Raynes: also please port that script to elixir for me

16:05 gtrak: shdwprince: it works for me

16:05 user> (a 1 2 3).... 1

16:05 Raynes: futile: If you sign in you can delete one of them.

16:05 futile: Raynes: meh

16:05 Raynes: futile: Pastes get claimed on sign-in.

16:05 You don't have to. Doesn't matter to me. Just sayin'. :p

16:05 gtrak: shdwprince: where a came from: (my-macro a [b c d])

16:05 futile: Raynes: neat but i have no incentive to delete one

16:05 thx

16:06 vraid: (proxy B []) tells me it can't create an ISeq, (proxy [B] []) tells me no matching constructor for B

16:06 futile: Raynes: unless its taking up tons of space in your mongodb

16:06 then ill delete it

16:06 Raynes: Nope.

16:06 I have tons of space.

16:06 futile: sweet

16:06 * nDuff tries signing into refheap, and... nope, still no integration for AFYD addresses. *grumble*

16:06 futile: Raynes: but yeah please port https://www.refheap.com/17275 to elixir so i can add it to https://github.com/sdegutis/zephyros/tree/master/libs

16:06 Raynes: nDuff: AFYD?

16:06 nDuff: Raynes: Google Apps For Your Domain

16:06 shdwprince: vraid: B in constuctor have parameter of class C

16:07 (proxy B [C.])

16:07 Raynes: nDuff: Well, you don't need integration. You can always just sign in and create a new password and what not.

16:07 nDuff: Raynes: yeah. Absolutely not creating yet another password.

16:07 shdwprince: gtrak: (my-macro a [a b c]) fails

16:07 Raynes: That's life on the internet, man.

16:07 nDuff: Raynes: bah. There's OpenID, and _almost_ everyone supports it.

16:08 futile: yep openid ftw

16:08 Raynes: I don't think that's true.

16:09 futile: just login with google yay

16:09 Raynes: About 90% of sites I sign into daily do not use openID.

16:09 They use oauth and such.

16:09 gtrak: shdwprince: https://gist.github.com/gtrak/6158977

16:09 what's fail about that?

16:09 futile: Raynes: they probably use OAuth because they get OAuth and OpenID confused, but they probably just want OpenID

16:09 vraid: shdwprince: 'don't know how to create an ISeq.."

16:10 TimMc: Raynes: Well, you're not supposed to use OAuth for logins, so...

16:11 Raynes: TimMc: Well, certainly everyone does it.

16:11 shdwprince: vraid: can you show the code?

16:11 Raynes: I'd entertain the idea of Github authentication on refheap if people wanted to add it.

16:12 shdwprince: Raynes: I really want one think about almost perfect refheap - works with luakit (vimperator-like browser)

16:12 TimMc: (You *can*, but it's usually a bad idea.)

16:13 shdwprince: Raynes: it just not recognize input field as input field and dont turn INSERT mode on

16:13 Raynes: TimMc: You'd make a great facebook employee.

16:13 TimMc: ?

16:13 Raynes: Can you just give me a cookie that lets me edit any paste I make for as long as I have the cookie? I usualyl only want to edit within about 15 minutes of pasting.

16:13 Raynes: Given how many sites use facebook authentication, it'd be entertaining if you worked for them with your feelings about the process. :p

16:14 vraid: shdwprince: http://hastebin.com/dasatoqena.lisp

16:14 shdwprince: error on line 13

16:14 Raynes: TimMc, futile: Well, I actually forgot, but you can edit and delete pastes you've created even if you haven't logged in these days.

16:14 futile: oh

16:14 TimMc: Oh, nice.

16:14 Raynes: And you can keep doing that until your browser wipes the session, which is usually when it restarts.

16:14 futile: Raynes: yeah i edited it once a few minutes ago

16:14 TimMc: Carry on, then.

16:15 futile: so hows that elixir port coming along?

16:15 Raynes: It's not.

16:15 TimMc: That was the fastest feature implementation I've ever seen!

16:15 futile: ha

16:15 shdwprince: vraid: You pass 2 params into constuctor (function?) mtapp and string "scene"

16:16 vraid: I guess (mtapp "scene") will make instance of C?

16:16 vraid: so call it with braces and pass result into vector

16:17 vraid: shdwprince: (proxy AbstractScene [MTApplication] and (proxy AbstractScene [mtapp] give the same error

16:17 and (proxy AbstractScene []

16:17 shdwprince: vraid: what is mtapp? function?

16:18 vraid: you need to pass instance of class C, not class or function

16:18 vraid: i thought it would be a local variable

16:20 hugod: cemerick: I seem to have to connect a web browser to the url (cemerick.austin.repls/exec) displays before my cljs repl will eval anything - is that correct?

16:20 shdwprince: vraid: oh, thats not old class C

16:21 vraid: maybe tracebacks tells more?

16:21 vraid: ah ofc

16:22 cemerick: hugod: no, that should ramp up a phantomjs process in the background; the URL is there only in case you want/need to manually point a browser at the REPL env

16:22 vraid: shdwprince: figured it out, thanks for the help on the way http://hastebin.com/xecajuxobe.lisp

16:23 hugod: cemerick: I see no phantomjs process - I have it installed (via brew) and on my path (afaict)

16:25 cemerick: hugod: it'll error hard if the command isn't found, so you should know pretty quick if it's not on your path. This is with (cemerick.austin.repls/exec), and not (cemerick.austin/exec-env)?

16:26 gfredericks: having created a github issue, is there any way to push code to it that doesn't involve a separate pull request? I always end up creating two things...

16:26 technomancy: gfredericks: two things is fine

16:26 as long as they're linked

16:27 gfredericks: :(

16:27 * gfredericks creates a second thing

16:30 technomancy: to me an issue is about "the problem is in the codebase" and a pull request is about "the problem is this patch hasn't been applied yet", which are different things.

16:31 gfredericks: that's interesting

16:32 wakeup: What would be an idomatic way to loop over an (Java) array of strings and return a hash-map with the strings as keys and ANY-VALUES?

16:33 gtrak: what's any-values?

16:33 zipmap's probably what you want though

16:33 tbaldridge: wakeup: (zipmap (seq string-array) any-values)

16:34 seq probably isn't even needed

16:34 ,(source zipmap)

16:34 clojurebot: Source not found\n

16:34 tbaldridge: clojurebot: you fail

16:34 clojurebot: I don't understand.

16:36 gfredericks: ,(zipmap (into-array ["foo" "bar" "baz"]) (range))

16:36 clojurebot: {"baz" 2, "bar" 1, "foo" 0}

16:36 futile: welp

16:36 just wrote some python. i have to admit, clojure is awesome.

16:36 nDuff: ...heh.

16:36 gtrak: this also works: ##(into {} (map vector [1 2 3] [:a :b :c]))

16:36 lazybot: ⇒ {1 :a, 2 :b, 3 :c}

16:38 gfredericks: gtrak: is there some advantage there I'm missing?

16:39 gtrak: gfredericks: not as far as I know :-), but he's learning the ropes.

16:39 there's a few more ropes in that one

16:40 hugod: cemerick: with c.a.r/exec

16:41 gtrak: gfredericks: potentially, zipmap for some awful reason still doesn't use transients.

16:41 wakeup: NullPointerException my.stuff/eval1839 (NO_SOURCE_FILE:1)

16:41 what would that mean?

16:41 gtrak: when it creates the collection itself... I don't see why it wouldn't.

16:42 gfredericks: gtrak: sounds like an easy patch

16:42 gtrak: http://dev.clojure.org/jira/browse/CLJ-1005

16:42 gfredericks: I don't know of any reason zipmap shouldn't use into

16:43 oh good

16:44 gtrak: wakeup: you've got a null somewhere.

16:44 what's the expression you eval'd?

16:45 silmawien: is #^ just another name for the ^ reader macro? for example used in (source clojure.core/spit)

16:45 shdwprince: wakeup, if that in repl try (try EXPR (catch Exception e (.printStackTrace e))) to get full stack trace

16:46 anyone know smaller way?

16:46 h0bbit: wakeup: stacktraces are a bit wonky. but it should contain enough information (fully qualified function name, and a line number) for you to debug your problem

16:46 llasram: silmawien: It's the old (deprecated) reader macro for metadata

16:46 shdwprince: (clojure.repl/pst)

16:47 gtrak: shdwprince: (clojure.repl/pst *e)

16:47 llasram: (after an exception)

16:47 hah

16:47 silmawien: llasram: cool ty

16:47 gtrak: ah, pst uses *e in the no-arg too

16:48 gfredericks: I want there to be a lib that can take a pile of sample data and generate a json/edn schema for it based on some guessing.

16:48 h0bbit: does anyone know how I can have clojure.repl (say) always required?

16:48 cemerick: hugod: ah, replicated

16:48 h0bbit: I remember reading that leiningen might let me do this...

16:49 cemerick: hugod: you have an old piggieback being pulled in by a different dependency. austin requires com.cemerick/piggieback "0.1.0"; if you have anything older, phantom won't be started

16:50 llasram: gfredericks: For any particular sort of JSON/EDN schema-validation?

16:50 cemerick: hugod: `lein deps :tree` (or `lein pedantic`) to find the offending dep, and add exclusions as needed

16:50 hugod: cemerick: ah - that must be a new release...

16:50 cemerick: yeah, was over the weekend

16:51 * cemerick again contemplates defaulting pomegranate to translate "1.2.3" to "[1.2.3,)" implicitly (without all the sliding-range nonsense)

16:51 h0bbit: lein pedantic is now deprecated

16:51 gfredericks: llasram: both for validation and for test generation

16:51 h0bbit: try lein ancient

16:51 llasram: gfredericks: Ah, interesting

16:52 h0bbit: https://github.com/xsc/lein-ancient

16:52 cemerick: h0bbit: well, some people still use older lein revs, etc

16:52 gfredericks: I want to use something like test.generative but my data would be _way_ too tedious to describe

16:52 h0bbit: cemerick: yup :)

16:52 gfredericks: haskell has the advantage of you've already described it in your type definitions

16:52 (only an advantage assuming you've already done that)

16:53 hugod: cemerick: it works :)

16:53 cemerick: hugod: nice :-)

16:55 hugod: cemerick: do you have a way to run cljs tests from lein with this?

16:55 cemerick: hugod: http://github.com/cemerick/clojurescript.test?

16:56 I have other bits as well, but they're not baked

16:56 pbostrom: what do people use for machine learning in Clojure? pure clojure using core.matrix and/or incanter? Wrappers around weka, mahout, or some other Java lib? Some combination of all these things? Any other libs I might want to look at?

16:56 wakeup: So, my first day of paid clojure programming is over :)

16:57 Even though the CL programmer in me is disgusted, I can't say I wasn't productive! ;)

16:57 gtrak: do you change your nick to gosleep?

16:58 hugod: cemerick: thanks! this should make the cljs experience much, much simpler

16:58 wakeup: gtrak: me? no :)

16:58 cemerick: hugod: getting there. :-) There's some fundamentals yet to be addressed, but the tooling is improving.

16:59 ddellacosta: cemerick: props on releasing austin by the way, can't wait to dig into it further. Thanks for all your work on the ecosystem tooling (as always).

17:00 cemerick: ddellacosta: :-) BTW, I think I owe you an email...will try to toss the inbox soon...

17:01 ddellacosta: cemerick: no worries, I'm slow and swamped as well…I really need to catch up on some friend stuff. I'm also doing some work with Apache Shiro lately, and thinking it may be useful to integrate some parts with Friend, as far as the authorization stuff…but that's a whole 'nother conversation...heh

17:08 cemerick: ddellacosta: I looked at Shiro briefly, scared the bejeezus out of me.

17:08 :-D

17:09 hugod: cemerick: I'm still missing a jump-to-source that works with cljs in nrepl

17:09 nrepl.el I should say

17:09 cemerick: hugod: heh. I'd take doc lookups for cljs or something at this point. :-P

17:11 futile: Is there any tool yet that runs a single .cljs script on node, doing all the compiling and such under the hood?

17:15 ddellacosta: cemerick: yeah, it scares the crap out of me too. It's more that I think Friend could use a more comprehensive authorization plugin kind of thing…but it may make more sense to do something kind of agnostic. Anyways, just pie-in-the-sky stuff at this point.

17:15 cemerick: sure

17:16 clj_newb_2345: anyone aware of a PAIP (paradigns of AI programming / norvig) clojure port that did more than the first 3 chapters?

17:18 hiredman: g/win 19

17:30 hugod: cemerick: what determines the js loaded by phantom?

17:32 cemerick: hugod: it's a shim that austin generates; you can see it by view-source'ing that /start URL (see https://github.com/cemerick/austin/blob/master/src/clj/cemerick/austin.clj#L125)

17:33 There's some gnarly duplication around those shim pages (both /start and /repl), and a bunch of cruft in general due to other use cases from the original browser-REPL codebase that I'll eventually weed out

17:34 xeqi: cemerick: is there a way to add other script tags to /start? say for including jquery

17:36 ah, I completely missed static-dir as an option

17:47 * hugod fails to get austin to load his project code

17:51 cemerick|away: xeqi: that's treading into territory where you probably want to connect to a browser running your app

17:51 hugod: details?

17:52 hugod: cemerick|away: I try running (my.ns/var) and it complains "Can't find variable: my"

17:52 code compiles fine with cljsbuild

17:52 cemerick|away: hugod: after a suitable (ns whatever (:require my.ns))?

17:52 hugod: ahh

17:53 ok..

17:53 cemerick|away: someone needs to hack together a require macro for cljs

17:53 hugod: too used to having a goog.require in the repl web page I guess

18:08 Raynes: tpope: You need to get into Elixir and make the indent script not suck.

18:20 rlb: If you read N lines from a (line-seq stream), will stream always end up exactly after the lines read? i.e. is it OK to temporarily wrap a stream with a line-seq when you just want to pull off a few lines?

18:23 Raynes: rlb: Sure. It just calls .readLine on it over and over again, so it'll be wherever that puts it.

18:25 rlb: Raynes: ok, thanks.

18:43 ddellacosta: huh, is there a way to pass a connection to clojure.java.jdbc and get a db-spec for use with various functions? I'm trying to override a Java method, so I already have a connection.

19:07 justin_smith: ddellacosta: I would guess that clojure.java.jdbc creates some dynamic var internally - you could create a block binding the var c.j.jdbc binds?

19:07 you could look at what c3p0 does

19:07 it sets up connections in a pool that can be used with c.j.jdbc

19:09 ddellacosta: justin_smith: I'll investigate that. I'm just spiking something out now, so just ended up calling prepareStatement on the java.sql.Connection I already had--it was simple to do, even if not entirely ideal (dealing with java.sql.ResultSet = yuck). But I'll look into what you're suggesting.

19:09 justin_smith: thank you!

19:09 justin_smith: ddellacosta: http://stackoverflow.com/questions/11571433/what-is-the-proper-way-to-store-a-global-connection-in-clojure seems to hint that :datasource in the connection config will be used as a raw connection

19:11 ddellacosta: justin_smith: it's just silly since I've already got the connection ready to go, and jdbc seems to convert everything to a java.sql.Connection behind the scenes

19:12 justin_smith: ddellacosta: yeah, it breaks the abstraction that c.j.jdbc so lovingly crafted - but since c3p0 works that way, I would assume that you can generalize that that is a way to provide a raw connection where it would otherwise find a spec for creating one

19:13 I have used c3p0 with that method and can verify it works - c3p0 creates and manages the connections

19:15 ddellacosta: justin_smith: okay, thanks…I'll think on the best approach. This is a one-off method override inside of a proxy call, so may not be worth thinking about it too hard. But, we'll see...

19:15 justin_smith: try {:datasource pre-existing-connection} as your db spec

19:16 it looks like that is all you need

19:19 akurilin: Is there a general recommendation for whether one should use a map or a keyword as function to get the value? It seems like using key as function allows to handle the nil map case more gracefully.

19:20 technomancy: akurilin: key-first is usually preferred

19:21 callen: have you seen http://opam.ocamlpro.com/?

19:21 akurilin: technomancy, okie dokie, thx!

19:21 justin_smith: I use key-first, unless key is not a literal, then I use hash-first, unles s hash is not a literal either, in which case I use get explicitly

19:22 callen: technomancy: yep

19:22 technomancy: I use it.

19:22 technomancy: ecosystem is still ghetto even if OPAM is nice.

19:22 technomancy: akurilin: IMO because it's obvious at a glance that it's not a function

19:22 callen: technomancy: I really think the answer for me is to write Rust and hope the dust settles sooner rather than later.

19:22 technomancy: callen: looks like night-and-day vs the bleak hellscape I witnessed in 2011

19:22 justin_smith: that is why I mention the binding vs. literal

19:22 callen: technomancy: things have improved a lot more recently but the lack of real concurrency is a killer.

19:23 technomancy: callen: oh right; I forgot you actually care about that =P

19:24 callen: technomancy: I think Rust is a reasonable alternative.

19:24 technomancy: the design choices there seem palatable to me.

19:25 technomancy: seems reasonable if you're building mozilla-like programs I guess

19:26 Raynes: I'm always shocked to see OCaml still being… used.

19:26 It feels so utterly dead that I can almost smell the corpse.

19:26 supersym: lol

19:26 technomancy: Raynes: that's what I thought when I tried it 2 years ago

19:26 Raynes: Not to say it's a bad language. I don't know enough about it to have anything against it.

19:27 technomancy: but now oreilly is doing a cc-licensed book, and there's a package manager that actually works

19:27 Raynes: But it smells of attic dust.

19:27 :\

19:27 supersym: I know people who said that about lisp :P

19:27 Raynes: Yeah, but OCaml is one language and Lisp is numerous languages, one of which happens to be pretty popular (guess which one)

19:29 justin_smith: ocaml is a really good tradeoff of runtime efficiency with high level design, but yeah it is showing its age

19:30 if not for the lack of unboxed floating point I could have done some very interesting things with it

19:30 technomancy: I have a hard time caring about the lack of concurrency when considering ocaml as a second language alongside clojure

19:30 it fits in all the cracks where clojure doesn't

19:31 justin_smith: super fast compile times

19:31 for one

19:31 Raynes: technomancy: I use Elixir as my second language alongside Clojure and therefore I have excellent concurrency semantics given Erlangyness. :D

19:35 hyPiRion: Raynes: eof pls

20:02 callen: technomancy: the reason, sadly, I need concurrency is that I write micro-daemons and services.

20:03 clj_newb_2345: I'm aware of http://weavejester.github.io/hiccup/hiccup.util.html

20:03 is there a way to have escape-html always preserve spaces?

20:03 i.e. I want "a b" to generate 3 spaces in etween

20:03 this is important since I'm displaying some code in HTML in a fixed width font

20:04 justin_smith: clj_newb_2345: a hack would be a search and replace of " " to "&nbsp;" in the right places

20:04 clj_newb_2345: justin_smith: yeah, but there's multiple levels of transforms

20:04 so I'd prefer to do it "the right way"

20:04 but I completely agree with you

20:05 that it would work for this particular case

20:05 justin_smith: yeah, a hack for sure

20:06 clj_newb_2345: eh, fuck it

20:06 enough reading about css-white-space

20:06 I'm using this hack :-)

20:06 justin_smith: clj_newb_2345: https://github.com/weavejester/hiccup/blob/master/src/hiccup/util.clj

20:06 check the def of escape-html

20:07 it is so small, just make a version adding your own substitutions

20:07 clj_newb_2345: justin_smith: you are brilliant

20:07 thanks

20:07 justin_smith: lol

20:08 funny coincidence that it does exactly what I first thought of

20:09 clj_newb_2345: justin_smith: yeah, also funny how when you initially told me to just do a replace, I thought "this is a hack"

20:09 but now, after reading the hiccup source, the exact same code is "this is brilliant"

20:10 justin_smith: well I did call it a hack myself - I am prejudiced against strings, all codes involving strings is an ugly hack until proven otherwise to me

20:11 callen: justin_smith: do you know Python?

20:11 justin_smith: if so, I have a hack to show you.

20:11 justin_smith: heh, a little, go ahead

20:11 callen: justin_smith: https://raw.github.com/sjzabel/django-audit-trail/master/audit_trail/lib.py

20:12 justin_smith: I cleaned that up and committed it into a project I work on today.

20:12 Very proud.

20:12 justin_smith: believe it or not, it replaced a hack that was actually much worse.

20:12 justin_smith: nice - so why does your user wander around in the request anyway?

20:13 callen: justin_smith: SOP in Python WSGI-land.

20:13 justin_smith: I'm about to do the same thing in some Clojure code I maintain actually

20:13 justin_smith: now I am imagining an implementation of a simple 2d game where the player and mobs are represented by data structures embedded in a larger map (a pun, get it?)

20:13 callen: (retain the user inside the request)

20:14 the reason to retain the user in the request is so that it's not a global.

20:14 believe me, you don't want to go that route.

20:14 if you can help it.

20:14 justin_smith: I understand carrying user in request, but why have it in various places?

20:14 callen: hrm. in various places?

20:15 justin_smith: it is iterating looking for the user data, no?

20:15 futile: can any of this networking stuff be simplified by using builtin libs? https://github.com/sdegutis/zephyros/blob/master/libs/zephyros.clj

20:15 callen: justin_smith: that's not normal code man. it's walking the entire call stack if needs be.

20:16 justin_smith: that's not an exemplar of anything normal or good.

20:16 normally you have access to the request directly.

20:16 justin_smith: that's a hack to get around some insane signaling bullshit.

20:16 justin_smith: ahh, that was the missing detail

20:16 so in the clojure version you would not be walking the heap looking for the user

20:16 callen: justin_smith: gods no, you just pass around the immutable request.

20:17 and assoc the user into it in the middleware before passing it on to handlers.

20:17 justin_smith: yup, that's what I do

20:17 callen: well that's normally what you do in Python too

20:17 BUT

20:17 again, some specific use-case stuff fucking you over leads you to the aforementioned code.

20:17 justin_smith: yes, an excellent example of a hack

20:18 and a potentially easy vulnerability on top of that - just cause a "user" object to be created in some context...

20:19 callen: justin_smith: not easily, it checks the class instance.

20:19 justin_smith: and accesses of request.user are generally read-only.

20:19 so you'd have to add an attribute that was actually a decorated property to execute arbitrary code

20:19 egghead: is there anything like doseq that returns the values of the operations instead of nil?

20:19 justin_smith: egghead: for

20:19 callen: and in general, it's not an easy vulnerability because there's no way to inject arbitrary arguments into the call-stack like that.

20:20 justin_smith: for vulns from arbitrary argument injection, you'd want to look to Ruby, not Python.

20:20 egghead: justin_smith: ya, but like doseq instead of lazy like for, I want it to do the side effects but return the values

20:20 callen: Python has better semantics for that.

20:20 justin_smith: egghead: (into [] ...) or (doall ...) will force it

20:20 egghead: I wrote a weird macro but feels like there should be a built in solution

20:20 callen: for example, you don't explode the params from POST or GET into the function arguments. And even if you could, it would just be a string, not arbitrary code.

20:21 justin_smith: yeah, python is less magical, I am familiar with that

20:21 egghead: into [] hmm

20:21 callen: justin_smith: a lot of the most recent Rails vulnerabilities were because there was a vector for turning yaml into arbitrary Ruby code. Nutty.

20:22 justin_smith: egghead: because vectors are not lazy; but doall is more idiomatic

20:23 but vectors are nice and callable and you can do get on them etc.

20:23 technomancy: (partial into []) is vec

20:23 fwiw

20:23 justin_smith: ah, of course

20:23 I like (into [] ) because the [] are visually distinctive and mean vector

20:23 but yeah, vec is simpler

20:24 egghead: so (vec (for [side-effect side-effects] (effect! side-effect))) ?

20:24 thanks

20:26 justin_smith: egghead: yup - check this:

20:26 ,(do (for [i (range 10)] (println \a i)) (vec (for [i (range 10)] (println \b i))) nil)

20:26 clojurebot: b 0\nb 1\nb 2\nb 3\nb 4\nb 5\nb 6\nb 7\nb 8\nb 9\n

20:27 justin_smith: but if you don't need the vec there is always doall

20:27 I just like pointing out the handy dual action of the vector transform

20:28 callen: this is the code (vec ...) actually calls: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazilyPersistentVector.java

20:28 if anybody cares. which I imagine you don't.

20:28 * callen coughs and walks away awkwardly

20:29 justin_smith: yep, that sure is some java code

20:30 callen: justin_smith: oh come on, you've gotten curious and read the code too.

20:30 justin_smith: yeah, often

20:31 callen: well.

20:31 justin_smith: I often sit down with a glass of red wine, put on my slippers, put on mozart, and read some code

20:31 callen: just taking the piss now.

20:31 justin_smith: in all seriousness, reading code, awesome stuff

20:32 you've seen evidence I do it on this very channel

20:32 callen: justin_smith: most people don't actually read the code to the things they use.

20:32 I've found a very reliable way to detect whether somebody is a great programmer or will become one is whether they read code.

20:33 justin_smith: I've had this idea of putting together a little chapbook of beautiful code

20:33 I've even tried to talk some designers at work into helping me with this

20:33 not joking

20:33 callen: justin_smith: I've actually considered guided "read-alongs" of open source codebases.

20:34 justin_smith: published as a book.

20:34 justin_smith: like the lions book?

20:34 callen: it wouldn't be the entire codebase, just the necessary bits to give you a decent comprehension of how it works and to point out interesting/unusual things along the way.

20:34 justin_smith: yeah but for modern stuff.

20:34 I'm not talking a docco dump of the entire codebase necessarily.

20:35 justin_smith: sure, makes sense

20:35 callen: justin_smith: it's something *I* would pay for but I worry most others wouldn't.

20:35 justin_smith: I've come really close to publishing something like that on pragprog for $5-10

20:35 depending on how voluminous it was.

20:36 there's a book or two on the architecture of open source projects but it's way too high level.

20:36 justin_smith: code and commentary on facing pages like they do with poetry translations could be done nicely

20:37 callen: the design and typography could be done in such a manner as to make it quite the aesthetic experience too.

20:37 justin_smith: what codebases do you think people would want to learn? I think jQuery is an obvious one. Not sure what else.

20:40 justin_smith: hmm

20:41 I think well written code, in general - maybe TeX

20:41 callen: justin_smith: I don't think most people actually want to read that. It's not relatable.

20:41 justin_smith: very few people use TeX anymore.

20:41 justin_smith: but it is well written

20:42 http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web

20:43 callen: too arcane man.

20:44 I might use LaTeX but very few people outside of academia do so anymore.

20:44 justin_smith: what is exemplary is the relationship between the comments and code

20:45 callen: well...Knuth.

20:47 hiredman: the problem with things like tex and literate programming is what do you do when you are thrown up against a large code based written by someone who doesn't go in to those things?

20:47 you have to learn to follow code without the literate stuff, at which point, how many people would still go through all the effort of maintaining the literate style?

20:48 justin_smith: hiredman: I've found that adding comments and unit tests is a great first step for taking on someone else's ad-hoc code

20:49 hiredman: so in response to my "how many people..." question that is like you and four other guys

20:49 justin_smith: heh, I don't even do true literate programming

20:49 but I like it when reading for the sake of reading code

20:49 of course I have to be able to read bare code as well

20:50 hiredman: in coders at work that is one of the interview questions they all get asked "how do you approach a big code base?" or something like that

20:50 the last time I came across literate code, I was trying to read about cribit tries, and this pdf was horrible

20:51 justin_smith: add unit tests as I read and edit the tests until they pass is something that has worked for me (then actually go back and turn them into tests of functionality, rather than tests of my reading comprehension)

20:52 and then adding any missing comments based on what I learn there

21:05 anyone familiar with lein-beanstalk?

21:11 ztellman: anyone have pointers on coming up with minimal examples for locals-clearing bugs?

21:12 I've found a case that has a bug, and the change that will make it go away, but it's full of a bunch of other code that may or may not be relevant

21:17 justin_smith: ztellman: I am no expert, but that is an interesting question. It seems like showing code that fails, but only without :dispable-locals-clearing set in *compiler-options* would be helpful (for all I know you are doing this already)

21:17 *:disable-locals-clearing

21:18 ztellman: justin_smith: sorry if I wasn't clear, this is where locals that should be cleared aren't being cleared

21:18 not the other way round

21:18 justin_smith: ahh

21:19 so not npe, but leaks

21:41 ztellman: justin_smith: hopefully this will put someone on the right track: https://gist.github.com/ztellman/6161154

21:41 I certainly have no idea what's going on

21:44 justin_smith: fascinating - I don't think you could express it much more concisely

21:50 benedikt: How can i "import/use" a clojure-contrib library in a project? I'm a bit lost. I have added clojure.core/contrib "1.5.1" in the :dependencies vector, but a java exception si thrown if i pput (:use [clojure.contrib.server-socket :only [create-server]]) in (ns), then a java FileNotFound exception is thrown.

21:55 dnolen: benedikt: don't use clojure-contrib it's deprecated

21:55 benedikt: dnolen: what should i use then?

21:56 dnolen: benedikt: I would probably just use the Java APIs directly or look for a non contrib library that accomplishes something similar

21:58 benedikt: dnolen: well, this is what google comes up with when searching for "clojure socket"

21:58 dnolen: benedikt: yes, a lot of old outdated information come up as relevant hits

22:04 benedikt: if i change profile.clj, how do i update the nrepl in emacs (nrepl-jack-in)?

22:12 zenoli: benedikt: I normally run lein repl in a terminal for better control and then just M-x nrepl to connect to it (though you have to note the port number).

22:12 benedikt: zenoli: that sounds like a much better way

22:13 zenoli: benedikt: I think nrepl-quit will kill a server started by nrepl-jack-in, though.

22:14 benedikt: I doesn't work to inlude a libaray in (ns (:use libname)) but (use 'libname) works to include it. What am i missing?

22:17 zenoli: (ns (:use [libname]))

22:17 technomancy: benedikt: you have to give ns the name of the namespace you're declaring

22:17 not just the ones you want to depend on

22:17 zenoli: That, too.

22:18 benedikt: zenoli: that worked. technomancy: i omitted it by mistake when copying from my file.

22:22 xeqi: cemerick: yeah, that is getting into app territory.

22:29 dnolen: all the source code for my "CSP is Responsive Design" post here - http://github.com/swannodette/swannodette.github.com/blob/master/code/blog/src/blog/responsive/core.cljs

22:30 core.async is damn pleasant to work with

22:30 atyz: Hi guys, This might seem like a stupid question. I'm currently setting up config in an app, currently I'm storing my config data in a regular var. Would it be more correct for me to use an atom? https://www.refheap.com/17299

22:31 And if not, when would be appropriate for me to use an atom?

22:45 danielszmulewicz: dnolen: are you an emacs user?

22:45 dnolen: danielszmulewicz: yes

22:45 danielszmulewicz: dnolen: nrepl + piggieback?

22:46 dnolen: danielszmulewicz: no I just use inferior-lisp

22:46 danielszmulewicz: dnolen: that gives you a browser connected repl or you need to refresh?

22:47 dnolen: danielszmulewicz: browser connected repl, but for some of this stuff I haven't bothered as I used settings so that <1s compile times and lot of it refactoring, not writing new code, so the compiler warnings are more useful.

22:47 "I use lein cljsbuild settings optimized for ~1s compile times" I mean

22:48 danielszmulewicz: when the fancy CLJS REPL experience is a bit further along I'll probably switch but it's still early days yet.

22:49 danielszmulewicz: dnolen: thanks. Would love to have a closer look at your setup. I've spent two nights on trying to set up an environment to get going smoothly with clojurescript in Emacs, and I'm still nowhere.

22:50 dnolen: piggyback + nrepl is nice because of the browser connected repl, but throw in cljsbuild in the mix and it breaks

22:50 dnolen: danielszmulewicz: I don't do anything fancy. Browser REPL + inferior-lisp and lein cljsbuild settings optimized for dev. Works well enough for me and at least as good as my JS dev - better since CLJS actually warns you about stupid mistakes.

22:51 danielszmulewicz: dnolen: cool, so at least you do use cljsbuild. good to know

22:51 dnolen: danielszmulewicz: I used lein cljsbuild auto

22:51 danielszmulewicz: dnolen: cool

22:51 dnolen: danielszmulewicz: https://github.com/swannodette/swannodette.github.com/blob/master/code/blog/project.clj

22:51 danielszmulewicz: dnolen: great. thanks.

22:51 dnolen: danielszmulewicz: I use dev settings until the code is ready to go, and then I switch the advanced profile when I'm done.

22:53 danielszmulewicz: dnolen: got it. fantastic. I can dive back in with those directions. More sleepless nights :-)

22:55 dnolen: I love the innovation in the Clojure community, but the tooling can be rough when you compare with CL.

22:56 dnolen: danielszmulewicz: very true, CLJS tooling is particularly young - just a matter of time though - I think core.async really puts CLJS ahead of the pack - so hopefully we get some more folks pushing things along.

22:57 danielszmulewicz: lot of opportunities here given the flexibility and simplicity of the CLJS analyzer

22:59 technomancy: have you ever considered making a Leiningen a GitHub org?

23:07 tomjack: is it dangerous to (.newInstance (class (proxy ...))) ?

23:16 dnolen: ambrosebs: I responded on the Typed CLJS design page http://dev.clojure.org/display/design/Typed+CLJS?focusedCommentId=8192590&#comment-8192590

23:17 tomjack: eh, well, moot :(

23:19 ambrosebs: dnolen: great! really helps

23:19 squidz: cemerick: awesome work on austin. Makes clojurescript a lot more welcoming

23:25 dnolen: ambrosebs: a bit off in the weeds, but typed channels are an interesting problem, you might have a channel that has many different types but on a code path you might want to narrow it ...

23:25 ambrosebs: dnolen: do you ever have unreadable/unwriteable channels?

23:26 or, would you ever want the type system to forbid reads or writes to a channel?

23:27 dnolen: ambrosebs: yes you would want that, bbloom submitted a patch for ReadPort & WritePort

23:27 w/ dynamic exceptions for bad ops

23:27 ambrosebs: ok. I will add that in.

23:28 dnolen: ambrosebs: does Typed Clojure have casting? Can I cast a more generic type to a more specific one?

23:28 (Chan Any) -> (Chan (U (Value :foo) (Value :bar) Number)) ?

23:31 ambrosebs: dnolen: hmm it's weird with channels.

23:31 dnolen: usually you'd rely on some predicate like chan-of-int?, but that doesn't make sense I think..

23:31 dnolen: the answer is yes, but unsoundly through the backdoor

23:32 dnolen: in general, there is safe casting though, yes.

23:32 dnolen: if a predicate exists.

23:32 dnolen: ambrosebs: oh hmm, I'm thinking about stuff like this http://github.com/swannodette/swannodette.github.com/blob/master/code/blog/src/blog/responsive/core.cljs#L64

23:33 ambrosebs: there many be types of messages on the channel, but if I filter out some type of message, is that propagated?

23:34 tomjack: cool, I hadn't seen that stuff. you've found it pleasant to do stuff like r/filter on channels?

23:34 r/map I guess is the best representative

23:35 dnolen: tomjack: yes very much - you build up your event stream using Rx style techniques, but you don't have to deal w/ for the more complex bits of logic

23:36 tomjack: I guess I should not be surprised that it could be pleasant, since Rx can be pleasant

23:36 ambrosebs: dnolen: no, we don't attempt to refine the type of mutable types

23:36 tomjack: and this has gotta be a lot better than Rx :)

23:36 dnolen: ambrosebs: well e is not mutable, so maybe that's enough?

23:37 tomjack: I could never decide whether r/map on a channel was a category error or not

23:37 dnolen: tomjack: I think so, I went back and forth w/ someone today trying to my example in pure Rx style, we'll see how that turns out.

23:37 "trying to do"

23:37 noidi: is this still true for core.async? "This library is work-in-progress, experimental, broken etc. It should only be used by people working on it, ATM."

23:38 ambrosebs: oh, yes that's fine. Once you have a local binding it gets updated wrt predicates.

23:38 noidi: it seems that people really don't pay heed to the latter sentence :)

23:38 dnolen: ambrosebs: OK cool, so that would still be cool to demo

23:38 ambrosebs: yes, occurrence typing at work.

23:38 dnolen: noidi: there are rough corners, but I've been using it's since it's release and the CLJS version is pretty rocking

23:39 ambrosebs: ok, well if you've got notes on what help Typed CLJS needs to move forward, I'll look at them :)

23:39 noidi: dnolen, yeah, I read your blog post. it was a great introduction to core.async, thanks for writing it!

23:39 dnolen: noidi: np

23:41 noidi: I fixed up the my CSP post so that it works w/ IE 6 :), nothing wrong w/ core.async all cross browser DOM quirks.

23:42 noidi: this one, http://swannodette.github.io/2013/07/12/communicating-sequential-processes/

23:42 noidi: yes, that's the one I was talking about

23:44 ambrosebs: dnolen: is a timeout channel readable & writeable?

23:45 dnolen: ambrosebs: ReadPort/WritePort hasn't landed yet, but I imagine timeout w/ only be readable when it does

23:45 bbiab

23:45 ambrosebs: ok.

Logging service provided by n01se.net