#clojure log - Apr 28 2013

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

0:08 andyfingerhut: I'm trying to create a Leiningen project.clj for a Clojure contrib library (data.priority-map), and not having much luck finding the right combination of options necessary to get "lein test" to work. Anyone know what might be needed besides :source-paths and :test-paths (assuming those are needed).

0:09 Ugh. Never mind.

0:09 :dependencies is the answer. Shame.

0:12 technomancy: danneu: check stdout?

0:12 andyfingerhut: do I smell a policy change in the works?

0:13 andyfingerhut: From me? No, I just want something to do experiments with different local versions of Clojure without having to learn how to edit pom.xml files.

0:13 technomancy: gotcha

0:14 andyfingerhut: Several contrib libs already do have pom.xml and project.clj files. Maybe 3 out of 20 or so.

0:14 pom.xml for official releases, and project.clj created by the developer for their own use.

0:17 technomancy: the original reason for the mvn-only policy was because lein couldn't deploy to remote repos at the time, right?

0:17 which hasn't been true since early 2011?

0:18 andyfingerhut: I'm sorry to say I don't know the answer or history there.

0:20 tomoj: might it make sense to define a multi-tie, which is like a (reduce #(nom/tie %2 %1) body noms), but which unifies regardless of the order in which the noms are tied? i.e., in the alphakanren notation, (== (multi-tie as m) (multi-tie bs n)) iff there is a bijection between the noms as and bs such that (susp bijection m) unifies with n and (# b m) for all b in bs?

0:27 dnolen: tomoj: yep, multi-tie would be nice

0:33 tomoj: actually reading more closely I don't know about that. Definitely want a tie that can bind more than one nom. What is the use case for what you're describing?

0:33 tomoj: I'm thinking about first-order logic formulas

0:34 and terms

0:35 so maybe.. (nom/tie a (nom/tie b `(= (+ ~a ~b) (+ ~b ~a))))

0:36 dnolen: tomoj: I need parse that some more - still, shouldn't be hard to try it out if you're willing to dig into nominal.clj

0:36 nominal.clj is a gentler introduction to the constraint stuff than FD, less stuff less fancy.

1:00 tomoj: a tricky thing is that suspc requires swap to be ground

1:03 dobry-den: after half a day of trying to figure out why my program only runs at 65% cpu on 8 linode cores, i learned about jvm arguments…..

1:03 i punched my couch pillows so hard when i found that out 30 min ago

1:04 -Xms512m worked

1:21 rbarraud: seen slava

2:23 sorenmacbeth: anybody know how I'd do a cancellable pmap? i.e., a pmap where if any of the futures throws an exception, all the others are cancelled immediately?

2:24 I can't use (shutdown-agents) because I have other long running futures that I don't want to cancel

2:24 I only want to cancel futures launched by the pmap

2:26 use case is I'm downloading a bunch of files in parallel, if any one of them fails, I want to immediately stop downloading the others, clean up and try again

3:33 abp: http://euroclojure.com/ :)

3:34 lynaghk`: sorenmacbeth: I tried using pmap for some parallel download stuff and ended up just using java.concurrent.exeuctors directly, which were nice and explicit

3:41 abp: lynaghk: I'd love seeing all that stuff done with some native Clojure message queues and a uniform configurable execution backend.

3:47 ucb: lynaghk, abp: this is a modification to futures to use custom executors; this might be a good start https://gist.github.com/guv/5445115

3:49 lynaghk, abp: there's also knit: https://github.com/mpenet/knit

3:50 skavez: Hello, I'm trying to apply a list of functions to a string and have the string modified sequentially. I'm a newb, but I figured reduce would work in this case, but it doesn't. Is there something I'm missing? Code: http://pastebin.com/9ZX4cp0t

3:51 ucb: skavez: you could try (-> "my string" (transform-1) (transform-2) ...)

3:51 ,(doc ->)

3:51 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

3:54 skavez: ucb: Thanks, I would've never found that! Is there a way to pass a vector in for the forms, instead of listing them all out?

3:54 ucb: skavez: don't know but I wouldn't think so

3:57 skavez: ucb: Ah, thanks. The reason I'm trying to feed a vector of functions in is users will probably specify which text transformations they want to apply, so I won't know ahead of time.

3:57 andyfingerhut: skavez: Each function in your vector takes a single string as its only argument, and returns a string? You should be able to use reduce in that case.

3:58 ucb: yeah, that too

3:59 skavez: andyfingerhut: Exactly. This is what I tried, but there must be some brain fart here: http://pastebin.com/9ZX4cp0t

4:01 sorenmacbeth: lynaghk, abp, ucb: cheers, I'll look into those.

4:02 andyfingerhut: skavez: Use "(fn [str f]" instead of "(fn [f str]"

4:06 styts: is anyone using vim for clojure development?

4:12 skavez: ucb / andyfingerhut: D'oh! I forgot the accumulator went first. Thanks!

4:23 dobry-den: ((comp lower-case trim) "FOO\n")

4:27 callen: styts: absolutely no one is doing that.

4:27 styts: it's totally unheard of and I'm gobsmacked you came up with that combo.

4:28 styts: what's next? peanut butter and jelly on the same sandwich?

4:28 fucking madness.

4:30 styts: callen: well, i've found out about vim-fireplace and am trying to get used to the workflow.

4:36 dobry-den: I ended up installing Emacs and Evil-Mode

4:40 Raynes: styts: I do.

4:40 Or Emacs.

4:40 I use both.

4:40 It depends on which day.

4:41 I'm ambideditorous.

4:41 styts: so you write code in the editor and send it to the repl, right?

4:43 deg: I'm trying to deploy my first CLJS app, and am getting a bit lost in all the possibilities.

4:44 First question, before I launch into details: Is Heroku a good way to go for a small app, where I want to keep costs at or near free?

4:49 borkdude: in compojure, if I use (context "/api" [] api-routes), what if one of the api-routes expects arguments?

4:49 derived from https://github.com/weavejester/compojure/wiki/Nesting-routes

4:52 I guess better not use context in this case

4:59 callen: deg: not if it needs to be reliable.

5:00 deg: At this stage, reliable is not really important... it's for personal use and for learning the tools.

5:00 callen: then it's fine but deploying clojure apps is hardly difficult

5:00 I wrote scripts using gantry for it in like 30m

5:00 deg: But, if something else is more reliable and still free, I'm certainly not wed to Heroku. How unreliable is it?

5:01 callen: at the free tier for clojure apps, pretty damn reliable

5:01 66% uptime

5:01 deg: I've got the basic deployment working, but it is complaining about using too much memory. (Typically 500-600MB -- not much over their baseline limit, but still surprising).

5:01 callen: unreliable*

5:02 I...didn't have any memory issues.

5:02 wtf are you doing?

5:02 are you fucking with the JVM heap settings?

5:02 deg: No, not that I know of.

5:02 My best guess is that I'm launching int the wrong way, or have extra crap in my project.clj.

5:02 callen: deg: this is on heroku?

5:03 deg: yes.

5:03 callen: deg: you followed their instructions for the buildpack?

5:03 deg: it's a standard clojure/ring/jetty app?

5:04 deg: It's a compojure app, modeled on the tutorial at. ... (one sec)

5:04 https://github.com/magomimmo/modern-cljs/

5:04 I see that most of the Heroku samples launch by having an explicit -main function

5:04 callen: "modern" CLJS?

5:05 shit hasn't even had a mature cycle yet, let alone the ability to have a modern setup.

5:05 deg: :-) I don't name 'em, I just use 'em.

5:05 callen: deg: first off, fuck cljsbuild

5:06 deg: But, copying the tuturial, I launch with lein ring server-headless

5:07 Umm, I feel your emotional pain. ( :-) ) but don't understand the problem.

5:07 callen: oh right, shoreleave.

5:07 deg: are you using trampoline?

5:07 deg: No. I tried, but it didn't seem to work.

5:08 And, I wasn't seeing enough feedback in the Heroku logs to understand why not.

5:08 callen: deg: so try it locally?

5:08 deg: My Procfile is simply 'web: lein ring server-headless'

5:08 Ok. So, I should locally try 'lein trampoline ring server-headless'?

5:08 callen: lein trampoline ring server

5:09 it doesn't need to be headless.

5:09 deg: I understood that "headless" here meant not to auto-launch a web browser. Oh, are you saying doesn't need to be headless on the local run?

5:11 callen: deg: just try both, jesus

5:11 deg: less talk more walk

5:12 deg: Hmm, so I tried (locally) lein trampoline ring server. No error in shell, but apparently no server launched either... Browser doesn't connect.

5:12 Are any logs generated anywhere? Nothing useful was on stdout.

5:13 And, just verified that lein ring server works fine locally.

5:13 callen: attempting a repro.

5:13 works for me.

5:14 deg: You tried the magmimmo sample project?

5:15 callen: deg: no, his project.clj scares me.

5:15 deg: it looks like the project.clj of somebody with 15 years of syphilis behind them.

5:16 deg: require lein 2.0.0, see what changes.

5:16 deg: Can you point me to a working sample project that uses Compojure?

5:16 callen: deg: https://github.com/bitemyapp/neubite/

5:17 deg: Thanks. Give me a few minutes to play with it, and I'll come back with success/failure. Thanks,

5:18 callen: deg: I don't need you to tell me it works, it's running on a 512mb DigitalOcean VPS right now.

5:19 deg: I meant if s/f on finding the differences between your working case and my broken case.

5:22 callen: deg: yes. do report any conclusions there.

5:24 deg: Heh. That project fails to compile for me with a NPE in mongodb. Something fucked in my env? I'll poke around some more.

5:33 callen: deg: DA, ENV COMRADE

5:33 deg: fire up mongodb locally or use mongohq's poverty tier.

5:33 don't need any fixture data.

5:37 deg: Yup... I was in a different window and found I was missing DATABASE_URL in my env.

5:37 callen: da.

5:38 deg: But, feels like I'm diving down the rabbit-hole here, if I now need to learn mongdb config, etc.

5:38 callen: might want to fake SECRET_KEY too.

5:38 oh for pete's sake.

5:38 don't be such a baby.

5:38 deg: I'm going to try to short-cut by just looking for diffs between the two project.clj files.

5:39 callen: deg: trying using a vanilla Luminus project.

5:39 deg: (afraid to ask, but) wtf is Luminus?

5:40 Raynes: Oh my. Go people use tabs instead of spaces.

5:41 callen: Raynes: they're insane.

5:41 deg: http://www.luminusweb.net/ use it, know it, love it.

5:42 deg: Yup, looking at it now, thx.

5:44 But, before I dive in too deep... Earlier, you suggested that shoreleave was heavy. Is best practice not to use it, and to use the tools in the Luminus stack?

5:46 I'd rather spend my time working in the most-supported stack, rather than trying to debug the stack I happen to be on now. I'm certainly not wed to that tutorial... my goal is just to get this app working.

5:54 ddellacosta: deg, I've written a tutorial on shoreleave which is more or less my experience trying to understand what it actually does: https://github.com/ddellacosta/barebones-shoreleave

5:55 to sum up, I don't know if it is ready for prime-time. I don't have any experience with luminus but my rough sense is that it is a bit more comprehensive than shoreleave

5:56 shore leave is more just about clojurescript <-> web app using compojure interaction

5:56 shoreleave

5:57 if you want "most-supported stack," then I'd say start with composure and understand how that works well. Then learn about using clojurescript in conjunction with that.

6:04 svedubois: How I can translate this JS to CLJS? var FizzyText = function() {this.message = 'dat.gui';};

6:13 nilbert: n/win10

6:14 clojurebot: I don't understand.

6:14 nilbert: sorry, wrong window :)

6:15 ddellacosta: svedubois: it's hard with a function that has side effects like that, unless I know what else is going on in the code

6:16 svedubois: I have taken the code from here http://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage

6:18 ddellacosta: ah, well, don't know concretely but this may help: http://stackoverflow.com/questions/15531261/accessing-this-in-clojurescript

6:37 deg: ddellacosta: Thanks. I'm taking a step back now to take a good look at Luminus, and will read your shoreleave link too.

6:37 callen: Thanks for your help. Looks like I need to regroup, find the right foundation, and get my memory footprint down to something sane.

6:38 ddellacosta: deg: btw, check this post out too, by the author of luminus, features a "competitor" to shoreleave they wrote called cljs-ajax: http://yogthos.net/blog/43-Introducing+cljs-ajax

6:38 deg: thx

7:01 clojure-new: Hello.

7:02 I'm trying to use jogl from clojure with help of https://clojars.org/org.clojars.toxi/jogl .

7:02 NeedMoreDesu: Why can't I derive class from class?

7:02 clojure-new: But i can't import javax.media.opengl.GLCanvas. Can you help me?

7:02 ClassNotFoundException javax.media.opengl.GLCanvas java.net.URLClassLoader$1.run (URLClassLoader.java:366)

7:02 Error ^

7:03 NeedMoreDesu: clojure-new: http://mavenhub.com/c/javax/media/opengl/glcanvas

7:04 clojure-new: NeedMoreDesu: What can i do about it?

7:05 NeedMoreDesu: Not sure if this helps, but try to add dependency to project.clj

7:05 [groupId/artifactId "version"]

7:06 [com.projectdarkstar.ext.net.java.dev.jogl/jogl "1.1.1"]

7:08 clojure-new: NeedMoreDesu: Thanks a lot, it solves the prbolem.

7:09 Strange, does it means actually i need two version of jogl?

7:09 [org.clojars.toxi/jogl "2.0.0-rc11"] and [com.projectdarkstar.ext.net.java.dev.jogl/jogl "1.1.1"]

7:10 NeedMoreDesu: Not sure. Maybe, those clojars jogl is some sort of interface?

7:11 Never actually use it, so I don't really know.

7:11 /s/use/used

7:11 clojure-new: Heh, just removed that clojars dependecy and everything still works as expected.

7:12 jaley: I'm considering core.logic for a problem I'm working on… anyone able to give me a quick sanity check, tell me if I'm completely barking up the wrong tree perhaps?

7:16 tomoj: ask?

7:16 AimHere: The golden rule of IRC is never to ask 'can anyone help me' or 'does anyone know X', just ask the question and wait for a bit

7:16 tomoj: anyone?

7:16 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

7:17 AimHere: People on IRC are lazy and have short attention spans. Asking them to actively prise out whatever it is you need to know is painful

7:18 On the other hand, they're often inveterate smartasses, so they'll take pride in giving you some sort of answer if you ask something (or blurt out something they think is completely wrong)

7:20 Most people generally take that as a cue to ask the damn question already

7:20 jaley: OK, so I want to do a kind of approximate rectangle packing type of problem, and my concern was that I don't know if core.logic will be able to pick some value fitting a continuous range style constraint?

7:20 AimHere: Heh, there you go

7:21 jaley: I basically want to arrange a bunch of images on a canvas in a way that "looks nice"

7:22 so it doesn't have to be "optimal" in the sense of a classic rectangle fitting problem, but… it's still a hard problem to solve algorithmically. Setting up a bunch of constraints and having core.logic sounds much simpler, if it's achievable...

7:26 AimHere: jaley, last I looked (which wasn't very recently or very deeply) core.logic needed to ask clojure proper for most things numerical, so I'd think you might have to do something similar here

7:30 jaley: AimHere: hmm ok, thanks

7:58 stian: Would love to get a few eyes on this little piece of code, especially whether I designed the API "idiomatically" http://codereview.stackexchange.com/questions/25575/api-wrapper-for-clojure-idiomatic-style-for-libraries

8:04 dobry-den: I'm having trouble understand the intersection of some concepts here. Since a Var is a "mutable storage bin", if you put a stateful Java object in one as the root binding, then all threads see and mutate that same object, right?

8:05 svedubois: I have a function FizzyText in a js file:

8:05 https://lukeletters-datgui-alpha.googlecode.com/git-history/dbb4fa0ef0428380044e825470e788dec1e37b86/docs/demo.js

8:05 And I would like to use it in CLJS.

8:05 After include the js file in the html I have tried with (FizzyText. "hello")

8:05 I get a TypeError: undefined is not a function.

8:05 How I can call FizzyText function win CLJS?

8:10 clojure-new: Hello again.

8:10 dobry-den: hi

8:11 clojure-new: I'm trying to port this to clojure http://www.13thmonkey.org/~boris/jgame/JGame/tutorial/Example1.java .

8:11 https://www.refheap.com/paste/14029 And i'm got this far.

8:13 Yellow text gisplays just fine but i need to rotate. In original java code it's done by mutating texttimerr variable(texttimer += 0.05; in doFrame method). How can i do that in clojure?

8:13 dobry-den: clojure-new: That error is often due to a forward reference in Javascript. It's silly but could that be it?

8:14 clojure-new: dobry-den: What error?

8:15 I'm having no errors, i'm just asking advise how to implement las two methods of http://www.13thmonkey.org/~boris/jgame/JGame/tutorial/Example1.java in clojure.

8:16 svedubois: I suppose perhaps is js/FizzyText

8:16 dobry-den: Gee, I finally noticed that I meant to type svedubois

8:18 svedubois: "undefined is not a function" is often due to a foreward reference

8:18 svedubois: But, with (js/FizzyText. "hello") I get an error: #<TypeError: Cannot call method 'appendChild' of null>

8:23 dobry-den: oh, i've never used cljs but i wouldnt have thought all js interop is done through js/

8:37 terom: clojure-new: you could use an atom to hold the value, then increment that in your method. Something like (def texttimer (atom 0)) and in the method (swap! texttimer #(+ % 0.05)). To get value of the atom, deref it like this: @texttimer

8:38 svedubois: Wrapping FizzyTect in a window.onload could solve the problem?

8:41 clojure-new: terom: Thanks, already solve it with ref. What the difference between atom and ref? Ref is more threadsafe?

8:42 solved*

8:43 terom: clojure-new: http://stackoverflow.com/questions/9132346/clojure-differences-between-ref-var-agent-atom-with-examples

8:43 svedubois: Why (js/FizzyText. "hello") gives a TypeError (Cannot call method 'appendChild' of null)?

8:44 clojure-new: Thanks.

8:48 Apage43: svedubois: i think that code you have expects to be called with new

8:48 oh, didn't see the .

8:48 nvm

8:49 svedubois: (new js/FizzyText "hello")

8:49 TypeError: Cannot call method 'appendChild' of null

8:49 Apage43: the only .appendChild in the JS you linked expects there to be an element of a specific ID on the page, if it is not there, that would cause the error

8:54 clojure-new: Awesome. Complete port of http://www.13thmonkey.org/~boris/jgame/JGame/tutorial/Example1.java to clojure https://www.refheap.com/paste/14030 .

8:54 Text is spinning now.

8:54 Any ideas how to make it more ideomatic?

10:09 maacl: Is it possible to implement a structure equivalent to a Java ConcurrentHashMap using a clojure atom map? My partial atempt is here https://gist.github.com/maacl/de1bef7207ba0cee375c but not sure it is concurrency safe.

10:27 icarot: Can anyone explain why both the tree-recursive fibonacci algorithm and typical recursive factorial function have the same space complexity (linear)?

10:29 borkdude: what do people use in more advanced form data processing and validation. I figured: first process (parse to int, etc), then validate on that, else you get duplication of this logic

10:29 Glenjamin: borkdude: i'm planning on a post on that subject to the mailing list, been mulling it around in my head for a while, and it seems difficult not to complect

10:31 borkdude: Glenjamin the way I'm dong it now: in a compojure POST route I send the data through a preprocessing function which does the conversion, then I validate that with noir.validation, if valid, I save the processed data to a db or smth, else I render the form again with the posted data and noir validation errors

10:32 Glenjamin: sounds about right, i'd be tempted to pass the raw data into the validation too

10:32 borkdude: Glenjamin I could merge it with the parsed input, so validations could be made on those also

10:33 Glenjamin: mm, could work

10:33 you could even make it a three-pass validation

10:33 raw-validation, parse-types, parsed-validation

10:34 borkdude: Glenjamin yes, could also work

10:34 abp: https://github.com/jkk/formative

10:34 Glenjamin: when you convert to types, you'll often want to return nil when you can't convert - but then it's tricky to give nice validation error messages off that

10:35 borkdude: Glenjamin or pass two maps to the validation function: raw and processed

10:35 abp looks interesting, will look into it

10:38 abp how does this library know to what type to parse a field

10:38 abp: borkdude: by specification

10:38 borkdude: :datatype on fields I think

10:38 borkdude: abp ok

10:39 Glenjamin: this looks like just what i was after

11:29 bttf: i've got a db.clj in my web app that has a var assigned to a select statement to the local db. when i :require this file in my application.clj and use the var, it does not update when the db has changed .. how can i make this behave so that it essenstially runs a select statement each time ?

11:32 n_b: bttf: Make it a function.

11:36 bttf: when i do that, it breaks the for loop that its used in .. i changed it to (for [x (myapp.db/all-posts)] ... )

11:37 do i need to prepend the ' to pass in a list rather than result of execution

11:41 n_b: bttf: Can you provide a paste of the code? http://refheap.com

11:41 and assuming it returns a seq, that for should work fine.

11:43 bttf: it returns a vector of maps

11:43 a sequence is a list, no ?

11:44 tcrayford: no

11:44 it has a list like interface (first/rest), but it isn't neccesarily constructed by cons cells

11:45 n_b: A Seq is anything with the ISeq interface

11:45 bttf: i see

11:45 getting pastes up

11:48 n_b: ,(= (seq '( 1 2 3)) (seq (vector 1 2 3)))

11:48 clojurebot: true

11:49 bttf: https://gist.github.com/bttf/b76860cf70b4c1cb298f

11:49 line 14 in application.clj

11:49 n_b: Ah, don't quote it.

11:50 bttf: right, i just did that. without it, it breaks

11:50 n_b: Can you expound on "it breaks"?

11:50 bttf: sure

11:50 i have lein ring running in the background

11:50 when i refresh the page, it gives me an error ...

11:50 n_b: oh

11:51 bttf: clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector, compiling:(application.clj:15:3)

11:51 n_b: all updates should be a function as well

11:51 Unless you don't expect it to change.

11:52 bttf: oh right

11:52 ok

11:54 svedubois: Can I write these 2 lines in only one without repeating map and models?

11:54 (map #(aset obj % true) models)

11:54 (map #(.add gui obj %) models)

11:55 n_b: svedubois: You can probably use comp

11:55 bttf: n_b: i guess i just dont understand the difference between referencing a var and calling a function. it works fine with a var, but when i turn it to a function it complains

11:56 n_b: Did you change line 39 to be (-> (all-updates) ?

11:56 bttf: yup

11:59 n_b: svedubois: Or do (map (. add gui obj (aset obj % true)) models)

11:59 bttf: i am still seeing the same error ... could it be with the for loop vector not receiving correct expressions

12:00 n_b: You're trying to call a vector as a function somewhere

12:01 Try just rebooting the lein server or reloading the namespace

12:01 bttf: ok now it's working ... in db.clj, i changed line 13 into (into [] (select posts))

12:01 which ... gives me the same exact output in the repl god dammit

12:02 (select posts) and (into [] (select posts))

12:03 n_b: I'm not familiar with korma, but that sounds like the REPL was forcing it to be realised while your handler wasn't, but I really don't know enough to do more than speculate

12:04 bttf: forcing it to be realized?

12:04 n_b: What's the value of (type (select posts))?

12:05 bttf: clojure.lang.PersistentVector

12:07 n_b: Hmm; I'm really not sure and don't want to give you wrong information. I'd ask a little later when someone more knowledgeable is around

12:07 bttf: alright thank you for your help

12:08 n_b: :) Sorry I couldn't give you a more complete answer

12:09 svedubois: (map (. add gui obj (aset obj % true)) models)

12:09 gives and error because (aset obj % true) returns always true and not the name of each model

12:09 n_b: The objects in models are being mutated, right?

12:11 (for [model models]

12:11 (do

12:11 (aset obj model true)

12:11 (.add gui obj model)

12:11 model))

12:13 I think ^ that should work and return you the objects you want

12:16 svedubois: I think this is one solution: (map (juxt #(aset obj % true) #(.add gui obj %) ) models)

12:16 At least it works

12:17 n_b: Ah, yes. juxt will do it but I'd argue it's not very idiomatic, since you're causing side-effects

12:20 noidi: (doseq [model models] (aset obj model true) (.add gui obj model))

12:21 ,(doc doseq)

12:21 clojurebot: "([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."

12:42 yacin: i only see the last line of a stacktrace on an error with nrepl in emacs. any idea on how to access the full trace?

12:43 TimMc: nDuff: I just saw an article in the New York Times that referred to pastebin as a "web forum for hackers" :-P

12:44 (pastebin.com, although they just called it PasteBin)

12:45 tcrayford: yacin: (.printStackTrace *e) in the repl

12:46 (pst *e) works as well

13:04 clojure-new: Hello, it there a way to get rid of "this" in proxies?

13:04 To make it implicit somehow i guess.

13:05 is there*

13:09 Another question, how can i access this.foo from clojure proxy?

13:09 Say foo is a variable.

13:12 TimMc: A variable? Surely you mean a member field.

13:12 clojure-new: Yes, member field.

13:13 TimMc: ^

14:44 satch5150: hi all, I included clj-crypto 0.0.4 in the project.clj of my lein project; leiningen downloaded the dependencies, but I do not know how to specify the namespace in the core.clj file in the ns macro

14:45 I Know the syntax of :use or :require, but not what how to specify the namespace of clj-crypto

14:45 the dependency statement in the project file is just [clj-crypto "0.0.4"]

14:45 anyone help ?

14:52 antares_: satch5150: it should be in the project docs. If there are no docs, file an issue about it and take a look at the source. There is no other way to know.

14:56 mthvedt: design pattern question: you have a record type, and you have some common operation on the record you want to memoize, but want everything to be able to be GCed also

14:57 if you didn't want a record, you could just reify closing over the pre-calculated results, but what if you want arecord?

15:07 i guess i want something like defrecord, but with reify-like lexical closures

15:12 gfredericks: I'm thinking of generalizing this vcr-clj library to do arbitrary I/O functions instead of just http

15:15 ghengis: is there a good profiling library, something that can be used like 'time' but more featureful?

15:20 xeqi: ghengis: criterium?

15:20 https://github.com/hugoduncan/criterium, more benchmarking then profiling

15:21 ghengis: yeah, i meant benchmarking : /

15:21 cool, "statistical processing of multiple evaluations" that's what i need

15:21 thanks :)

15:44 n_b: Is there any way to tell what could be holding onto the head of a sequence?

15:45 gfredericks: not easily; sneakiest cases are closures, and closures hidden by macros in particular

15:47 n_b: This is what I'm doing, so I don't think it's quite so complex as that: https://gist.github.com/9a387004e26d4b4505a3

15:48 Would it be the way I've built the pages+title seq up? I would've thought doseq would drop the head

15:54 Morgawr: hello, let's say I have two vectors of [x y z] and [x y k] and I want to use a function to return only the elements of the first vector that don't appear in the second vector (not vice-versa), so in this case I'd want [k]

15:55 how can I do that? is there some quick one-liner?

15:55 keep in mind that order might be different and the elements are uniques (I can use a set too)

15:55 gfredericks: (remove (set second-vector) first-vector)

15:55 you could use filterv with complement if you need a vector back

15:56 Morgawr: gfredericks: thanks!

15:56 that's perfet

15:56 perfect*

15:58 gfredericks: there's a nil/false edge-case there you should be aware

16:07 akhudek: there is nothing worse than getting a completely unhelpful stack trace error from lein :-(

16:09 seems that it's coming from extract-native-deps

16:10 ryan5: What's a good way to startup and run http-kit on a production server? I had been runnning my webapp on jetty6, which "just runs" as a service after I 'sudo apt-get install' it. But now, I want to use http-kit instead. However I didn't see how to run http-kit as a service. Any suggestions?

16:16 mpenet: ryan5: an uberjar+upstart (or whatever init deamon you use)

16:22 ryan5: ok.thank you mpenet... I just searched on those terms and found lein-init-script.

16:26 amalloy: n_b: nothing sneaky at all: you've defined 'dump as a var, so it is permanently reachable: no piece of it can ever be collected. same with all your other defs

16:28 n_b: amalloy: You are, once again, the spotlight illuminating my dumb mistakes. Thanks

16:29 I even remember reading about avoiding this exact pitfall in Clojure Programming >>

16:30 tgoossens: what was the fn called that could take an arbitrary amount of arguments and always return the same?

16:30 gfredericks: clojurebot: amalloy is the spotlight illuminating my dumb mistakes

16:30 clojurebot: Ack. Ack.

16:31 gfredericks: tgoossens: constantly

16:31 amalloy: &(doc constantly)

16:31 lazybot: ⇒ "([x]); Returns a function that takes any number of arguments and returns x."

16:31 tgoossens: yes that was it!

16:31 thanks

16:31 n_b: clojurebot does quotes now?

16:31 gfredericks: has he ever not??

16:31 lazybot: gfredericks: Uh, no. Why would you even ask?

16:31 n_b: I'll have to be more literary in my phrasing from now on

16:32 gfredericks: clojurebot: amalloy?

16:32 clojurebot: amalloy is the spotlight illuminating my dumb mistakes

16:36 n_b: I'll consider that my contribution to the clj community for the week :P

16:50 arohner: {:post []} can break (recur)?!?

16:51 gfredericks: ,(macroexpand-1 '(fn [x] {:post []} (recur x)))

16:51 clojurebot: (fn* ([x] (clojure.core/let [% (recur x)] %)))

16:52 gfredericks: ,(fn [x] {:post []} (recur x))

16:52 clojurebot: #<CompilerException java.lang.UnsupportedOperationException: Can only recur from tail position, compiling:(NO_SOURCE_PATH:0:0)>

16:53 amalloy: hah

16:53 Bronsa: uh

16:55 amalloy: arohner: write a better wrap-postconditions macro that expands to (fn [x] (let [% (f x)] (check %) %))

16:56 mnemnion: I'm trying to write a macro that does this (def-with-quoted-symbol 'symbol function-name)

16:56 that expands to (def symbol function-name)

16:57 unquoting is tripping me up here

16:58 the idea is that I can have a map like so { 'symbol1 function-1 , 'symbol2 function-2 }

16:58 then feed it to my macro one key-value pair at a time and get a bunch of redefinitions

16:58 storing the unquoted symbol doesn't work because the symbol doesn't resolve to anything prior to definition

17:07 gfredericks: mnemnion: maybe you should describe your higher use case

17:08 based on scanning your question you might have a misconception or two about macros

17:09 mnemnion: it's quite possible. There's definitely a gap in my understanding of quoted symbols and their resolution

17:10 so here's what I'm trying to do. I'd like to make a map like so { symbol1 function1 symbol2 function2 } etc

17:10 so that I could seq it and repeatedly call (def symbol1 function1) on the key-value pairs.

17:11 obviously, the symbols aren't defined when I want to make the map, so I get a fail. I can make a map like so: {'symbol1 function1 'symbol2 function2}

17:12 but this, for example, does not work: (def ~'symbol function)

17:12 mthvedt: mnemnion: what is the error

17:13 mnemnion: "First argument to def must be a Symbol"

17:13 also get that for (def 'symbol function)

17:13 that, I wouldn't expect to work, since the symbol is quoted

17:14 but why (def ~'symbol function) doesn't unquote the symbol, that, I do not understand

17:14 I feel like it should be equivalent to (def symbol function) but it is not.

17:14 mthvedt: mnemnion: if you write {'foo bar}, you get a map containing {foo bar}

17:14 'foo returns the symbol foo

17:17 arohner: is there a clojure library anywhere that "properly" indents a clojure form?

17:17 sw2wolf: ,(sqrt 1000000)

17:18 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sqrt in this context, compiling:(NO_SOURCE_PATH:0:0)>

17:18 arohner: i.e. I've (read) a file and munged it, now I want to spit it out again, either 1) preserving original whitespace or 2) dumping "proper" whitespace

17:18 mnemnion: hmm yes, that's the case, but...

17:18 Apage43: mnemnion: that just passes def the literal form (clojure.core/unquote (quote foo))

17:19 sw2wolf: ,(Math/sqrt 1000000)

17:19 clojurebot: 1000.0

17:19 xeqi: arohner: clojure.pprint/pprint ?

17:19 arohner: xeqi: pprint doesn't indent code

17:19 mnemnion: (def my-map {'foo "ignore-me"}) gives the expected key-value pair {foo ignore-me}

17:19 Apage43: as def is not a fn but a special form, and behaves similarly to a macro in that it takes its arguments as read, and they aren't evaled first

17:20 amalloy: arohner: pprint has a code-indenting mode

17:20 mnemnion: something like (first (seq (keys my-map))) does return foo in the repl

17:20 amalloy: clojure.pprint/code-dispatch or something

17:20 mnemnion: but (def (first (seq (keys my-map))) println) complains 'first argument to def must be a symbol'

17:20 * Apage43 was taking about (def ~'foo ...)

17:21 mthvedt: try `(def ~(first blah blah) println)

17:21 mnemnion: Apage43: appreciated, that helps me understand why it doesn't work for sure

17:21 arohner: amalloy: aha, thanks

17:22 Apage43: mthvedt: and then you have to eval that if you want to really do that

17:22 mnemnion: mthvedt: that works, thanks. I'm somewhat mystified as to why.

17:22 Apage43: you can (eval `(def ~(first seq keys my-map) …))

17:23 er

17:23 mnemnion: Is that really the minimum number of steps required to do this?

17:23 Apage43: with the proper parens

17:23 mnemnion: gotcha

17:23 mthvedt: mnemnion: when you call def, you give it a symbol literal which it doesn't evaluate, and (first (seq (keys my-map))) is not a symbol

17:23 Apage43: mnemnion: if you want to pass the result of some evaluation as the first arg of def I think you need eval

17:23 mthvedt: it returns a symbol, but it isn't one

17:24 mnemnion: right, because I'm inside a macro.

17:24 I think that's the big thing I was missing. Thanks all.

17:35 ...pity you can't map def, huh

17:36 arrdem: mnemnion: you can't?

17:36 mnemnion: i can wrap it, no big

17:36 gfredericks: mnemnion: metaprogramming with def isn't done very often

17:36 micahmartin: Is there an idiomatic way to check if the current runtime is Clojure or ClojureScript?

17:36 mnemnion: yeah, this is a special circumstance.

17:36 hfaafb: https://github.com/functional-koans/clojure-koans/blob/master/src/koans/10_lazy_sequences.clj#L25 can anyone help me complete the last koan on this page? I'm not sure what function it is expecting.

17:37 gfredericks: mnemnion: also anything you can do with def you can do with the namespace API

17:37 without macros

17:38 micahmartin: are you using cljsbuild crossovers?

17:38 micahmartin: no

17:39 gfredericks: some homespun version of that?

17:40 ,(= "0.75" (/ 3 4)) ;; that should work :)

17:40 clojurebot: false

17:40 micahmartin: kinda… just copied code and changed extensions for now… still a work in progress

17:40 gfredericks: well (str (/ 3 4)) rather

17:40 micahmartin: ok… yeah… that'll work

17:40 gfredericks: I know this sort of problem is on the horizon, maybe for the next version of clj. don't know for sure though.

17:41 but checkout cljsbuild's crossovers if you're not familiar with them

17:41 well unless you don't plan to keep a single source file

17:42 micahmartin: was hoping for something like Ruby's RUBY_PLATFORM

17:42 I'm familiar with cljsbuilds crossover.. might use it soon here.

17:42 gfredericks: (def RUBY_PLATFORM (if (= "0.75" (str (/ 3 4))) :js :jvm))

17:42 mnemnion: the final version is actually simple and elegant

17:42 (defn def-deref [x y]

17:42 (eval `(def ~x ~y)))

17:43 thanks again

17:43 micahmartin: gfredericks: right… whether or not that's idiomatic….

17:44 gfredericks: micahmartin: I don't follow cljs too closely, but I think folk are mostly waiting for a designed approach from on high

19:03 howdynihao: so i really like catnip

19:06 it would be nice if clojars.com had some sort of popularity indicator

19:07 .org*

19:30 brehaut: howdynihao: clojuresphere is useful for popularity

19:58 capcrunch: is there a clojure library that implements matrix operations ?

19:59 akhudek: core matrix

19:59 https://github.com/mikera/matrix-api

19:59 seanholm: https://github.com/mikera/matrix-api

19:59 snap

20:39 gfredericks: brehaut: probably only useful for popularity of libraries, eh? not user-level plugins?

20:39 brehaut: gfredericks: probably true

21:09 dnolen: spectral_norm.cljs went from >4000KLOC pretty-printed advanced

21:09 copmiled to ~1000KLOC with changes in master

21:09 not sure if we can compile (js/print "hello wolrd") -> print("hello world");, but there's a lot more still we can do to improve.

21:15 wmealing: i'm wondering if someone could assist me in setting up midje lazytest

21:15 i get a backtrace like https://gist.github.com/wmealing/655c75b72f7af0d93e04

21:15 or..

21:15 (just a second)

21:16 https://gist.github.com/wmealing/bc5e33e4c4b7f33447a4

21:17 xeqi: howdynihao: it has a download count, but we left the popularity meter to things like clojuresphere. it needs a significant ux upgrade, so maybe I should put that in my notes to make clear

21:17 wmealing: https://gist.github.com/gists <— my ~/.lein/profiles.clj..

21:21 amalloy: dnolen: 4000KLOC? do you really mean over four million lines of code?

21:39 dnolen: amalloy: oops hehe

21:57 arohner: why does clojure.tools.reader.edn/read parse #uuid and #inst?

21:57 I thought edn wasn't supposed to deal with data literals

21:58 ah, they're in the edn spec

21:59 tomoj: that's what the 'e' is for

22:02 arohner: tomoj: yes, but a bunch of people were worried about code execution through clojure.core/read, so then tools.reader.edn was added, to be safe

22:02 so I was surprised to see it instantiating other classes

22:05 gfredericks: arohner: they were mostly worried about read-eval

22:05 which is _not_ in the edn spec

22:07 micahmartin: How do you write one try/catch clause that catches everything in both Clojure and ClojureScript?

22:07 arohner: AFAICR, Ruby has had it's share of remote code execution through unexpected class instantiation as well

22:07 micahmartin: Have done lots of research and although there doesn't seem to be a way, I'm not satisfied with that reality.

22:08 gfredericks: micahmartin: I'll be surprised if you come up with something. I can't imagine that anything in clj-jvm besides (catch Throwable ...) does what you want, and I can't imagine that meaning anything in cljs

22:09 xeqi: I haven't see any holes in the default data readers

22:09 micahmartin: it doesn't compile in cljs

22:09 xeqi: * haven't seen

22:09 gfredericks: arohner: yeah class instantiation is an issue with the clojure reader too I think. But presumably not with the edn reader.

22:17 arohner: gfredericks: aha, missed that you can pass in data-readers, and it only includes #inst and #uuid by default

22:17 which are presumably safe

22:24 gfredericks: "Presumably Safe: an optimist's lament"

23:41 dnolen: spectral_norm.cljs is now produces ~250 lines of code under advanced compilation

23:41 hello world generates 170 lines of pretty-printed code

23:51 akhudek: wow, impressive

23:54 dnolen: akhudek: it's been a learning experience, I understand a lot better what can be eliminated by Closure and what patterns prevent it.

23:56 tomoj: wow, 170 lines sounds so small

23:56 dnolen: tomoj: yeah, most of that is goog utility fns

23:57 tomoj: the rest is extend-type on JS natives which Closure can't optimize, I might remove that stuff.

Logging service provided by n01se.net