#clojure logs

2013-08-05

00:00RaynesAnd we have a programming language designed to do everything else.
00:00callenxeqi: what?
00:00callenxeqi: no, this is me being lazy and writing a lein plugin for something stupid.
00:00RaynesYou 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
00:03xeqicallen: I was just suprised to see a manual ssh to clojars
00:03xeqigiven `lein deploy clojars` is builtin.
00:03callenthis is quickly becoming monstrous.
00:04callenxeqi: does that do the pom and the jar too?
00:04callenthank you for telling me that existed.
00:05callen(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:")
00:05callenthere, shriek in horror you bastards.
00:05callensee what you made me do?
00:05callenxeqi: you shouldn't be, you're the one that told me about lein deploy.
00:06callenI asked about this yesterday and it was *crickets*
00:07callenwell alright then, I can nuke this then.
00:42bjaif 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?
00:43RaynesWell, 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.
00:51technomancymuhoo: can you get that in the issue tracker please?
02:39xsynIs there anyway to give an index to the items in a lazy-seq?
02:41TEttingerxsyn, there
02:42xsynhi
02:42TEttingerthere's always ##(vec (map inc [1 2 3 4]))
02:42lazybot⇒ [2 3 4 5]
02:42xsynawesome, thank you
02:42TEttingerit only makes sense for finite seqs
02:42xsynI'll take a look
02:42TEttingerif you do it on, say, ##(vec (repeat 5))
02:43TEttingerthat will be an execution timeout
02:43lazybotExecution Timed Out!
02:43xsyn:)
02:43TEttingerbecause repeat 5 is an infinite sequence
02:43xsynit's a finite seq, so should be good
02:43xsynI've been breaking my brain on some of these things. Absolute n00b
02:43TEttingervecs may have different conj order if you conj on them, compared to lazyseqs
02:44TEttinger,[(conj (map inc [2 3 4 5]) 7) (conj [3 4 5 6] 7)]
02:44clojurebot[(7 3 4 5 6) [3 4 5 6 7]]
02:45TEttingeryeah, you can see there, map returns a lazyseq, and conj'ing on it attaches at the beginning, but the vec attaches at the end
02:46xsynuhm
02:47xsynI'm not sure I understand
02:47seancorfield(map vec my-lazy-seq (range)) ??
02:47lazybotseancorfield: Definitely not.
02:47seancorfieldgee, thanx lazybot :)
02:48seancorfield##(take 6 (map (iterate #(* 2 %) 2) (range)))
02:48lazybotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn
02:48seancorfieldbah... too late for this stuff
02:49seancorfieldoh, ##(take 6 (map vec (iterate #(* 2 %) 2) (range)))
02:49lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$vec
02:49TEttingerxsyn, uh hm. map returns a lazyseq, as you've probably run into by now (my biggest beginner mistakes revolved around laziness)
02:49seancorfield##(take 6 (map vector (iterate #(* 2 %) 2) (range)))
02:49lazybot⇒ ([2 0] [4 1] [8 2] [16 3] [32 4] [64 5])
02:49seancorfieldi knew i'd get there eventually :)
02:50TEttingerthese days I try to only deal with finite sequences, and vec them whenever possible to get more stuff I can do with them
02:50TEttingerlike indexes
02:50seancorfieldand there's always map-indexed right? :)
02:50TEttingerdoes that work on seqs?
02:50TEttinger,(doc map-indexed)
02:50clojurebot"([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."
02:51seancorfieldall depends what xsyn really wants
02:51TEttingerlooks like it
02:51xsynTEttinger: I'm busy pulling a data obj via congomongo, which comes back as a bunch of maps in a lazy seq
02:51zeroemalternatively, you could also manage the loop yourself and just pass an incrementing value along with everything else
02:51TEttingerI've used congomongo a bit
02:51xsynwhat I want to do is to be able to pull a specific map out of that based on it's index
02:52seancorfieldnth?
02:52clojurebotmonad labyrinth is http://oglaf.com/labyrinth/ (SFW, but has NSFW links)
02:52xsyn*looks*
02:52seancorfield,(doc nth)
02:52clojurebot"([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."
02:52seancorfield,(nth (range) 25)
02:52clojurebot25
02:53xsynhah, that looks promising.
02:53TEttingerzeroem, 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
02:53TEttingerI mean I get it now
02:53seancorfieldalthough why would you be pulling anything much beyond first of that sequence? other than just iterating thru the whole result?
02:54TEttingermy 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
02:55seancorfieldgenerally, with congomongo, i find i'm either (doall (map f some-congo-result)) or (doseq [row some-congo-result] ... row ...)
02:56TEttingermy 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
02:56TEttingerthat one line took me about an hour to write
02:57TEttingerit's array indexing code
02:57TEttingerin a section that was a speed bottleneck
02:57xsynnth may well work
02:58seancorfielddon't have to explain it to me... but i'm off to bed anyways...
02:58xsynthank you all
02:58seangonexsyn: glad we could help...
02:58xsynme too :)
02:58xsynnice community
02:58TEttingerxsyn, I learned something too, I thought nth only worked on numbered index colls
02:58TEttingerthanks seangone
02:59zeroemTEttinger: if you have a set, then maybe this? http://clojuredocs.org/clojure_core/clojure.set/index
03:00zeroemassuming that by "indexing" you mean the database/fast look up kind of indexign
03:00TEttingernot really, literally finding the index that lines up in a large array to a subset of a smaller array, all 1D emulating 2D
03:03TEttingerzeroem, I haven't been using sets enough, that could be really handy
03:05zeroemoh my, look at the time
03:09xsynhmm, I actually need the reverse of n
03:09xsynnth*
03:10xsynso from a k v pair, what is the index in the se
03:10xsynseq*
03:13TEttingerxsyn, ah, but v could repeat
03:13xsynit's unique
03:13TEttingerso you really want the first that satisfies (= v what-I-want), which will also work for unique
03:13xsynbut I understand the abstration
03:14xsynwell, I want to know where it is in the seq
03:14xsynnot the actual value of it
03:14samratin clojure.java.jdbc is it possible to insert! with a `where` condition? I want to avoid adding duplicate columns.
03:15xsynI need a break
03:15xsynbbiab
03:17TEttinger,(keep-indexed (fn [idx elem] (if (= elem :search-target) idx)) (repeatedly (fn [] {(rand-int 10000) (if (= (rand-int 4) 0) :search-target :not-correct)})))
03:17clojurebotExecution Timed Out
03:19samratthis is what I want to do(with java.jdbc) https://www.refheap.com/17238 . Is that possible?
03:20muhootechnomancy: done.
03:20samratI'm doing a separate query to check for duplicity
03:26TEttingerxsyn, 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"]]
03:26TEttingerand if you just want the key, that might be... key
03:26TEttinger(that's not technically true, but map entries act like 2-element vectors)
03:28TEttingeroh nvm, you wanted the index in the seq, not the map
03:31TEttinger(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)
03:32TEttingerworst case is linear time, best case is the first entry is what you want
03:32TEttingeractually nth on a seq is linear, so O(n^2)
03:39shdwprinceprovide one more argument to nth (like nil) to receive that value if not found and avoid out of bounds
03:56TEttingerhttp://www.reddit.com/r/technology/comments/1jk1gz/sourceforge_starts_using_enhanced_adware/ uh oh...
04:07bjadoes ns's :require support [library :only [something :as other-name]]?
04:07bjaerr, that question is awful, nvm
04:10muhoowho the hell uses sourceforge anymore?
04:11muhooit's not 2001 anymore
04:13bjasf still exists?
04:13bjado they support git?
04:13muhoohttp://24.media.tumblr.com/tumblr_llpyemJT3v1qjfdudo1_500.gif
04:15katratxobja: http://sourceforge.net/p/forge/documentation/Git/
05:18dotemacsI guess you'd use SF just retro kudos
05:59xsynI'm trying to use congomongo's distinct-values, as found here: https://github.com/aboekhoff/congomongo/blob/master/src/somnium/congomongo.clj
05:59xsynbut I'm getting a: No matching method found: distinct for class com.mongodb.DBApiLayer$MyCollection
05:59xsyndoes anybody have any ideas why?
06:15mccraiglooking for a clojure parser combinator lib : anyone got good/bad experiences to report ?
06:18hyPiRionmccraig: 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
06:18TEttingerxsyn: well, are you calling distinct or distinct-values?
06:18hyPiRionthen there's parsatron, but I've not used it so I can't comment on its quality
06:19xsynTEttinger: I'm calling distict-values
06:19TEttingerxsyn, also, your MyCollection you're passing in, it must not be coerceable to DBCollection
06:20TEttingererr, or it doesn't have a getColl?
06:20TEttingerget-coll I mean
06:20xsynhmm
06:20xsynit seems ok
06:20TEttingernot knowing what MyCollection is, I can't comment
06:20xsyn:) that's a clue
06:21xsynI don't know what my collection is
06:21xsynwhich means, that the collection is probably the isse
06:21xsynthe collection I'm passing it should just be a users collection
06:23mccraighyPiRion : 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 ?
06:24TEttingerTSV is easy to parse
06:26TEttinger,(clojure.string/split "alpha\tbeta\tgamma" #"\t")
06:26clojurebot["alpha" "beta" "gamma"]
06:26mccraigwell, yes : fixed-field is easy to parse too
06:26TEttingerthe few gigs is the hard part
06:27TEttingeryou probably want to split the file if possible
06:27TEttingerunix split is handy
06:27mccraigit's fixed-field, so a lazy sequence of records is straightforward
06:33h0bbit_dark_element, hello :D
07:14hyPiRionmccraig: yeah, that's too much for instaparse, but a hand-written one should suffice really
07:15mccraighyPiRion: sure, i', just trying to minimise the code i have to write
08:03lgs0phtIs this channel also about datomic?
08:05cmdrdatslgs0pht: you probably want to ask at #datomic
08:18xsynTEttinger: it was a semantic thing I didn't expect it wanted a string for the collection, rather than the :symbol
08:18TEttingeroh weird
08:19TEttingerglad you figured it out
08:21xsynThanks for your help today, I finally broke through 10 lines of code that have been keeping me up at night
08:23ro_stxsyn: are you Guy?
08:23xsynHey Rob
08:24xsynYeah :)
08:24TEttingerxsyn, I know how it is
08:24ro_sthey :-)
08:24TEttingerI've been dreaming in code lately
08:24ro_stglad to see you in clojure land!
08:24TEttingerhey ro_st
08:24xsynro_st: I'm about to put my first bit of Clojure into production :)
08:24ro_sto/ TEttinger
08:24TEttingercool!
08:24ro_stxsyn: that rocks, man!
08:25clojurebotclojurebot is a time-capsule for snark
08:25xsynro_st: I saw some of your stuff the other day, it's looking great
08:25ro_stwhich stuff is that?
08:25xsynThe Cognician stuff
08:25ro_stoh, our actual app?
08:25xsyn*nod*
08:25xsynit's come a long way
08:25ro_stheh, thanks
08:26ro_styeah. going to go a helluva lot further, too :-)
08:26ro_stso many plans.
08:26xsyngood :)
08:27ro_stfeel free to hit me up on the twitters if ever you want some help
08:27ro_stgetting quite serious about the whole clojure thing here in SA!
08:28TEttingersan antonio?
08:28ro_stsouth africa :-)
08:28TEttingerwoah, way off
08:28TEttingercool
08:30xsynro_st: Thanks man, I will. I think my biggest fear at the moment is I'm not sure it's entirely idiomatic
08:30xsynbut I'm slowly getting my head around that
08:31ro_stthat's the sort of thing that sinks in
08:31xsynI'd also be interested to chat about workflow
08:31ro_stquicker'n you'd think
08:31ro_stfor sure!
08:31xsynhow's the cpt clojure user group?
08:31ro_stwe're meeting again on the 17th
08:32ro_stdoing 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
08:32ro_stif no newbs show up we'll probably just end up yakking
08:33ro_sti've got my head around Pedestal for the most part now, so i might show some of that too
08:33xsynwas just about to ask about that
08:33xsynI want to spend some time on that tut
08:33xsynapparently it's about 8 hours worth of learning
08:33ro_stway more than that
08:34ro_stthe 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
08:37xsynWell hopefully I'll be able to put the sweat in after this goes lives
08:41ro_stawesome :-) be keen to hear what you think
09:19cmajor7what'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?
09:23ro_stcmajor7: we use (System/getenv "key") and we have a config ns that just fetches many of these into CAPITALISED-THINGS
09:23ro_stwhere a default is suitable, we do (def SOME-THING (or (System/getenv "SOME_THING") :a-default-value))
09:23shdwprincecmajor7: or you can store config in hash map and use (read-string "data...") to get it
09:24ro_stwe also make these vars ^:dynamic so that they can be rebound in test runs
09:24ro_stcmajor7: fyi, http://12factor.net/config
09:27cmajor7ro_st: yep, was thinking about using ^:dynamic for profiles, but it seems a bit strangle to use ENV properties for app properties
09:27cmajor7shdwprince: yes, hence EDN, store them as map and use reader to get them
09:28ro_stby putting it outside the code, you make it possible to run the code in different configs without having to version control those files
09:28ro_stwhich is what that link i pasted basically says
09:28ro_stallows you to treat the whole git repo as a unit with consistent semantics, rather than the whole lot except for this one config file
09:29cmajor7ro_st: not sure I follow: "without having to version control those files" vs. "whole lot except for this one config file"
09:30ro_stif you run your code in more than one environment eg production and test
09:30ro_sts/test/staging
09:30cmajor7ro_st: I do want them versioned controlled, at least their sensible defaults
09:31cmajor7ro_st: right, so why use System/env vs. EDN ?
09:31ro_stto 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
09:32ro_styou can use edn as well, but env vars are universal
09:32cmajor7but can't you just run with -Dprofile=qa, and have your code to read by profile vs. to "know about all possible deployments"
09:33ro_styou could :-) but then your code has to know all the profiles
09:33sbinqHi, 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?
09:34ro_stin 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
09:34ro_stdnolen: over to you :-) /cc sbinq
09:35cmajor7only 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..
09:35ro_stcmajor7: you could totally do the edn thing. but it's complecting your app behaviour with your app configuration.
09:36ro_stwe created a config ns with everything in it. we've got about 20 different things in ther enow
09:36ro_staws creds, datomic, various enable-thing flags
09:36nirrubHi - 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}"
09:36cmajor7ro_st: is it really complecting? how do you represent a nested map using System/env?
09:36nirrubThis only happend when I run the uberjar via a regular java -jar command
09:37ro_stcmajor7: we don't
09:37ro_stwe use scalars
09:37ro_stcmajor7: you might like http://github.com/weavejester/environ
09:38stuartsierra1nirrub: Your resource is inside a JAR file, so you can't get it as an ordinary File.
09:39cmajor7ro_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
09:39TEttingersbinq, 100 wide, 100 high?
09:39ro_stthere you go, then :-)
09:39TEttingerand the async code might generate a process for every cell in that 100 * 100 block
09:39nirrub@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?
09:39sbinqTEttinger: but it is not a number of go "processes" - it is size of greed, correct? Or I do not see them launched somewhere?
09:40stuartsierra1nirrub: I don't understand your question. If you need a java.io.File, you can't get it out of a JAR.
09:40nirrubstuartsierra1: Ok, thanks a bunch!
09:40sbinqTEttinger: s/greed/grid, sorry
09:40TEttingersbinq, heh I was confused
09:41TEttingeryeah, I think it loops 10000 times, and creates an async process with >! in each
09:41cmajor7ro_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...
09:42sbinqTEttinger: m. isn't >! just writing to a channel - not creating a process?..
09:42ro_stcmajor7: we prefix all our env vars
09:42cmajor7right, that is how you cheat the proper structure :)
09:43ro_st-grin- yes :-)
09:46dnolensbinq: there 10,000 concurrent running go blocks, each go block is in an infinite loop.
09:48jonasendnolen: did you test the reader optimizations for anything other than V8?
09:48sbinqdnolen: 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?
09:48dnolenjonasen: not really why?
09:48dnolensbinq: they are launched by writing "go"
09:50kmicubREPL is now called "bionic REPL" https://github.com/cemerick/austin
09:50sbinqdnolen: 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?..
09:50jonasendnolen: I don't have spidermonkey or jsc installed so I was just wondering if you saw similar numbers
09:51dnolensbinq: oh oops that's just a typo
09:52sbinqdnolen: oh thanks, I was having many doubts about my sanity already ;) what should be the correct version?
09:53ro_stcemerick: thanks for austin! definitely going to try it out
09:54cemerickro_st: sure :-) Knocking together a quickie demo vid right now.
09:55kmicuYou already have good demo vid in README ;]
09:55dnolensbinq: updating now
09:55ro_stvideo, awesome. clojure community could certainly do with more videos!
09:56sbinqdnolen: thank you, will check updated post
09:56dnolensbinq: I'll be including the code for all the posts into the blog repo over the next week or so
09:56kmicuyep, more clojure porn
09:56ro_stdnolen: when do you start campaigning to use cljs at the NYT? :-)
09:56hyPiRionro_st: honestly, I think the Clojure community has many videos (presentations?) already. But I would love to have more, of course.
09:57ro_sthyPiRion: it has lots. but it can always do with more. i've watched everything already.
09:57ro_steven the koan walkthroughs
10:00ro_stit'd be great to see some more Datomic videos. plenty of topics in the docs that could benefit
10:05dnolensbinq: post updated
10:05sbinqdnolen: thank you!
10:06dnolensbinq: thx for pointing it out
10:09TEttingersbinq, sorry, I don't know how the async works, I guess my answer was misleading
10:10sbinqTEttinger: it's ok, thanks for trying to help :)
10:20degAre 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:20dnolensbinq: 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:23dnolenstuartsierra1: can we do another CLJS release?
10:23stuartsierra1dnolen: suer
10:23stuartsierra1*sure
10:23dnolenstuartsierra1: thx!
10:23stuartsierra1It's cookin.
10:24stuartsierra1http://build.clojure.org/job/clojurescript-release/30/
10:44jonasendnolen: so CLJS-565 didn't make it into this release?
10:45dnolenjonasen: no, but releases are quite easy now, pretty much automated
10:45jonasendnolen: ok, no problem.
10:51isomorFFFHello, 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:52isomorFFFI think it's because of number of arguments
10:54kmicuo_O
10:56stuartsierra1isomorFFF: Check the javadoc for java.io.BufferedWriter: you're probably calling it with the wrong number or wrong type of arguments.
11:20Anderkentis there a lein thing that warns you about unused imports/uses/requires?
11:26kmicumaybe eastwood, bikeshed, kibit...
11:29clgvAnderkent: slamhound can rebuild your ns form
11:29Anderkentclgv: yeah but not if you `use` stuff
11:30Anderkent(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:31squidzwhat'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:32squidzor Hour > Week because there are many hours in a week
11:32clgvsquidz: keywords and a function to compare by granularity
11:32squidzclgv: what do you mean?
11:34clgvsquidz: 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:37clgvsquidz: btw there are libs for using units in clojure. maybe one of these already implemented the comparison
11:38squidzwhat 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:40squidzSo i'm not sure what would be a good way with clojure(clojurescript)
11:41squidzfor 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:43squidzthe data structure that is
11:50konrAre there other clojure conferences besides clj/conj and clj/west?
11:50nDuffkonr: LambdaJam has a lot of Clojure folks, though it isn't a Clojure conference as such.
11:51konrnDuff: interesting!
11:51tim_EuroClojure
11:52zerokarmaleftstrangeloop brings a lot of clojure folks also
12:05clgvwhat knowledge is there about multiple data_readers.clj files?
12:06clgve.g. when a library has one and the project using it wants to have one as well?
12:07gfredericksclgv: looks like they get merged together
12:07gfredericksif there's a conflict it throws at clojure-load-time
12:08clgvgfredericks: but in a uberjar scenario one would replace the other in a non-specified way?
12:08gfredericksthat's an interesting question
12:08gfredericksI'm gonna go try it.
12:11gfredericksclgv: that is indeed the case
12:11gfredericksI was able to clobber a lib's file by supplying my own
12:11gfredericksand confirmed the value was missing at runtime from the repl
12:11gfredericksI wonder if this is something leiningen should be worried about
12:12clgvgfredericks: humm than it's probably better not to include that file in a lib
12:12gfredericksI've done that at least twice
12:12gfredericksit's kind of a lame limitation
12:13gfrederickshmmm
12:13gfredericksI could see an argument the other way though
12:13gfrederickscertainly a lib that does reading internally can just set it at runtime
12:17clgvgfredericks: I thought of including it to not have to tell every user to write that file in their project
12:18TimMcgfredericks: Clobber the entire file, or just one reader entry?
12:19xeqiany files of the same name will have this problem for an uberjar
12:19gfredericksTimMc: the whole file
12:20gfredericksapparently if you have two files in two libs with the same absolute name, `lein uberjar` will silently pick one
12:20technomancyI think there's an open ticket for :uberjar-merge-with
12:20clgvxeqi: yes, there are namespaces therefore but data_readers.clj needs to be top-level so it is *special* ;)
12:20gfredericksI was just heading to the githubs to check
12:20technomancyhttps://github.com/technomancy/leiningen/issues/973
12:22technomancystill time to get it into 2.3.0 if anyone cares enough to implement it =)
12:24clgvtechnomancy: my question was more directed in the direction of tagged literals best practices related to data_readers.clj
12:25gfrederickstechnomancy: I was having trouble testing https://github.com/technomancy/leiningen/issues/1276
12:26technomancypray tell
12:27clgvshould a library have its own data_readers.clj for easier setup in projects?
12:27clgvthat was about it^^
12:34clgvhuh, in CCW data_readers.clj seems not to be loaded? I thought that is no leiningen business but clojure runtime business
12:35TimMcgfredericks: Oh, that makes sense for uberjars. I mean, in a mechanical sense, not in a design sense.
12:35TimMcI just avoid data readers. :-P
12:35clgvI have a DSL where they would be pretty useful for bootstrapping
12:37clgvoops. repl in wrong project ;)
12:37gfredericksI've been using a timeless date library
12:37gfredericksnice to have data readers there for literals
12:39clgvhumm, the namespace of the function in the data_readers.clj gets not loaded automatically?
12:39gfrederickstechnomancy: I was trying to call resolve-and-apply from inside the test, and kept getting a "suppressed exit" exception
12:39gfrederickstechnomancy: which I thought made sense when I was calling -main prior
12:40gfredericksbut then it kept doing it
12:40gfrederickseven after switching to resolve-and-apply
12:40technomancygfredericks: apply-task calls abort in the case of an arity mismatch
12:40technomancyline 187
12:43cmajor7what 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:43tbaldridgecmajor7: well that question doesn't really make sense, but look into reducers
12:43cmajor7tbaldridge: why does not it make sense?
12:43tbaldridgecmajor7: http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
12:44cmajor7I know about redicers
12:44tbaldridgethe question is "how do I loop, but make the loop use multiple cores".
12:44cmajor7but here the data is streaming in
12:44tbaldridgeover what?
12:44cmajor7yes, the loop _can_ use multiple cores
12:44tbaldridgewhat is the streaming system
12:44cmajor7tcp/ip
12:45cmajor7think socket
12:45cmajor7it does not matter really
12:45tbaldridgecmajor7: 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:45tbaldridgeJava queues will allow you to enqueue data from one thread and read it from another.
12:46tbaldridgeOr clojure.core.async will allow you to do this with "fibers" or micro-threads like Erlang/Go
12:47tbaldridgebut 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:47cmajor7tbaldridge: 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:47tbaldridgeyep
12:48technomancycmajor7: if you can reframe your problem in terms of seqs it's a lot more tractable
12:48cmajor7tbaldridge: I guess what I am wondering if there are clojure reducers for streams
12:48tbaldridgeso you're asking for thread affinity?
12:48technomancyloop/recur isn't really a good fit for application-level code
12:49cmajor7tbaldridge: 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:49tbaldridgecmajor7: so what's the problem with jumping around the CPU sockets?
12:49cmajor7technomancy: right, does not have to be loop/recur
12:50cmajor7tbaldridge: cache lines are not reused, performance is jumpy, but again, this is not the problem I am looking for a solution to
12:51cmajor7tbaldridge: "looping construct that reads form a stream and "does" using multiple cores" is
12:52tbaldridgecmajor7: 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:53cmajor7tbaldridge: I am not
12:53tbaldridgecmajor7: 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:54tbaldridgebuild it right, them build it fast. Queues and threads is what you want, either from core.async or custom-built from Java.
12:54tbaldridge*then build it fast
12:55squidzis core.async a good candidate for loading large resources in the background while a user is on a page?
12:55tbaldridgeor seqs as technomancy said, but those aren't really concurrency constructs.
12:55tbaldridgesquidz: yes
12:55clgvsquidz: thats a job for `future
12:56clgvimho ;)
12:56cmajor7tbaldridge: 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:56tbaldridgesquidz: clgv: it depends on the number of resources. Load 10,000 resources at once and you'll crash your jvm
12:57tbaldridgeclgv: core.async will allow you to queue up thousands of resources that are load balanced over a smaller number of loaders
12:57ddellacostaI 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:58clgvtbaldridge: I mentioned `future` to him to prevent him from breaking a nut with a sledgehammer ;)
12:58ddellacostanot finding it on the Java interop page (http://clojure.org/java_interop)
12:58squidzI mean load one large resource like a json file from a server without locking the page
12:58squidzfor clojurescript
12:58tbaldridgesquidz: oooh
12:59ddellacostaah, I see, there is a cast function. Nevermind.
12:59tbaldridgeit depends what you mean by "loading". you can abuse core.async to allow you to "yield" back to the browser.
12:59squidzis core.async a good application for that
12:59tbaldridgesquidz: 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:00squidzi 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:00tbaldridgesquidz: that's the job of the browser, unless your CLJS code is doing post-processing after it loads
13:01tbaldridgefor instance, loading a massive 20MB image won't lock my browser while its loading
13:02squidztbaldridge: what do you mean by post-processing?
13:03xeqicemerick: austin looks neat, will have to try it out this evening
13:03cemerickxeqi: sure, let me know where it breaks :-)
13:04tbaldridgesquidz: 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:04cemerickBeen using it for quite a while, so it shouldn't be too rough
13:04tbaldridgesquidz: 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:04squidzokay I see
13:04maharjcemerick: 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:06cemerickmharju: this in the browser-connected-repl-sample?
13:06mharjucemerick: yeah
13:06squidzbecause 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:06squidzthat shouldn't be a problem?
13:07tbaldridgenope
13:08cemerickmharju: 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:09cemerickmharju: what version of leiningen are you using?
13:10mharjucemerick: oh, Leiningen 2.0.0-preview7 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM
13:10mharjuquite old. it seems I've not updated this machine
13:10cemerickmharju: yeah, I'd twiddle that first
13:11mharjucemerick: yeah, I'll try, thanks :)
13:14mharjucemerick: that was it. I was quite sure I updated leiningen last week but.. :)
13:14cemerickmharju: sounds good :-)
13:33gtrakbaltimore clojure meetup, take 2 :-), in a couple weeks.
13:36mharjuis there a guide on how to connect a cljs repl to fireplace?
13:41mharjuIt says " (do
13:41mharju (def repl-env (reset! cemerick.austin.repls/browser-repl-env (cemerick.austin/repl-env)))
13:41mharju (cemerick.austin.repls/cljs-repl repl-env)))
13:41mharjuargh
13:41cemerick??
13:41lazybotcemerick: Definitely not.
13:41callenmharju: upgrade your leiningen.
13:41mharjuthat was an accidental paste
13:42cemerickah
13:42cemerickmharju: Just connect to an nREPL endpoint with fireplace, then use austin
13:42mharjuI tried to put the message that the browser repl is waiting on http
13:42mharjucemerick: okay, basically what I pasted was what I tried to eval with the nrepl connection
13:42mharjubut it was not correct :)
13:43dark_elementcemerick hey i hardcoded the generated browser repl url after running "(austin-exec)" in my cljs code.
13:43cemerickthe URL it prints out is one you can paste into e.g. a browser, and have it service the browser-repl
13:44dark_elementcemerick i just wanted to try it out quickly before moving to a better setup with templating
13:44dark_elementcemerick I see the repl xhrs being made in browser but still the evaluation doesn't complete
13:45mharjucemerick: okay, I'm running the browser-sample now. It serves the localhost:8080-page, is that enough?
13:45wakeuphi
13:45cemerickmharju: once you have an env reset!'ed into that atom, yes
13:45cemerickdark_element: you invoked something exec-related in cljs code? Not possible (it's a Clojure function).
13:46wakeupI am coming from CL (used to MAKE-HASH-TABLE), how the hell do I
13:46wakeupappend a key/value pair to a HASH-MAP?
13:46dark_elementcemerick ohh no. I ran (austin-exec) in repl and harcoded the generated url in cljs.
13:46mharjucemerick: yeah, so first env reset!, then localohost:8080 and then eval? (cemerick.austin.repls/cljs-repl repl-env) and it should work?
13:46cemerickwakeup: &(assoc {} :a :b)
13:47cemerickdark_element: oh, I see; that's the /start URL?
13:47cemerickmharju: yes
13:47dark_elementcemerick yup
13:47wakeupcemerick: (assoc (hash-set "foo" "bar") "baz" "boom")
13:47wakeupClassCastException clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative clojure.lang.RT.assoc (RT.java:702)
13:48jajuNeed some advice/help with a configuration approach for an app.
13:48Bronsawakeup: a hash-set is not a hash-map
13:48wakeupBronsa: true, may bad
13:48dark_elementcemerick cljs code looks something like this right now "(repl/connect "http://localhost:65384/1810/repl/start&quot;)&quot;
13:48cemerickdark_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:48dark_elementcemerick ahh ok
13:49dark_elementcemerick yes works
13:49cemerickthe /start resource is basically a shim HTML file that does what your template would do
13:49cemerickI guess I should make the message, etc. more clear...
13:49mharjucemerick: 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:50cemerickmharju: could you paste the full interaction/exception somewhere?
13:50dark_elementcemerick 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:51cemerickdark_element: There's a fn for that in cemerick.austin.repls
13:51jajuI 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:51cemerickdark_element: second part of step #3 @ https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample
13:51jajuHow would one go about such a setup?
13:52mharjucemerick: https://www.refheap.com/adba008cd790b2db49daed7b0
13:53cemerickmharju: yuck
13:53dark_elementcemerick ok
13:54cemerickmharju: 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:54mharjucemerick: yes, I do reset! it before loading
13:54dark_elementcemerick i should get the templating in place to understand it better
13:54mharjuthe comment about loading was in the wrong place, sorry :)
13:55cemerickdark_element: The sample app is ~10 lines :-)
13:55cemerickmharju: this is running out of the sample project?
13:55mharjucemerick: yes, plain vanilla
13:55functionformI 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:55functionformits very helpful
13:56mharjucemerick: The only thing I added was that (comment ...) section on the top of the bcrepl_sample.clj
13:56dark_elementcemerick heh :). Just that I am trying to get it working with a project i am working on.
13:56cemerickmharju: what browser?
13:57mharjucemerick: chrome 28.0.1500.95
13:57mharjuIt works if I do it on lein repl
13:57cemerickwas hoping for IE 5 or something :-P
13:57mharjubut not if I eval it from fireplace
13:58cemerickmharju: oh, this is only via fireplace?
13:58mharjuyes
13:58cemerickhrm
13:59cemerickits nREPL support is a bit idiosyncratic, but I hadn't expected this
13:59cemerickmharju: 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:59konris anybody using Finagle or something similar on clojure?
14:00cemerickWorks nicely in my fireplace fork, for all the good that does anyone. :-P
14:00quackv4h
14:00dark_elementcemerick, great intro video to the project by the way.
14:02mharjucemerick: okay, I'll open an issue, thanks :)
14:02cemerickdark_element: thanks, which one ;-)
14:04dark_elementcemerick heh
14:04wakeupCan anyone point me to the documentation of fn's parameter specification? e.g. keyword parms, arbitrary arity, optional parameters
14:06rasmustowakeup: this isn't function-specific, but I found it to be a useful page: http://blog.jayfields.com/2010/07/clojure-destructuring.html
14:13mharjucemerick: I posted the issue, hopefully it's clear enough
14:16justin_smithwe have an artifact on clojars that shouldn't be used - how do I go about deleting it?
14:17technomancyjustin_smith: redeploy with "delete me" in the description and give me a ping
14:17futileI love you guys.
14:17futileYou're all so humble and patient.
14:17justin_smithtechnomancy: thanks
14:18futileAwesome channel to be in.
14:18squidzfutile: which channel?
14:19futileThat wouldn't be so polite to say.
14:19futileLet it suffice to say that you guys are great.
14:19futileAnd don't change :)
14:22dark_elementcemerick, ok setup done. But switching to a namespace didn't work right away and after while i got a hanged repl.
14:23cemerickhrmph
14:23cemerickdark_element: what does "didn't work right away" mean?
14:23dark_elementcemerick ok now it's intermittently working and need to refresh to get the repl working again.
14:24dark_elementcemerick ohh ok let me explain. I tried changing the package and after that repl hung up for a while.
14:25dark_elementcemerick so i tried to interrupt evaluation which gave me couple of these messages "java.lang.ThreadDeath" and "java.lang.InterruptedException"
14:25cemerickdark_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:25dark_elementcemerick and after that the namespace switched
14:26dark_elementcemerick let me try again with a new repl
14:26cemerickdark_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:27dark_elementcemerick yes it happened to me few times on ThreadDeath but mostly because i was trying out something crazy on repl.
14:28RaynesExcellent. Oracle's documentation site is down.
14:29dark_elementcemerick i am trying to switch to a namespace that is already compiled in the output js.
14:29antares_Raynes: http://docs.oracle.com/javase/7/docs/ is up for me. Also, I downloaded a copy a while ago just in case.
14:29cemerickdark_element: ok; that _should_ be snappy
14:29RaynesYeah, looks like nothing is working for me.
14:29gfrederickstechnomancy: oh I bet that's the issue (calling abort); thx!
14:31RaynesThere we go.
14:31dark_elementcemerick hmm right now even a simple eval like "(+ 1 2)" is not working.
14:32cemerickdark_element: sounds wonky. Maybe a lein clean is in order, just for kicks?
14:32dark_elementcemerick all right on it.
14:32cemerickand ditch ./out and ./.repl too
14:37dark_elementcemerick all right
14:40dark_elementcemerick ran #3 and #4 from https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample
14:41dark_elementcemerick all right figured it out i had two tabs running
14:45cemerickdark_element: ah
14:45cemerickyeah, that's trouble
14:45dark_elementcemerick sorry about that.
14:45cemerickit'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:45cemerickdark_element: maybe file an issue for that?
14:46dark_elementcemerick, is there any way i can switch back to clj repl from piggieback ?
14:46cemerickdark_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:46justin_smithtechnomancy: 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:46dark_elementcemerick, all right even better i'll send a pull request.
14:47dark_elementcemerick, but ill file it first so that we don't loose track of it
14:47cemerickdark_element: If you can put it together, great! It might be a sticky wicket.
14:48dark_elementcemerick ok
14:49technomancyjustin_smith: you need to use a new version to redeploy, but that sounds reasonable
14:49technomancyanyone coming across it via the web will see the latest with the warning
14:51justin_smithtechnomancy: thanks
14:55wakeupHow to I convert a string to a utf-8 encoded byte array?
14:56wakeupe.g. usable with clojure.data.codec.base64
14:56justin_smithwakeup: maybe (.getBytes string)
14:56justin_smithI don't know if that is utf8 always, or how to ensure that though
14:58wakeupjustin_smith: well the problem is, if you don't know what you are going to encode...
14:58justin_smith,(.getBytes "hello world" "utf8")
14:58clojurebot#<byte[] [B@1621157>
14:58justin_smiththe second arg is the encoding
14:58wakeupthanks
14:59justin_smithI don't know what all encodings it accepts, by trial and error utf8 and utf16 are in there
14:59justin_smithand utf32
14:59wakeupwhat do I have to require in order to get .getByte?
15:00justin_smiththere is an s on it
15:00justin_smith.getBytes
15:00justin_smithit is a native jvm method on strings
15:00wakeupah cool thanks
15:00wakeupwhats the reverse?
15:01ztellman,(keys (java.nio.charset.Charset/availableCharsets))
15:01clojurebot#<SecurityException java.lang.SecurityException: denied>
15:01technomancy,(= "hello" (String. (.getBytes "hello"))) ; <- wakeup
15:01clojurebottrue
15:01ztellmanok, well, that's how you'd get all the avaiable charsets
15:02ztellmanavailable*
15:02justin_smithztellman: cool, thanks
15:02justin_smithtechnomancy: and thanks for that trick too, I didn't know that one
15:02wakeupNot to start a flamewar, but coming from CL, and having a client that wants me to write Clojure...
15:03wakeupthis "language" is madness
15:03wakeupI'm cool with all the concepts and so forth
15:03wakeupagree with some designd decisions
15:03wakeupbut basically I have to know Java to use clojure
15:03justin_smithwakeup: it definetly took me a while to adjust, but it grows on you (except for the startup time)
15:03wakeupI don't have a real repl
15:03wakeupthere is no debugger
15:04technomancyyeah, it really missed the boat by not putting VAX filesystem support in the core language.
15:04wakeupI get java stack traces as errors
15:04nDuffwakeup: re: debugger, have you looked at ritz?
15:04wakeuptechnomancy: are you hating on PATHNAME ? you use strings for filenames...
15:05nDuffwakeup: 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:05justin_smithwakeup: 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:06wakeupjustin_smith: I have to restart the repl all the time to make it see new libs
15:06nDuffwakeup: ...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:06justin_smithyeah, the classpath thing is annoying
15:06wakeupnDuff: There is ABCL
15:06nDuffwakeup: you don't _have_ to restart the JVM to get new libs; you can use pomegranate.
15:07mnemnionIs 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:07wakeupnDuff: The platform is also the reason while Clojure will never be a real language
15:07mnemnionI specifically can't use #_
15:07nDuffwakeup: *shrug*. You can keep your "real language" definition. I'll keep my ability to grab real marketshare.
15:07ztellmanwakeup: for someone who doesn't want to start a flamewar, you're doing a fine approximation of someone who does
15:08wakeupnDuff: 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:08nDuffwakeup: you realize there already _are_ non-JVM-targeting implementations?
15:08nDuffwakeup: ...and that Clojure's core team is building software that runs across them?
15:08technomancywhy not use abcl then?
15:09wakeuplike I said, clients choice
15:09wakeupI will recommend it to him
15:09mnemnionthe 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:09technomancyheh
15:09wakeupbut it's his choice
15:09mnemnionthere are projects in the works. It's a matter of time, like most kinds of maturity.
15:10technomancyI hope the client has read http://home.pipeline.com/~hbaker1/ObjectIdentity.html
15:10gtrakwakeup: just be happy for lisp getting more popular :-)
15:10justin_smithwakeup: 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:10wakeupclojure != lisp
15:10wakeupplease
15:10nDuffwakeup: clojure is certainly a LISP. It's not Common LISP, but the definition is broader than that.
15:10wakeupI respect clojure but not as a lisp, and I don't mean that in an offense
15:10technomancyclojurebot: no *true* scotsman uses clojure
15:11wakeup:)
15:11clojurebotclojure is a very attractive hammer with a nice heft to it
15:11wakeupalso I don't benefit from any language families popularity
15:11dnolenwakeup: as as I understand such would not be McCarthy's stance, there is no archetypal Lisp. And thank god for that.
15:12wakeupI don't want to go too deep into what defines a lisp
15:13dark_elementcemerick, i just got java.lang.OutOfMemoryError.
15:13dnolenwakeup: and there's no need since you would only express your opinion which doesn't hold a candle to what McCarthy gave us.
15:13wakeupdnolen: exactly
15:13wakeupor whatever
15:13wakeupas I said no flame war intended
15:13tbaldridge(inc dnolen)
15:13lazybot⇒ 11
15:14wakeupWho came up with WITH-OUT-STR?
15:14tbaldridge"no flame war intended" said the man who splashed gasoline around the room and started smoking a cigar....
15:14wakeupoh come on
15:14technomancy~gentlemen
15:14clojurebotYou can't fight in here. This is the war room.
15:15rasmustowith-out-str is really useful, but yeah, the first hyphen is pretty important to understand what it does
15:15dark_elementcemerick, interestingly the cljs repl server is still running.
15:15wakeupWhy with-out-str instead of something more similar to with-output-to-string?
15:15gtrakwakeup: curious what you could have against that
15:15wakeuphonest questions
15:16cemerickdark_element: yeah, I wouldn't run a Clojure/ClojureScript app with default heap settings, etc
15:16gtrakout is clearer than output because of *out*
15:16wakeupgtrak: it's a crippled version of CL's w-o-t-s with a really bad name
15:16technomancywakeup: why nconc?
15:16wakeupno way in hell I would have guessed it
15:16technomancyrplacd
15:16wakeuptechnomancy: well it's not like clojure has a lot of historic baggage does it?
15:16gtrakwhy is it crippled?
15:17gtrakhonestly curious, I don't know anything about CL
15:17wakeupgtrak: as I understand it cannot bind arbitrary names but instead alsways binds *out*?
15:17wakeupCL: (with-output-to-string (out) (print 'foo out))
15:17gtrakyea, you can bind other things though, what else would you want to bind?
15:17kmicuprogramming or guessing, who cares?!
15:18dark_elementcemerick all right
15:18Greg-clojure not implementing tail recursion isn't a JVM limitation is it? because scala does it
15:18tbaldridgewakeup: if you want to bind to something else you can use binding.
15:18technomancyGreg-: tail recursion, no. full TCO, yes.
15:18wakeupgtrak: 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:18justin_smithGreg-: design decision: if you use recur it can throw an error if not in tail position
15:19Greg-anything in the pipeline for java 8 to help with that?
15:19gtrakhmm, I've never wanted to capture *err*, but it would be a trivial macro.
15:19cemerickGreg-: Last I knew, Scala does a CPS transform when it can; when it can't, I think you silently get stack consumption
15:19justin_smithGreg-: the ugly part being that you cannot do generalized recursion that way, you end up needing trampoline for that
15:19jwpalmerll
15:19jwpalmersorry! wt
15:20Greg-ok
15:20justin_smiths/generalized recursion/generalized tail calls/
15:24wakeupSo pathnames are strings right? How do I ensure a directory exists?
15:24Greg-that looks like a vim command in a room full of emacs users *get 'im!*
15:24wakeupGreg-: acually thats vi unrelated
15:24ztellmanwakeup: http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html#exists()
15:24gtrakwakeup: http://docs.oracle.com/javase/7/docs/api/java/io/File.html#exists() and clojure.java.io
15:25wakeupGreg-: it's more like unixy
15:25gtrakztellman wins :-)
15:25ztellmanphoto finish, folks
15:25justin_smithwakeup: ,(.exists (java.io.File. "/home/justin"))
15:26Greg-ah ok
15:26gtrakand don't you start complaining about java apis being everywhere, I'd get upset if everything was duplicated
15:27justin_smithmore clojury (-> "/home/justin/" clojure.java.io/file .exists)
15:27RaynesI much prefer the first example.
15:27RaynesI'm very sad that people are beginning to interpret "MOAR ARROWS!" as more clojury.
15:28gtraklure them in with the arrows... then yell at them.
15:28Raynes-> in general exists to improve clarity in pieces of code that are lacking it. This isn't one of them.
15:29hyPiRion(-> Raynes inc)
15:30ztellmanhaha
15:31hyPiRionI'd probably do something like (:import (java.io File)) and then do (.exists (File. "/home/justin")).
15:31hyPiRionoh no, the ascii fish strikes again
15:32gtrakclojure.java.io has a file function for that though
15:32wakeupztellman: What do I have to require to use File. etc.
15:32wakeup?
15:32gtrakpolymorphic
15:32ztellmanwakeup: import, not require
15:32ztellmansee hyPiRion's example
15:34gtrakworks on URL's, Strings and handles nulls: https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/io.clj#L40
15:34RaynesAn 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:35dnolenI would just use io, (ns foo (:require [clojure.java.io :as io])) (.exists (io/file "/path/to/file"))
15:44chrisrossianother dumb question: in order for a record to have methods, you must also define at least one protocol, right?
15:45dnolenchrisrossi: you can implement interfaces too
15:46chrisrossisure, 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:46chrisrossilike, there's no way to say this record type is its own protocol and spare having to declare methods twice?
15:47gtrakchrisrossi: why do you need a protocol, then?
15:48gtrakjust to spare yourself having to use accessors?
15:48dnolenchrisrossi: 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:48tbaldridgegtrak: Not that, because you can always use get and assoc as accessors
15:48vraidi'm trying to use a java library that requires me to do "public class A extends B{ public A(C c) {}}"
15:48hiredmanchrisrossi: don't thing about it that way
15:49hiredmanchrisrossi: a record is just a container for data (a map)
15:49gtraktbaldridge: I meant only the convenience of defining methods within the scope of a record definition, instead of by themselves in a namespace
15:49hiredmanchrisrossi: you can extend protocols to them either in line or via the extend* functions/macros
15:49vraidi tried doing it by (proxy [B] []), but i get no matching constructor and can't manage to solve it
15:49hiredmanchrisrossi: they don't have "methods"
15:49gtrakthose symbols are available to the impls.. not sure why else you'd want to do it
15:50chrisrossiwell, the O'Reilly book calls them methods.
15:50hiredmanso?
15:51gtrakchrisrossi: protocols are for polymorphism, that was the point I was leading up to.. you can use pure functions otherwise.
15:51cemerickchrisrossi: hopefully only in the context of the corresponding generated interface, and/or inline implementations of those methods
15:51chrisrossibut, 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:51hiredmanchrisrossi: that sounds good
15:52hiredmanchrisrossi: next consider, do you even need a record? why not just use a map?
15:53vraidwhat would be the right way to extend a java class in clojure?
15:53dnolenchrisrossi: exactly, if a function doesn't need to be polymorphic, no need for it to be a part of the record.
15:53shdwprincevraid: proxy in common
15:53chrisrossihiredman: i probably don't. ;)
15:53gtrakvraid: let me dig up cemerick's awesome flowchart
15:53gtrakhttp://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
15:53vraidshdwprince: i couldn't get it to work for "public class A extends B { public A (C c) {} }"
15:54chrisrossii don't become literate in something unless i use it, though, and i wanted to become literate in records.
15:54shdwprince(proxy A [instance-of-C] (method1 [this] ...)) should work
15:54chrisrossiand i still have some OO wiring that likes the organizational grouping of functions to structs (ie classes)
15:55gtrakchrisrossi: just imagine 'this' as your (now explicit) first arg, and always return one.
15:56dnolenchrisrossi: records are not common, people try to avoid them.
15:56vraidshdwprince: not (proxy [A] ..?
15:56chrisrossiyeah, i understand the pattern. it's really for legibility that i wanted to combine them into the same form. more than anything else.
15:56hiredmanchrisrossi: becoming literate in records by using them badly seems pretty silly to me
15:57shdwprince&(doc proxy)
15:57lazybot⇒ "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:57hiredmanchrisrossi: the first step is determing how to decide if a record is appropriate, and we just did that little exercise
15:57shdwprince(proxy Class [constructor_params] ...)
15:57chrisrossithat's why i came here. the cognitive dissonance detector in my brain was going off.
15:57chrisrossithanks.
15:58shdwprinceResult of proxy is new anonymous class extending passed and with super(params) in constuctor
15:59shdwprince*extending class, passed in first argument
15:59chrisrossithe nice thing about clojure is refactoring between records and maps is pretty easy.
16:00shdwprinceHow 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:02gtrakshdwprince: what?
16:03shdwprince(defmacro my-macro [name params] `(defn ~name ~params (prn 1)))
16:03gtrakoh, you're looking for an 'apply' sort of thing?
16:03gtrakor... what
16:04futileRaynes: might wanna disable the Submit button on refheap once its been pressed, so we dont accidentally double post
16:04shdwprincegtrak: my real macro is much complex
16:04Raynesfutile: Like you just did? :P
16:04gtrakwhat's wrong with the above?
16:04shdwprince(my-macro abc [a b c]) extends to (defn abc [a b c] (prn 1)), but not evaluates
16:05futileRaynes: yes
16:05futileRaynes: also please port that script to elixir for me
16:05gtrakshdwprince: it works for me
16:05gtrakuser> (a 1 2 3).... 1
16:05Raynesfutile: If you sign in you can delete one of them.
16:05futileRaynes: meh
16:05Raynesfutile: Pastes get claimed on sign-in.
16:05RaynesYou don't have to. Doesn't matter to me. Just sayin'. :p
16:05gtrakshdwprince: where a came from: (my-macro a [b c d])
16:05futileRaynes: neat but i have no incentive to delete one
16:05futilethx
16:06vraid(proxy B []) tells me it can't create an ISeq, (proxy [B] []) tells me no matching constructor for B
16:06futileRaynes: unless its taking up tons of space in your mongodb
16:06futilethen ill delete it
16:06RaynesNope.
16:06RaynesI have tons of space.
16:06futilesweet
16:06futileRaynes: 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:06RaynesnDuff: AFYD?
16:06nDuffRaynes: Google Apps For Your Domain
16:06shdwprincevraid: B in constuctor have parameter of class C
16:07shdwprince(proxy B [C.])
16:07RaynesnDuff: Well, you don't need integration. You can always just sign in and create a new password and what not.
16:07nDuffRaynes: yeah. Absolutely not creating yet another password.
16:07shdwprincegtrak: (my-macro a [a b c]) fails
16:07RaynesThat's life on the internet, man.
16:07nDuffRaynes: bah. There's OpenID, and _almost_ everyone supports it.
16:08futileyep openid ftw
16:08RaynesI don't think that's true.
16:09futilejust login with google yay
16:09RaynesAbout 90% of sites I sign into daily do not use openID.
16:09RaynesThey use oauth and such.
16:09gtrakshdwprince: https://gist.github.com/gtrak/6158977
16:09gtrakwhat's fail about that?
16:09futileRaynes: they probably use OAuth because they get OAuth and OpenID confused, but they probably just want OpenID
16:09vraidshdwprince: 'don't know how to create an ISeq.."
16:10TimMcRaynes: Well, you're not supposed to use OAuth for logins, so...
16:11RaynesTimMc: Well, certainly everyone does it.
16:11shdwprincevraid: can you show the code?
16:11RaynesI'd entertain the idea of Github authentication on refheap if people wanted to add it.
16:12shdwprinceRaynes: I really want one think about almost perfect refheap - works with luakit (vimperator-like browser)
16:12TimMc(You *can*, but it's usually a bad idea.)
16:13shdwprinceRaynes: it just not recognize input field as input field and dont turn INSERT mode on
16:13RaynesTimMc: You'd make a great facebook employee.
16:13TimMc?
16:13TimMcRaynes: 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:13RaynesGiven how many sites use facebook authentication, it'd be entertaining if you worked for them with your feelings about the process. :p
16:14vraidshdwprince: http://hastebin.com/dasatoqena.lisp
16:14vraidshdwprince: error on line 13
16:14RaynesTimMc, 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:14futileoh
16:14TimMcOh, nice.
16:14RaynesAnd you can keep doing that until your browser wipes the session, which is usually when it restarts.
16:14futileRaynes: yeah i edited it once a few minutes ago
16:14TimMcCarry on, then.
16:15futileso hows that elixir port coming along?
16:15RaynesIt's not.
16:15TimMcThat was the fastest feature implementation I've ever seen!
16:15futileha
16:15shdwprincevraid: You pass 2 params into constuctor (function?) mtapp and string "scene"
16:16shdwprincevraid: I guess (mtapp "scene") will make instance of C?
16:16shdwprincevraid: so call it with braces and pass result into vector
16:17vraidshdwprince: (proxy AbstractScene [MTApplication] and (proxy AbstractScene [mtapp] give the same error
16:17vraidand (proxy AbstractScene []
16:17shdwprincevraid: what is mtapp? function?
16:18shdwprincevraid: you need to pass instance of class C, not class or function
16:18vraidi thought it would be a local variable
16:20hugodcemerick: 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:20shdwprincevraid: oh, thats not old class C
16:21shdwprincevraid: maybe tracebacks tells more?
16:21vraidah ofc
16:22cemerickhugod: 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:22vraidshdwprince: figured it out, thanks for the help on the way http://hastebin.com/xecajuxobe.lisp
16:23hugodcemerick: I see no phantomjs process - I have it installed (via brew) and on my path (afaict)
16:25cemerickhugod: 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:26gfrederickshaving 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:26technomancygfredericks: two things is fine
16:26technomancyas long as they're linked
16:27gfredericks:(
16:30technomancyto 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:31gfredericksthat's interesting
16:32wakeupWhat 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:33gtrakwhat's any-values?
16:33gtrakzipmap's probably what you want though
16:33tbaldridgewakeup: (zipmap (seq string-array) any-values)
16:34tbaldridgeseq probably isn't even needed
16:34tbaldridge,(source zipmap)
16:34clojurebotSource not found\n
16:34tbaldridgeclojurebot: you fail
16:34clojurebotI don't understand.
16:36gfredericks,(zipmap (into-array ["foo" "bar" "baz"]) (range))
16:36clojurebot{"baz" 2, "bar" 1, "foo" 0}
16:36futilewelp
16:36futilejust wrote some python. i have to admit, clojure is awesome.
16:36nDuff...heh.
16:36gtrakthis also works: ##(into {} (map vector [1 2 3] [:a :b :c]))
16:36lazybot⇒ {1 :a, 2 :b, 3 :c}
16:38gfredericksgtrak: is there some advantage there I'm missing?
16:39gtrakgfredericks: not as far as I know :-), but he's learning the ropes.
16:39gtrakthere's a few more ropes in that one
16:40hugodcemerick: with c.a.r/exec
16:41gtrakgfredericks: potentially, zipmap for some awful reason still doesn't use transients.
16:41wakeupNullPointerException my.stuff/eval1839 (NO_SOURCE_FILE:1)
16:41wakeupwhat would that mean?
16:41gtrakwhen it creates the collection itself... I don't see why it wouldn't.
16:42gfredericksgtrak: sounds like an easy patch
16:42gtrakhttp://dev.clojure.org/jira/browse/CLJ-1005
16:42gfredericksI don't know of any reason zipmap shouldn't use into
16:43gfredericksoh good
16:44gtrakwakeup: you've got a null somewhere.
16:44gtrakwhat's the expression you eval'd?
16:45silmawienis #^ just another name for the ^ reader macro? for example used in (source clojure.core/spit)
16:45shdwprincewakeup, if that in repl try (try EXPR (catch Exception e (.printStackTrace e))) to get full stack trace
16:46shdwprinceanyone know smaller way?
16:46h0bbitwakeup: 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:46llasramsilmawien: It's the old (deprecated) reader macro for metadata
16:46llasramshdwprince: (clojure.repl/pst)
16:47gtrakshdwprince: (clojure.repl/pst *e)
16:47llasram(after an exception)
16:47llasramhah
16:47silmawienllasram: cool ty
16:47gtrakah, pst uses *e in the no-arg too
16:48gfredericksI 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:48h0bbitdoes anyone know how I can have clojure.repl (say) always required?
16:48cemerickhugod: ah, replicated
16:48h0bbitI remember reading that leiningen might let me do this...
16:49cemerickhugod: 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:50llasramgfredericks: For any particular sort of JSON/EDN schema-validation?
16:50cemerickhugod: `lein deps :tree` (or `lein pedantic`) to find the offending dep, and add exclusions as needed
16:50hugodcemerick: ah - that must be a new release...
16:50cemerickyeah, was over the weekend
16:51h0bbitlein pedantic is now deprecated
16:51gfredericksllasram: both for validation and for test generation
16:51h0bbittry lein ancient
16:51llasramgfredericks: Ah, interesting
16:52h0bbithttps://github.com/xsc/lein-ancient
16:52cemerickh0bbit: well, some people still use older lein revs, etc
16:52gfredericksI want to use something like test.generative but my data would be _way_ too tedious to describe
16:52h0bbitcemerick: yup :)
16:52gfrederickshaskell has the advantage of you've already described it in your type definitions
16:52gfredericks(only an advantage assuming you've already done that)
16:53hugodcemerick: it works :)
16:53cemerickhugod: nice :-)
16:55hugodcemerick: do you have a way to run cljs tests from lein with this?
16:55cemerickhugod: http://github.com/cemerick/clojurescript.test?
16:56cemerickI have other bits as well, but they're not baked
16:56pbostromwhat 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:56wakeupSo, my first day of paid clojure programming is over :)
16:57wakeupEven though the CL programmer in me is disgusted, I can't say I wasn't productive! ;)
16:57gtrakdo you change your nick to gosleep?
16:58hugodcemerick: thanks! this should make the cljs experience much, much simpler
16:58wakeupgtrak: me? no :)
16:58cemerickhugod: getting there. :-) There's some fundamentals yet to be addressed, but the tooling is improving.
16:59ddellacostacemerick: 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:00cemerickddellacosta: :-) BTW, I think I owe you an email...will try to toss the inbox soon...
17:01ddellacostacemerick: 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:08cemerickddellacosta: I looked at Shiro briefly, scared the bejeezus out of me.
17:08cemerick:-D
17:09hugodcemerick: I'm still missing a jump-to-source that works with cljs in nrepl
17:09hugodnrepl.el I should say
17:09cemerickhugod: heh. I'd take doc lookups for cljs or something at this point. :-P
17:11futileIs there any tool yet that runs a single .cljs script on node, doing all the compiling and such under the hood?
17:15ddellacostacemerick: 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:15cemericksure
17:16clj_newb_2345anyone aware of a PAIP (paradigns of AI programming / norvig) clojure port that did more than the first 3 chapters?
17:18hiredmang/win 19
17:30hugodcemerick: what determines the js loaded by phantom?
17:32cemerickhugod: 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:33cemerickThere'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:34xeqicemerick: is there a way to add other script tags to /start? say for including jquery
17:36xeqiah, I completely missed static-dir as an option
17:51cemerick|awayxeqi: that's treading into territory where you probably want to connect to a browser running your app
17:51cemerick|awayhugod: details?
17:52hugodcemerick|away: I try running (my.ns/var) and it complains "Can't find variable: my"
17:52hugodcode compiles fine with cljsbuild
17:52cemerick|awayhugod: after a suitable (ns whatever (:require my.ns))?
17:52hugodahh
17:53hugodok..
17:53cemerick|awaysomeone needs to hack together a require macro for cljs
17:53hugodtoo used to having a goog.require in the repl web page I guess
18:08Raynestpope: You need to get into Elixir and make the indent script not suck.
18:20rlbIf 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:23Raynesrlb: Sure. It just calls .readLine on it over and over again, so it'll be wherever that puts it.
18:25rlbRaynes: ok, thanks.
18:43ddellacostahuh, 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:07justin_smithddellacosta: 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:07justin_smithyou could look at what c3p0 does
19:07justin_smithit sets up connections in a pool that can be used with c.j.jdbc
19:09ddellacostajustin_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:09ddellacostajustin_smith: thank you!
19:09justin_smithddellacosta: 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:11ddellacostajustin_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:12justin_smithddellacosta: 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:13justin_smithI have used c3p0 with that method and can verify it works - c3p0 creates and manages the connections
19:15ddellacostajustin_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:15justin_smithtry {:datasource pre-existing-connection} as your db spec
19:16justin_smithit looks like that is all you need
19:19akurilinIs 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:20technomancyakurilin: key-first is usually preferred
19:21technomancycallen: have you seen http://opam.ocamlpro.com/?
19:21akurilintechnomancy, okie dokie, thx!
19:21justin_smithI 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:22callentechnomancy: yep
19:22callentechnomancy: I use it.
19:22callentechnomancy: ecosystem is still ghetto even if OPAM is nice.
19:22technomancyakurilin: IMO because it's obvious at a glance that it's not a function
19:22callentechnomancy: I really think the answer for me is to write Rust and hope the dust settles sooner rather than later.
19:22technomancycallen: looks like night-and-day vs the bleak hellscape I witnessed in 2011
19:22justin_smiththat is why I mention the binding vs. literal
19:22callentechnomancy: things have improved a lot more recently but the lack of real concurrency is a killer.
19:23technomancycallen: oh right; I forgot you actually care about that =P
19:24callentechnomancy: I think Rust is a reasonable alternative.
19:24callentechnomancy: the design choices there seem palatable to me.
19:25technomancyseems reasonable if you're building mozilla-like programs I guess
19:26RaynesI'm always shocked to see OCaml still being… used.
19:26RaynesIt feels so utterly dead that I can almost smell the corpse.
19:26supersymlol
19:26technomancyRaynes: that's what I thought when I tried it 2 years ago
19:26RaynesNot to say it's a bad language. I don't know enough about it to have anything against it.
19:27technomancybut now oreilly is doing a cc-licensed book, and there's a package manager that actually works
19:27RaynesBut it smells of attic dust.
19:27Raynes:\
19:27supersymI know people who said that about lisp :P
19:27RaynesYeah, but OCaml is one language and Lisp is numerous languages, one of which happens to be pretty popular (guess which one)
19:29justin_smithocaml is a really good tradeoff of runtime efficiency with high level design, but yeah it is showing its age
19:30justin_smithif not for the lack of unboxed floating point I could have done some very interesting things with it
19:30technomancyI have a hard time caring about the lack of concurrency when considering ocaml as a second language alongside clojure
19:30technomancyit fits in all the cracks where clojure doesn't
19:31justin_smithsuper fast compile times
19:31justin_smithfor one
19:31Raynestechnomancy: I use Elixir as my second language alongside Clojure and therefore I have excellent concurrency semantics given Erlangyness. :D
19:35hyPiRionRaynes: eof pls
20:02callentechnomancy: the reason, sadly, I need concurrency is that I write micro-daemons and services.
20:03clj_newb_2345I'm aware of http://weavejester.github.io/hiccup/hiccup.util.html
20:03clj_newb_2345is there a way to have escape-html always preserve spaces?
20:03clj_newb_2345i.e. I want "a b" to generate 3 spaces in etween
20:03clj_newb_2345this is important since I'm displaying some code in HTML in a fixed width font
20:04justin_smithclj_newb_2345: a hack would be a search and replace of " " to "&nbsp;" in the right places
20:04clj_newb_2345justin_smith: yeah, but there's multiple levels of transforms
20:04clj_newb_2345so I'd prefer to do it "the right way"
20:04clj_newb_2345but I completely agree with you
20:05clj_newb_2345that it would work for this particular case
20:05justin_smithyeah, a hack for sure
20:06clj_newb_2345eh, fuck it
20:06clj_newb_2345enough reading about css-white-space
20:06clj_newb_2345I'm using this hack :-)
20:06justin_smithclj_newb_2345: https://github.com/weavejester/hiccup/blob/master/src/hiccup/util.clj
20:06justin_smithcheck the def of escape-html
20:07justin_smithit is so small, just make a version adding your own substitutions
20:07clj_newb_2345justin_smith: you are brilliant
20:07clj_newb_2345thanks
20:07justin_smithlol
20:08justin_smithfunny coincidence that it does exactly what I first thought of
20:09clj_newb_2345justin_smith: yeah, also funny how when you initially told me to just do a replace, I thought "this is a hack"
20:09clj_newb_2345but now, after reading the hiccup source, the exact same code is "this is brilliant"
20:10justin_smithwell 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:11callenjustin_smith: do you know Python?
20:11callenjustin_smith: if so, I have a hack to show you.
20:11justin_smithheh, a little, go ahead
20:11callenjustin_smith: https://raw.github.com/sjzabel/django-audit-trail/master/audit_trail/lib.py
20:12callenjustin_smith: I cleaned that up and committed it into a project I work on today.
20:12callenVery proud.
20:12callenjustin_smith: believe it or not, it replaced a hack that was actually much worse.
20:12justin_smithnice - so why does your user wander around in the request anyway?
20:13callenjustin_smith: SOP in Python WSGI-land.
20:13callenjustin_smith: I'm about to do the same thing in some Clojure code I maintain actually
20:13justin_smithnow 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:13callen(retain the user inside the request)
20:14callenthe reason to retain the user in the request is so that it's not a global.
20:14callenbelieve me, you don't want to go that route.
20:14callenif you can help it.
20:14justin_smithI understand carrying user in request, but why have it in various places?
20:14callenhrm. in various places?
20:15justin_smithit is iterating looking for the user data, no?
20:15futilecan any of this networking stuff be simplified by using builtin libs? https://github.com/sdegutis/zephyros/blob/master/libs/zephyros.clj
20:15callenjustin_smith: that's not normal code man. it's walking the entire call stack if needs be.
20:16callenjustin_smith: that's not an exemplar of anything normal or good.
20:16callennormally you have access to the request directly.
20:16callenjustin_smith: that's a hack to get around some insane signaling bullshit.
20:16justin_smithahh, that was the missing detail
20:16justin_smithso in the clojure version you would not be walking the heap looking for the user
20:16callenjustin_smith: gods no, you just pass around the immutable request.
20:17callenand assoc the user into it in the middleware before passing it on to handlers.
20:17justin_smithyup, that's what I do
20:17callenwell that's normally what you do in Python too
20:17callenBUT
20:17callenagain, some specific use-case stuff fucking you over leads you to the aforementioned code.
20:17justin_smithyes, an excellent example of a hack
20:18justin_smithand a potentially easy vulnerability on top of that - just cause a "user" object to be created in some context...
20:19callenjustin_smith: not easily, it checks the class instance.
20:19callenjustin_smith: and accesses of request.user are generally read-only.
20:19callenso you'd have to add an attribute that was actually a decorated property to execute arbitrary code
20:19eggheadis there anything like doseq that returns the values of the operations instead of nil?
20:19justin_smithegghead: for
20:19callenand in general, it's not an easy vulnerability because there's no way to inject arbitrary arguments into the call-stack like that.
20:20callenjustin_smith: for vulns from arbitrary argument injection, you'd want to look to Ruby, not Python.
20:20eggheadjustin_smith: ya, but like doseq instead of lazy like for, I want it to do the side effects but return the values
20:20callenPython has better semantics for that.
20:20justin_smithegghead: (into [] ...) or (doall ...) will force it
20:20eggheadI wrote a weird macro but feels like there should be a built in solution
20:20callenfor 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:21justin_smithyeah, python is less magical, I am familiar with that
20:21eggheadinto [] hmm
20:21callenjustin_smith: a lot of the most recent Rails vulnerabilities were because there was a vector for turning yaml into arbitrary Ruby code. Nutty.
20:22justin_smithegghead: because vectors are not lazy; but doall is more idiomatic
20:23justin_smithbut vectors are nice and callable and you can do get on them etc.
20:23technomancy(partial into []) is vec
20:23technomancyfwiw
20:23justin_smithah, of course
20:23justin_smithI like (into [] ) because the [] are visually distinctive and mean vector
20:23justin_smithbut yeah, vec is simpler
20:24eggheadso (vec (for [side-effect side-effects] (effect! side-effect))) ?
20:24eggheadthanks
20:26justin_smithegghead: yup - check this:
20:26justin_smith,(do (for [i (range 10)] (println \a i)) (vec (for [i (range 10)] (println \b i))) nil)
20:26clojurebotb 0\nb 1\nb 2\nb 3\nb 4\nb 5\nb 6\nb 7\nb 8\nb 9\n
20:27justin_smithbut if you don't need the vec there is always doall
20:27justin_smithI just like pointing out the handy dual action of the vector transform
20:28callenthis is the code (vec ...) actually calls: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazilyPersistentVector.java
20:28callenif anybody cares. which I imagine you don't.
20:29justin_smithyep, that sure is some java code
20:30callenjustin_smith: oh come on, you've gotten curious and read the code too.
20:30justin_smithyeah, often
20:31callenwell.
20:31justin_smithI often sit down with a glass of red wine, put on my slippers, put on mozart, and read some code
20:31callenjust taking the piss now.
20:31justin_smithin all seriousness, reading code, awesome stuff
20:32justin_smithyou've seen evidence I do it on this very channel
20:32callenjustin_smith: most people don't actually read the code to the things they use.
20:32callenI've found a very reliable way to detect whether somebody is a great programmer or will become one is whether they read code.
20:33justin_smithI've had this idea of putting together a little chapbook of beautiful code
20:33justin_smithI've even tried to talk some designers at work into helping me with this
20:33justin_smithnot joking
20:33callenjustin_smith: I've actually considered guided "read-alongs" of open source codebases.
20:34callenjustin_smith: published as a book.
20:34justin_smithlike the lions book?
20:34callenit 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:34callenjustin_smith: yeah but for modern stuff.
20:34callenI'm not talking a docco dump of the entire codebase necessarily.
20:35justin_smithsure, makes sense
20:35callenjustin_smith: it's something *I* would pay for but I worry most others wouldn't.
20:35callenjustin_smith: I've come really close to publishing something like that on pragprog for $5-10
20:35callendepending on how voluminous it was.
20:36callenthere's a book or two on the architecture of open source projects but it's way too high level.
20:36justin_smithcode and commentary on facing pages like they do with poetry translations could be done nicely
20:37callenthe design and typography could be done in such a manner as to make it quite the aesthetic experience too.
20:37callenjustin_smith: what codebases do you think people would want to learn? I think jQuery is an obvious one. Not sure what else.
20:40justin_smithhmm
20:41justin_smithI think well written code, in general - maybe TeX
20:41callenjustin_smith: I don't think most people actually want to read that. It's not relatable.
20:41callenjustin_smith: very few people use TeX anymore.
20:41justin_smithbut it is well written
20:42justin_smithhttp://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web
20:43callentoo arcane man.
20:44callenI might use LaTeX but very few people outside of academia do so anymore.
20:44justin_smithwhat is exemplary is the relationship between the comments and code
20:45callenwell...Knuth.
20:47hiredmanthe 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:47hiredmanyou 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:48justin_smithhiredman: I've found that adding comments and unit tests is a great first step for taking on someone else's ad-hoc code
20:49hiredmanso in response to my "how many people..." question that is like you and four other guys
20:49justin_smithheh, I don't even do true literate programming
20:49justin_smithbut I like it when reading for the sake of reading code
20:49justin_smithof course I have to be able to read bare code as well
20:50hiredmanin 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:50hiredmanthe last time I came across literate code, I was trying to read about cribit tries, and this pdf was horrible
20:51justin_smithadd 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:52justin_smithand then adding any missing comments based on what I learn there
21:05justin_smithanyone familiar with lein-beanstalk?
21:11ztellmananyone have pointers on coming up with minimal examples for locals-clearing bugs?
21:12ztellmanI'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:17justin_smithztellman: 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:17justin_smith*:disable-locals-clearing
21:18ztellmanjustin_smith: sorry if I wasn't clear, this is where locals that should be cleared aren't being cleared
21:18ztellmannot the other way round
21:18justin_smithahh
21:19justin_smithso not npe, but leaks
21:41ztellmanjustin_smith: hopefully this will put someone on the right track: https://gist.github.com/ztellman/6161154
21:41ztellmanI certainly have no idea what's going on
21:44justin_smithfascinating - I don't think you could express it much more concisely
21:50benediktHow 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:55dnolenbenedikt: don't use clojure-contrib it's deprecated
21:55benediktdnolen: what should i use then?
21:56dnolenbenedikt: I would probably just use the Java APIs directly or look for a non contrib library that accomplishes something similar
21:58benediktdnolen: well, this is what google comes up with when searching for "clojure socket"
21:58dnolenbenedikt: yes, a lot of old outdated information come up as relevant hits
22:04benediktif i change profile.clj, how do i update the nrepl in emacs (nrepl-jack-in)?
22:12zenolibenedikt: 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:12benediktzenoli: that sounds like a much better way
22:13zenolibenedikt: I think nrepl-quit will kill a server started by nrepl-jack-in, though.
22:14benediktI doesn't work to inlude a libaray in (ns (:use libname)) but (use 'libname) works to include it. What am i missing?
22:17zenoli(ns (:use [libname]))
22:17technomancybenedikt: you have to give ns the name of the namespace you're declaring
22:17technomancynot just the ones you want to depend on
22:17zenoliThat, too.
22:18benediktzenoli: that worked. technomancy: i omitted it by mistake when copying from my file.
22:22xeqicemerick: yeah, that is getting into app territory.
22:29dnolenall 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:30dnolencore.async is damn pleasant to work with
22:30atyzHi 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:31atyzAnd if not, when would be appropriate for me to use an atom?
22:45danielszmulewiczdnolen: are you an emacs user?
22:45dnolendanielszmulewicz: yes
22:45danielszmulewiczdnolen: nrepl + piggieback?
22:46dnolendanielszmulewicz: no I just use inferior-lisp
22:46danielszmulewiczdnolen: that gives you a browser connected repl or you need to refresh?
22:47dnolendanielszmulewicz: 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:47dnolen"I use lein cljsbuild settings optimized for ~1s compile times" I mean
22:48dnolendanielszmulewicz: when the fancy CLJS REPL experience is a bit further along I'll probably switch but it's still early days yet.
22:49danielszmulewiczdnolen: 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:50danielszmulewiczdnolen: piggyback + nrepl is nice because of the browser connected repl, but throw in cljsbuild in the mix and it breaks
22:50dnolendanielszmulewicz: 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:51danielszmulewiczdnolen: cool, so at least you do use cljsbuild. good to know
22:51dnolendanielszmulewicz: I used lein cljsbuild auto
22:51danielszmulewiczdnolen: cool
22:51dnolendanielszmulewicz: https://github.com/swannodette/swannodette.github.com/blob/master/code/blog/project.clj
22:51danielszmulewiczdnolen: great. thanks.
22:51dnolendanielszmulewicz: I use dev settings until the code is ready to go, and then I switch the advanced profile when I'm done.
22:53danielszmulewiczdnolen: got it. fantastic. I can dive back in with those directions. More sleepless nights :-)
22:55danielszmulewiczdnolen: I love the innovation in the Clojure community, but the tooling can be rough when you compare with CL.
22:56dnolendanielszmulewicz: 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:57dnolendanielszmulewicz: lot of opportunities here given the flexibility and simplicity of the CLJS analyzer
22:59dnolentechnomancy: have you ever considered making a Leiningen a GitHub org?
23:07tomjackis it dangerous to (.newInstance (class (proxy ...))) ?
23:16dnolenambrosebs: I responded on the Typed CLJS design page http://dev.clojure.org/display/design/Typed+CLJS?focusedCommentId=8192590&amp;#comment-8192590
23:17tomjackeh, well, moot :(
23:19ambrosebsdnolen: great! really helps
23:19squidzcemerick: awesome work on austin. Makes clojurescript a lot more welcoming
23:25dnolenambrosebs: 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:25ambrosebsdnolen: do you ever have unreadable/unwriteable channels?
23:26ambrosebsor, would you ever want the type system to forbid reads or writes to a channel?
23:27dnolenambrosebs: yes you would want that, bbloom submitted a patch for ReadPort & WritePort
23:27dnolenw/ dynamic exceptions for bad ops
23:27ambrosebsok. I will add that in.
23:28dnolenambrosebs: does Typed Clojure have casting? Can I cast a more generic type to a more specific one?
23:28dnolen(Chan Any) -> (Chan (U (Value :foo) (Value :bar) Number)) ?
23:31ambrosebsdnolen: hmm it's weird with channels.
23:31ambrosebsdnolen: usually you'd rely on some predicate like chan-of-int?, but that doesn't make sense I think..
23:31ambrosebsdnolen: the answer is yes, but unsoundly through the backdoor
23:32ambrosebsdnolen: in general, there is safe casting though, yes.
23:32ambrosebsdnolen: if a predicate exists.
23:32dnolenambrosebs: 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:33dnolenambrosebs: there many be types of messages on the channel, but if I filter out some type of message, is that propagated?
23:34tomjackcool, I hadn't seen that stuff. you've found it pleasant to do stuff like r/filter on channels?
23:34tomjackr/map I guess is the best representative
23:35dnolentomjack: 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:36tomjackI guess I should not be surprised that it could be pleasant, since Rx can be pleasant
23:36ambrosebsdnolen: no, we don't attempt to refine the type of mutable types
23:36tomjackand this has gotta be a lot better than Rx :)
23:36dnolenambrosebs: well e is not mutable, so maybe that's enough?
23:37tomjackI could never decide whether r/map on a channel was a category error or not
23:37dnolentomjack: 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:37dnolen"trying to do"
23:37noidiis 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:38ambrosebsoh, yes that's fine. Once you have a local binding it gets updated wrt predicates.
23:38noidiit seems that people really don't pay heed to the latter sentence :)
23:38dnolenambrosebs: OK cool, so that would still be cool to demo
23:38ambrosebsyes, occurrence typing at work.
23:38dnolennoidi: there are rough corners, but I've been using it's since it's release and the CLJS version is pretty rocking
23:39dnolenambrosebs: ok, well if you've got notes on what help Typed CLJS needs to move forward, I'll look at them :)
23:39noididnolen, yeah, I read your blog post. it was a great introduction to core.async, thanks for writing it!
23:39dnolennoidi: np
23:41dnolennoidi: 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:42dnolennoidi: this one, http://swannodette.github.io/2013/07/12/communicating-sequential-processes/
23:42noidiyes, that's the one I was talking about
23:44ambrosebsdnolen: is a timeout channel readable & writeable?
23:45dnolenambrosebs: ReadPort/WritePort hasn't landed yet, but I imagine timeout w/ only be readable when it does
23:45dnolenbbiab
23:45ambrosebsok.