#clojure log - May 08 2013

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

0:23 devn: How did I miss the-ns for so long?

0:26 Raynes: devn: Because you never tried to break clojail. ;)

0:26 We have a long history of abusive namespace hackory based around the-ns.

0:28 technomancy: gdev: you only use emacs for one clojure project?

0:28 gdev: technomancy, yeah, one at a time

0:29 Raynes: technomancy: I'm curious how many people use multiple vim instances.

0:29 If I had to use more than one I'd cut people.

0:29 technomancy: Raynes: I thought everyone did?

0:29 Raynes: I certainly don't

0:30 Have no reason to.

0:30 technomancy: because then you can make fun of emacs's >1s startup time

0:30 Raynes: I open things in split buffers, tabs, etc.

0:30 And you can of course switch to background buffers like with Emacs.

0:30 technomancy: so you have like your work buffers in the same buffer list as your OSS stuff?

0:31 Raynes: My work *is* open source.

0:32 I don't think I've worked on a single thing not open source since I got to Geni.

0:32 technomancy: nice!

0:32 good work if you can get it =)

0:32 but I mean your work projects and side projects

0:34 gdev: i'm still trying to understand the original question; what gave the impression that I only use emacs for one project?

0:35 technomancy: gdev: otherwise having nrepl launch on emacs boot would be pretty annoying

0:36 gdev: technomancy, ah, well usually when I'm opening emacs its to edit a clojure file; even if I wasn't it wouldn't bother me having it going

0:36 technomancy: right, but each project will have a different classpath

0:37 I guess if you always had a .clj file as the argument to emacs it could work

0:37 arrdem: I tried to have nrepl open whenever I edited a .clj but I didn't get it right :/

0:38 gdev: so my workflow would be, cd <project dir>/<src dir>, emacs core.clj, ??? profit

0:38 what could possibly go wrong?

0:38 technomancy: gdev: guess it's fine if you never use gui emacs

0:39 I have it so emacs starts a shell when it launches

0:39 then I cd to the project and hit C-c C-j for jack-in

0:41 gdev: what I'm trying to do now is if I'm in a file and i hit C-x C-e, instead of saying "no lisp subprocess" it just says "starting nrepl-jack-in"

0:42 technomancy: (eval-after-load 'clojure-mode '(define-key clojure-mode-map (kbd "C-x C-e") 'nrepl-jack-in)) ; maybe

0:47 gdev: i'll have to put that on my to-do list for tomorrow. I have a rule, no configuration changes after 10 pm.

0:48 arrdem: gdev: that's one way to keep insomnia at bay

0:49 gdev: arrdem, yes and also not having to deal with that awkward moment when you wake up the next morning face down on your keyboard and when you look up you've noticed your config folder has turned into a pumpkin

0:50 arrdem: gdev: ah a friend of mine _wting realized that having a ~/conf dir which is git controlled and symlinking from there helps keep config pumpkins at bay

0:52 technomancy: dinc

0:52 that is to say, double inc

0:53 arrdem: (def dinc (comp inc inc))?

0:54 technomancy: exactly

0:54 clojurebot: oinc?

0:54 clojurebot: oinc is octo-inc: (apply comp (take 8 (repeat inc)))

0:54 arrdem: (inc clojurebot)

0:54 lazybot: ⇒ 23

0:55 * arrdem attempts to rationalize "plink" to keep with the theme

1:05 gdev: ,((#(apply comp (take % (repeat inc)))20)22)

1:05 clojurebot: 42

1:05 gdev: odd way to add two numbers

1:31 tomoj: dnolen: so any thought on whether supporting with-bindings* etc alongside existing binding macro (i.e. no var reification, just a bit of ugliness to let {push,pop,get}-thread-bindings get/set the values of dynamic vars) is on the table?

1:32 dnolen: tomoj: I'm not likely to look at anything related to vars until we're much closer to bootstrapping.

1:33 tomoj: ah, well, I realize I can just throw them in my library then

1:33 since no changes to existing stuff is required

1:37 and people who use binding will still get the benefits, and they have no need to use {get-thread-,with*-}bindings, nice

2:04 oh, shit, actually, I needed to change the emit for :def

2:04 :(

2:04 so core-async will be pended on bootstrapping (or will just not work with dynamic scope)

2:08 well I guess I can define a macro which adds existing dynamic vars (e.g. *print-fn*) and lets you define new ones

2:09 core-async seems capable of giving us generators

2:09 question is, do we even want that? :)

2:10 I'm guessing no..

2:48 devn: good evening gents

2:49 anyone else feel like the reader page gets way too many questions and there seem to be many variations on the answers people receive?

2:55 yogthos: howdy

3:04 ciphergoth: damn, compojure generates a lovely function which handles requests as they arrive, but no statically available information on what my routes and endpoints are

3:04 so when I want to say "redirect to over here", I repeat myself specifying the URL

3:05 callen: ciphergoth: you can return the result of passing the request to the intended function too.

3:05 ciphergoth: somewhat like middleware.

3:06 ciphergoth: that doesn't return an HTTP 3XX though.

3:06 ciphergoth: callen, oh you mean instead of redirecting?

3:06 callen: right, but you could write a wrapper that does a redirect-fn and sets the status to 3XX and spits out the alternate result by fn.

3:06 would take maybe...120 seconds to write.

3:06 ciphergoth: right, but I want to do much more than redirecting, like including links in "href=" and "action="

3:06 callen: or less.

3:07 I have my own ideas on how to handle that, but I doubt they apply to your use-case.

3:07 ciphergoth: Think you'd need something that wasn't compojure!

3:08 callen: erm, no. I'm fine with Compojure.

3:08 I just bundle up my routes and ship them into a universal rendering context

3:09 that then gives me the ability to define purpose-oriented referents for the URLs

3:09 but, I usually don't need to do that, because I'm not an idiot and don't change URLs.

3:09 ciphergoth: well, you do a (defroutes foo this that) and then a (defroutes (context "/admin" [] foo))

3:09 and it's not until the latter is written that you even know what the url for "that" is

3:09 callen: not quite. It sits on the template rendering side.

3:10 ciphergoth: I'm not planning on changing my URLs, I just prefer to write code in a way that adheres to DRY and makes it harder for me to make mistakes!

3:10 callen: I feel you, I just don't see why you can't solve your problem.

3:11 ciphergoth: you need to understand that Lisps in general, Clojure included, are not omakase like Rails.

3:11 ddellacosta: ciphergoth: it sounds like you are looking for something vaguely like Rails "rake routes?"

3:11 callen: ciphergoth: you are expected to prepare your own dishes from the materials provided and craft precisely what you want.

3:11 ciphergoth: I have never used Rails

3:11 ddellacosta: okay, nevermind.

3:11 callen: You will not be provided a best-practices 100% all possible use-cases imagined framework for everything.

3:12 we even abandoned the one remotely serious micro-framework for a template oriented framework instead because it lent more power to the programmer.

3:12 we just don't...need that stuff.

3:12 ciphergoth: it's all data, write your own code to do what it is you have in mind.

3:12 ciphergoth: what are you using for templates?

3:12 ciphergoth: enlive

3:12 tomoj: 'omakase' good word

3:13 ddellacosta: I think DHH uses it a lot

3:13 I wonder if he likes sushi.

3:13 callen: tomoj: it's apropos and apolitical (no value assignment).

3:14 ciphergoth: I'd be interested to hear what other people have done in their web applications

3:14 callen: I don't have any strong opinions one way or the other as it regards omakase frameworks, I've used those and I've used more minimal stacks and been happy with both. Nevertheless, I have to describe it without getting peopled riled up.

3:14 tomoj: excellent

3:14 callen: ouch @ enlive.

3:14 ddellacosta: ciphergoth: if there is one thing I've found it seems like most people are using a big variety different libraries in the web space to solve their problems

3:14 callen: ciphergoth: I have a simple CMS on github.

3:14 ddellacosta: variety *of*

3:14 ciphergoth: it seems like lots of people must have felt the need to create an endpoint with a URL in one place, and create a hyperlink to it in another place

3:15 so I'm keen to know what sort of dishes people have prepared for themselves with the ingredients provided to address this :)

3:15 ddellacosta: the thing is, I don't know if we'll ever have these big over-encompassing "CoC" frameworks in Clojure

3:15 callen: ddellacosta: pedestal'ish.

3:15 'ish.

3:15 ddellacosta: well, compojure/ring is quite common, obviously

3:15 yeah, pedestal…I have to learn more about it. It scares me a bit, I'll admit. haha

3:16 callen: ciphergoth: I don't have anything open sourced that addresses your specific thing. I would strongly recommend reconsidering enlive so that it's easier to handle things like the concept of a "template context" without doing repetitive whole document processing.

3:16 ddellacosta: I think Noir did a bunch of stuff nicely, but the way it implemented some things was too side-effect intensive

3:16 callen: ddellacosta: myself and most other clojure web devs aren't impressed.

3:16 ddellacosta: callen: re: Noir?

3:16 callen: no, Pedestal.

3:16 ddellacosta: oh, pedestal?

3:16 callen: I was fine with Noir.

3:17 ciphergoth: OK so supposing I was using the templating system of your choice, what might the solution look like?

3:17 ddellacosta: ah, yeah, again, I haven't dug into it yet

3:17 callen: I use compojure/ring/libnoir/luminus now.

3:17 ddellacosta: yah, that seems like a solid stack…

3:17 callen: ciphergoth: Clabango, which resembles Jinja/Django templates. I have a universal render-template function that handles template context.

3:17 ciphergoth: that sounds great, how does it address this issue?

3:17 ddellacosta: ciphergoth: there is another question here which is, are you doing client-side-heavy development or server-side templating?

3:17 callen: ciphergoth: if I need to add global or template context, it's simple to do so. In the process, I can munge my routes to provide injectable/renderable aliases for routes.

3:18 ddellacosta: I highly recommend Luminus if you need ideas on how to structure a Clojure web app.

3:18 It's quite nice.

3:18 ciphergoth: how does a template context help here?

3:18 callen: ciphergoth: I described a possible solution above.

3:18 ddellacosta: yeah, I've poked at it a bit, but otherwise just rolled my own stuff w/compojure

3:18 callen: ciphergoth: read what I said.

3:19 ddellacosta: I poked and prodded yogthos as he's been developing Luminus. Got him to switch template libraries, bwahahahaha. :)

3:19 ddellacosta: what was he using before?

3:19 callen: ddellacosta: hiccup.

3:20 ddellacosta: ah.

3:20 ciphergoth: callen: you mena the bit that starts "I just bundle up my routes..."

3:20 callen: ciphergoth: da comrade.

3:20 ddellacosta: I've been doing web dev solo and in a team context long enough that I'm wary of anything that doesn't put my html in a file that ends in .html

3:20 ddellacosta: callen: haha

3:20 callen: normally that would mean enlive, but enlive is awful.

3:21 ddellacosta: callen: actually, I pretty much agree. What don't you like about enlive though? (I have my own feelings about why that is as well...)

3:21 ciphergoth: How do you "bundle up your routes" in compojure?

3:21 All compojure gives you is a function that responds to requests

3:21 ddellacosta: ciphergoth: you mean, other than using defroutes?

3:21 ciphergoth: how is that useful at render time?

3:22 ddellacosta, defroutes composes several functions into one, but I don't see how to use what it generates at render time

3:22 no matter what templating system you have

3:22 I don't see a way to query what defroutes creates to extract a URL I can then use in a template

3:23 callen: ciphergoth: split the data structure out and inject it into the defroutes after the fact.

3:23 ddellacosta: ciphergoth: sorry, I'm jumping in on the conversation late, but what exactly are you trying to do? You can get route info in the request map

3:23 callen: ddellacosta: wants URL/handler aliases or something that he can inject client-side into the HTML.

3:24 (url "handles-stuff") => "/handles/stuff/?true

3:24 ciphergoth: not necessarily client-side

3:24 callen: not literally client-side

3:24 ciphergoth: server-side at the moment actually

3:24 callen: I mean in HTML viewed by the client

3:24 ciphergoth: right

3:24 callen: rendered server-side

3:24 ciphergoth: yes

3:25 ddellacosta: ciphergoth: so, you want your url to be like callen's example (url "handles-stuff")

3:25 ciphergoth: So I refer to URLs in two places: one where I write (GET "....") and the other where I set an href property on an "a" entity. I'd like ot not repeat myself

3:25 ddellacosta: but be represented otherwise (/handles/stuff/?true) ?

3:25 callen: ciphergoth: write the code you want.

3:25 ciphergoth: you're spending more time discussing it in IRC than it would take to implement, seriously.

3:25 ciphergoth: OK so nothing currently exists to do this, if I want there to be a library with this property I should write it myself.

3:25 I'm surprised!

3:26 callen: that really isn't my experience. If someone else had written a solution it would be far more stable, better thought out etc than what I would write when I first thought of the problem.

3:27 ddellacosta: ciphergoth: I guess I don't get it--if you have a map of your routes somewhere, you can just easily pull out aliases. If they are systematized, then it's just a transformation of the route information.

3:27 ciphergoth: this seems like a need that every single webapp would need, so it's weird that no-one has written a framework that makes it easy.

3:27 ddellacosta: ...

3:28 ciphergoth: it seems like just a simple function to me, so maybe that's why there isn't a library for it. But maybe I'm still not understanding what you are trying to do.

3:28 ciphergoth: when you say a map, you mean a literal Clojure map?

3:28 ddellacosta: ciphergoth: yes.

3:28 ciphergoth: right, so instead of using the macros compojure provides, I should put all my routes in a map

3:28 completely work around compojure basically

3:29 write my own way of compsing route information togethe

3:29 I can do that, but I just would have thought someone else woudl already have done so!

3:29 callen: simple function/macro.

3:29 tomoj: I did my own routing thing too..

3:29 callen: ciphergoth: that's not the attitude Lisp hackers tend to take.

3:29 ciphergoth: will do something ugly for now. Thanks guys!

3:30 callen: ciphergoth: you're being overly schlep sensitive and need to just "get 'er done"

3:30 sigh, gone anyway.

3:30 so whiny.

3:30 ddellacosta: I still don't think I understood what he wanted.

3:30 it seemed too trivial to be under discussion…but I probably didn't get it.

3:31 anyhow, gotta run, cheers mates

3:31 callen: ddellacosta: toodles.

3:31 I understood what he wanted, I just didn't understand why it was so hard to just do.

4:05 wink: is public/resources somehow special to lib-noir? can't find why I can't slurp outside of that dir...

4:20 ah. grep failed me...

4:28 Glenjamin_: Hi guys, is there a function like seq that returns strings?

4:28 eg (??? "string") => "string" (??? "") => nil

4:29 so i can do something like (or (??? potentiall-empty-string) "default")

4:31 mthvedt: (if (seq? %) % nil)

4:31 sorry

4:31 seq not seq?

4:31 Foxboron: Glenjamin_: you could use empty?

4:31 then wrap that around something

4:31 edoloughlin: Or clojure.string/blank?

4:32 ,(doc clojure.string/blank?)

4:32 clojurebot: "([s]); True if s is nil, empty, or contains only whitespace."

4:32 Glenjamin_: yeah, mthvedt's approach seems sensible - was checking if there was a core functions which already wraps the pattern

4:33 mthvedt: i sometimes wish there was a core function that did that

4:33 Foxboron: make your own :)?

4:34 amalloy: &(doc not-empty) ;; Glenjamin_

4:34 lazybot: ⇒ "([coll]); If coll is empty, returns nil, else coll"

4:34 Foxboron: ohhhh

4:34 Glenjamin_: (def some-str #(when-not (clojure.string/blank? %1) %1))

4:34 oo

4:34 ,(or (not-empty "") "default")

4:34 clojurebot: "default"

4:34 noidi: I don't think a string-specific function would be as useful as seq

4:34 Foxboron: amalloy: and thats the function that came right after "empty" in the quickref

4:34 Glenjamin_: huzzah!

4:35 noidi: with seq, you don't pass it a seq but something seq-able

4:35 Glenjamin_: not-empty seems very similar to seq, but without the cast to a Seq type

4:35 which is exactly what I was after in this case

4:36 noidi: oh, cool

4:37 Glenjamin_: ,(inc amalloy)

4:37 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0:0)>

4:37 Glenjamin_: (inc amalloy)

4:37 lazybot: ⇒ 53

5:07 AWizzArd: Via “lein localrepo” I installed jcuda and jcublas, cause those libs are not available in any Maven repo. This worked nicely, until today. Now I get the message that Leiningen could not transfer the artifacts from central. I want Leiningen to just take what it has in ~/.m2 and only contact central if something is missing. Ideas?

5:13 edoloughlin: AWizzArd: have you tried asking on #leiningen? I've not done this with lein but I had similar problem on a Java project (using Apache Buildr). I set up a private remote repo and deployed to that. I see it might be possible to do this with lein: https://github.com/technomancy/leiningen/blob/stable/doc/DEPLOY.md

5:15 Buldr tried the Maven repos and then fell back to the private remote...

5:15 AWizzArd: Hmm I see.

6:01 mccraig: alia vs cassaforte experiences anyone ?

6:07 shriphani: hi. I am trying to create an infinite list using this: (def dates-list (concat (list start-date) (list (clj-time/plus (last dates-list) (clj-time/days 1))))) But the list only has length 2. Isn't referencing dates-list sufficient to create an infinite list ?

6:10 stain: not sure what you are trying to do.. but (last dates-list) would just evaluate to the last element of the previous binding of dates-list

6:11 you would not want to look for the last element of a truly infinite list anwyay ;)

6:11 shriphani: stain, I just want a sequence of dates.

6:12 I expected it to lazily generate the next one as needed.

6:12 mccraig: shriphani: try the iterate function : (iterate (fn [old-date] (make-a-new-date old-date)) first-date)

6:13 shriphani: mccraig, is there a way to do it using just the lists though ?

6:15 mccraig: shriphani: not sure what you mean

6:15 edoloughlin: shriphani: why not implement something using lazy-seq?

6:15 ,(doc lazy-seq)

6:15 clojurebot: "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. See also - realized?"

6:15 stain: do you want to call (nth) on it?

6:19 shriphani: umm no. I wanted to try out somehting like this: let x = 1 : map (2*) x (that is haskell code)

6:21 mccraig: shriphani: (iterate #(* 2 %) 1)

6:21 tomoj: #3 question to ask rich if I ever get to talk to him: which dictionary do you use? :)

6:21 mccraig: ,(take 10 (iterate #(* 2 %) 1))

6:21 clojurebot: (1 2 4 8 16 ...)

6:27 AWizzArd: When I make a closure (let [size 8] (defn ...)) then `size` is used as a final constant and needs no lookup time during runtime. Can I achieve the same with a def?

6:29 clgv: AWizzArd: yes there is ^:const

6:29 AWizzArd: (def ^:const pi 3.14159)

6:29 AWizzArd: Very good, thanks.

7:22 zackzackzack: How would I go about dynamically redefining clojure.test/test-var to do something else?

7:25 Nevermind! Somebody had the foresight to make it dynamic

8:36 mpenet: mccraig: yeah :p but I might be biaised

8:37 mccraig: imo alia is more production ready atm and covers more features (async, more config options). The main difference between the 2 libs is the api other than that, cassaforte aims to be a bit higher level, alia forces you to use execute, prepare and so on (which is a good thing imo).

8:38 mccraig: under the hood both lib use the same query dsl (hayt, it's a shared library), so you can switch between the 2 quite easily anyway

8:39 mccraig: both are resonably documented, but I expect the clojurewekz guys to create tons of guides soon.

9:11 just checked, cassaforte has no way of setting consistency or any per query option atm

9:47 gdev: has anyone done any remote pair programming on clojure? No one in my office knows clojure or does pair programming so remote looks like my only option

9:47 just curious about how to set up my workstation for it

9:48 ucb: gdev: you can share a tmux screen

9:48 s/screen/session/

9:48 gdev: alternatively, you can try with screenhero

9:48 I'd also recommend a voice channel, e.g. skype

9:49 gdev: oh wow, screen hero looks cool

9:49 ucb: yeah, it mostly works too

9:50 "mostly"

9:50 duck1123: unless you're on linux. :(

9:52 gdev: duck1123:) yea i just noticed that in the FAQ

9:53 it also has a link to contact them if you want them to support other platforms so start the penguin email storm and they migth implement it for nix

9:55 although, I haven't tried it using wine

9:55 tsdh: Is it possible to declare generic parameters with gen-class, e.g., Map<String,Integer> instead of just Map?

9:56 ucb: gdev: you could always run a vm with ... never mind ;)

9:57 gdev: tsdh:) did this not answer your question? http://stackoverflow.com/questions/3688730/how-to-pass-a-typed-collection-from-clojure-to-java

10:00 I really need to create a stack overflow account. That way I can post my questions on there and then link them in this channel

10:01 tsdh: gdev: Ok, there doesn't seem to be a way except for writing a Java interface first and then making the gen-class-ed class implement that.

10:02 gdev: tsdh:) yeah when you're dealing with gen-class it has to be AOT compiled so it needs a lot of ceremony to do what you need

10:05 tsdh: gdev: Yeah, just now I have to provide some student with a simple interface to my clojure lib. Just a few static methods that return maps. So for now, I'm keeping them to return just Map, although on the java side one would expect Map<String,SomeOtherType>.

10:05 That's good enough, since he only needs that for testing purposes.

10:06 gdev: can you post the code on refheap.com ?

10:10 tsdh: gdev: Sure. https://www.refheap.com/paste/14302

10:41 pjstadig: i just used juxt

10:41 * pjstadig rings the bell

10:45 pjstadig: is there a schedule for the 2013 Clojure/West videos yet?

10:47 https://twitter.com/ClojureWest/status/326455152586420225

11:22 tomoj: oh, CFP for strange loop done tomorrow?

11:24 Bodil: tomoj: Yep.

11:24 bbloom: tomoj: ooh, the last day is tomorrow? hmmm probably should get on that...

11:26 tomoj: I wonder how bad an idea it is to submit one when you haven't quite solved the problem yet

11:28 Bodil: tomoj: fwiw, I'm submitting an ELC talk on a language I haven't really written yet. It's a great way to make sure you get things done by September. :)

11:29 tomoj: ah, btw, I'd love to see your talk - can't remember whether I decided it was worth pinging you or not, but I was going to tell you that I have often fantasized about that language you're making :)

11:30 Bodil: So far it's just my fantasy too... needs a bit of work. :)

11:34 ejackson: Bodil: cgrand calls it TDD - talk driven development :)

11:35 wink: better than hope or desperation driven

11:35 bbloom: wink: that's what occurs on the plane ride to the conference

11:35 wink: hehe

11:35 yep

11:36 ejackson: only when you're lucky...

11:36 Bodil: ejackson: Hah, very true. :)

11:37 * wink hasnt given a talk since 2011 :/

11:37 jtoy: can anyone show me how if I had to update a count as im reading through a large file, how I would do it? I think i need to use some imperitave programming or use refs?

11:38 gfredericks: you're reading lines from a file?

11:38 just for the sake of producing this count?

11:38 jtoy: gfredericks: im running some analytics on each line and based on the reults i want to update the counter

11:38 yes

11:39 gfredericks: that sounds like you could create a line-seq and just reduce over it

11:41 jtoy: gfredericks: yes, that does sound right, it looks like reduce will make the result turn non-lazy and give methe number i want

11:41 gfredericks: but the laziness still lets you process the file in a streaming fashion

11:41 justin_smith: I heard Hickey talk about Hammock driven development - that is when you are motivated to code for a conference in a tropical location, right?

11:42 jtoy: gfredericks: ok, i'll test it

11:42 bbloom: justin_smith: heh. i think hammock driven development is a programmer centric view of the "open mode" discussed in John Cleese's (awesome & hilarious) lecture on Creativity: http://vimeo.com/18913413

11:43 justin_smith: bbloom: yeah, but it seemed to fit this conference talk nicely

11:43 bbloom: justin_smith: it did, i just needed an excuse to link to john cleese

11:45 jtoy: gfredericks: I am collecting a couple of different numbers, so I dont think I can use reduce? is that correct? I thikn i still would need to increment?

11:45 justin_smith: jtoy: you can reduce into a vector or map

11:46 jtoy: justin_smith: could you show me a simpe example of just that? Im not sure how that would work exactly

11:47 justin_smith: (reduce (fn [[a b] x] [(inc a x) (inc b (/ x 2))]) [0 0] [1 2 3 4 5 6])

11:47 just define the reduce fn to take an array and return one

11:47 (or map or whathaveyou)

11:48 oops, change inc to + above, but that is not the important part of the example

11:49 jtoy: i see

11:50 justin_smith: when I want to gather data about a sequence I define a simple data structure that will hold the result and any intermediary values I need, then a function that takes and returns that structure, then I fill that function in to update the structure as apropriate for each element

11:50 jtoy: justin_smith: great, I will use this method

11:51 tomoj: if pedestal has a god map, does angular have a devil map?

11:53 justin_smith: lemme guess, god map is a rewrite of global state into a single data structure in order to make a library re-entrant?

11:53 tomoj: I'm not terribly sure I understand the pattern (nor pedestal), but that sounds right

11:53 Anderkent: Does anyone know if https://devcenter.heroku.com/articles/debugging-clojure is still up to date? I'm getting errors when trying `lein repl :connect http://server/url`

11:53 tomoj: it's the Big Atom in the Sky

11:54 (nor "re-entrant")

11:55 justin_smith: tomoj: I have seen a number of libs do this - a lib is written so that it refers to some global state inside the lib, and that works until someone wants to instances of what the lib does

11:55 re-entrancy is the ability to make two objects defined by some stateful library side by side without them messing each other up

11:56 tomoj: hmm

11:56 justin_smith: so they create a state object/hash and shove all the globals in there (and add an extra arg to everything / create a special var / whatever)

11:57 *two instances of what the lib does

11:57 tomoj: I see

11:57 with pedestal you wire up all these pure functions and explicitly describe the connections between them and the model, and then it just runs them in a state-monad-ish way. I suspect it should have no problem running two instances

11:59 justin_smith: we had to do this same thing recently when we realized our in-house lib was storing an atom referring to db config

12:00 but if two parts of one app wanted to use different dbs?

12:00 boom, move the config out of a single atom in the lib into an arg / special var

12:00 tomoj: right

12:00 like the java.jdbc issue?

12:00 justin_smith: yeah

12:00 exactly

12:01 the hilarious part is we were using clojure.java.jdbc, and the atom was supposed to be simplifying things

12:01 in the end we realize that was the right way all along

12:02 tomoj: so in pedestal when you build a new app it has an atom in there

12:02 Pure_loulou: hello room :),i want to represant a graph in clojure,which data type to use?

12:02 tomoj: but there's no var associated with the atom

12:02 i.e. there is room for polytheism

12:02 Pure_loulou: maps is the normal way to represent a graph in clojure?

12:03 justin_smith: Pure_loulou: there are graph libs, but I have just used a pair of maps, one describing nodes, the other describing edges

12:04 each node/edge having keys to look up the related edge/nodes in the other map

12:04 tomoj: there's also inductive graphs, but I haven't seen a lib that does that yet

12:04 except my WIP

12:05 jtoy: justin_smith: do you see any basic error with the way I am doing my reduce: https://www.refheap.com/paste/14308

12:06 justin_smith: jtoy: you are adding a boolean, which will not work

12:06 booleans do not overload to int

12:06 jtoy: ah, right

12:07 justin_smith: dont think it fixed my other error though, ill continue looking

12:07 justin_smith: I would also define the sequence separate from the reducer

12:08 the sequence is just complex enough to benefit by standing alone

12:08 jtoy: justin_smith: you mean just using let to define it to its own variable?

12:09 justin_smith: yeah, I tend to find bugs faster when less is generated inline

12:09 (and I think other people do to)

12:10 jtoy: cool, ill try that too

12:32 kephale: CCW question (cemerick?): is there currently a way (or a chance of a future way) of using the eclipse internal/local dependency system for external dependencies?

12:33 cemerick: kephale: Eclipse doesn't have a dependency system of its own...?

12:33 kephale: cemerick: can't you link jars from other projects?

12:33 for java project at least

12:34 cemerick: kephale: oh, you mean adding project A to the classpath of project B?

12:34 kephale: cemerick: yeah!

12:34 nothing fancy, just for multi-project development

12:35 cemerick: If you have project A set up right (i.e. so your clojure source dirs are eclipse source roots, etc), then yes. It's not automatic though.

12:36 Though, you can load any Clojure file into any REPL whenever you want, regardless of the classpath. That's worked well enough for me 95% of the time.

12:37 kephale: cemerick: aha. good point, and that is probably better than restarting the REPL anyway

13:34 chessguy: hey, i'm playing with a pedestal app, because i want to show the cool tooling, but i'm missing a step somewhere. it's not generating the css somewhere. i feel like there's a lein task i need to run or something. any help?

13:40 rkneufeld: chessguy: You shouldn't need to do anything extra to have css work. Have you generated a new project or are you in one of the samples?

13:40 chessguy: rkneufeld: i'm in the todomvc example

13:41 rkneufeld: the styles look right if i go to the dev link, but if i go to design mode, or render, it doesn't look right

13:42 rkneufeld: and if i (watch :dev) i get a lot of FileNotFoundException: out/public/generated-js (No such file or directory)

13:43 rkneufeld: chessguy: there is definitely a lot broken with that sample, I'm surprised that so many people find it ;)

13:43 chessguy: rkneufeld: i think it's the only one for which i've been able to get recording to work

13:43 rkneufeld: any suggestions?

13:43 rkneufeld: chessguy: at this point we've only made it work on the dev page, fwiw - so render and design mode just plain won't work.

13:43 chessguy: ugh

13:44 it seems like it's really close to working, it's just not loading the styles

13:44 rkneufeld: chessguy: FYI, the chat sample in the official repo should work for recording.

13:45 chessguy: it is pretty close - we never got around to mucking with tooling vs. app templates and getting that sorted out in the rest of the sample pages.

13:45 chessguy: let me try that one again

13:45 rkneufeld: *tool pages (not samples)

13:45 chessguy: As the originator of that todomvc sample I would definitely say it is a bad example of many things ;)

13:46 chessguy: rkneufeld: well, it at least looks great :)

13:46 at least, when the styles work

13:46 rkneufeld: chessguy: heh, the funny part is that was provided by the spec

13:47 tieTYT2: what's the word that means the opposite of appreciation? I regret learning clojure because it's making me feel that way about java

13:48 chessguy: rkneufeld: well, thanks for providing some kind of example, anyway. even a bad example is better than nothing

13:48 i'm really looking forward to seeing a screencast or tutorial on pedestal

13:49 rkneufeld: chessguy: I'm really looking forward to making one - now that we've wrapped up the data flow engine cleanup we should be a lot closer to that.

13:49 chessguy: rkneufeld: oh yeah, Craig said you guys were working on wildcard-matching or something

14:35 kastrup: Raynes: Has anyone tried to take tryclojure and turn it into a full-fledged learning system for Clojure?

14:41 gfredericks: what fledges does tryclojure lack?

15:00 kastrup: gfredericks: Try Clojure is sweet--I love it, but it is more of an appetite whetter. I'm wondering if it could be used as a more comprehensive teaching tool.

15:01 muhoo: i'm trying to read a map in from a file inside project.clj to get around a requirement by a library that it have passwords in project.clj. no luck though. (-> ".lein-env" slurp read-string :migratus) appears to show up as a list even though it is a map. java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Associative

15:01 i refuse on matter of principle to put passwords into project.clj and thus into git.

15:02 kastrup: gfredericks: I'm thinking it might be interesting to expand the material and possibly add some features (like saving a user's repl session, etc).

15:03 amalloy: kastrup: 4clojure?

15:04 muhoo: nobody can help with "this thing i'm certain is a map says it's a list, what's the deal?"

15:04 muhoo: amalloy: true, but as i'm beating on this thing, it seems that (type) says it is indeed a PersistentArrayMap. weird.

15:04 amalloy: then the exception is coming from something else

15:05 kastrup: amalloy: Nice. Few new things under the sun!

15:06 muhoo: aha! i see the problem. defproject is a macro, and it looks like by the time it is done, any code inside it is not executed yet

15:06 solussd`: xb

15:06 muhoo: :-/

15:07 i suspect ~ will be needed here, or exec. wil beat on it. sorry for the thrash

15:08 amalloy: thank you. ~ was all i needed.

15:20 tieTYT2: i have a vector and I want to compare adjacent elements and sometimes return them both and sometimes return just one of the two. Is a reduce function the best way to do this?

15:28 amalloy: tieTYT2: try combining mapcat and partition

15:34 AWizzArd: I am implementing some neural network stuff using CUDA. I can store weights as floats or doubles on the GPU. The code will look nearly identical for both versions, only tiny differences here and there.

15:34 Currently I am using a macro “emit-cuda-defrecord” which spits out both records, implementing the same protocol.

15:35 Only the code looks ugly, cause we are talking about 2k - 3k LOC, full of ~ and ~'.

15:35 Any ideas? I would love to write down the code as if I were doing only one implementation, say, for doubles.

15:36 And have then some maybe not so nice looking code (20-100 loc) which replicates my implementation and replaces only a few details.

15:37 tieTYT2: amalloy: I'll look that up, thanks

15:39 ah what I forgot to say is, if I've got [1 2 3] I want to compare 1 to 2, and then the result of that to 3

15:40 ah partition can do that

15:40 AWizzArd: symbol-macrolet maybe?

15:43 amalloy: AWizzArd: i don't think anyone knows enough about your problem yet to give meaningful advice

15:45 AWizzArd: amalloy: think of a defprotocol for matrices with 75 functions. I want to provide several implementations of this protocol. One that uses pure Java and runs everywhere, one that uses blas and is faster but needs some extra installation, and one that uses cuda.

15:45 amalloy: in those 75 FNs I work with double-array calls and such. I could have two cuda implementations, and not just one.

15:46 One that uses doubles on the GPU, and one that uses floats.

15:47 I basically want to have 2x 75 FNs, where in the replication a few names were changed.

15:59 mthvedt: maybe there's some clojure templater that can template code?

16:01 AWizzArd: I think for now I will go with the implementation that uses doubles, and see later if floats are worth the effort.

16:02 muhoo: wow, all the little gems hiding in the clojure ecosphere: https://github.com/joegallo/robert-bruce

16:02 i was just writing some hack to retry clj-http on error 406 to deal with a broken site, and thinking "wow i wish someone had already thought of a way to to this", and here it is already

16:08 tieTYT2: is there a way to make clojure output more information in its exceptions? eg: clojure.lang.ArityException: Wrong number of args (1) passed to: core$reduce would be so much better if it told me the type that's being passed in

16:13 dnolen: tieTYT2: that would be nice but you should have a line number for that exception

16:13 recycle: any idea on how to pass a clojure sequence as a command line param to main function ? (that is - prevent argv from being tokenized at whitespace)

16:18 tieTYT2: dnolen: I do, but if that line number is the middle of a threading macro, it doesn't help much

16:20 dnolen: tieTYT2: ? even in a threading macro it should be pretty easy to spot the reduce that isn't being given enough params

16:30 ppppaul: recycle,

16:30 IFS

16:30 talk to the #bash people or nDuff

16:32 IFS=\n

16:32 your bash fn is going to get complicated...

16:32 TimMc: reiddraper: What's the plan for the meetup on Thursday?

16:32 ppppaul: recycle, you can use commas

16:33 [1,2,3]

16:33 tomoj: muhoo: robert-bruce is nice indeed

16:33 or looks it

16:35 I want something better for rate-limiting

16:35 TimMc: recycle: It really is a shell-specific question, but here's how I generate passwords from the shell: alias pw="java -jar ~/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar -e '(println (apply str (repeatedly 20 #(rand-nth (map char (range 33 127))))))'"

16:35 recycle: yeah - escaping definitely does the trick

16:36 thanks!

16:36 TimMc: quoting

16:36 escaping is backslashes

16:36 recycle: yep yep,sorry :)

16:42 tomoj: TimMc: hmm

16:42 would it be unreasonably paranoid to use SecureRandom?

16:49 AWizzArd: tomoj: it’s good, go ahead and use it

16:50 tomoj: A better question would've been whether it's unreasonably unparanoid to use java.util.Random

16:51 ppppaul: i have to buy my random numbers for the government

16:53 Apage43: tomoj: depends on what for

16:53 -anything- having to do with access control or security, yes

16:54 ordnungswidrig: tomoj: what's your risk?

16:55 TimMc: I'm not worried about someone being ablee to gather enough random data from my computer to be able to predict the PRNG output.

16:56 Apage43: it doesn't take much

16:57 TimMc: A big source of leakage (I think) would be JS on a malicious web page calling Math.random()

16:59 Apage43: Unfortunately, for anything I *really* care about, I end up using a passphrase with (probably) much lower entropy. :-/

16:59 Apage43: That's probably not an issue, as Math.random() is probably just seeded around the time, and not pulling from any system RNG. At best they can predict the numbers that would be generated -on that page-

17:00 which has implications if you do JS crypto (badly), but otherwise probably not

17:02 typically though there has to be some locality involved

17:03 e.g. if you generate two keys of some description with java.util.Random, anyone who can get the first can predict bits of the next one (and vice versa)

17:03 rodnaph_: hey - i'm trying to set up a browser connected nrepl session with piggieback, but i'm falling a bit flat as i think i may have misunderstood the intention of the library. does anyone have experience who could help?

17:05 specifically - i'm expecting to be able to connect to nrepl via my editor and dynamically update and evaluate clojurescript straight to the connected browser... am i mistaken that this is what it provides?

17:14 Apage43: rodnaph_: you can get a cljs repl connected to a browser yes https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments

17:15 What *piggieback* does is make the interaction with the cljs repl actually have nREPL behavior instead of behaving as if you evald' an expression in a repl that reads input from you, which is what you get if you follow that article

17:15 piggieback is just for making running a repl in a repl a bit smoother, but it is not *required*

17:16 should probably try to get set up without it first

17:16 rodnaph_: ok, i'll have to read that a few times i think ;)

17:16 yah i have used the standard browser connected repl before, but i was using vim + slime + screen.

17:17 i'm switched to vim-fireplace now, which afaik, speaks nrepl. so i was experminenting to see if it would talk to the repl -> and to the browser. seamlessly.

17:17 Apage43: ah

17:17 well

17:18 vim-fireplace supports code eval, but doesn't give you a repl buffer

17:18 if you switched its repl session to cljs that -could- work.. but it might confuse it

17:20 rodnaph_: hmm... ok, i'm just going to keep on playing then and see what i can make work. thanks v much for the info.

17:36 addywaddy: newbie here :)

17:36 got a question regarding restructuring. https://gist.github.com/addywaddy/b3a19cc7f70fb33201d2. Any ideas?

17:38 tomoj: addywaddy: not clear what you want

17:38 your second example is an error

17:38 &([:a :b] [:c :d])

17:38 lazybot: java.lang.IllegalArgumentException: Key must be integer

17:38 tomoj: you want to make sure there are 3 args and not 2? or you want to make sure the remaining args are all vector pairs? or..?

17:38 addywaddy: tomoj: ah sorry

17:39 tomoj: anyway easiest way to ensure the function is not called in an incorrect way is to not call it in an incorrect way :P

17:39 addywaddy: what I want is to past on the list of arrays to bar expanded.

17:42 tomoj: (let [foo (fn [first & rest] [first rest])] (apply foo :name '([:a :b] [:c :d])))

17:42 &(let [foo (fn [first & rest] [first rest])] (apply foo :name '([:a :b] [:c :d])))

17:42 lazybot: ⇒ [:name ([:a :b] [:c :d])]

17:42 tomoj: you mean like that?

17:50 mikerod_: What is a good way to generate a tree structure in clojure when you have a root node, a function determining if a node has children, and a function that gets the children of a node? I'm thinking analogously to `tree-seq` except I don't have a tree to walk, instead I just have the root node.

17:51 tomoj: mikerod_: that's what tree-seq expects

17:52 well obviously you mean something different

17:52 mikerod_: tomoj: I know, but tree-seq doesn't return a data structure that represents the tree. At least that isn't what I gather from it.

17:53 addywaddy: :tomoj I think I need to use apply: https://gist.github.com/addywaddy/b3a19cc7f70fb33201d2

17:56 tomoj: mikerod_: I see

17:57 malesch: tree zipper and node/edit

17:58 gilles: hi

17:59 mikerod_: What I mean is, tree-seq doesn't return a structure that preserves the hierarchy. It seems the intended use of tree-seq is to walk an existing tree data structure represented as root.

18:00 malesch: Thanks. I have started to explore the clojure.zip lib. I'll look into the node/edit.

18:01 tomoj: here's my stack-consuming version https://www.refheap.com/paste/7afe71b0e23cadf87de5a0e99

18:01 I think that's what you mean?

18:02 hmm, or https://www.refheap.com/paste/bb4fb39b2173a06def02d1e45

18:03 ?

18:05 mikerod_: tomoj: Thanks for these examples. This is along the lines of what I am looking for.

18:06 I'm surprised that there are no functions provided in core clojure that is similar to this already.

18:11 tomoj: it sort of seems like cheating to use clojure.walk

18:12 the clojure.zip idea is interesting since your args are almost the same as zipper's, except missing make-node

18:12 which is the thing that clojure.walk does for us in my example

18:13 mikerod_: tomoj: Yeah, I can see what you mean.

18:57 tieTYT2: why do the code snippets here use the int function? http://www.drdobbs.com/architecture-and-design/the-clojure-philosophy/240150710?pgno=3

18:58 what would go wrong without it?

18:58 hiredman: ,(int \c)

18:58 clojurebot: 99

18:58 dnolen: ,(- \A 65)

18:58 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>

18:59 hiredman: ,(inc (int \c))

18:59 clojurebot: 100

18:59 tieTYT2: oh right

18:59 mebaran151: I'm trying to get lein ritz to work but I think it's choking on the space in Program Files: here is the error I get on nrepl-ritz-jack-in: Exception in thread "main" java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified; right after the Compiling Clojurescript prints

18:59

18:59 tieTYT2: jesus, this sample could be simpler

18:59 mebaran151: anybody here run lein-ritz on Windows with emacs?

19:16 TimMc: *sigh*

19:16 Short-timer.

19:45 gdev: ,(tree-seq even? inc [0 1 2 1 1 4 3 1 6 3 3])

19:45 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Argument must be an integer: [0 1 2 1 1 ...]>

19:45 gdev: ,(tree-seq even? seq [0 1 2 1 1 4 3 1 6 3 3])

19:45 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Argument must be an integer: [0 1 2 1 1 ...]>

19:46 gdev: ,(tree-seq sequential? seq [0 1 [2 1] 1 [4 3 1] 6 3 3])

19:46 clojurebot: ([0 1 [2 1] 1 [4 3 1] ...] 0 1 [2 1] 2 ...)

21:05 holo: hi

21:06 ,(apply merge-with (comp flatten vector) [{:a "ab"} {:a "ac"} {:a "ad"}])

21:06 clojurebot: {:a ("ab" "ac" "ad")}

21:06 holo: is there a more concise way to return this result?

21:11 Raynes: $google flatland useful

21:11 lazybot: [flatland/useful · GitHub] https://github.com/flatland/useful

21:11 Raynes: holo: If you use that, there is a function in flatland.useful.seq that will let you do

21:11 (s/groupings ffirst (comp val first) [{:a "ab"} {:a "ac"} {:a "ad"}])

21:11 {:a ["ab" "ac" "ad"]}

21:11 Not really more concise though.

21:13 holo: (inc Raynes) ; thanks, I think I may just get there some useful functions

21:13 lazybot: ⇒ 30

21:24 amalloy: &(reduce #(update-in %1 [(ffirst %2)] (fnil conj []) (val (first %2))) {} [{:a "ab"} {:a "ac"} {:a "ad"}])

21:24 lazybot: ⇒ {:a ["ab" "ac" "ad"]}

21:24 amalloy: a no-dependencies approach

21:30 holo: (inc amalloy) ; fnil is amazing! didn't know about it. thanks

21:30 lazybot: ⇒ 54

21:31 n_b: ,(doc fnil)

21:31 clojurebot: "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."

21:32 holo: this takes handling nil values to a different level

21:39 mange: Is there a reason why fnil stops at three replacements?

21:43 amalloy: four args is already a lot for a function; if you're worried 0-4 of the first four args may be nil, you need a more sophisticated approach than fnil :P

21:43 xeqi: maybe combine it with partial?

21:44 mange: Or I might want something like (apply fnil f defaults) for something.

22:16 benkay: has anyone worked with the clj-crypto library? it's throwing an error "No matching method found: init for class javax.crypto.Cipher"

22:19 holo: if map entries type is likely to deprecate, so is key and val?

22:31 gdev: Raynes, what is your talk going to be about and did you ever go shopping?

22:38 Raynes: gdev: Talk is about laser and I did not go shopping.

22:38 https://github.com/Raynes/laser

22:38 Probably going to pull an all nighter on this sucker.

22:39 Because I was too lazy to write but half of it a day before I give it. :p

22:42 gdev: cool, if you need any help lemme know

22:54 shriphani: hi. I am trying to read a gzipped text file in clojure and when I do this : https://www.refheap.com/paste/14332 , I get an array of size 4300 but doing zcat filename | wc -l gives me 8 million. What am I doing wrong ?

22:56 hiredman: you certainly don't get an array out of that

22:58 shriphani: hiredman, I thought for returned a list no?

23:03 hiredman, I changed the for to a map and I still get 4300 only.

23:15 benkay: can anyone hook me up with contact information for macourtney?

23:32 shriphani: hi. what is the alternative to using doall while line-seq-ing over a large file (several GBs).

23:32 n_b: shriphani: What, exactly, are yo trying to do?

23:33 apply a function to each line?

23:33 shriphani: n_b, I am going over a very large gzipped text file and yes applying a function to a line.

23:33 n_b: and what does the fn do?

23:33 does it have side-effects, and do you need the return value?

23:33 shriphani: the issue here is that when I use zcat <file> | wc -l , I get 8 million lines and using (doall (line-seq ..)), I get 4300.

23:33 currently just identity

23:34 n_b: Do the results look right, or do they look like gzip junk?

23:34 shriphani: using zcat they look ok and the first 4300 look right as well

23:35 I am able to get lines beyond that using zcat

23:35 but I can't get > 4300 using doall

23:36 so my guess is that maybe I shouldn't use doall.

23:39 n_b: my guess would actually be the GZip class not implementing bufferedreader

23:39 and getting closed

23:41 shriphani: n_b, I used (reduce (fn [x y] (+ x 1)) 0 (line-seq in)) and then I got 4300 again

23:42 n_b, I cast the GZIPInputStream as an io/reader and I cast that as a BufferedReader

23:42 is that wrong ?

23:44 n_b, then is it possible to read that file in? It seems like a very simple task...

23:52 n_b: I'm honestly not too familiar with all the InputStream stuff in Java-land, just going off of former experience with reader issues

23:53 shriphani: ah. your estimate seems to be correct. GZIPInputStream doesn't implement BufferedReader (so says S/O).

23:54 n_b: I'm sure there's a UnbufferedInputStreamObjectFactoryAbstractFactoryImpl that'll solve it for you somewhere in java.util then :P

23:54 tomoj: naturally, it's not a Reader?

23:54 shriphani: I am surprised at how java regularly shows up to make life hell for me...

23:55 n_b: Clojure does very little to abstract away the host platform

23:56 shriphani: so what is the work-around for this? Is there a way to read this .gz file ?

Logging service provided by n01se.net