#clojure log - Sep 12 2012

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

0:04 l1x: o hai

0:07 how could i get this working? i am interested []s which are not violating the #{} when i add "a" "b" and "a * b" to the #{} https://gist.github.com/3704221?

0:08 maybe i could do it the filter and return it with that

0:10 llasram: l1x: Or add `:when (not= a b (* a b))` to the bindings in your `for`

0:10 l1x: hmm rite, thanks!

0:10 llasram: Actually, that won't quite cut it -- need to be all distinct. But you get the idea

0:10 l1x: yep

0:11 i come up with a predicate which can be used in the :when

0:11 thanks!

1:01 mk: how can I improve http://pastebin.com/cBtReXqV ? (no errors, mostly style)

1:01 the code for the listeners seems a bit ugly

3:10 yanne: I solved http://www.4clojure.com/problem/27#prob-title with this: #(= (apply str %) (apply str (reverse %))) but I consider it cheating. Is there a way to solve it without instance checks?

3:12 cark: have you looked into the seq function ?

3:14 yanne: probabaly not, thanks for the pointer :)

3:14 cark: =)

3:24 yanne: cark: just what I needed, somehow missed it on the doc page

3:24 cark: great =)

3:25 by using (apply str) you were calling seq under the hood (i think)

3:26 and reverse must be doing something like it too

3:31 kral: morning

6:18 no7hing: is it possible to use nrepl in a production application without the need to wrap commands?

6:20 like if you started the app with a repl in the first place

6:20 with/via

6:22 clgv: embedding a repl in you application should be possible. I used clojure's standard repl in one of my projects in the standalone jar when I specify a certain commandline parameter

6:36 naeg: how can I remove the redundant calls in this snippet: http://bpaste.net/show/OjzDLlSiV4fu4s10EWGF/

6:36 (it's core.logic, but I guess it's the same for a normal (cond))

6:42 clgv: naeg: with `cond` you cant. there is `case` though - but does it have a core-logic equivalent?

6:43 naeg: oh the numbers are within the `some-goal`. hmm then case probably does not fit. or is this a different core.logic syntax?

6:43 naeg: clgv: some-goal could be a simple function in a cond. it's always the same in each case, only one argument differs

6:44 clgv: I could replace it with a macro though?

6:44 clgv: naeg: oh, you can use a `partial? then

6:44 args `partial`

6:44 ,(map (partial + 10) (range 5))

6:44 clojurebot: (10 11 12 13 14)

6:45 pyrhho: I'm trying to mount a java servlet (specifically one of these: http://metrics.codahale.com/manual/servlet/) into my ring app. Ideally it would be mounted on a sub-path. anyone have any experience doing that? or is there a better way to do it?

6:45 naeg: clgv: that would just save me from writing the [a b b d] each time, I actually want something that would expand to each of these cases

6:45 clgv: naeg: then you need a macro

6:46 naeg: clgv: but that would be overdone if I just use that macro once I guess?

6:46 clgv: naeg: but is the redundancy after macroexpansion really needed?

6:47 naeg: clgv: as far as I can tell, yes. I'll paste the actual code...

6:48 clgv: naeg: can you reason why?

6:48 naeg: clgv: http://bpaste.net/show/f6uEIczpyn83NkHIfuop/

6:49 clgv: naeg: so whats `conda` doing with those?

6:49 naeg: clgv: It's a algorithm for checking a connect four field. in (check-board) I first determine distinct indices for each coordinate in the field, and then I try to find patterns in these indices. a +1 pattern is a row, a +10 a col, +11/+9 are diags

6:50 clgv: it tries the first goal, if that succeeds, it's finished. if it failed, it moves on to the next goal and so on

6:50 logical disjunction with short-circuit behaviour on first success

6:51 clgv: naeg: ah ok. couldnt you just use a logic variable with domain = #{1 10 11 9} instead of the repetition?

6:52 that's how I would have done it in prolog

6:52 naeg: clgv: how could I create a disjunction between each of those then?

6:53 from my understanding I need a cond here (conda is just better than conde because of it's short-circuit behaviour - no need to check cols and diags if rows already won)

6:53 clgv: naeg: does the order of those statements matter to your problem?

6:54 naeg: clgv: nope, don't care whether he checks diags before rows or whatever

6:54 clgv: naeg: ok. then introduce a local logic variable with the domain #{1 10 11 9} and use it in your goal

6:55 naeg: clgv: of course! now i understand what you meant - thanks

7:04 clgv: It's a good idea, but it's _a lot_ slower

7:04 clgv: naeg: oh. it does not short circuit I guess

7:05 naeg: can you add short circuiting behavior after the first match? maybe some local "fail"

7:05 naeg: clgv: hmm...I'm not sure, but I think it should. I'm telling core.logic to search only for one solution

7:05 clgv: naeg: disclaimer: I never tried core.logic so far

7:07 naeg: clgv: one problem is that I can't use a actual domain, but have to use (membero diff [1 10 11 9]) instead

7:07 clgv: naeg: why cant you use an actual domain?

7:08 naeg: clgv: bug in the FD stuff of core.logic :/

7:09 clgv: too bad :|

7:10 naeg: clgv: ok, it's fast when using domains. but it sometimes results into true when it shouldn't

7:11 clgv: naeg: what is core.logic trying to do when you just use (membero diff [1 10 11 9]) ?

7:11 naeg: clgv: the logic var diff has to a member of this list

7:11 that takes a lot more time than using a domain

7:12 clgv: naeg: so it does enumerate through all values?

7:12 naeg: I do think so

7:13 the bug seems not to effect my new version with two domains though, but obviously is a bug

7:22 ejackson: you were the one suggesting a core.logic solution for an algorithm to check a connect four field, right? here it finally is: http://bpaste.net/show/mp5AEFjlQlxI6c3w5Iwm/

7:26 clgv: naeg: you should generalize it for variable field sizes^^

7:28 naeg: clgv: the other algorithms I wrote aren't that general either :P

7:31 clgv: naeg: I thought it as exercise. would work with variables in 2d grid and dx,dy in #{-1,0,1} instead of diff ;)

7:32 naeg: basically everything I do is an exercise, but I want to move on now. spent about two weeks just on the checking algorithm for my connect four game :P

7:32 clgv: oh ok. then it is time ;)

7:33 naeg: core.logic could use some more comments ^^

7:34 naeg: clgv: well, it's straighforward to someone familiar with core.logic. and for the others i'm writing a blog post about all those different algos, including a in-depth explanation (especially for core.logic ;))

7:35 clgv: naeg: I meant comments within the implementation^^

7:37 naeg: that will for sure happen while writing the blog post

7:39 clgv: naeg: I meant the core.logic implementation, in particular clojure.core.logic ;)

7:39 naeg: clgv: oh^^

7:40 well, I learnt about it by watching talks, reading the wiki and then sometimes look into the source

7:41 clgv: naeg: I just wanted to check how +fd works but got last in blocks of code ;)

8:22 no7hing: clgv: thanks

8:23 but wait

8:23 that's for starting the app with a repl right away?

8:24 i'm looking for something like erlang's console

8:24 that you can attach to a running application

8:25 clgv: no7hing: I just told that as an example. embedding nrepl in your application should be possible as well.

8:26 no7hing: but then i have to wrap all my commands like this: (repl/message {:op :eval :code "(time (reduce + (range 1e6)))"})

8:27 or am i not getting something here?

8:27 based on that example i'd love to be able to just enter (time (reduce + (range 1e6)))

8:27 clgv: no7hing: maybe there is a comfort function that does that already. otherwise it is an easy exercise ;)

8:27 xeqi: no7hing: thats if you are connecting without using a pre-built frontend

8:27 no7hing: oh

8:28 xeqi: `lein repl :connect ...` would let you use the reply frontend connected to the embedded nrepl server

8:28 no7hing: thanks and seems like i have some more reading to do!

8:45 clgv/xeqi: works like a charm

9:05 clgv: :q

9:05 ups

9:05 wmealing_: #

9:48 dgrnbrg: hey, which package is the .?. macro located in?

9:51 antares_: dgrnbrg: sounds like something highly experimental. Are you looking for it in the new contrib?

9:53 chouser: wow, that's not even in https://github.com/rplevy/swiss-arrows

9:53 dgrnbrg: i can't remember where i saw it

9:54 it was a lib that had -?>, -?>>, .?.

9:54 ejackson: what does it do ?

9:54 dgrnbrg: core.incubator has the first wo

9:54 dgrnbrg: if you get nil at any step, it immediately returns nil

9:54 ejackson: two

9:54 dgrnbrg: thus preventing NPEs

9:54 chouser: you could use perhaps (-?> foo .bar .baz)

9:54 dgrnbrg: chouser: i think that'll be it, thanks :)

9:56 ejackson: dgrnbrg: yup. its core.incubator: https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L37

9:56 clgv: clojure.walk does not preserve metadata :(

9:57 cemerick: clgv: Because transients (and therefore into, used by walk) in 1.4.0 don't preserve metadata. Use a 1.5.0 build.

9:57 I discovered that last week myself. It's a shame the bugfix didn't get into 1.4.0.

9:59 clgv: cemerick: you are way ahead of me. I use walk in 1.2.1 - couldnt update that project yet

9:59 it's next on the todo list though

10:00 cemerick: RIP 1.2.x ;-)

10:00 ejackson: 1.2 !

10:01 when I was a boy we had to use 1.2 and fight of leopards to use the village compiler !

10:01 clgv: cemerick: hopefully. I guess I plan a week for it ^^

10:01 ejackson: :P

10:01 cemerick: ejackson: I know, right? Remember when we had to load our numerics into little boxes and cart them all over the place like that?

10:02 clgv: Upgrading shouldn't be that tough :-)

10:02 ejackson: and the boxes were always the wrong size, and we had to open them with out teeth.

10:02 s/out/our/

10:02 clgv: cemerick: oh there is a lot of contrib in there.

10:03 cemerick: Ah. RIP contrib, then.

10:09 clgv: cemerick: now I have a meta preserving `walk`^^

10:11 just wrapped it in another function

10:13 mytrile: Hey, guys. I'm new to clojure and I'm trying some things but I have a problem: Say we have json with dates and text for almost every day. I've wrote some function to get the data for the current date, but I don't know how to find the next date if no data exists for the current date: https://gist.github.com/3917ad97e498e4c0dd78

10:21 no7hing: is alter-var-root and a dynamic var the best way to store e.g. a server

10:21 ?

10:22 like in (def ^:dynamic *client* nil) and in the init-fn (alter-var-root #'*client* (fn [_] client)) ?

10:23 ejackson: no7hing: dunno about best, but I've often used atoms to store servers and things

10:24 mytrile: maybe read the file into a something that can give you proper handle of dates and times. Like a map keyed by date-time. That way you can do these things easily. Depends.

10:24 no7hing: so (defonce client (atom nil)) and then (reset! client the-client)

10:25 i'am torn :D

10:25 ejackson: no7hing: 'zakly

10:26 mytrile: ejackson: the dates are transformed to map: { :01 { :01 "Some text" :02 "Some text" }} etc

10:26 ejackson: mytrile; but that's only within a month

10:27 konr_trab: How can I download a file to an object in memory in clojure? Via clj-http?

10:27 mytrile: ejackson: When you read the whole json file you have all months

10:27 ejackson: konr_trab: yes.

10:28 mytrile: yes, but if the missing 'today' is the last in the month, you have a problem no ? Maybe I misunderstand.

10:28 mytrile: ejackson: When today is the last of the month I should get the first date of the next month

10:29 If a date is missing/last I should get the next one

10:31 ejackson: basically, somehow, it doesn't matter how, you need to be able to create an ordered list of the existing dates, a function to to map real dates to that representation, as well as a next date. All of that is free if you just transform everything to date-time out the gate.

10:32 if you have a sorted vector of the dates in your file, you can easily check if today exists, as well as the next exsting day after today.

10:32 jweiss: anyone have a link to Rich's rant referenced here (or some other link containing roughly the same arguments)? https://twitter.com/timcharper/status/13992964908

10:33 mytrile: ejackson: sorted vector, got it

10:33 ejackson: thanks

10:34 ejackson: best of all would be a sorted-map, where the keys are date-times (clj-time.core)

10:34 then you can get the dates easily by calling keys on your sorted-map, and can lookup fast into the map

10:36 mytrile: ejackson: yeah, but what's going on when an element in map is not found, that's my problem

10:42 ejackson: mytrile:if they're dates (or something comparable) then you can do something like (first (filter #(> % query-date) existing-dates)

10:42 but only do that if the lookup fails.

11:12 nsxt: any recommended libs for managing/differentiating between environments (dev, test, production)?

11:15 never mind, just found environ

11:30 DrPheltRight: 5/cr

11:34 gtrak: how do I disable URI path uri-decoding in a compojure route?

11:53 abalone: clojurescript one setup requires lein 1.x for lein bootstrap? hm.

11:56 i wonder what will happen if i skip the lein bootstrap and just stick with lein 2

11:56 oh. i can't "go". :-P

12:26 ohpauleez: cemerick: ping

13:06 casion: what would be an idiomatic way to find the index of the first occurrence of a sequence of values in a vector? I came up with https://www.refheap.com/paste/5045 and neither seems terribly good

13:08 I guess I could use map-indexed and subvec too

13:08 ohpauleez: casion: I'm digging through some of my code, I swear I've done this too

13:09 and I think I used a mix of some and subvec

13:10 casion: ohpauleez: I was thinking of that now, but getting the index still would mean using .indexOf or similar wouldn't it?

13:12 dnolen: (some (fn [[i a b]] (if (= [a b] [x y]) i)) (map vector (range) v (rest v)))

13:14 casion: dnolen: ohh, that's clever

13:15 ohpauleez: casion, usually if you say the words "filter first" in your problem statement, `some` is in the answer

13:15 just a little rule of thumb you might find handy

13:15 casion: hmmm

13:17 dnolen's solution seems to be much slower than the recursion solution I put on refheap, but more readable

13:18 dnolen: casion: definitely slower, quite a few allocations. not sure if that matters for what you're doing.

13:18 keugaerg: casion: but IMHO , donolen's answer is workings lazily

13:19 casion: keugaerg: I don't need lazy unfortunately, I'm processing a file header

13:19 keugaerg: casion: ok no pb :-)

13:20 casion: ohpauleez: dnolen: out of curiosity any other way you'd imagine doing it? This kind of problem still stumps me in regards to functional thought processes

13:21 took me 2 days just to come up with what I did :\

13:23 ohpauleez: nope. I'd think: (first (filter ..)), some, loop/recur, or dropping into Java to see if there was a quick efficient way to pull it out. dnolen's solution would probably take me about an 30 minutes to an hour to tease out. The real trick to functional programming is thinking about how you're REALLY getting through the data and the higher-level constructs you have to capture that promise

13:23 "I just need to filter through this data to find the first occurrence of …" => `some`

13:24 "To find the first occurrence I need to …" -> (fn [] ..)

13:24 casion: ohpauleez: yeah, that's actually the first thing I thought of, then I couldn't figure out how to get the index using some...

13:26 either way, thank you both :) I feel more confident with this by the day

13:26 thorbjornDX: I have two seqs of seqs, and I'd like to turn each of the inner seqs into a set, and merge the two together (to form one seq of sets). What's the best way to do this?

13:26 ohpauleez: Awesome. Totally happy to help

13:26 nDuff: I recall there being an actively-maintained site covering 3rd-party packages for Clojure, but its name escapes me. Could I ask a reminder?

13:26 technomancy: nDuff: clojuresphere?

13:27 ohpauleez: clojure toolbox

13:27 clojurewerkz

13:27 that's it I think

13:28 nDuff: Ahh -- it's Clojuresphere I had in mind. Clojurewerkz puts out some good tools, but it's more the aggregator I was looking for.

13:28 Thanks!

13:33 * nDuff looks at the state of the available testing frameworks

13:33 technomancy: don't do it!

13:33 ohpauleez: haha

13:34 nDuff: ...hmm. Lazytest actually looks closest to what I'd like as a workflow, but it doesn't exactly appear to be actively maintained.

13:34 technomancy: I think you could easily port the lazytest workflow to clojure.test

13:34 orthogonal things should be orthogonal

13:34 ohpauleez: nDuff: test.generative, lazytest, Midje, expectations

13:34 technomancy: it's silly that the triggering mechanism is tightly coupled to the testing framework =(

13:35 ohpauleez: I used lazytest for a long time, and since switched over to clojure.test and test.generative

13:36 I too really like the layout and approach in Lazytest

13:36 technomancy: test.generative isn't really a framework, is it?

13:36 ohpauleez: not so much, but another approach to testing

13:36 ethanis: hey folks, I'm having issues with leiningen + clj-time

13:36 and they're only happening on my machine running openjdk

13:36 I cannot reproduce them on mac os, for whatever reason

13:37 I get an Exception: "caused by: java.lang.ClassNotFoundException: clj_time.core.DateTimeProtocol" when doing lein run

13:37 dnolen: casion: I would just use my solution unless performance is really critical. Based on your description it seems like you're already dumping the file header into a vector which seems like needless work - if you have the data already as a String why not just call String .indexOf directly?

13:38 ethanis: is this a matter of having to compile things ahead of time if they contain protocols which extend java classes (like org.joda.time.DateTime)?

13:39 is there some known idiosyncrasy with clojure/leiningen + openjdk

13:40 thorbjornDX: I ended up doing (for [s1 (map set seq1) s2 (map set seq2)] (into s1 s2)), tell me if it's terrible please! :)

13:40 ethanis: looking inside my ~/.m2 directory, I see two copies of clj-time

13:40 technomancy: ethanis: never heard of any issues with openjdk, no

13:40 ethanis: is it possible that my project is failing to resolve the newer copy?

13:40 technomancy: plenty of issues with AOT and protocols though

13:40 hiredman: ethanis: you should run lein clean in both places

13:41 ethanis: will do

13:41 nz-: ethanis: try lein deps :tree and see if you are using correct version of the lib

13:41 S11001001: thorbjornDX: it will re-setify all seq2 elements for each seq1 element

13:41 ethanis: great pointer

13:41 abaranosky: is there a way to run all tests recursively under one subdirectory: i.e. `leon test plant.fruit.*` ?

13:42 thorbjornDX: S11001001: so I should just make a set from one of the two seqs?

13:42 technomancy: abaranosky: you could use a test selector for that

13:42 thorbjornDX: S11001001: or do '(into #{} s1 s2)

13:42 S11001001: thorbjornDX: into's second argument is always seq'ed

13:42 technomancy: I wonder if test selectors should support partial application

13:42 thorbjornDX: S11001001: ah, okay. Thanks.

13:43 ohpauleez: thorbjornDX: Also, can you just use map to pull out the second seq from both? So you can avoid the comprehension?

13:43 I'm not exactly sure how your data looks

13:45 nDuff: ...hrm. The ease of invocation without using lein certainly varies a bit between those. (Can't use lein due to dependencies in an Ivy repo).

13:45 thorbjornDX: ohpauleez: I don't quite follow. My data is a seq of seqs about ~10 elements long, with ~7 elements per inner seq.

13:45 abaranosky: technomancy: I'd need to list each namespace explicitly to use test selectors, right? Or alternatively I can add metadata like "(deftest ^{:unit true}"? Is that correct?

13:46 S11001001: ohpauleez: a map wouldn't be necessary at all

13:46 ohpauleez: thorbjornDX: Ah my bad, I thought you had a two seqs, each with two inner seqs

13:46 ethanis: hmm, lein reps :tree reports the same (correct) version of clj-time in both cases

13:47 hiredman: abaranosky: you can do stuff like check the namespace name of the var to have selectors apply to entire namespaces

13:47 ohpauleez: and you wanted to merge the second of each of the second seqs

13:47 hiredman: or just put a doseq at the bottom of your test file that tags all the test vars

13:47 technomancy: abaranosky: yeah, what hiredman said, but each prefix would have to be its own test selector

13:47 which is why I was musing about partially-applied test selectors

13:47 thorbjornDX: ohpauleez: I do have two seqences, with the same number of 'inner' sequences (sorry my last statement didn't make that clear)

13:48 technomancy: lein test :prefix/plant.fruit

13:48 ethanis: *lein deps

13:48 technomancy: probably not the right syntax, but it looks tidy

13:48 hiredman: ethanis: did you run lein clean?

13:48 ethanis: yep

13:49 thorbjornDX: ohpauleez: '('(1 2 3) '(4 5 6)) '('(3 4) '(6 7)) ; I don't know if that syntax is 100% right

13:49 hiredman: ethanis: and did anything change? do you get errors on both places now?

13:49 abaranosky: leon midge has something like `leon midge plants.fruit.*`

13:49 technomancy: leon?

13:49 clojurebot: leon is a good sign it's time to turn off auto-"correct"

13:49 abaranosky: crap sorry I'm not awake yet :)

13:49 technomancy: haha

13:49 ethanis: hiredman: now I'm trying running the errant machine as "dev", since I was formerly trying to run it in "production" mode.

13:49 technomancy: abaranosky: yeah, I think partial test selectors are a much more general approach that would get you that kind of functionality

13:50 ethanis: (this is an application built atop noir: that's where the prod/dev distinction comes in)

13:50 abaranosky: wait a sec, that wasn't me, I think Colloquoy automatically altered those words because it though tI misspelled them???

13:50 lazybot: abaranosky: Oh, absolutely.

13:50 abalone: lein git-deps says it's setting up a dependency and then says Cannot run program "git" (in directory ".lein-git-deps") CreateProcess error=2 cannot find the file specified. ... this is windows .. my cmd prompt knows what lein is and what git is... and the directory .lein-git-deps exists... wha should i do?

13:50 technomancy: abaranosky: yeah, it's a macosecks "feature"

13:50 hiredman: git deps are dumb, so this is the universe telling you not to use them

13:51 technomancy: it's always amusing to run into someone who hasn't turned it off yet =)

13:51 ethanis: and lein run in dev mode yields the same problem, so that's seemingly not the issue

13:51 thorbjornDX: ohpauleez: er, I don't need those inner quotes

13:51 hiredman: ethanis: but what about on the osx machine?

13:51 abalone: hm. ok

13:51 ethanis: hiredman: switching the osx machine to prod? Will try that now.

13:52 hiredman: ethanis: my guess is you have a stale class file on the osx machine that is causing it not to throw this error, but if you had a fresh environment it would show the same error

13:52 ohpauleez: thorbjornDX: (set (flatten ['((1 2 3) (4 5 6)) '((3 4) (6 7))])) ?

13:53 &(set (flatten ['((1 2 3) (4 5 6)) '((3 4) (6 7))]))

13:53 lazybot: ⇒ #{1 2 3 4 5 6 7}

13:53 ethanis: hiredman: classfiles should live exclusively in ~/.m2 if I haven't changed my configuration from the defaults, right?

13:53 hiredman: ethanis: nah, ./classes/

13:53 thorbjornDX: &(for [s1 (map set '((1 2 3) (4 5 6))) seq2 '((3 4) (6 7))] (into s1 seq2))

13:53 lazybot: ⇒ (#{1 2 3 4} #{1 2 3 6 7} #{3 4 5 6} #{4 5 6 7})

13:53 hiredman: which lein clean should clean out

13:54 ohpauleez: ohhh

13:54 thorbjornDX: ohpauleez: ^ is what I would prefer to get.

13:54 ohpauleez: Yeah, the comprehension makes sense

13:54 abaranosky: technomancy: I'm not really a fan of Colloquoy; do Macs have a better alternative?

13:54 thorbjornDX: ohpauleez: so by using 'for', I have to realize all of the sequence?

13:56 technomancy: abaranosky: erc or irissi would be my recommendations

13:56 abaranosky: but from what I've heard that is an OS X problem, not a Colloquoy problem

13:58 ohpauleez: thorbjornDX: Yes, for will realize the entire sequence

14:02 shinobi_one: can someone help me with this function? :) http://pastebin.com/mG5YY2L5

14:02 S11001001: shinobi_one: read doesn't read a line

14:03 thorbjornDX: ohpauleez: ok, thanks for the help.

14:03 S11001001: ,(doc read)

14:03 clojurebot: "([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* ."

14:03 shinobi_one: hmm so how can i modify this to work?

14:04 nDuff: shinobi_one: In the future, by the way, please consider using a pastebin without the annoying ads. gist.github.com and refheap are both good.

14:05 ethanis: INTERESTING

14:05 "lein repl

14:05 Exception in thread "Thread-1" java.io.FileNotFoundException: /home/ubuntu/startlabs/target/stale/dependencies"

14:06 shinobi_one: nDuff: oh sorry, I use ad block so I never see any of those xD

14:07 i forgot the internet had ads xP

14:10 casion: dnolen: data isn't string, I'm working with an input-stream so it's a byte-array that I'm processing

14:11 TimMc: shinobi_one: I think java.io has LineReader or something. clojure.core/read is somewhat unrelated.

14:11 casion: and some delimiters can cross byte-boundaries for god knows what reason :|

14:12 shinobi_one: TimMc: I can do (with-open [rdr (reader "some file")] (count (line-seq rdr))) to count the number of lines in a file so it can't be too unrelated

14:12 TimMc: reader != read

14:12 shinobi_one: ah true!

14:12 i misread clojure.core/read for clojure.core/reader good point

14:13 TimMc: (drop 5 (line-seq ...))

14:13 ethanis: hey hiredman: it looks like I've resolved things

14:13 TimMc: or nth or something

14:13 abalone: i asked the following on #clojurescript but there are more users here, so apologies for the crosspost... hello :) what's the best setup for unit testing clojurescript code? (is there a setup that works with lein 2? i see a few things that require lein 1.x)

14:13 ethanis: thanks for the help

14:15 now a question for the audience: is it insecure to run a jetty server on port 80 as root?

14:16 and if so, why would running it behind an apache instance be any more secure?

14:16 technomancy: ethanis: usually it's placed behind apache or nginx

14:16 TimMc: ethanis: "root" is the problem.

14:16 ethanis: yes, but doesn't apache require you to run it as root?

14:17 dnolen: abalone: CLJS doesn't have a testing setup like clojure.test yet.

14:17 ethanis: (to bind port 80, specifically)

14:17 TimMc: I believe the actual network-facing processes are run as "apache".

14:17 Good point about port 80, though.

14:18 nz-: ethanis: apache binds the port and then gives away the root privileges, i think

14:18 technomancy: ethanis: right, but the point is your application code doesn't need to be in the same process that way

14:18 ethanis: nz, technomancy: completely valid, thanks for the rationale

14:18 nz-: ethanis: so most of time apache process doesn't have root access

14:19 ethanis: alright, that does sound like a valuable thing to do then

14:21 one more question: is there anything tricky about piping an nrepl session through ssh that I should be aware of?

14:21 abalone: dnolen: ok thanks.

14:22 technomancy: ethanis: no, that should be pretty straightforward

14:22 you can do it over https too though; see drawbridge

14:24 ethanis: awesome, thanks for the heads up, technomancy

14:24 I always learn a ton from the clojure IRC channel

14:25 technomancy: the clojure channel consistently ranks in the top 10 for user satisfaction on language-related freenode channels in a series of recent studies

14:26 Hodapp: this is why I was sent here as an asshole troll to give some other channels a chance

14:26 HA HA JUST KIDDING

14:26 >_>

14:26 <_<

14:32 jkkramer: -=784

14:36 gfredericks: jkkramer: you bought something?

14:37 jkkramer: gfredericks: my cat likes to jump on the keyboard when I leave the room

14:38 gfredericks: does the cat always emit code fragments?

14:40 jkkramer: I suspect they are encoded messages. so far unable to decode them

14:41 wonder if I could rebind my caps lock key to be cat lock

14:43 gfredericks: ~rimshot

14:43 clojurebot: Badum, *tish*

14:43 S11001001: jkkramer: your cat is telling you to use a language that permits in-place decrement, i.e. variables

14:43 abalone: jkkramer: S11001001 insulted your cat

14:44 jkkramer: she is partial to purrl

14:44 borkdude: there was this thing on clojure lately in the twitterverse mentioning indicators for higher salary and clojure, what was it?

14:44 I have to promote clojure a bit in front of java people and I might mention it ;)

14:45 thing on twitter I mean

14:45 eh no on clojure (fuck I'm tired)

14:45 abalone: so if i avoid stuff in clj that doesn't exist in cljs, then i can write my code and unit test it normally with clojure.test ... and have a symlink to a .cljs file and build my js and be happy.

14:45 gfredericks: borkdude: that was a few weeks ago right?

14:45 borkdude: gfredericks yes I think so

14:45 technomancy: borkdude: it was pretty suspect; it listed sketchy stuff like peoplesoft and certifications

14:45 gfredericks: I think ssierra tweeted it, as I sow

14:45 technomancy: I wouldn't take it seriously

14:46 borkdude: any other tips on how I can promote clojure in just a few slides in 5 minutes are welcome!

14:46 technomancy ok

14:46 gfredericks: technomancy: my favorite part was how it described clojure as being useful because it runs on the jvm which runs in web browsers

14:46 technomancy: gfredericks: applets _are_ the future, man

14:46 gfredericks: ~applets

14:46 clojurebot: Gabh mo leithsc?al?

14:47 gfredericks: clojurebot: applets |are| the future, man

14:47 clojurebot: Roger.

14:47 gfredericks: ~applets

14:47 clojurebot: applets are the future, man

14:47 gfredericks: mission accomplished

14:48 technomancy: gfredericks: RISC architecture is going to change everything, man! http://www.cnet.com/i/bto/20091209/3675717991_f750f4a35f_o.jpg

14:48 borkdude: clojure in 5 minutes… any tips…. guys?

14:48 gfredericks: borkdude: that is a challenge

14:48 abalone: borkdude: compare code bloat in one language with clojure ?

14:48 S11001001: borkdude: "take it easy" is the clojure motto

14:49 technomancy: borkdude: referential transparency and easy access to JVM libs

14:49 gfredericks: sell them on the immutable data structures, sane concurrency constructs, and static metaprogramming

14:49 technomancy: immutable data structures by themselves are a hard sell, but the fact that they enable referential transparency (which makes most concurrency headaches disappear) is easier to buy

14:50 borkdude: abalone that was my idea. any appealing examples?

14:50 gfredericks: technomancy: depends on the audience I would think

14:50 technomancy: true

14:50 cgag: i wanted to do a 5 minute talk about clojure at my company but it seemed like so much to talk about in 5 minutes

14:50 abalone: borkdude: there are probably existing examples

14:50 antares_: many Java experts have been recommending sticking to immutable data structures for many years

14:51 scriptor: maybe mention enlive or hiccup, and talk about how its just clojure data

14:51 Chousuke: referential transparency helps immensely even if there is zero concurrency

14:51 hyPiRion: borkdude: For whom are you giving this?

14:51 abalone: borkdude: haha, compare cljs to generated js

14:51 gfredericks: does hiccup let you use a map for the :style attribute?

14:51 borkdude: scriptor that's a nice, show a few cool clojure libs? I was thinking Seesaw maybe also

14:52 hyPiRion my colleagues (lectureres at a polytechnic)

14:52 scriptor: yep, anything that shows how useful macros can be if they're used reasonably

14:52 is also good

14:53 gfredericks: if you talk about macros, emphasize that it's all compile-time so it's actually conceivable to wrap your head around the effects

14:53 in contrast with e.g. ruby

14:53 borkdude: gfredericks good one

14:54 scriptor: borkdude: also, when showing code listings, focus on one piece of code at a time

14:54 as in, smaller code examples

14:54 gfredericks: and white-out all the parens so they can actually see the code

14:54 scriptor: people seem to get turned off by large blocks of lisp

14:55 borkdude: ok guys, tnx for the advice, I have enough to fill 5 minutes

14:55 cark: tho the advantages of clojure are best seen when coding in the large

14:55 scriptor: throw in the matrix quote about not seeing the code

14:55 jkkramer: borkdude: not sure about how effective it is as a 5-min selling tactic, but for me the biggest factor in convincing myself and others to use clojure has been simplicity & composability: clojure makes it easier to build modular, maintainable software with less code

14:55 borkdude: a colleague of my still thinks of clojure as a scripting language and doesn't think you can build large systems with it ;(

14:56 gfredericks: man if only clojure were useful as a scripting language

14:56 cark: gfredericks: haha so true

14:56 gfredericks: please somebody invent clojuresh

14:56 whatever that would mean exactly

14:56 cark: i read somewhere that clojure in python has good startup times

14:57 didn't try it myself

14:57 gfredericks: oh how is that project coming?

14:57 borkdude: wasn't there something on really fast start up time lately?

14:57 gfredericks: yeah drip

14:57 cark: isn't drip a little buggy right now ?

14:57 borkdude: ah yes, drip I think

14:58 cark: there was nailgun too ?

15:00 gfredericks: the only solution is to build a JPM

15:01 cark: what's a jpm ?

15:03 luxbock: would you recommend a newbie like me to learn clojure? I know the basics of Python but have never programmed anything beyond simple scripts with it

15:03 or am I better of getting better at Python, and considering clojure later on?

15:04 S11001001: luxbock: what do you like about python?

15:04 scriptor: luxbock: python's different enough from clojure that it wouldn't help all that much, and clojure should be fine on its own

15:04 borkdude: this image from cemerick's clojure survey might also be worth showing: http://bit.ly/Pjfqb5

15:05 scriptor: although documentation wise, there is far more for complete beginners for python than there is for clojure

15:05 luxbock: I was first learning Python many years ago as a teenager when I had a phase where I wanted to learn how to program, but I moved on to other ventures before I really got good at it

15:05 dnolen: borkdude: what languages do your colleagues use? always good to put things in relation to what people already know.

15:05 luxbock: so now that I'm trying to pick up on it again, Python was the most natural thing for me to get to

15:05 cark: luxbock: clojure is the better, simpler language. but it's harder to get started with clojure because of the whole jvm hosted thing

15:06 borkdude: luxbock Python: nice. Clojure: watch out, another addicting computer activity.

15:06 dnolen mainly Java, some Python

15:06 dnolen that was what I was going to do: show that learning clojure, might be useful for understanding concepts in other languages too (closures, lambda's, etc)

15:07 dnolen: borkdude: then perhaps highlight problems people encounter with those languages that Clojure addresses.

15:08 cark: borkdude: database access =)

15:08 luxbock: I don't really have any specific purpose for what I want to do with programming, but I figure it's one of those skills that can come handy at a lot of times so while I have a lot of free time and find it interesting, I might as well

15:08 dnolen: certainly Clojure offers quite a bit over Java pain points. If your colleages mostly use Python for simple scripting I'm not convinced Clojure offers enough.

15:08 borkdude: dnolen hmm, I don't think a lot of my colleagues do heavy concurrency problems, it might be difficult to sell clojure for that

15:08 amalloy: cark: knowing gfredericks, i'd guess he meant jpm to mean "java python machine", as superior to "java virtual machine"

15:09 borkdude: dnolen not a lot do Python, some use it for scripting, but mainly for sysadmin people

15:09 gfredericks: amalloy: java physical machine

15:09 amalloy: well, those exist though, right?

15:09 gfredericks: cark: sorry, was being productive

15:09 cark: gfredericks: huu wow that's been a while since i last heard of *that*

15:09 gfredericks: amalloy: maybe, I'm not hip enough to know that kind of thing

15:09 borkdude: dnolen a lot of my colleagues don't feel the pain of Java, because they simply don't know much about other OO langs

15:10 cgag: i'm sure they'd appreciate having literals for vectors and maps

15:10 dnolen: borkdude: yes so concurrency advantage doesn't by you much in this case. but the benefits of simpler reasoning about state is somethign they can identify with.

15:10 borkdude: dnolen about other (even other OO) langs I mean

15:10 dnolen: borkdude: but your colleages must create bugs

15:10 borkdude: where do these bugs come from?

15:10 cark: borkdude: i would pick some activity they're doing in java, and show that you can do it with 20% the line count and 20% the bugs of java

15:10 scriptor: borkdude: if you have enough time, you could try to rewrite some company code in clojure

15:11 borkdude: I think I'm going to show them some REPL fun a swell

15:11 cark: 20% being quite conservative =P

15:11 borkdude: as well

15:13 abalone: +1 for the idea of rewriting company code in clojure

15:13 ejackson: dnolen: all horrors arise from the bottom of the Mandlebrot set

15:13 * ejackson tips hat to Charlie Stross

15:13 borkdude: abalone scriptor don't think I have enough code, and we're not a company ;

15:13 abalone scriptor enough time I mean

15:14 scriptor: borkdude: ah, what would you use clojure for if it was chosen?

15:14 borkdude: scriptor everything

15:14 hyPiRion: heh.

15:15 clj-OS - the operating system for all your needs.

15:15 dnolen: borkdude: in 5 minutes sounds like you emphasize the fun part of Clojure - don't over hype the advantages.

15:15 borkdude: dnolen yes, well, it's only because I taught some students clojure and have to present something about this course

15:15 scriptor: and make sure to distinguish fun from "toy"

15:16 borkdude: dnolen so I guess I need to sell it a bit for the learning experience, more than financial benefit, or etc

15:16 dnolen students only had Java and C#, so with learning clojure they not only know clojure, but also about other FP languages and programming concepts, etc, blabla

15:16 dnolen: borkdude: development speed is also a plus. A demo building a UI on the fly w/ Seesaw would probably wake people up.

15:17 scriptor: borkdude: can you expand more on "everything"? Sounds like you'd teach it in class?

15:17 borkdude: scriptor I have taught it, just 6 lessons

15:18 cark: borkdude: demonstrate higher order functions: map, filter and how that all can be defined as reduce, with a concrete example of a vector containing meaningfull maps

15:18 antares_: borkdude: you can sell clojure as a small productive language with good performance baseline and impressive stability, running on a very mature runtime

15:18 * nDuff blinks at seesaw

15:18 nDuff: oooh

15:18 shiny

15:19 borkdude: hmm, elections have closed here in NL…

15:19 antares_: borkdude: best of both Java and Ruby/Python worlds, lets you concentrate on the problem. That is all. Selling macros and advanced features is not necessary.

15:20 borkdude: tnx

15:20 ghadishayban: Any way to do macroexpansion without symbol resolution *and* without having to put ~' in front of every symbol?

15:21 xeqi: cemerick: have you used friend and wrap-anti-forgery together?

15:21 dnolen: ghadishayban: no

15:21 cemerick: xeqi: not yet

15:21 problem?

15:21 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

15:21 ghadishayban: dnolen: ok…

15:22 xeqi: it will login fine, but the next request doesn't pull out an identity

15:22 cark: ghadishayban: you're trying to do variable capture ?

15:22 xeqi: I'll see if I can track it down

15:22 ghadishayban: dnolen: you can do codewalking calling (eval) everytime you see an unquote….but then you don't have access to local bindings

15:22 xeqi: just checking to see if you had and knew what the problem was

15:22 ghadishayban: without some &env voodoo

15:23 cark: yeah I'm trying to send in a form to clojurescript browser attached repl...

15:24 borkdude: tnx guys, for all the input, cya

15:24 ghadishayban: as in… (let [foo (some java land call)] (send to cljs (def bar ~foo)))

15:24 you can always call a macro and put ~' everywhere

15:25 but then you have ~' everywhere

15:25 dnolen: ghadishayban: not sure what you're trying to do. you can't send CLJS forms directly to the browser REPL, the browser REPL compiles to JS and sends JS for eval.

15:26 well I mean CLJ data literals but not code in general.

15:26 ghadishayban: dnolen: right, i'm talking about sending a proper form to the CLJS compiler, with inserted literals from java-land

15:28 dnolen: ghadishayban: oh you're generating CLJS code w/ CLJ?

15:28 ghadishayban: dnolen: si

15:29 inject a form into cljs-land that defs something

15:30 not something you'd do in a production setting. most of the cljs-clj communication involves the cljs asking for data furnished by clj.

15:30 and communication happening through (read-string)

15:31 jweiss: can anyone point me to some "encapsulation is folly" material, to persuade OO-trained coworkers that they don't need it?

15:31 https://twitter.com/timcharper/status/13992964908 <- a tweet suggesting suggesting the arguments are out there, but this particular one probably not on a webpage

15:31 ghadishayban: but for some deftests, it would be useful to set some constants in the browser, like credentials

15:32 dnolen: is this crazy?

15:34 dnolen: ghadishayban: I need to think about it some more. but yeah syntax-quote behavior won't be very helpful in this case ...

15:39 ghadishayban: dnolen: it's really no problem for a couple one off forms…

15:39 i just have that sneaking suspicion that there's an easier way to do it

15:43 dysinger: technomancy: I built a project that works under leiningen 1.7.x but under 2.0 it bails during uberjar with "duplicate entry: META-INF/LICENSE.txt" all the classes after this entry are not included in the uberjar.

15:43 just fyi

15:46 melipone: hello! Do I need to just change the JAVA_HOME env variable to change the java running clojure? I'm trying to replicate the experiment http://blog.gonzih.org/blog/2012/09/07/clojure-on-beaglebone-openjdk-vs-oracle-embedded-jre-benchmark/

15:46 hiredman: melipone: why?

15:46 just use the full path to the java you want

15:47 I think I am getting my bealge board back from the beagle hospital on monday, I can't wait

15:47 melipone: hiredman: I understand

15:48 hiredman: I don't understand what you say about the java full path.

15:49 * nDuff ponders whether it's worth getting permission from the Powers That Be to release his library for working with Esper from Clojure

15:49 hiredman: /usr/local/whatever/java …

15:49 melipone: hiredman: but I'm using clojure not java!

15:50 hiredman: /usr/local/whatever/java -jar clojure.jar

15:50 melipone: hiredman: but what if I do lein run? what does it do?

15:50 hiredman: melipone: if all you want to do is run the code from the website there you don't need lein

15:51 you just need a clojure repl

15:52 melipone: let me ask another way: how do I find the java version running clojure in clojure itself?

15:52 hiredman: (System/getProperties)

15:52 melipone: hiredman: thanks

15:53 hiredman: melipone: http://thelibraryofcongress.s3.amazonaws.com/beagleboneled.html if you setup nrepl you can dev locally with a remote repl

15:54 (editor etc on your laptop, repl on the beaglebone)

15:55 xeqi: cemerick: heh, they alternate returning sessions without info from the other middleware

15:55 cemerick: ut-oh :-P

15:55 a pox on our respective houses, I guess

15:56 xeqi: login -> response :session has friend identity but no ring-forgery code; redirect -> response :session generates new ring-forgery code since previous one disappears, but no identity

15:56 yeah, should be work-aroundable

15:57 but poxes!

15:57 nDuff: Can one do a thread-local unbinding of a var with a root binding present?

15:58 TimMc: xeqi: Butt poxes? Sounds bad, dude. Go see a doctor.

15:58 Sorry, I'm 8 years old today.

16:00 gfredericks: TimMc: no peanut-butter celery for you

16:04 naeg: is there some convention when passing around HOFs as arugments? like putting -f on the name: (fn [some-f] (some-f 1 2 3))

16:05 ohpauleez: naeg: typically, I add -fn

16:05 but I don't think there's a set convention

16:05 naeg: -fn makes more sense than -f though

16:05 ohpauleez: some people just call the arg f

16:06 hiredman: http://dev.clojure.org/display/design/Library+Coding+Standards

16:07 xeqi: I use f, g, h, if they are meant to be any function, prolly a math background

16:07 pred if its more a predicate type function

16:08 ohpauleez: I do the pred arg too

16:08 naeg: I like to be a bit more explaining with my arguments

16:09 hiredman: I often end up with (defn f …) (defn g …) while writing code, and then sit around trying to figure out names

16:09 naeg: (especially because i'm currently writing code which is probably read by clojure newcomers)

16:09 konr_trab: Is there a parser generator for Clojure, or something nicer than having to import antlr?

16:10 Hodapp: I thought it had combinators...

16:10 S11001001: konr_trab: a couple

16:11 * TimMc remembers trying to work on Olin Shivers & Co.'s parser-generator macro in Scheme

16:17 xeqi: konr_trab: I've seen a couple, but nothing up to date or on the scale of parsec :/

16:21 konr_trab: xeqi: this one looks good, but it's from 2010 http://lithinos.com/clj-peg/

16:22 cemerick: xeqi: feel free to file an issue, maybe on both libraries :-P

16:22 TimMc: LIB FIGHT

16:23 ohpauleez: konr_trab: I've used JParsec and ANTLR with success. In Clojure I wrote some stuff with fn-parse. A little dated, but parsers aren't something that need to be continuously updated. Once they do their job, they're done.

16:23 konr_trab: If you like the looks of clj-peg and it works in your project go for it. Or fork the repo and update whatever you need

16:25 xeqi: konr_trab: that one might work, I was thinking of fnparse and its clojure-contrib dependency for one thats not up to date

16:26 cemerick: yeah, I think I'll wait a bit and ask weavejester some questions. Its almost like the ring-response generated in the app should be filling the session

16:27 * filling the session with default values based on the request's session

16:38 weavejester: I'm running into some session problems trying to use both ring-anti-forgery and friend. They like to return session values at different times, which then causes the other one to be forgotten.

16:38 is it desired for the app's response to contain default session values based on the request?

16:39 vishesh: for refs if I have (def a1 (ref 1000)) and (def a2 a1), and I ref-set any of a1 or a2, other changes too. Why is that?

16:41 cark: (def a2 a1) creates a var a2 which resolves to the value of var a1

16:44 hum i might be misunderstood : redefining a1 afterwards does not change a2's value

16:45 hiredman: a ref is a cell

16:46 e.g. (def a2 a1) stores the value of a1 (the ref) as the value of a2

16:46 (var a1) -> ref -> 1000

16:46 (var a2) -> same ref -> same value 1000

16:47 brainproxy: having an issue w/ arguments I'm passing to a macro

16:48 nDuff: vishesh: If you want to refer to the value inside a ref, rather than the ref itself, you need to use deref

16:48 vishesh: otherwise, you're creating a second var pointing to the same ref

16:48 brainproxy: I can pass a literal like [:a :b :c] just fine, but if I need to "compute the literal" before using it as an argument I'm having trouble

16:48 nDuff: brainproxy: ...as in, you want to eval it?

16:49 amalloy: brainproxy: a macro can only perform operations on source-code literals. that is how they work

16:49 vishesh: hiredman, nDuff: Thanks. I guess I wasn't clear about the ref being a cell part...

16:49 nDuff: brainproxy: ...generally, wanting to use eval inside a macro is a code smell, meaning things could/should be designed differently.

16:50 brainproxy: nDuff: don't want to use eval inside

16:50 nDuff: brainproxy: ...then I don't follow the question.

16:50 cark: (defmacro do-it [the-code] `(do ~the-code))

16:50 vishesh: The commute function, during commit takes the most recent value globally and applies the func if I

16:50 brainproxy: cark: right, but inside the defmacro I have a thing like ~@(map ... arg-i-passed)

16:51 vishesh: The commute function, during commit takes the most recent value globally and applies the func if I'm right?

16:51 brainproxy: in other words to build up the `(...) parts I need to work over some data I'm passing into the macro

16:51 but I guess I need to break up the macro into pieces

16:51 and do the map prior to the call to my macro/s

16:52 as a way around that, I wasn't sure if I could take a computed value and turn it back into a literal that I could pass into the macro

16:52 cark: i think you can't make a macro run the code you pass to it at compile time

16:54 brainproxy: cark: you can do things like `( ... ~@(map #( ... `() ...)) ... )

16:54 cark: mhh i don't follow

16:54 brainproxy: you aren't restricted to just one top-level `()

16:55 you can unqoute within that and do a computation and hand back more `() inside the top-level `()

16:55 cark: right, but you macro will not be using the code you pass to it to do its job, it can lay it down , use it as a pattern, but not as code to be run

16:55 TimMc: ,`(+ 1 ~(count `(+ 0 0 0)))

16:56 clojurebot: (clojure.core/+ 1 4)

16:56 zerokarmaleft: has anyone taken over maintainership of lein-hadoop? seems like https://github.com/ndimiduk/lein-hadoop hasn't been updated since 1.1

16:56 brainproxy: cark: yes I know

16:57 well, anyway, I think the easy solution is perhaps to use a dynamic and refer to that in the macro, binding it to my computed value before I call the macro

16:57 cark: but what is it exacly you're trying to achieve ?

16:58 SegFaultAX|work2: Is DSLs in Action any good?

16:58 brainproxy: either that or break it up into 2+ macros and do the map outside the macro

16:58 cark: I'm trying to build up a (do ...) that has a rather complex body

16:58 TimMc: brainproxy: You can always call out to helper functions.

16:59 Not everything has to be one big `() block.

16:59 cark: TimMc: right that's what i do when it gets hairy, easier to debug too !

16:59 TimMc: You can explicitly call gensym in a let-block outside of it, pass those gensym values to helpers, etc.

17:00 cark: tho i find i'm using macros less and less

17:02 brainproxy: TimMc: i know, but in the end I need to map over a collection, and I either need to do it inside the macro, but around one of the inner `(), or I need multiple macros and do the map before I ever get to calling the macros

17:02 or ... there's the dynamic option

17:02 cark: would you have a minimal example ?

17:03 brainproxy: cark: let me get past the hump and I'll see if I can gist up an example

17:06 Sgeo__: Oh, brainproxy

17:06 Um, perhaps have the macro emit code that does a let?

17:07 Or is that difficult in your situation

17:18 cark: brainproxy: after reading agaibn what you said, i can only think of one of these two things https://gist.github.com/3709981

17:21 weavejester: xeqi: What did you mean by "likes to return session values at different times"?

17:35 xeqi: weavejester: when I first hit a page, the ring forgery token is added to the session

17:35 weavejester: xeqi: Yep

17:36 xeqi: when I :post to "/login" friend adds a friend/identity to the session, but the ring forgery token is not assoc in the map

17:36 so its forgotten

17:36 weavejester: xeqi: That sounds like a bug in friend

17:36 xeqi: on the redirect a new ring forgery token gets assoced, but the friend/identity token is forgotten

17:37 weavejester: xeqi: And perhaps a bug in ring-anti-forgery, too!

17:37 xeqi: I guess I would have both to always add the tokens they want to the session

17:37 hiredman: could that result from having the session middleware multiple times in the stack?

17:37 xeqi: not just when they change

17:38 but I just want to make sure I'm not suppose to be returning default values of the session as seen in the request

17:38 weavejester: The problem is that both middleware doesn't correctly add to the session

17:38 xeqi: hiredman: nope, its (-> app friend ring-anti-forgery hiccup/site) basically

17:39 k, I'll file bugs on both then

17:39 just wanted to confirm before hand

17:39 weavejester: They should modify the session in the request and add the updated session to the response.

17:40 I need bed now, so I'll fix ring-anti-forgery tomorrow :)

18:24 brainproxy: cark: I appreciate your taking the time to write that gist; i ended up being able to move the problematic map inside the top-level `(...) of my map and now all is well

18:25 i got to hung up on thinking that a (doall (map...)) inside that part of my macro was going to be problematic, but with a little refactoring it worked out to do it that way

18:26 whoops, above i meant to say "`(...) of my macro"

19:57 SrPx: Can Clojure libraries be used on Clojurescript?

20:00 nDuff: SrPx: Only ones written to use the subset of the language that cljs supports

20:00 jtoy: j #bash

20:00 nDuff: SrPx: ...generally, when those exist, it's very intentional.

20:01 SrPx: nDuff: I see

20:02 nDuff: so most Clojure libraries would not be

20:02 (compatible)

20:03 thorbjornDX: SrPx: (source compatible)

20:03 SrPx: my brain is broken methinks

20:05 nDuff: SrPx: Correct.

20:09 typeclassy: is there any way to add clojurescript as a dependency for a leiningen project? putting compiler.jar in lib/ doesn't seem to give me access to the cljs namespace

20:10 dslsd: I was reading about generating functions and it seems like it's considered a bad idea in general. I'm used to things like define_method from ruby. (intern *ns* ...) seems to not be a good idea. I would like to generate functions for monday-friday: monday?, friday?, etc.

20:10 How should I do that?

20:11 technomancy: dslsd: the best way to generate functions in clojure is partial application and composition

20:13 dslsd: technomancy: i guess i hadn't really thought about using partial for this -- i think that will probably get me close, but it would be nice to have some cozy functions like (friday? date) for a date, instead of (is-it? :friday date)...

20:13 technomancy: (def friday? (partial is-it? :friday)) ; season with metadata to taste

20:14 dslsd: sure, it's just the names I'd like to generate, but say no more. I think that's okay.

20:14 Thanks.

20:14 amalloy: or with a macro if you must. (with-day-questions (friday? x)) can expand to (letfn [(friday? [d] ...)] (friday? x))

20:15 technomancy: (let [[sunday? monday? ...] (map (comp partial is-it?) [:sunday :monday ...])] ...)

20:15 boo

20:47 gfredericks: it is interesting that cljs functions aren't IWithMeta

20:47 you'd think that would be feasible since JS functions can have properties

20:47 hiredman: metadata on fuctions is fraught with issues

20:48 gfredericks: or maybe that would require being able to clone functions :/

20:48 hiredman: what sort?

20:48 hiredman: gfredericks: the contract for things like with-meta brings equality in to play

20:49 (= x (with-meta x {:foo 1}))

20:49 gfredericks: ah right

20:49 that will be false on jvm and js

20:49 what does with-meta do for vars?

20:49 hiredman: you cannot with-meta vars

20:49 there are two different metadata paths

20:50 one for mutable references and one for immutable values

20:50 gfredericks: oh that's terribly interesting

20:50 hiredman: I am sort of surprised you are not aware of this

20:50 gfredericks: I don't do a whole lot with metadata

20:51 but I'll take your expectation as a compliment :)

20:51 hiredman: well there is a single path for reading metadata, two paths for "writing" depending on which interface the object implements

20:52 gfredericks: so then why not make functions act like reference types?

20:52 hiredman: I dunno, cause they aren't?

20:52 IObj and IReference are the two paths for setting metadata

20:53 (these days, that has changed a few times)

20:53 gfredericks: well just because it's called IReference doesn't mean it necessarily has to do with references specifically, does it?

20:53 just with non-values?

20:54 hiredman: I don't know

20:54 gfredericks: the interface seems to have to do strictly with metadata

20:54 anyhow, good learnings; thanks

21:15 dslsd: How do people deploy Clojure web applications? I can't seem to find anything but information about Heroku, but I'd rather have more control over my deployment and environment. Tomcat? Are there any nice "put together" solutions for configuring an EC2 instance and deploying a clojure app to it?

21:18 emezeske: dslsd: I've heard that it's reasonable to just "lein run" your project

21:18 gfredericks: executable jars good too

21:20 emezeske: dslsd: You might look at http://palletops.com/ if you want to automate the deployment

21:22 hoover_damm: dslsd, with ring I believe the default behavior is with jetty or tomcat

21:22 dslsd, but there's nothing stopping you from using immutant

21:23 gfredericks: is there still nothing standard for cljs testing? I'm whipping up a clojure.test immitation for myself atm

21:23 hoover_damm: it supports ring too

21:25 emezeske: gfredericks: https://github.com/kumarshantanu/clip-test

21:25 gfredericks: Haven't used it myself, but maybe it's helpful?

21:28 gfredericks: emezeske: this looks promising; thanks

21:30 xeqi: dslsd: clojars uses an executable jar w/ run-jetty in it. Uses an nginx frontend as well

21:33 gfredericks: in cljs how do I catch arbitrary errors?

21:33 (catch js/Error e ...) will miss strings, etc

21:54 Khaoz: When i enter in clj execute use '[clojure.string :only (split)] it does not persist for the next commands ?

21:55 gfredericks: you have parens around the use?

21:55 i.e., (use '[clojure.string :only (split)])

21:55 * Khaoz ...

21:56 Khaoz: youre right.. i'm still getting used with the parentheses

21:56 but i like them, no matter what :D

21:56 gfredericks: thank you very much

21:56 gfredericks: :)

21:56 no problem

22:49 abalone: gfredericks: how's clip-test going for you?

22:50 gfredericks: abalone: I didn't try it; was already at a point where it was easier to finish building my own, which worked great for my purposes

22:51 spent all of 25 minutes on getting deftest and is working correctly

22:58 abalone: gfredericks: wow. nice work! did you see my comment earlier about my cheat?

22:59 as long as i stick to the cljs subset of clj, i can use clojure.test. and when i'm done, copy the file to file.cljs and generate js

23:00 gfredericks: ah right

23:00 wait wat

23:01 use clojure.test for what? running your tests on the jvm?

23:01 abalone: yeah :-P lame right?

23:01 gfredericks: (i.e., did you mean "the clj subset of cljs"?)

23:01 abalone: yeah.

23:01 gfredericks: ah ha; gotcha; well I'm testing interactive raphael diagrams

23:02 I thought for a little bit about trying to use jasmine

23:12 gtuckerkellogg: i've been using swank-clojure, and am considering moving to nrepl.el. Has anyone modified the clojure-test-mode and midje-mode for nrepl.el? Will clojure-mode eventually expect nrepl instead of slime?

23:20 nsxt: when working with relational databases, is the convention to use hyphens in column names rather than underscores?

23:22 i think it makes more sense to dispense with underscores entirely (so as to eliminate the need to process keywords), but it seems like the sql world frowns upon hyphens in identifiers

23:51 technomancy: gtuckerkellogg: clojure-test-mode hasn't been ported yet. clojure-mode itself won't need any changes.

23:51 the stuff that clojure-mode has for slime is unnecessary for nrepl.el because it doesn't have to bootstrap the same way.

Logging service provided by n01se.net