#clojure log - Apr 05 2014

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

0:30 LLKCKfan: Does anyone know about old Caloric Prestige Series Ranges(stove/oven)?

0:43 Xavier89: ho

0:43 ho

0:44 hi

0:45 LLKCKfan: Hello

0:45 TimMc: technomancy: You around?

0:46 technomancy: LLKCKfan needs kicking again

0:48 Paula: ...

0:48 Paula: hla

0:50 TimMc: I didn't even know you could do CTCP with a *channel*.

0:59 amalloy: TimMc: sounds like a sentence i'd read in an IRC romance novel

2:19 Raynes: ls

2:19 lazybot: bin boot dev etc lost+found root srv sys

2:43 nightfly: pwd

2:43 lazybot: #clojure

2:44 nightfly: whoami

2:44 lazybot: nightfly

3:05 amalloy: exciting evening for lazybot

3:27 AmandaC: ls dev

3:27 lazybot: dev lib lost+found media root sbin selinux src sys var

3:27 AmandaC: lazybot IS FULL OF LIES!

3:36 Raynes: He's full of truth, AmandaC. Pure truth.

3:36 AmandaC: Raynes: YOU’RE LYING!

3:45 ddellacosta: AmandaC, did you just type in IRC thinking it was a term? I do that kind of sh%t all the time

3:46 AmandaC: nah, though I have done that before

3:46 * AmandaC points up at nightly and lazybot

3:46 AmandaC: oh wait, that might be before your join

3:46 ddellacosta: AmandaC: wait, does lazybot accept some subset of unix commands!?

3:47 AmandaC: ddellacosta: it appears no, it’s just a joke. :p

3:47 ddellacosta: AmandaC: oh. I'm torn on whether I like the joke or the supposed ability to perform ls on some filesystem in the cloud better...

3:49 ah, I see now, I should have checked history...

3:49 amalloy: ddellacosta: it's actually a real filesystem, the actual / on the server lazybot runs on. but he randomly chooses like 10-15 directories to actually include in the output

3:50 ddellacosta: amalloy: ha! so it's both a joke *and* performing ls on some filesystem...

3:51 amalloy: ddellacosta: i included a few commands and called it the unix-jokes plugin

3:51 ddellacosta: amalloy: nice...heh

3:51 amalloy: mutt

3:51 lazybot: Woof!

3:51 ddellacosta: hahaha

3:51 amalloy: this one has actually been triggered once, amazingly

4:06 _gregking: sup

4:09 ambrosebs: sarp

4:09 Raynes: carp

4:10 ambrosebs: sarp?

4:11 apparently clojurebot has nothing to say

4:48 doky: hello does anybody know how to parse params from command line to map ? i have this code but problem is when some pamam has white space https://www.refheap.com/71995

4:51 supersyy: https://github.com/clojure/tools.cli

4:52 that might be a more suitable tool for parsing cli options

4:52 since it probably isn't too smart to start out with a string literal to begin with

4:53 doky: supersyy: thanks i will use it

4:56 supersyy: but will it works when i use it in cycle, i need to have it in something like repl, to execute these commands in loop and every time evalute this statements

4:56 clgv: supersyy: doky: I can recommend tools.cli - I used it in 3 projects already

4:57 doky: huh? what exactly do you want to do? tools.cli is intended as "command line interface"

4:59 doky: clgv: idea is: run program and there you write statemens to evaluate ... for example create,update,delete users

4:59 with options you wrote

4:59 https://www.refheap.com/71995

5:00 clgv: so you want to build a language that you have a repl for to manipulate your business data?

5:01 doky: clgv: yes

5:01 clgv: doky: well, there is a shortcut - you have clojure^^

5:01 supersyy: right

5:01 i was thinking the same thing

5:01 cYmen_: good morning

5:01 clgv: seems that your operations are prefix notation anyway

5:02 supersyy: also if you already have a few shell tools laying around, you might want to try something like 'conch'

5:02 cYmen_: or just use the shell of your db ;)

5:02 clgv: doky: just take the verbs like "create" and build functions for them. if really needed for convenience you can build wrapper macros

5:03 cYmen_: right, but I assumed he wants to build more powerful abstractions

5:03 supersyy: cYmen_ yeah but I assumed he wants something like a wrapper around that stuff :P

5:03 haha

5:03 clgv: supersyy: :P

5:04 doky: clgv: supersyy cYmen_ oh im a bit confused .. so what will be the best way to do it ?

5:04 cYmen_: ^^

5:04 clgv: doky: can you describe the big picture you envision?

5:06 doky: the only statements i need to evaluate is [create|update|delete] [admin|moderator|user] [-u NAME| -p PASS] {-n REALNAME}

5:07 realname is not needed

5:08 clgv: doky: (create :admin <OTHER PARAMS>)

5:09 doky: the message is, just write the statements as plain clojure function calls (or macro calls if needed)

5:09 doky: clgv: ah ok

5:12 cYmen_: Also, this looks a bit like you have different tables for admins/users/mods. If so, I think that's weird. :)

5:13 clgv: doky: the great benefit of lisp is that you can implement languages on top of it without having to write reader/parser ;)

5:14 doky: cYmen_: table is the same only param changes

5:14 supersyy: yeah... with LightTable its all I need :)

5:14 one big toolkit

5:17 but as clgv said without the bigger picture,... There are tons of ways of doing the same thing in Clj - just look at the project Euler solutions and how many different approaches people can find to a single problem

5:17 clgv: doky: if all you want to do is programmatically manipulating a database - there are already clojure libraries which provide you with the basic functionality

5:18 cYmen_: Even if you want a dsl for it there is already Korma.

5:18 doky: clgv: i uses korma

5:18 supersyy: aha

5:18 cYmen_: So basically, you want to restrict the possible actions?

5:19 clgv: doky: so then just use it :D

5:21 doky: clgv: ok i haven't though about that solution :) I thought that better way will be to be sure that all params are ok and then store to db

5:22 supersyy: I still don't get what you need the CLI options for then if you use korma

5:23 but anyway, processing cli switches, options and such can be a tedious job without a tool and might quickly pop up corner cases

5:24 doky: supersyy: i am not sure if i know what do you think ... can i pass string to korma ?

5:25 supersyy: yes

5:25 doky: supersyy: like whole statement ?

5:25 supersyy: SQL raw or entities

5:25 both are supported

5:25 doky: supersyy: aha

5:26 supersyy: Personally I did have some trouble figuring out the Korma particulars, took me a day or 3 before I finally got it

5:27 the manual isnt too clear on the mechanics of mostly joins - relations stuff

5:29 doky: supersyy: so the only i need is restricted other statements, becase if user will write pure sql which evaluates, he can do anythink with db

5:31 clgv: doky: well dont let the user write sql at all.

5:32 doky: this opens the door to SQL injection like problems

5:32 doky: clgv: but when i will execute as raw ?

5:32 clgv: doky: if you want your user to write queries write a query DSL

5:33 doky: clgv: no my idea was to have that params as i wrote

5:37 clgv: sorry if maybe you thnink that i dont get it as you thought but i only learn clojure for not long time

5:37 cYmen_: clgv: I don't see how you can take anything the user inputs (like a name even) and use it without being in danger of sql injections.

5:38 clgv: cYmen_: well, then we are all doomed

5:38 doky: clgv: :)

5:38 clgv: cYmen_: in practice you usually have escaping or checking of inputs to prevent that

5:39 cYmen_: Or we could just escape everything properly. ^^

5:41 doky: the other solution i have is this but here param -n needs to be the last one https://www.refheap.com/71999 and it still produce the last one word as key with value nil

5:41 with this string "create user -u viktor -p secret -n \"myReal name\""

5:42 * cYmen_ stares at the code.

5:42 clgv: doky: why are you so fixed on parsing strings? just write Clojure function calls instead of those strings.

5:43 cYmen_: Second!

5:44 doky: clgv: im not sure if i understand ?

5:45 clgv: doky: well you could just have a function "create" which is called like "(create :admin ...)"

5:46 doky: and params must have fixed possion, right ?

5:46 clgv: doky: if you need to support user queries you can do (clojure.edn/read user-query) to get Clojure data from a given string

5:46 doky: depends on how you implement that function

5:47 doky: clgv: sure :)

5:47 clgv: doky: you have fixed position or arbitrary key value pairs as default options

6:25 AeroNotix: anything for paypal integration?

6:25 Soon I'm gonna open source an auth.net library

6:28 doky: clgv: no i haven't, as you wrote that string, params indicate options

6:37 clgv: doky: you did not understand me. I was just stating the default options there are ;)

6:43 wombawomba: Newbie here. I've created a lazy sequence of primes (found at https://gist.github.com/aeriksson/d27ffc64899a0face006) using the algorithm in http://stackoverflow.com/a/10733621. However, my code has some performance issues, and I'm looking for ways to speed it up. Any ideas?

6:47 cYmen_: I doubt anybody will be able to help you unless you show people your code and tell them which "performance issues" it has.

6:47 clgv: wombawomba: maintaining the map is certainly one of the problems

6:48 wombawomba: cYmen_: see the gist I linked; https://gist.github.com/aeriksson/d27ffc64899a0face006

6:48 clgv: wombawomba: I'd maintain a vector of found primes

6:49 wombawomba: for each new number you can do the divisibility check by e.g. reducing over the vector

6:49 wombawomba: yeah I kindof figured the map might be problematic

6:50 it's central to the algorithm though; using a vector as you propose lowers the space and time complexity

6:50 er, increases

6:51 clgv: wombawomba: are you sure? gotta check the original

6:51 wombawomba: the map only maps integers to integers though, so perhaps I could use some other data structure

6:51 clgv: wombawomba: ah you want to implemet the sieve of eratosthenes for the lazy-seq?

6:51 wombawomba: right

6:51 clgv: wombawomba: I think those two approaches do not fit together well

6:52 wombawomba: since you cant be really lazy with the sieve approach

6:52 wombawomba: sure I can

6:53 the algorithm I pasted works fine, just slowly

6:53 clgv: but you have performance issues :P

6:53 cYmen_: wombawomba: The core idea of the sieve is to remove all multiples of a number...if you have an infinite sequence that will take a while

6:53 clgv: the vector approach I mentioned will be faster for that lazy-seq ;)

6:53 cYmen_: At least that's what I think clgv means. :)

6:54 wombawomba: the sieve status is stored in the map (and in p), so evaluating it lazily is not really a problem

6:54 also, the map size grows as sqrt(n), which should make it plenty fast

6:55 clgv: first of all I'd store the sieve status in a java.util.BitSet since thats the most efficient way in terms of memory and operation runtime ;)

6:55 wombawomba: the python generator approach is analogous to a lazy-seq afaik, and it works well

6:56 I think my issues stem from the fact that recursing with a constantly changing map is slow

6:56 cool, I'll check that out

6:56 also, would making the map transient make sense?

6:58 clgv: wombawomba: in principle yes. but I'd use sieve of eratosthenes for fixed size ranges only.

7:02 wombawomba: hm.. I can't really use a bitset to encode a mapping between integers though, right?

7:05 clgv: no. you can use a BitSet to mark the primes or maybe primes...

7:05 it is totally suitable if you build a non-lazy sieve

7:07 cYmen_: How do you profile this?

7:09 wombawomba: cYmen_: I just used time to see how long it took to get the first 2000 primes, as seen at the bottom of the gist I linked

7:09 iXeno: hi... I wanna fire up a clojure runtime from java (or actually from scala, but let's say java for simplicity) - and be able to discard it and reload it when needed... and also provide java objects (or scala objects, bit again lets say java) to it during init... how should I do that?

7:09 cYmen_: Oh, I mean like how do you figure out where the bottlenecks are.

7:09 iXeno: all docs seems to focus on running clojure from lein and have that run java

7:11 wombawomba: oh, well that's a good question then. I'd like to know the answer to that too :)

7:58 ekhall: Hi everyone - was wondering if there were any Datomic users out there. Still getting db-id problems that I can't sort out. I made a gist at https://gist.github.com/ekhall/9991029

7:59 I've gotten the same errors in demos when I simply change the entity name in the edn file - can't sort out why such a simple change causes these problems.

8:35 pyrtsa: ekhall: I'm sorry, I can't comment in detail without seeing the definition of add-patient, but it seems to me you haven't created a partition named :db.part/patient (and you're not allowed to: the "db" namespace prefix is reserved for Datomic).

8:36 Either create your own partition (its ident could be e.g. :part/patient) or keep using the :db.part/user partition in your tempids.

8:37 ekhall: pyrtsa: thank you Pyrtsa, I added the clojure file to the gist with the update-patient.

8:37 pyrtsa: The partition needs to be installed with a transaction like [{:db/id (d/tempid :db.part/db), :db/ident :part/patient, :db.install/_partition :db.part/db}].

8:38 ekhall: ^ So update your schema with the above. (Of course, replacing (d/tempid ...) with #db/id[...].)

8:39 wombawomba: clgv: FWIW, the slowdown in my code seems to have mainly stemmed from my update-map function. I changed it to use a loop instead, and my code now seems to run faster than that from contrib/lazy-seq

8:39 pyrtsa: ekhall: The error message said just that, btw: "Invalid db/id: #db/id[:db.part/patient -1000003]"

8:39 ekhall: prytsa: So in the other examples where there was a User entity that worked that partitiion was already set up? I guess the thing that confuses me is that (while learning) I've taken example schema that have occasionally worked (such as a "User" entity) and simply changed the entity name and suddenly it doesn.t

8:40 I'll have to go look at that partitioning. Thank you.

8:40 pyrtsa: ekhall: Datomic has three partitions installed by default: db.part/db (for attributes etc.), db.part/tx (for transaction entities only), and :db.part/user (for you to play with, but you should create your own partitions).

8:41 ekhall: Ah, so user is already setup. I had a feeling it was something like that. Thank you pyrtsa

8:41 clgv: wombawomba: ah yes, using lazy operations for collections you want to compute eagerly is always not optimal...

8:41 pyrtsa: ekhall: Partitions are essentially just dedicated subranges of the positive values of Long typed entity IDs.

8:43 ekhall: Thank you pyrtsa - now I'm headed in the right direction.

8:43 pyrtsa: Cool.

8:43 ekhall: There's also #datomic for Datomic specific discussion.

8:46 wombawomba: clgv: fixing that gave a 350x speedup for 2000 primes, and making the map transient gave a further 0.3x

8:47 I'm now 8x faster than the code in contrib.lazy-secs for 20000 primes

8:47 clgv: wombawomba: you are implementing this for learning purposes right?

8:48 wombawomba: yup

8:48 why?

8:48 clojurebot: why is Why

8:48 clgv: that I do not need to ask how you use the primes ;)

8:49 wombawomba: heh, I'm using them to solve https://projecteuler.net/ problems

8:49 which, again, is for learning :)

8:50 clgv: btw: for benchmarking you should usually use "criterium" though in this case for large numbers you get a fair comparison with "time" as well I guess

8:50 wombawomba: well, for using primes in different algorithms a lazy sequence is in most cases not that optimal as far as I can tell from experiences with spoj.com

8:53 wombawomba: yeah I guess that's probably true

8:53 although I think it makes for cleaner code :)

8:54 clgv: a function returning a vector of primes can be implemented cleanly as well ;)

9:07 petron: why aren't regexes functions?

9:07 e.g. (#"a*b" "aaaabbb") => true

9:08 hm, maybe they are. *checks*

9:08 gfredericks: they aren't

9:08 petron: and would it be possible to make them act as if they are?

9:08 clgv: petron: since they are not on the JVM and Clojure function calls are based on the clojure.lang.IFn interface

9:09 gfredericks: petron: not possible as a language user; clojure could be changed to let them be

9:09 you'd have to decide if they should act like re-find or re-matches

9:09 clgv: you'd either need to create a subclass of Pattern or you'd need a IFn protocol instead of the interface

9:09 petron: meh, that raises ClassCastException java.util.regex.Pattern cannot be cast to clojure.lang.IFn

9:09 gfredericks: ,(proxy [java.util.regex.Pattern clojure.lang.IFn] [])

9:09 clojurebot: #<VerifyError java.lang.VerifyError: Cannot inherit from final class>

9:09 gfredericks: sounds like subclassing Pattern isn't possible either

9:09 clgv: petron: gfredericks is right, there'd be the problem what the function call to a pattern would do since there a multiple possibilities

9:10 petron: so that (#"a*b" "aaaabbb") is equal to (re-find #"a*b" "aaaabbb")

9:10 clgv: gfredericks: I'd have bet on that ^^

9:10 gfredericks: petron: you *can* do this is CLJS because IFn is a protocol there

9:10 s/is/in/

9:10 clgv: gfredericks: comes to my mind: http://steve-yegge.blogspot.de/2010/07/wikileaks-to-leak-5000-open-source-java.html

9:11 gfredericks: :)

9:11 I love how easy it is to call private functions in clojure

9:13 "Today the Eclipse Foundation put out a private briefing calling me a 'non-thread-safe AbstractKeywordRemovalInitiatorFactory'"

9:13 clgv: :D

9:16 ambrosebs: haha!

9:18 siscia: Hi all, is clojars down ?

9:18 TimMc: clgv: That is fantastic.

9:19 gfredericks: http://www.downforeveryoneorjustme.com/clojars.org

9:19 ^ says clojars is up

9:19 clgv: siscia: no

9:19 gfredericks: and so do I

9:20 siscia: clgv: Thanks :)

9:25 gfredericks: my test.check failure has been shrinking for ~14 hours now

9:25 jonh: everything good takes time

9:25 :D

9:25 gfredericks: I'm thinking I might need to start a fork/helper-lib for integration-style testing w/ test.check

9:25 I guess helpers would be better so you can use it both ways

9:27 clgv: gfredericks: uff!

9:27 you need a progress report for that one ;)

9:29 ambrosebs: gfredericks: what's testing?

9:30 Bronsa: so it looks like calling `symbol` is not as unexpensive as I thought

9:30 I got a 10% perf improvements in tools.analyzer simply by avoiding a bunch of unnecessary calls to it

9:31 ambrosebs: serious

9:31 clgv: Bronsa: commit?

9:31 Bronsa: ambrosebs: looks like calling String.intern is quite expensive

9:31 clgv: https://github.com/clojure/tools.analyzer/commit/71c0484e99f53f8bb50fdf215625ace78183917f

9:32 clgv: interesting

9:32 ambrosebs: Bronsa: how did you figure that out?

9:32 Bronsa: ambrosebs: yourkit

9:32 ambrosebs: nice

9:33 and omg 10% nice work!

9:47 yotsov: is there ongoing work on clojurescript equivalents to tools.analyzer.jvm and tools.emitter.jvm ?

9:50 ambrosebs: yotsov: Bronsa has a GSoC proposal for that

9:51 yotsov: ambrosebs: thanks

10:34 gfredericks: okay so let's say

10:34 a library wants to be able to serialize-deserialize things.

10:34 e.g., via pr and clojure.edn/read

10:34 but it needs to customize some special cases

10:35 like byte arrays or specific 3rd-party types

10:35 extending print-method seems like a bad choice for a library to be making

10:35 but what else is there?

10:37 xeqi: gfredericks: tagged elements? though it would have to include some data_readers iirc

10:37 gfredericks: edn tags are very asymmetric

10:37 you can make your own inside your library and not bother anybody else and that's great

10:38 but to make the corresponding types print with the tag requires a global change to print-method

10:38 I keep running into this whenever I make a library that needs to serialize/deserialize generic data

10:51 john2x: is there a library that provides Midje's checkers for clojure.test?

11:09 wombawomba: I'm getting some strange results when using a transient map in my algorithm. Specifically, I have two different versions of the same lazy sequence, one using a transient map and the other using a dynamic binding: https://gist.github.com/aeriksson/6f2a4c34481221f953a1. While the latter sequence produces correct results, the results of the former are subtly incorrect. What gives?

11:13 ambrosebs: wombawomba: looks like you're bashing the transient in place.

11:13 Use assoc! like assoc.

11:13 don't rely on side effects.

11:15 ,(doc assoc!)

11:15 clojurebot: "([coll key val] [coll key val & kvs]); When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets the val at index. Note - index must be <= (count vector). Returns coll."

11:15 mahakala: Does anyone in here have experience with heroku, postgresql, and setting environment variables? My app won't deploy and I need help.

11:15 ambrosebs: The doc for assoc! is awful, ignore it.

11:17 wombawomba: ambrosebs: Sorry, I'm not sure I understand. How should I use assoc!, do you mean?

11:17 ambrosebs: wombawomba: use the result of assoc!, and don't assoc! a transient more than once

11:17 gfredericks: ambrosebs: yeah it misleads wrt usage and is incorrect since it occasionally doesn't return coll

11:18 I might create a jira ticket just to slightly bog down the process with docstring updates

11:18 wombawomba: ah, I see

11:18 ambrosebs: gfredericks: please do

11:19 gfredericks: on it!

11:19 I'll have to decide on new wording myself though.

11:19 ambrosebs: assuming there's no current ticket.

11:20 gfredericks: http://dev.clojure.org/jira/browse/CLJ-1385

11:21 I think alex misunderstood the description

11:21 unless it was edited later

11:21 wombawomba: ambrosebs: I actually started out using it that way, but it ran slowly because I had to use persistent! when building my lazy-seq (since I can't use recur) for that.

11:21 Is there any way to get around both these issues?

11:24 mahakala: Can anyone here answer my question?

11:27 gfredericks: bjeanes: where are you when somebody has questions about heroku and env variables

11:28 ambrosebs: wombawomba: I can't read your code. Might help to rewrite it with persistent data structures.

11:29 wombawomba: ambrosebs: oh, I have that too. one second

11:29 ambrosebs: thanks

11:29 mahakala: is bjeanes the man for this topic?

11:31 ambrosebs: wombawomba: maybe post your first transient attempt

11:39 jonasen: https://github.com/jonase/elements <- a fun app I've been working on (using CLJS, SVG, React&Reagent and ofcourse core.async)

11:40 wombawomba: ambrosebs: all four versions are now at https://gist.github.com/aeriksson/6f2a4c34481221f953a1

11:47 ambrosebs: wombawomba: can you add an extra loop argument for the c's in (cons c ...), then just pass the tranisent around with recur, and use persistent! at the end, and use the result to build a lazy-seq?

11:47 wombawomba: very likely I'm missing something

11:49 ah sieve is infinite?

11:50 wombawomba: yes

11:54 ambrosebs: wombawomba: haven't used it myself, but maybe try https://github.com/ztellman/bizarro-collections

11:55 I don't think transients can help here

11:56 I'm not particularly an expert, hopefully someone will double check.

12:00 wombawomba: hm oka

12:00 y. I'll have a look

12:02 alpheus: What transforms a vector into a vector of pairs? e.g. (f [1 2 3 4 5 6]) => [[1 2] [3 4] [5 6]]

12:03 ambrosebs: ,(vec (map vector (partition 2 [1 2 3 4 5])))

12:03 clojurebot: [[(1 2)] [(3 4)]]

12:03 ambrosebs: close enough

12:03 alpheus: partition -- that's what I was looking for

12:09 ambrosebs: wombawomba: might be worth checking if you're using the fasted arithmetic ops https://github.com/ztellman/primitive-math

12:10 *fastest

12:43 favetelinguis: total beginner trying to get things running in lighttable so i can use test.check in school project but not much is going my way, anyone got time to help?

13:56 abaker: so what's the preferred mechanism for asserting constraints on function inputs … pre/post? something in a do form? something else?

14:21 kenrestivo: i'm getting an access denied ("Reason: forbidden") when doing lein deploy clojars, using the same username and password that i can log in just fine using the web interface.

14:21 sorry "ReasonPhrase: Forbidden"

14:24 xeqi: kenrestivo: that version already exists

14:24 kenrestivo: yep

14:24 xeqi: thanks, bumped version and all is well

14:29 doky: hello can anybody know how to correctly receive data ? https://www.refheap.com/72300

14:34 xeqi: doky: you're doing a read-string then a pr-str and then a read-string again on the response text?

14:34 lemonodor: kenrestivo: i run into that all the time. a friendlier error message might be nice.

14:35 doky: xeqi: and how it should be ?

14:36 xeqi: just read the string once and get back the vector?

14:38 doky: xeqi: ok i will try

14:44 i'm confused ... still get only one of maps https://www.refheap.com/72300

14:45 xeqi: isnt problem with emit-clojure-ds ?

14:47 xeqi: doky: possibly, you're not including the server code or your middleware stack that will transform :body into a string

14:49 it looks like your read-string call is only returning the first map (since you wrap that result in vector). this leads to thinking its a server setup problem

14:50 doky: xeqi: https://www.refheap.com/72300

14:52 xeqi: do i need something like to write it to stream or something like that ?

14:56 xeqi: doky: looks like ring servlet stuff treats a vector :body as a chunked response, and then sends the individual elements https://github.com/ring-clojure/ring/blob/1.2.2/ring-servlet/src/ring/util/servlet.clj#L89

14:57 which would make coorespond with what your seeing

14:57 I'd wrap :body in a pr-str

14:57 so that :body is a string and it gets sent as a string representing the entire vector

14:57 doky: ok i will try

15:02 xeqi: thanks you very much :) thats work great :)

15:07 munderwo: Hi all. Im using aleph and compojure to write a proxy. Im running into an exception 'localedata.jar (Too many open files)' . Anybody have an idea what localdata.jar does or who might be calling it too many times?

15:20 yotsov: munderwo: I guess I would check if the problem persists if switching to another java implementation: if using 1.5 then trying 1.6, if using openjdk then trying oracle jdk...

15:21 munderwo: thanks, I gave that a shot. Mysteriously it seems to have happened in connection with me doing something stupid with configuration and atoms… weird.. but have fixed it now.

15:23 afgdf: hello, do i need to learn cypher to fully use neo4j in clojure(neocons)?

15:31 yotsov: afgdf: it is probably very subjective, but I would think if you want to use any data store, it pays to know its "native" query language. I am trying to imagine using Postgres only via Hibernate never learning SQL... not a nice thought. When you have a data store, and you want to go prod with it, you always end up with times when you want to talk to it directly, with nothing standing between you and it

15:51 Bronsa: ,(require 'clojure.reflect)

15:51 clojurebot: nil

15:52 ivan: https://github.com/monsanto/nreplds nREPL domain socket support; I had no idea this existed

15:52 Bronsa: ,(->> (clojure.reflect/type-reflect clojure.lang.ISeq) :members (filter (comp '#{equals} :name))))

15:52 clojurebot: ()

15:52 Bronsa: :/

15:53 err

15:53 ,(->> (clojure.reflect/type-reflect clojure.lang.ISeq :ancestors true) :members (filter (comp '#{equals} :name))))

15:53 clojurebot: ()

15:54 Bronsa: looks like type-reflect doesn't return Object members when the class doesn't override them

15:56 cddr: Any idea how one might run a lein task from a test?

16:00 gfredericks: cddr: that's tricksy because of lein's dual-jvm architecture; why're you trying to do that?

16:13 cddr: Trying to practice "TDD" and so before adding doc generator to the project, I was thinking of writing some tests to ensure that the docs get generated correctly

16:14 Maybe overkill for most use-cases and if you really want to do this, you can write those unit tests in bash

16:15 Can you expand on the dual-jvm architecture? A google search doesn't come up with anything useful

16:22 gfredericks: leiningen's default behavior is to have one jvm for itself and another for everything that runs in your project

16:22 so in your case this means that the code for running a lein task isn't even around when your tests are running

16:25 cddr: That makes sense

16:25 Ihearyouman: gfredericks: that also means it uses a clojure compiler for itself and another for every project right?

16:27 gfredericks: Ihearyouman: I'm not sure exactly what you mean by that, but probably so?

16:31 Ihearyouman: gfredericks: like it uses its own clojure.jar for its stuff and a different clojure.jar for projects

16:32 gfredericks: that's definitely true when the requested version of clojure is different from the one leiningen happens to be using

16:32 otherwise they'd be the same jar, coincidentally

16:41 Ihearyouman: gfredericks: ok, I asked cause 'lein run' downloaded a clojure.jar the first time for lein app project but I don't really know what clojure version is lein using internally

16:55 gfredericks: Ihearyouman: ah right

17:05 zakwilson: When I try to run a freshly-generated project from lein-droid (with lein droid doall, or subsequently with lein droid run), I get java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on classpath

17:25 And this problem happens consistently with multiple newly-created projects and even different versions of lein-droid.

17:26 cYmen_: Could somebody tell me what "reify" means?

17:27 And how to pronounce it. :p

17:30 andyf_: cYmen_: The definition is roughly the phrase "thing making" or "to make a thing out of"

17:30 cYmen_: uh...so? :)

17:31 andyf_: I've heard it pronounced two different ways: REE-if-eye and RAY-if-eye

17:32 zakwilson: Google gives the definition as "make (something abstract) more concrete or real"

17:32 andyf_: In Clojure it more specifically means to make a Java object (a thing) with a certain set of method behaviors implemented for it

17:32 cYmen_: So it creates a class and an instance of it?

17:34 zakwilson: Yes

17:37 andyf_: zakwilson: Have you tried 'lein deps :tree' to see if tools.nrepl is in your dependencies, perhaps somewhere indirectly you didn't intend it? I haven't used lein-droid, so can't help you more specifically there.

17:46 zakwilson: andyf_: I had not, and I think that has me pointed in the right direction (it's not using the dev profile for dependency resolution, and that's where the nrepl dependency is specified, but something tries to use it at runtime)

17:49 andyf_: and now I have it not crashing on launch by using 'with-profile dev'. That'll do.

17:50 andyf_: cool

17:50 amalloy: cYmen_: well, reify creates a class once at compile-time, and creates instances of that class at runtime

17:50 cYmen_: hm okay

17:50 amalloy: (which, really, is what a lot of things in clojure do - fn does that as well, for example)

17:51 in particular reify creates classes that satisfy a set of interfaces+protocols that you choose

17:51 cYmen_: So basically you're creating something like a java interface?

17:53 amalloy: no

17:53 cYmen_: Glad I asked.

17:53 amalloy: you're creating an implementation of an existing interface

17:53 cYmen_: At runtime but the interface is defined at compile time?

17:53 amalloy: ,(.close (reify java.io.Closeable (close [this] (println "closing!"))))

17:53 clojurebot: closing!\n

17:53 cYmen_: O_o

17:54 amalloy: no. no interface is ever created by reify

17:54 cYmen_: Uh...okay but a class?

17:54 amalloy: yes

17:55 here i took an existing interface, java.io.Closeable, and created an object implementing it; then i called its .close method like i would any other object

17:55 cYmen_: So it's like a cast?

17:55 amalloy: not at all

17:56 cYmen_: what other languages are you familiar with, for analogy?

17:56 cYmen_: But if you're just creating an instance of a class what does the function definition do there?

17:56 C++, Python

17:57 andyf_: The function definition gives the behavior of that instance when that method is called on it.

17:57 cYmen_: At compile-time?

17:58 andyf_: Perhaps clearer to say "that class" rather than "that instance"

17:58 amalloy: yes, at compile time

17:59 cYmen_: Alright, so basically what the statement above does is define a new class which adheres to an interface and then instantiate it?

18:00 amalloy: yes, although those two things happen at different times. consider: (defn foo [message] (reify Closeable (close [this] (println message))))

18:00 that creates a class once, at compile time, and creates an instance every time it is called

18:01 cYmen_: So, the best way to think about it is like this is Java's "new" with the class definition being sort-of in-place?

18:02 amalloy: well, that exists in java: (reify Closeable (close [this] (println message))) => new Closeable() {public void close() {System.out.println(message);}};

18:03 that's exactly what reify does

18:03 cYmen_: okay

18:03 thanks

18:19 AmandaC: ,true

18:19 clojurebot: true

19:04 AmandaC: ClojureScript question — how could I set a value on a window object, specifically __onGCastApiAvailable

19:12 gtrak: AmandaC: aset?

19:17 amalloy: or just set!, as long as you have the externs set up so that gclosure doesn't optimize that away

19:55 AmandaC: If I want multiple statements in an if’s “true” block, what should I be using?

19:56 gfredericks: if the false part is empty, you want when

19:56 otherwise you just nest a do

19:56 * gfredericks thinks programmers end up saying the weirdest things

19:57 AmandaC: ,(doc do)

19:57 clojurebot: It's greek to me.

19:57 AmandaC: o.o

19:57 * AmandaC tries le goog

19:57 gfredericks: do just combines multiple statements into one

19:58 AmandaC: ah

19:58 gfredericks: ,(do (println 3) (println 4) "Five")

19:58 clojurebot: 3\n4\n"Five"

19:58 gfredericks: the docs are "missing" because it's a special form

19:58 ,(clojure.repl/doc do)

19:58 clojurebot: excusez-moi

19:58 gfredericks: &(clojure.repl/doc do)

19:58 lazybot: ⇒ ------------------------- do (do exprs*) Special Form Evaluates the expressions in order and returns the value of the last. If no expressions are supplied, returns nil. Please see http://clojure.org/special_forms#do nil

19:58 gfredericks: hey there it is

20:23 yedi: in om: having to manually manage / persist scroll state seems so inelegat

20:23 s/inelagat/inelegant

20:53 arrdem: ,(source when)

20:53 clojurebot: Source not found\n

20:54 arrdem: ,(defmacro arrdems-shitty-when [c & forms] `(if ~c (do ~@forms)))

20:54 clojurebot: #'sandbox/arrdems-shitty-when

20:54 arrdem: ,(source arrdems-shitty-when)

20:54 clojurebot: Source not found\n

20:54 arrdem: ~botsmack

20:55 amalloy: arrdem: source works by looking up :line and :file metadata, and then going to read the file

20:55 it's never going to work for something you def at the repl

20:55 arrdem: amalloy: lame... source should be metadata :P

20:56 that would actually be cool... if the expression tree was metadata...

20:56 amalloy: sure, but people complain about clojure's slow startup time already

20:56 arrdem: I didn't mean for production...

20:57 amalloy: you can always use technomancy's serializable-fn

20:57 which indeed stores the source, and lexical closure, as metadata

20:58 arrdem: shiny...

20:58 (inc technomancy)

20:58 lazybot: ⇒ 105

21:00 arrdem: Raynes: is there a better way for me to do IO on lazybot than just a /msg?

21:01 Raynes: I don't understand the question. Can I buy a vowel?

21:01 arrdem: I'm pondering digging my cloutjure project back up again, part of which was going to be tracking per user chan karma

21:02 Raynes: So you want to talk to lazybot to do what?

21:02 Get the amount of karma?

21:02 arrdem: yarp

21:03 ideally without spamming #clojure :P

21:03 Raynes: That would be a lot of /msg

21:03 amalloy: well, it would be like zero /msg, because karma is channel-local

21:03 Raynes: It'd be best if you could just talk to his database.

21:04 arrdem: yeah that's why this is hard... I mean I could design a query system designed to detect when #clojure is idle and spam then... but why.

21:04 amalloy: pffft

21:04 arrdem: lol @ amalloy

21:04 khushildep: Hello all - I wanted to ask, is it a breach of guidelines to post a link to a position we are looking to fill in our company for strong functional programmers?

21:04 AmandaC: I don’t suppose there’s any way I could get a hybrid clojure/clojurescript REPL in Emacs? Preferably with the -script one running in my webpage. I imagine not, but I figured I’d ask anyway. :p

21:05 arrdem: khushildep: to this chan or to the mailing list... the mailing list seems to put up with it but I've never seen anyone try to recruit here in ~20 months of activity.

21:06 khushildep: arrdem: thanks for the advice so mailing list is the best place or is there somewhere else which would be more suited?

21:07 arrdem: khushildep: probably... but don't come to me if your email gets moderated.

21:07 khushildep: :)

21:07 amalloy: there are occasional recruiting messages to the mailing list

21:07 i think it's fine

21:07 gfredericks: reiddraper: woohoo I finally figured it out: https://github.com/fredericksgary/test.check/blob/1941fa1f78e59013fefb2bebed5b63549a15a7e8/src/main/clojure/clojure/test/check/generators.clj#L626

21:07 amalloy: but then, i don't read the mailing list :P

21:08 gfredericks: I thought for a couple days it was going to have to be terrible

21:08 arrdem: I skim the daily digest... takes ~30s and I get to feel more involved without contributing anything :P

21:08 xeqi: khushildep: I've seen several job posts on the mailing list, and I'd welcome them there

21:09 arrdem: $seen nsa

21:09 lazybot: I have never seen nsa.

21:09 arrdem: sneaky bastards

21:10 dang someone else thought of that already :P

21:17 gfredericks: $seen the matrix

21:17 lazybot: I have never seen the.

21:17 gfredericks: $seen Community

21:17 lazybot: I have never seen Community.

21:17 gfredericks: there we go

21:21 pro tip: you cannot (reasonably) recur in a macro because of the arg-mismatch caused by &env and &form

21:22 apparently this is the first time I've wanted to recur inside a macro

21:24 eh, it was a dumb idea anyways. emitting a call to the macro works just fine.

21:27 amalloy: that's interesting, gfredericks. i guess i've never tried it either

21:27 you can always (defmacro foo [x] (loop [x x] (... (recur (rest x))))), though, even if emitting a call to the macro were no good (eg, because you've lost some other context

21:27 )

22:25 mercwithamouth: arrays in clojure are FIFO?

22:27 technomancy: arrays on the jvm are fixed-length

22:29 mercwithamouth: technomancy: hmm i was more so looking for an explanation to https://gist.github.com/anonymous/37688d104f0fd7420a42

22:29 i see what's going on. i was wondering if it starts from the bottom because thats how arrays work when iterating over them or if 'assoc' was behind it

22:31 tmciver: mercwithamouth: [1 2 3 4] is a vector. reduce takes one element at a time, left to right.

22:32 mercwithamouth: new developer... if left to right would the result be {1 1, 2 4...} then?

22:32 wouldn't*

22:33 tmciver: mercwithamouth: ah, that's a map and its keys are not in the same order as the input collection (vector).

22:34 mercwithamouth: ok so i shouldn't put much emphasis on the order since with maps order is inconsistent since lookup focuses on the key

22:34 alright

22:34 tmciver: mercwithamouth: yep

22:34 mercwithamouth: works for me

22:59 AmandaC: Can someone point me at some simple code that uses core.async so I can get a feel for how I should be using it?

23:01 Actually, which would be more idiomatic — I’m making something that pulls contacts out of a contacts database. I was thinking of using it where it’s a channel that gets retuned and then the API’s user can pull from that, but I’m thinking maybe a lazyseq would be more idiomatic?

23:03 Argh, I think I’m getting ahead of myself again in this mess.

23:05 bob2: I'm still learning c.a, too, but do you have code that does the above already, without c.a? I'm finding it easier to go from working code to core.async'd than to jump straight to it.

23:06 AmandaC: The problem is what spits out the contact info is a callback, one contact at a time.

23:07 bob2: ah, it's an existing api?

23:07 * AmandaC is toying with Firefox OS’s stuff, for fun.

23:07 AmandaC: Yep

23:07 mercwithamouth: hmm why doesn't this work? https://gist.github.com/anonymous/a08eefaaf162fac167a3

23:07 coventry: AmandaC: That does sound like a good context for using a core.async channel.

23:08 mercwithamouth: reverse (str greet reply) in the gist, sorry

23:08 bob2: mercwithamouth, what did you want (greet "hey!") to do?

23:08 greet is presumably a string not a callable?

23:08 mercwithamouth: return the string "hey"

23:08 then join the two

23:10 coventry: AmandaC: There are some examples of serializing javascript callback outputs in the dotsters game, might give you some ideas about how to do it with the db callbacks. http://rigsomelight.com/2013/08/12/clojurescript-core-async-dots-game.html (It's cljs, but for this purpose the behavior should be the same for clj.)

23:10 mercwithamouth: bob2: oops =P

23:10 dur...thanks

23:17 gtrak: is there a way to link async channels to cascade on close?

23:17 besides incidentally in things like pipe and friends?

23:30 yedi: in om: is there a way to update the cursor of the parent node?

23:31 i'm using build all to build some subcomponents, but those subcomponents need to be able to update the parent components state

23:32 ap-: hello all! Clojure newcomer here (but long time common lisp user)

23:32 yedi: hey there

23:32 welcome

23:32 ap-: I have question regarding tooling...

23:33 arrdem: welcome to the land without setq :P

23:33 ap-: there must be a way of doing this.. but what the heck is equivalent of *break-on-signals* ?

23:33 i.e. have clojure stop and show me a stack trace when an exception is raised?

23:33 eraserhd: What simple html generation mechanism are people using these days?

23:33 jph-: eraserhd, templating? i'm using selmer atm, but many use hiccup

23:33 arrdem: ap-: it should do that by default. the exception stack isn't terribly readable, but that's the default behavior.

23:34 ap-: as long as you allow the exception/signal to propagate to the top level at least

23:34 ap-: no - it only does it if the signal is uncaught

23:34 which is totally different

23:34 eraserhd: jph-: Hiccup seems good for working with html as data, but not good for templating. Unless I'm missing something.

23:34 jph-: eraserhd, checkout selmer

23:34 yogthos/selmer on github

23:35 for a quick example, create a demo project with "lein new luminus testapp"

23:35 arrdem: ap-: we're sitting atop the JVM here. You can manually implement your catch cases to do a stack trace print, but there is no standard way to get such printing for free.

23:35 jph-: and then browse the src/testapp/views directory

23:36 eraserhd: jph-: This looks useful.

23:36 arrdem: ap-: the core.stacktrace library provides the utilities you want to do this.

23:36 ap-: arrdem: thanks

23:36 jph-: eraserhd, yep, it has nice inheritance stuff for partial views, etc

23:36 arrdem: ap-: no worries!

23:37 ap-: I sure do miss the slime debugger/inspector I tell you that.

23:37 but clojure really rocks.

23:37 arrdem: yeah.. the lack of out of the box form stepping is one of the things that several people are working on with varying degrees of success.

23:37 ap-: even if I've had to reprogram my brain to write code with immutable structures

23:38 jph-: ap-, "It Gets Better"

23:39 and once you realise the benefits you get from immutability

23:39 arrdem: jph-: we have awesome stuff like a real load path! :P

23:39 jph-: yep

23:39 clojure has spoilt me for almost all other languages

23:39 * arrdem still can't believe how bad CL modules are

23:39 jph-: i took a brief look at the CL variants recently

23:39 ap-: arrdem: whatyda mean?

23:39 jph-: none really stood out for me

23:39 ap-: like, libraries?

23:40 jph-: ap-, for me, i want a CL that has a good third party library packaging/dependency system

23:40 arrdem: ap-: to me Clojure's namespace and selective import structures are huge features. Only in the last six months did R7RS bring anything remotely like that to Scheme, and CL still doesn't have an equivalent that I consider usable.

23:40 jph-: arrdem, i fucking love how clojure does namespaces now i 'get it'

23:41 arrdem: jph-: I mean quicklisp is a thing... but it's not a thing I like

23:41 anyway. we shouldn't be trash talking in front of the new guy :P

23:41 ap-: arrdem: weird... I thought how weird/clunky clojure namespaces were for the first 4 weeks. (compared to how nice the symbol based ones of CL were.)

23:41 arrdem: must be one of those things your head gets used to.

23:42 jph-: ap-, for a month or two namespaces were voodoo to me, i had to keep looking at examples to figure out how to use them

23:42 now it's second nature

23:44 arrdem: jph-: I mean from a language implementation sandpoint, namespaces are kina weird.

23:44 jph-: not first class and all... which is actually nice about CL's namespaces.

23:44 jph-: arrdem, you mean they're hidden away elsewhere?

23:44 ap-: I'm thinking of writing something where there would be thousands (literally) of agents around. Is that "normal" or insane? The idea is that periodically, some subset of them would be "woken up" by some external event. Is such a design going to get me into troubles with some limitations I don't yet understand?

23:45 jph-: i remember a friend bitching about namespace overlapping in ruby... i only experienced it once, i never have that issue in clojure

23:45 i have so much control over my namespaces

23:45 arrdem: ap-: depends on how your threadpool is controlled and how many agents you expect to have active at once

23:45 jph-: at first i thought it was too much control, and made code harder to read

23:46 arrdem: ap-: that may actually be a better use of the core.async library

23:46 jph-: ie, you could either (:require [clojure.string :as s / str / string] or :refer :all or :refer [upper-case]

23:46 lots of power

23:46 arrdem: I still don't get why use lets you :exclude and require doesn't...

23:46 ,(doc require)

23:46 ap-: arrdem: are there guidelines? i.e. a grunty server, 8 cores, 64 Gb ram... 10,000 threads should be ok?

23:46 clojurebot: "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents...

23:47 arrdem: ap-: I mean the only way to find out is to try... right? :P

23:47 ap-: benchmark then optimize and all that..

23:47 ap-: arrdem: yeah, but that's the expensive way... others may have the relevant experience already

23:47 I noticed Rich Hickey's Ants demonstration just declared a big array of agents at startup, no?

23:47 arrdem: I've got 1k DOGE says I can spin up and hammer 10k threads in < 15 lines...

23:48 ap-: but it's just a toy...

23:48 arrdem: ... and a high load toy is a reasonable approximation of a presumably lower load production system, no?

23:48 ap-: arrdem: oh, spinning them up is easy... keeping them from starving and keeping each other from working is another story

23:49 arrdem: totally. all that depends on the parallelism semantics of your application and I can't comment.

23:49 ap-: but my impression is that clojure is encouraging me towards this sort of design. Just curious if others have done that.

23:49 arrdem: clojure.core.reducers may be something for you to look at

23:49 ap-: I guess I'm a bit scared because I have no idea how I would profile/debug such a design (at the moment).

23:50 (core.reducers? don't even know what that is. I'll go check it out).

23:50 arrdem: $google clojure core reducers

23:50 lazybot: [Clojure - reducers] http://clojure.org/reducers

23:51 jph-: ap-, the difference is you dont have state to really worry about

23:51 ap-, due to immutability

23:52 arrdem: jph-: unless he does evil things with mutables or atoms...

23:52 jph-: yeh

23:52 which reminds me, i always get a laugh about that "one library that rich hickey doesnt want you to know about!"

23:52 that lets you mutate stuff

23:52 ap-: well... yeah, each agent will at least have to keep some sort of state

23:53 but it's fairly well contained; an event occur; some subset of agents each "consider" the task, compute some internal state, and add some value to a priority queue somewhere, then go back to sleep.

23:53 jph-: you do have to learn a different way to think

23:54 but at the end, you have a much more dependable, performant system

23:54 arrdem: anyone know of a 2d topology library for Clojure or am I just gonna have to roll my own..

23:56 jph-: i'd assume there's something in the java world you can leverage

23:56 arrdem: yeah I'm looking at JTS now.

23:57 well this is garbage... no circles! only polylines...

Logging service provided by n01se.net