#clojure log - Aug 30 2011

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

0:00 technomancy: redinger: try clearing out ~/.emacs.d/swank; that should probably do it

0:01 scgilardi: they're still both .el files masquerading as .elc

0:02 redinger: yeah, they're still there

0:02 as .elc files

0:06 technomancy: derp; I'm not restarting Emacs in between testing it

0:08 flazz: given a list of key value pairs how can i build a map? is there a better way than reduce?

0:09 scgilardi: are the pairs vectors or sequential in-line '([:a 1] [:b 2]) vs. '(:a 1 :b 2)

0:09 [swift]: hmm.. does anyone know how you can access the window object in clojurescript? window/document works, for example, but i can't see how to call a method on the window object directly

0:11 semperos: flazz: ##(apply hash-map [:a 1 :b 2 :c 3])

0:11 lazybot: ⇒ {:a 1, :c 3, :b 2}

0:11 semperos: that structure?

0:11 flazz: scgilardi: the former, unflattened per se

0:11 scgilardi: try (into {} my-list-of-pairs)

0:11 technomancy: ok, whew, now it works with a fresh emacs and a clear ~/.emacs.d/swank dir

0:11 for reals this time

0:11 semperos: ##(into {} [ [:a 1] [:b 2] ])

0:12 lazybot: ⇒ {:a 1, :b 2}

0:12 amalloy: scgilardi, flazz: that version only works if they're actually vectors, not just lists

0:12 flazz: i can make them vectors

0:12 i'm pulling the values from a java object

0:12 i'm really asking for the most idiomatic clojure way, reduce works great but i'm not sure on its readability

0:14 scgilardi: into works great

0:14 redinger: technomancy: First time it compiles just fine and works, second time error cannot load slime-cdf... with no extension

0:16 technomancy: hm; the docstring for load-file claims that should work

0:16 but it does not

0:16 scgilardi: flazz: great

0:17 redinger: yeah, adding the extension to load-file seems to fix it

0:17 srid: @?

0:17 clojurebot: @ is splicing unquote

0:18 technomancy: well, I gotta take off, but thanks for he help

0:18 will have it sorted out tomorrow

0:18 redinger: sure!

0:23 dnolen: the ClojureScript compiler is neat.

0:33 * srid finally ported hiccup templates to enlive. phew! gotta understand more of enlive.

0:50 scottj: dnolen: thanks for :use :only patch, I hoped someone would do that

0:55 just applied it, works fine

0:56 btw livereload + cljs-watch is pretty nice

1:01 dnolen: scottj: nice! livereload?

1:02 scottj: it's a ruby program + chrome extension that will monitor in this case the bootstrap.js and reload the page when it's changed

1:02 it does the same for html/css

1:03 all I had to do for configuration was tell it to ignore my.js etc and only monitor bootstrap.js

1:05 also anyone who hasn't botherd to setup ctags for cljs this works --langmap=Lisp:+.clj+.cljs

1:20 flazz: should the io! macro be used as close to the io as possible?

1:22 amalloy: it should be used anywhere you want to assert that you're not in a transaction

1:23 scottj: flazz: normally it's in the function that does io but not necessarily right by the io (often removed from it by let/bindings that don't do io)

1:25 flazz: so if i'm doing a java call that does IO i would have it in my function?

1:26 scottj: only if you're using refs

1:26 amalloy: scottj: i don't follow that last

1:28 i mean, i don't think i've ever bothered to write (io!) in my own code. but if i were writing a library that did IO via some java interop, i would be pleased if i remembered to use (io!)

1:28 so that the client doesn't accidentally call my code from a transaction

1:29 scottj: amalloy: fair enough

1:35 scgilardi: I continued to work on the clojure-jack-in loader in a fork: https://github.com/scgilardi/swank-clojure/tree/1.3.x . It's working for me now. I sent a pull request to technomancy.

1:47 MasseR: Is (doto (.clone foo) (sumtin)) a good pattern for having an immutable interface when dealing with java objects?

1:48 hiredman: there is not substitute for reading documentation

1:48 no amount of cloning will ever give you an immutable value

1:48 MasseR: hiredman: True, but it reduces the risk of side-effects

1:49 hiredman: nope

1:52 MasseR: hiredman: Let's say I have some javascript object (say, a Calendar), which I bounce around different functions. On one of them, I need to call a setter, and all of the functions now get the modified object

1:52 There is no longer the original

1:53 amalloy: it doesn't give you any meaningful protections. (sumtin foo) can still modify both foo *and* (.clone foo). you might end up having *two* objects not= to the original foo

1:54 MasseR: amalloy: It hides the modifications inside the functions. Especially if the modified foo is not the value I want, but rather modifying foo, allows me to .get the value I'm interested in

1:54 amalloy: MasseR: you are free to do anything you want, but it does not hide any modifications

1:54 MasseR: (.get (doto (.clone cal) (.set Calendar/DAY_OF_MONTH 1)) Calendar/DAY_OF_WEEK)

1:54 amalloy: foo can hold a reference to a mutable object

1:55 then (.clone foo) can mutate the object referred to, and foo will appear different

1:55 MasseR: Ah now I see where you're going

1:55 You're right

1:55 So, I just need to live with the mutations

1:59 amalloy: FWIW, i think that code would be clearer with some arrows:

1:59 (-> (.clone cal) (doto (.set ...)) (.get Calendar/...))

1:59 but i'm notoriously wrong about such things, so take that with a grain of salt

2:03 hiredman: there is not guarantee of how deep the copy clone creates provides

2:03 you are just churning out useless copies of objects (garbage)

2:04 read the doccs

2:04 jblomo: is there a string trim function that takes a set of characters instead of whitespace?

2:05 MasseR: Btw, way off topic, but duckduckgo is magnificent in finding java docs. You can either use a bang pattern !java to redirect to oracles search (meh) or just write "java calendar" and get a zero-click info straight from the class.

2:09 amalloy: jblomo: not that i know of. i'd just write one with regexes

2:09 jblomo: ,(->> "/my/test/path/" (drop-while #{\/}) reverse (drop-while #{\/}) reverse)

2:09 clojurebot: (\m \y \/ \t \e ...)

2:09 jblomo: ,(apply str (->> "/my/test/path/" (drop-while #{\/}) reverse (drop-while #{\/}) reverse))

2:09 clojurebot: "my/test/path"

2:10 jblomo: i wonder what's faster

2:10 amalloy: not that :P

2:12 i mean, i guess i could be wrong, but you're traversing the whole string a little more than 3 times, and you're calling StringBuilder.append about a zillion times

2:13 whereas a regex replace can look at the front, look at the back, and copy the middle once

2:13 &(rseq "test")

2:13 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Reversible

2:14 amalloy: really? that is super lame

2:14 jblomo: yea, i think you're probably right constructing all those strings

2:14 looks like clojure.string does it manually with recur

2:14 https://github.com/clojure/clojure/blob/f30995c86056959abca53d0ca35dcb9cfa73e6e6/src/clj/clojure/string.clj#L190

2:15 hiredman: or you can write a reduce or a loop

2:15 I mean, regexs :/

2:15 amalloy: hiredman: you usually know the right answer here. is there a reason that (rseq "some-str") doesn't work? of course String doesn't implement Reversible, but anything that's Indexed and Counted should in theory be rseqable

2:15 (and, yes, Strings are none of those *either*, but there's special-casing for count and nth on strings already)

2:17 hiredman: I got nothing

2:17 amalloy: anyone excited about waiting several months for a patch/ticket to be rejected?

3:39 scottj: pinot remotes are awesome

3:51 michaelr525: hello!

3:53 tsdh: Is there a way to make the REPL automatically pretty-print the results of expressions?

3:54 scottj: tsdh: there's a thread from ~1mo ago about that

3:54 tsdh: scottj: Thanks, I'll look it up.

3:56 hiredman: pprint does a pretty good job

3:56 (repl :print pprint)

3:57 it does deref vars, which is kind of annoying

4:00 tsdh: hiredman: Where's the function `repl' defined?

4:01 hiredman: clojure.main

4:03 tsdh: hiredman, scottj: I've found the thread where Phil explains how to do exactly that for leiningen projects. Thanks for the pointer!

4:25 michaelr525: it

4:25 err

4:36 amalloy: so if i write (let [xs (take n (iterate f x))] (last xs)), the compiler does the locals-clearing for me, right? i don't have to worry about hanging onto N (possibly large) elements all at once?

5:01 clgv: how do I set up a local repository for my self-written libraries that leiningen can use? is it possible to do this via leiningen only (plugins)?

5:02 hiredman: lein install

5:03 raek: clgv: you already have one :)

5:03 see "lein help install"

5:05 clgv: raek: I dont get it completely. ok there is already a local repository. but how do it get my own first leiningen project to add to it, so that my second leiningen project can use it?

5:06 scottj: cd project1; lein install; cd project2; add project1 to project.clj ; lein deps

5:07 clgv: scottj: oh thanks. I'll try that in a few

5:07 scottj: or cd project2; ln -s ~/project1 checkouts/project1;

5:07 that way you don't have to lein install all your changes for porject 2 to see them

5:08 clgv: oh that sounds interesting. does the checkout approach give me access to the project without having to build a jar at all?

5:08 scottj: yeah

5:08 btw lein install builds jar for you

5:08 clgv: great. thats even better.

5:09 I only supply the jar once in a while to one of my students

5:10 I remember a repository for java dependencies that was mentioned here - what was its URL?

5:11 * clgv is tidying his build processes^^

5:11 scottj: clojars?

5:11 clojurebot: contributing to clojars is a great idea! see http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1

5:12 clgv: scottj: not really. there are mainly clojure jars. I meant jars of java projects.

5:13 might it be jarvana.com?

5:13 scottj: idk

5:20 clgv: ah maven central as default rpository in leiningen has my dependency as well^^

5:38 robermann: does exist a macro/function similar to javadoc, but working with Clojure's own code? It should point to http://clojuredocs.org/

5:50 scottj: not that I know of, I use (defun jsj-clojure-example (name) (interactive "sFunction (ex. clojure.set/join): ") (browse-url (concat "http://clojuredocs.org/clojure_core/" name "#examples"))) (define-key clojure-mode-map (kbd "C-c d") 'jsj-clojure-example) in emacs

5:52 Raynes: robermann, scottj: https://github.com/dakrone/cd-client

5:54 robermann: thank you both :)

5:54 Raynes: I'll add support to lazybot.

6:00 robermann: Raynes: cd-client does not open a new browser, right?

6:01 Raynes: The browse-to function does, but the rest don't.

6:04 robermann: ok

6:17 clgv: Can I tell leiningen to ignore the .gitignore file in my "classes" directory when performing "lein clean"?

6:24 michaelr525: clgv: i don't know about ignoring from leiningen, but maybe you shouldn't put there the gitignore file..

6:24 afair, you can ignore whole directories from the gitignore at the root directory

6:25 clgv: michaelr525: but then I couldn't keep the "classes" directory in git which is annoying with eclipse ;)

6:26 michaelr525: you want to keep just the directory but not the files in it?

6:27 clgv: indeed

6:28 michaelr525: then you can ignore /classes/* from .gitignore

6:29 clgv: I can, but if there is no file in "classes" it cant be added to git ;)

6:30 it's a hack but there seems to be no way to tell git to create that directory since it only manages files

6:30 michaelr525: you can put a file there, then add two rules to .gitignore, one to ignore everything in classes and another an exception to the first rule for the dummy file

6:31 clgv: but the dummy file will be delete on every "lein clean" which is the annoying thing ,)

6:31 michaelr525: hehe

6:32 and then the directory disappears from git?

6:33 i mean, add file -> add to git with directory -> delete file -> direcotry still in source control?

6:34 clgv: most likely no

6:37 humm the does using the "checkouts" directory require any special way to add the checkout to the dependencies in the project.clj?

6:39 michaelr525: i don't know. but regarding the previous question I just tested it and it keeps the directory.

6:39 clgv: you did a a clone of he project and the directory was created?

6:39 michaelr525: yes

6:40 but the strange file is the deleted file was also there

6:40 hmmm

6:40 s/file/ting

6:40 s/ting/thing

6:40 lazybot: <michaelr525> s/file/thing

6:40 michaelr525: lazybot: (what)

6:41 oh cool

6:43 ah no, you were right

6:43 I didn't commit the changes

6:43 the directory disappears on clone

6:43 clgv: directories are only part of the name of the files in git afaik

6:44 michaelr525: ah

7:01 triyo_: Is there a way to compile/build a .clj file as if it where a .cljs file in ClojureScript? I have a Clojure module that fully conforms to ClojureScript.

7:04 triyo: Meaning if I rename my file to .cljs, it compiles.

7:06 manutter1: triyo: not quite sure what you mean by "compile/build as if it were a .cljs file"

7:06 you mean compile it as JavaScript?

7:06 triyo: To compile a cljs to js, you run (closure/build ...)

7:06 yup

7:07 so I have a module that actually can be used in Clojure and ClojureScript

7:08 manutter1: what operating system? If you're running Linux you might try making a symbolic link to the .clj file and give the link a .cljs suffix

7:08 dunno if that would work in windows

7:08 triyo: However, to compile it in CLJS space, I have to rename the file.... I could right a script that does that automatically during cljs build process.

7:09 or as you say a s-link

7:09 Wondering if this would be a common practice. Soundsa bit to hackish

7:11 I'm looking at the source and the .cljs extensions are hardcoded.

7:11 Fossi: that sucks

7:11 a lot

7:12 Raynes: Man, that was stupid. I ran 'cake killall' on my server. I just killed every website/service that I run on that thing. :|

7:12 * Raynes makes sure 4clojure is still up.

7:12 Raynes: I guess it isn't running off a cake instance, thankfully.

7:12 triyo: Raynes: thats not to bad. Last week I ran rsync on higher level directory. ;)

7:13 Raynes: :)

7:15 $cd clojure.core map

7:15 lazybot: clojure.core/sorted-map: http://clojuredocs.org/v/1494

7:15 clojure.core/ns-unmap: http://clojuredocs.org/v/1577

7:15 clojure.core/zipmap: http://clojuredocs.org/v/1579

7:15 Raynes: $examples clojure.core map

7:15 lazybot: https://gist.github.com/1180686

7:16 Raynes: Ladies and gentlement, I give you clojuredocs support in lazybot. Enjoy.

7:16 * manutter1 cheers

7:17 pyr: nice!

7:17 triyo: very cool

7:30 robermann: cool!

7:32 clgv: $help

7:32 lazybot: You're going to need to tell me what you want help with.

7:32 clgv: $help cd

7:32 lazybot: clgv: Search clojuredocs for something.

7:33 Raynes: Yeah, that isn't all that helpful.

7:33 clgv: hmm a command listing when using $help would be great ;)

7:33 manutter1: $help commands

7:33 lazybot: Topic: "commands" doesn't exist!

7:33 Raynes: I think there is a command that lists commands somewhere.

7:34 Oh, I commented it out. I think there was an issue where there were so many commands that I couldn't gist them all.

7:35 clgv: Raynes: could you provide a lazybot instance for #clojure.de as well?

7:35 Raynes: There was an outdated partially hand-written list of commands on the wiki, but I moved the repo recently and it broke all the links.

7:36 Sure.

7:36 $join #clojure.de

7:36 lazybot: Raynes: It is not the case that you don't not unhave insufficient privileges to do this.

7:36 Raynes: $login

7:36 lazybot: You've been logged in.

7:36 Raynes: $join #clojure.de

7:36 I'll make him autojoin there.

7:36 clgv: ah nice. thx. :)

7:36 lets see what happens when I do that:

7:36 $login

7:36 humm nothing like I guessed ;)

7:37 Raynes: :p

7:38 He's actually supposed to print a message saying that your credentials are incorrect, but it threw an NPE instead.

7:38 manutter1: Not as informative, but just as effective :)

7:38 clgv: lol, k. I always cause exceptions in other peoples software ;)

7:39 it's hobby of mine :P

7:44 java.classpath still has no official release on clojars where the warn-on-reflection flag is disabled. there only SNAPSHOT versions of others which leiningen complains about when building an uberjar

7:44 $login

7:45 Raynes: $shell git pull

7:45 lazybot: Updating f88166f..b36c238 Fast-forward src/lazybot/plugins/login.clj | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)

7:45 Raynes: $reload

7:45 lazybot: Reloaded successfully.

7:45 Raynes: clgv: Give that another go.

7:45 clgv: $login

7:45 lazybot: Username and password combination/hostmask do not match.

7:45 Raynes: There we go.

7:45 clgv: :)

8:22 michaelr525: hey

8:22 !

8:22 (set-face-attribute 'default nil :font "Droid Sans Mono-12" :weight 'bold)

8:22

8:22 how to set my font to be bold by default?

8:22 the above line doesn't do it

8:27 Fossi: i guess you should ask in #emacs or such

8:29 michaelr525: good idea!!!

8:36 solussd: what happened to clojure.str/as-str ?

8:36 *clojure.string/as-str

8:37 chouser: what does it do?

8:39 solussd: ,(clojure.string/as-str :mykeyword)

8:39 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>

8:39 solussd: should return "mykeyword"

8:39 chouser: solussd: I think 'name' works for that now

8:40 solussd: well, it was in clojure.contrib.string is clojure.string not the same thing?

8:40 ok

8:40 ,(name :blah)

8:40 clojurebot: "blah"

8:40 solussd: cool thanks

8:40 chouser: np

8:57 clgv: What happens if I reference multiple standalone uberjars in my clojure main project where each of these uberjars may contain a different clojure version?

9:01 manutter1: cljv: (cue the bit from Ghostbusters where he warns the mayor about "fire raining from the skies, cats and dogs living together" etc...)

9:02 My Java skills are way rusty, but I do remember Classpath Version Hell

9:02 robermann: how could I customize "lein repl" startup? For example, I'd like to execute some predefined use/require, something as http://www.learningclojure.com/2010/03/conditioning-repl.html

9:03 cljv: in general, the first element found in the classpath will be used

9:06 michaelr525: I wonder in what use case can Aleph be usefull?

9:06 Especially in the context of using it for web server/service.

9:07 https://github.com/ztellman/aleph/

9:07 I wonder

9:07 I wanda

9:07 I wonder

9:07 I wanda

9:07 robermann: michaelr525: async web service client

9:08 the caller is not locked in waiting the response

9:08 michaelr525: there is nothing new in this, that's what ajax is about

9:08 where aleph makes things simpler/advanced?

9:09 clgv: is there a lein plugin for packaging a jar (not uberjar) together with its dependencies other than clojure&contrib in an archive?

9:09 robermann: Aleph seems server-side

9:10 (both sides)

9:11 michaelr525: the async server (async response) is new, but I can't think of a case where this can be usefull

9:11 tomoj: websocket is an example

9:12 michaelr525: for websocket why and aleph async web server would be better than a regular web server?

9:12 robermann: I could think all use cases targeted now by JMS/Tibco

9:12 tomoj: it might be, because this is something netty is good at

9:12 also consider implementing something like the twitter streaming api

9:13 michaelr525: sorry, not familiar with it..

9:13 tomoj: well, just long-lived streaming http responses with live updates from different sources coming in

9:13 aleph makes that a piece of cake

9:13 michaelr525: oh

9:13 robermann: async messaging services server 2 server

9:13 michaelr525: hmm

9:14 tomoj: I don't even know how you might do it another way

9:14 robermann: in http

9:14 suppose, for example, you want send data from your server to another server which would collect your logs

9:15 why your thread should wait the response?

9:15 michaelr525: it shouldn't, you create a new thread and make a request :)

9:16 tomoj: if that works, you don't need aleph

9:16 robermann: but that thread would lock the caller, in general; you could also give it to a framework an free your thread

9:16 michaelr525: that's why I wonder

9:17 tomoj: if you're serving thousands of websocket connections, that won't work :)

9:17 s/thousands/<big number>/

9:17 robermann: it is the reason which lies under java io versus java nio

9:17 michaelr525: shit, i have to catch a train, sorry to leave in the middle of an interesting discussion, but I'll be back in half an hour or so

9:18 tomoj: yeah, the spots where aleph is going to be useful are mostly the spots where async io would be useful

9:18 robermann: no problem; this discussion could be of your interest http://java.dzone.com/articles/java-nio-vs-io

9:20 (although that discussion is on java)

9:29 st3fan: is there a better solution for https://gist.github.com/1180874 ?

9:30 i wish i could see other people's solutions on 4clojure

9:31 manutter1: Depends on your definition of "better" I suppose. :)

9:31 st3fan: manutter1: more elegant :)

9:31 manutter1: What problem number is that again?

9:31 clgv: st3fan: there should be a more efficient one with respect to runtime

9:31 Scriptor: manutter1: https://4clojure.com/problem/27

9:31 hmm, can't seem to log back into 4clojure

9:32 st3fan: just wondering if i really need to special case the string one

9:32 clgv: st3fan: strings behave like seqs

9:32 gtklocker: Hello clojures

9:32 clgv: &(reverse "blablubb")

9:32 lazybot: ⇒ (\b \b \u \l \b \a \l \b)

9:32 st3fan: &(seq '(1 2 3))

9:32 lazybot: ⇒ (1 2 3)

9:32 st3fan: oh!

9:33 one sec :)

9:33 clgv: &(= "blaalb" (reverse "blaalb"))

9:33 lazybot: ⇒ false

9:33 Scriptor: yea, it's easily a one liner :)

9:33 clgv: lol haha

9:33 &(= (seq "blaalb") (reverse "blaalb"))

9:33 lazybot: ⇒ true

9:33 st3fan: yeah so this is nicer: https://gist.github.com/1180887

9:34 Scriptor: that's what I have, although I used the shortcut syntax

9:34 for anonymous functions

9:34 st3fan: right

9:34 4clojure is great

9:34 learning a lot

9:35 clgv: if you know you have something with a given length (i.e. no lazy-seq) then you can be more efficient by iterating from front to middle and back to middle while comparing

9:35 then you will only have n/2 comparisons and not n

9:36 st3fan: smart

9:37 manutter1: ,(/ 5 2)

9:37 clojurebot: 5/2

9:38 manutter1: $findfn [5 2] 2

9:38 lazybot: [clojure.core/second clojure.core/last clojure.core/count clojure.core/peek clojure.core/fnext]

9:39 clgv: &(quot 5 2)

9:39 lazybot: ⇒ 2

9:40 manutter1: Oh yeah, that's what I was looking for :)

9:40 clgv: $findfn 5 2 2

9:40 lazybot: [clojure.core/max-key clojure.core/cond clojure.core/dosync clojure.core/sync clojure.core/char-escape-string clojure.core/with-loading-context clojure.core/*clojure-version* clojure.core/with-precision clojure.core/quot clojure.core/case clojure.core/min-key cloju... https://gist.github.com/1180907

9:41 tomoj: whee

9:41 clgv: $findfn 7 3 2

9:41 lazybot: [clojure.core/quot clojure.core/unchecked-divide]

9:44 robermann: ,show logs

9:44 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: show in this context, compiling:(NO_SOURCE_PATH:0)>

9:47 ohpauleez: is findfn only part of sexpbot?

9:48 clgv: ohpauleez: it is part of lazybot

9:49 ohpauleez: clgv: thanks

9:51 mattmitchell: Is there a way to view the source code of a function? I seem to remember a repl utility that allowed you to do that?

9:51 coopernurse: mattmitchell: (source foo)

9:52 mattmitchell: coopernurse: hmm, I got "unable to resolve symbol: source in this context"

9:52 clgv: &(source source)

9:52 lazybot: java.lang.Exception: Unable to resolve symbol: source in this context

9:52 clgv: &(source doc)

9:52 lazybot: java.lang.Exception: Unable to resolve symbol: source in this context

9:53 mattmitchell: coopernurse: is that in the repl only?

9:53 I'm in emacs using slime

9:53 michaelr525: back!

9:53 clgv: its either clojure.repl or clojure.contrib.repl-utils

9:54 coopernurse: mattmitchell: I'm reading the docs to source, and it will only work if the .clj file is in the classpath

9:54 mattmitchell: coopernurse: ok, is it clojure.contrib.repl-utils/source ?

9:54 clgv: &(use 'clojure.repl)

9:54 lazybot: ⇒ nil

9:54 clgv: &(source source)

9:54 lazybot: ⇒ Source not found nil

9:54 clgv: &(source doc)

9:54 lazybot: ⇒ Source not found nil

9:54 clgv: &(source defn)

9:54 lazybot: ⇒ Source not found nil

9:55 clgv: hm lazybot seems not to have access to the sources

9:55 coopernurse: &(doc source)

9:55 lazybot: ⇒ "Macro ([n]); Prints the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Example: (source filter)"

9:55 mattmitchell: ,clojure.contrib.repl-utils/source

9:55 clojurebot: #<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.repl-utils, compiling:(NO_SOURCE_PATH:0)>

9:55 Raynes: $help source

9:55 lazybot: Raynes: Link to the source code of a Clojure function or macro.

9:55 Raynes: But that command only works for core and contrib namespaces.

9:55 coopernurse: yeah, so I think it all depends on whether you have source in your classpath

9:55 I'm not sure if clojure.jar contains .clj files, or just .class files

9:56 let me look

9:56 Raynes: $cd clojure.repl source

9:56 lazybot: clojure.repl/source: http://clojuredocs.org/v/2445

9:56 clojure.repl/source-fn: http://clojuredocs.org/v/2449

9:56 robermann: coopernurse: contains also .cli

9:56 coopernurse: robermann: yeah, jar tvf shows a fair number of .clj files

10:03 st3fan: hm wow the web repl on http://try-clojure.org/ is awesome

10:04 i want to make an ipad specific version of that

10:04 ipad optimized

10:10 coopernurse: st3fan: yeah, someone released a clojure repl for android. nifty, but w/o a real keyboard, not something to spend much time with imho

10:12 st3fan: i know .. will just be nice to play around when i am bored and i just have my iphone or ipad with me

10:13 hm i could do a special keyboard for the iPad with a bunch of shortcuts

10:13 TimMc: giant paren buttons

10:14 and other braces

10:14 st3fan: yeah

10:14 TimMc: Or with paredit mode, just the opening braces.

10:18 st3fan: i find paredit really tricky to use

10:18 specially when you need to correct things

10:18 TimMc: It took a little getting used to.

10:18 Keep the cheatsheet handy.

10:18 st3fan: but i probably simply don't know the right commands

10:24 robermann: is it possible to customize "lein repl" with an auto-load script?

10:25 clgv: see :repl-init at https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L102

10:29 ddwwk: I'm having issues with clojure.java.shell. (sh "wget" "https://example.com/50meg.mp3") hangs

10:29 where example.com is not real

10:30 somethings work, but large files aren't working. And I've read around somewhere that the io can be glitchy with shell, but I can't figure out a workaround

10:30 robermann: clgv: it seems to work when using "lein interactive" (because requires a project.clj) and not "lein repl"? I mean, in order to use :repl-init I need a project.clj in the current dir?

10:34 clgv: robermann: right, :repl-init is for projects. I don't know if there are other configuration options for "lein repl" outside of projects.

10:36 pjstadig: ddwwk: could you not just use an HTTP client to get the file?

10:38 ddwwk: pjstadig: I'd like to, but I had to use a patched version of clj-http that supports cookies (for authentication), and after a looong time of testing I still couldn't figure out how to get the cookies to work.

10:38 actually, the clj-http was returning 'ssl failed with peer" or something like that

10:40 so I might have needed to make clj-http ignore ssl mismatches, but wget seemed to be the solution of least drag.. because I was able to export the cookies from cookies from selenium in such a way as to allow wget to actually succeed from the command line

10:41 clj-webdriver has been kicking a$$

10:41 robermann: clgv: mmm after googling a bit it seems that just having a user.clj in the classpath should solve my needs

10:41 ddwwk: if only it had a headless "get" command, it'd kick more

10:41 clgv: robermann: ah interesting

11:11 okidowu: help wanted on running clojure in NB 6.91. Downloaded and installed plug-in. problem with maven build/compile

11:11 pjstadig: ddwwk: you could also try a Java http client...it sounds like shelling out isn't going to work reliably

11:11 ddwwk: pjstadig: I may have to do that. like use common's http client directly

11:14 okidowu: Hi, has any one used NB clojure

11:15 coopernurse: okidowu: no, but do use intellij

11:16 okidowu: Need a free IDE

11:18 coopernurse: okidowu: intellij community edition is free, and works with la clojure

11:18 TimMc: okidowu: emacs

11:18 clgv: okidowu: eclipse and CCW are free

11:19 * ddwwk likes ccw

11:19 coopernurse: okidowu: install screencast here for intellij/clojure: http://www.screenr.com/PEMs

11:20 okidowu: ok will try. thanks

11:24 dnolen: ambrosebs is on a roll, https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/numbers.clj

11:25 ambrosebs: dnolen: starting to get the hang of reading prolog :)

11:26 one thing that struck me is the declarative docstring

11:27 communicates the role of the function perfectly

11:29 dnolen: ambrosebs: very cool.

11:31 speaking of which, one big hurdle I'd like to cross with core.logic is environment trimming / runtime groundness analysis. Would really bring us within striking distance of SWI-Prolog perf on many more benchmarks. would also make core.logic efficient for parsing.

11:33 ambrosebs: dnolen: what do you mean by parsing?

11:34 dnolen: Prolog has definite clause grammars, so it's ideal for parsing and it doesn't have the lexing/parsing distinction.

11:35 ambrosebs: *opens prolog book*

11:37 pdk: [11:33] <ambrosebs> dnolen: what do you mean by parsing?

11:37 parsing in general or

11:38 ddwwk: so one could build languages?

11:39 ambrosebs: pdk: parsing definitive clause grammars .. I think

11:45 "A very important application area of Prolog is parsing. In fact, Prolog originated from attempts to use logic to express grammar rules and to formalize the process of parsing"

11:57 ddwwk: so I am looking over the clj-http tests and I see the headers expressed in this way: {:headers {"Accept-Encoding" "identity, gzip"}}

11:57 and {:headers {"Accept" "application/json"}}

11:58 so, I'm wondering if something like this would work: {:headers {"Cookies" "name=value; name2=value2"}}

12:00 TimMc: ddwwk: How long would those cookies last, and what domain are they attached to?

12:02 ddwwk: TimMc: not long. I'm using them in conjunction with clj-webdriver (selenium) that crawls a Remedy work ticket web interface. Trying to automate the downloading of documents.

12:04 it looks like Accept and Accept-Encoding are hardcoded into clj-http

12:04 in case statements

12:05 can't tell yet if random other headers are merged in

12:05 insideout: on that topic, does anyone know what is the best fork of clj-http?

12:06 ddwwk: I'm looking at: https://github.com/vitalyper/clj-http/blob/master/src/clj_http/client.clj

12:06 which seems fairly recent, with some tweaks

12:06 brb

12:11 insideout: ddwwk: it see wrap-accept and wrap-accept-encoding. is that what you mean?

12:18 dnolen: ambrosebs: using Prolog for parsing is pretty sweet. Again, the beautiful part is that you don't need a separate lexing step.

12:20 ambrosebs: dnolen: so is it just perf that stops us doing similar things in minikanren?

12:20 or is there something tied to prolog?

12:20 dnolen: ambrosebs: DCG stuff is already there. But it's not efficient because of the lack of groundness analysis and lack of environment trimming.

12:22 ambrosebs: right, I'm guessing other minikanren implementations do this?

12:22 edw: Is there an HTTP *client* out there that will return a ring-style response?

12:22 dnolen: ambrosebs: they do not.

12:22 ambrosebs: ah :)

12:23 dnolen: ambrosebs: it's a problem with miniKanren's design that I'd like to solve.

12:23 ambrosebs: it's not a big deal for many logic programs. But for parsing where you're looking at every single character, you do not want to unify and grow your substitution map for each char.

12:26 ambrosebs: dnolen: interesting

12:27 dnolen: ambrosebs: I did a bunch of work on it, but I didn't arrive at a satisfactory solution.

12:28 ambrosebs: dnolen: good to hear

12:29 I think it's about time I studied the minikanren implementation

12:29 haven't read most of Byrd's dissertation yet

12:30 dnolen: ambrosebs: it's pretty cool. I would look at the Scheme miniKanren implementation since it's a lot less code to look at ~200 lines. my implementation is hardly any different - just longer because of perf reasons and because Clojure terms are not just lists.

12:31 ambrosebs: 200? sheesh

12:31 dnolen: ambrosebs: yeah it's pretty amazing.

12:57 ddwwk: back

13:00 insideout: yea, I don't see an extra "wrap-any-other-headers"

13:02 this version has cookie support: https://github.com/r0man/clj-http/tree/cookies

13:03 but I was getting ssl errors, so I am still not sure whether I was feeding it cookies in the correct format.

13:04 TimMc: ddwwk: What I meant was, that isn't enough information for cookies.

13:05 ddwwk: TimMc: ah.. yes.. as I've been investigating it though, I believe the other information associated with cookies are held by the browser.

13:05 when we send a get request that has cookies associated with it, at least for wget, it only wants the name value pairs, and not the expiration date, the domain, etc.

13:06 within the http header of the get request

13:06 TimMc: Ah, I suppose there's a difference between setting a new cookie (which needs that info) and updating the value of an existing one.

13:06 ddwwk: in the browser state, however, it'll have more thorough informatino

13:06 right

13:06 I think when the server sets the cookie, it sends all the information

13:07 TimMc: Still, the first time you set it, you need all that stuff.

13:07 ddwwk: TimMc: yea, and selenium has all that stuff because it is automating a real instance of the browser.

13:08 so I wonder, does clj-http (cookie version) want only the cookies as described in a get header, or the full cookies, as would be managed by a client.

13:09 and then apache.commons http client would have to know what to do with the full cookie objects when creating the get

13:24 this might work: https://github.com/mamciek/clj-http/blob/fc1033c48ba917b48c8bd1a8eaef4bef6152536d/src/clj_http/core.clj

13:33 This is good too: https://github.com/mattrepl/clj-apache-http/tree/5f7c156c557bd5c97d5b03da406d8ac6bfbfad37

13:33 commenting here for later reference

13:52 amalloy: st3fan: what paredit is *especially* good at is correcting things. if you find it harder to do with paredit than without, you're missing out on some cool commands

13:54 ibdknox: dnolen: when did cljs get :use?

13:55 dnolen: ibdknox: I submitted a patch (not worked in yet), you'll see the problem even if you switch to require.

13:55 ibdknox: http://dev.clojure.org/jira/browse/CLJS-65

13:55 ibdknox: dnolen: awesome

13:57 dnolen: k, I'll look into it. I wonder if I have to clean the output directory.. :/

13:59 dnolen: ibdknox: yeah the :use :only thing is nice. hopefully the patch is up to snuff. ClojureScript compiler is not scary.

13:59 scottj: dnolen: :use :only works with cljs-watch for me with pinot, but not with my own namespaces

13:59 ibdknox: out of curiosity

13:59 dnolen: scottj: can you elaborate your issue on that ticket ?

14:00 ibdknox: have either of you tried compiling from the repl?

14:00 scottj: dnolen: where are you getting the warning and error, my cljs-watch does't look like that?

14:00 ibdknox: I suspect this is a compiler level issue

14:00 scottj: ibdknox: nope

14:01 dnolen: ibdknox: that's what I was doing before. in fact when working on :use :only cljs-watch wasn't working for me, so switch to compiling from REPL

14:01 scottj: sorry I confused, I thought you were saying the patch didn't work on your own namespaces ?

14:02 ibdknox: dnolen: hmm, well the only thing I'm doing is calling cljs.closure/build

14:02 scottj: dnolen: at least in cljs-watch, yes, I haven't tried outside that. I was wondering if the output in issue you posted was actually from cljs-watch, since I don't get that maybe I'm behind

14:03 ibdknox: scottj: that's a compiler error

14:03 scottj: you only get that when the javascript engine chokes

14:03 dnolen: ibdknox: yeah it's not clear to me what's going on, cljs-watch chokes, compiling at REPL works. I admit I didn't look really closely.

14:04 ibdknox: dnolen: no worries :)

14:07 weird

14:08 doing require works for me

14:08 with cljs-watch

14:09 dnolen: scottj: ibdknox: stuff to look into :) I wasn't sure I got my patch 100% and this good stuff to know.

14:09 scottj: ibdknox: do you think not having access to request will be a problem with remotes? I think with json you can return cookies, with remotes you'd have to do it in js instead of http I think

14:10 ibdknox: you mean requireing and using the same thing works? I tried that without success

14:10 ibdknox: scottj: do you have dnolen's patch for use?

14:10 scottj: yeah

14:10 I'm using it with pinot namespaces fine

14:10 ibdknox: I haven't tried it with that yet

14:10 without it

14:10 cljs is working

14:10 err

14:10 cljs-watch

14:10 scottj: ok, I see

14:11 ibdknox: it may have nothing to do with that, though :)

14:11 scottj: one advantage of :use :only is it makes ctags work better

14:12 if you have ph/html you can't M-. to go to the definition, but with use only you'll have html and then M-. works

14:13 ibdknox: ok

14:13 yeah, I confirmed that it worked with the latest cljs

14:13 and multiple local files

14:13 tried it with 3 local ns's

14:13 now trying from scratch, just to make sure

14:15 scottj: ibdknox: btw I still have .#foo.cljs problems

14:15 my file had unsaved changes in emacs, Building ClojureScript files in :: srcjava.io.FileNotFoundException: The file src/emailatask/cljs/.#frontend.cljs does not exist.

14:16 ibdknox: just updates cljs-watch, still have problem. Are you just using or actually calling the functions after using them?

14:18 ibdknox: I just put that file in my directory

14:18 .#frontend.cljs

14:18 it doesn't pick it up

14:18 scottj: did you put cljs-watch on your path?

14:19 mattmitchell: how do you get the highest int value out of a list?

14:19 ibdknox: m(doc max)

14:19 ,(doc max)

14:19 clojurebot: "([x] [x y] [x y & more]); Returns the greatest of the nums."

14:19 mattmitchell: doh! max :)

14:19 thanks

14:19 ibdknox: ,(apply max [1 2 3])

14:19 clojurebot: 3

14:20 amalloy: &(apply min-key - [1 2 3]) ;; if you want people to hate you

14:20 lazybot: ⇒ 3

14:20 ibdknox: lol

14:21 :-p

14:22 amalloy: &(last (sort [1 2 3])) ;; if you want to leave in some slow bits to magically improve later?

14:22 lazybot: ⇒ 3

14:22 ibdknox: scottj: because if you did, you'll have to copy that file over every time you pull

14:22 amalloy: gotta get that job security ;)

14:24 dnolen: I'll try your patch tonight, but I'm fairly confident a base install of clojurescript and cljs-watch are working ok with local requires

14:24 scottj: ibdknox: my path includes ~/src/cljs-watch which is the repo, copy where?

14:25 ibdknox: scottj: k, a lot of people simply copy the script into something already on their path

14:25 scottj: if I touch .\#foo.cljs realfile.cljs then I get a NPE probably bc .\#foo.cljs doesn't have namespace

14:26 where in cljs are you blocking . files?

14:26 oh ext-filter

14:26 ibdknox: https://github.com/ibdknox/cljs-watch/blob/master/cljs-watch#L53

14:27 scottj: the only way I can see that failing is if your system isn't reporting the correct name

14:30 scottj: ibdknox: it's some kind of link, I don't know about this stuff. lrwxrwxrwx 1 scott scott 27 2011-08-30 14:28 .#frontend.cljs -> scott@mamey.8204:1314574098

14:30 it doesn't .exists or .isFile in java

14:31 furd: I'm having a really confusing issue where I have two functions that do the same thing.

14:31 ibdknox: scottj: wait... it doesn't pass .isFile?

14:32 scottj: it's kind of a good warning that I haven't saved :)

14:32 furd: One of them dramatically faster than the other.

14:32 ibdknox: scottj: because that line also checks for that too

14:32 furd: But when I use the faster version of the function in another function, the results I get are much, much slower when compared to the.. slower function?

14:32 ibdknox: furd: are you using lazy-seqs?

14:32 furd: I put up a https://gist.github.com/1181618

14:33 rindolf: Hi all. Is the best way to work on clojure code be using Counterclockwise+Eclipse, or do people here use vim/etc.?

14:33 furd: It's being passed a lazy-seq in the form of a range

14:34 ibdknox: rindolf: I think emacs is the most prevalent here

14:34 technomancy: rindolf: usually the best way is whatever you're already most comfortable with

14:34 scottj: ibdknox: are you manually editing cljs-watch and the .clj file

14:34 ibdknox: rindolf: I use vim most of the time though

14:34 rindolf: ibdknox: ah, OK.

14:34 ibdknox: scottj: sadly, yes

14:35 ibdknox: once I move it into clojurescript, I won't have to have the file embedded

14:35 lol

14:35 talking to myself again

14:40 srid: Ouroboros

14:40 scottj: ibdknox: does cljs-watch filtering only effect what files it watches not what files cljs compiles?

14:42 ibdknox: scottj: correct

14:42 amalloy: technomancy: well, i learned emacs for clojure and i'm glad i did. but it's reasonable to stick with what you know for a while so that it's less overwhelming

14:42 ibdknox: scottj: your issue is probably with the compiler itself

14:43 scottj: ibdknox: yeah I think so

14:44 furd: I don't understand why the function that is so much slower in isolation would provide results so much faster when given a range vs the other, faster sum-divisors function, am I missing something huge and life altering?

14:45 ibdknox: scottj: btw, in response to the remotes thing, you should be able to set cookies like you normally would in noir inside of a remote

14:46 furd: I would continue to simplify your case

14:46 scottj: ibdknox: oh I'm not using noir, do you put your cookies on the ring response map?

14:46 ibdknox: scottj: later down the line, yes

14:46 scottj: ibdknox: that's another thing, remotes worked great with compojure w/o noir I hope that's able to continue

14:46 dnolen: ibdknox: yeah, not certain what's up, was pretty sure I tested several times w/o my patch. If I run into the issue again I will elaborate the exact steps to reproduce.

14:47 scottj: ibdknox: if you return a map from a remote it's not treated as a ring response map is it?

14:47 ibdknox: scottj: I probably won't go out my way to do that, no, since the point is to provide an end to end solution

14:47 scottj: ibdknox: btw it was cool how remotes are just functions and you can call them on the clojure side too

14:48 ibdknox: dnolen: okidoke, let me know :)

14:48 scottj: what's pinotid for?

14:49 ibdknox: scottj: events primarily

14:51 scottj: ibdknox: have you used advanced mode? I did run into a problem where some code worked fine in normal mode but the event type got removed in advanced mode I suspected because the compiler just saw :submit not the event name EventType/SUBMIT or whatever it is

14:53 ibdknox: scottj: I haven't messed with advanced much yet, since it takes so much longer to compile. Those issues should be pretty easy to fix though.

14:53 scottj: I actually do lookup EventType/*

14:53 scottj: ibdknox: maybe at runtime not compile time

14:55 ibdknox: also, a plain ajax helper function would be a nice additon to pinot

14:56 simard: I'm trying to run the mandlebrot example that uses penumbra, but I'm getting an error when evaluating (ns example.gpgpu.mandelbrot ...) with slime after a few seconds: org.lwjgl.DefaultSysImplementation.getPointerSize()I [Thrown class java.lang.UnsatisfiedLinkError]

14:57 amalloy: simard: missing a native library, i guess?

14:57 simard: I can see a few INFO lines from the "lein swank" server before this happens, saying PM penumbra.Natives extractNativeLibs

14:57 I did run lein deps and lein native-deps before, but I guess I'm still missing something

14:58 technomancy: supposedly penumbra sidesteps the whole native-deps stage now

14:58 it handles all the native code internally

15:00 furd: ibdknox: Okay, I went to a more simple case of filtering a range using the predicate to remove other factors but I still can't see how this is possible: https://gist.github.com/1181618

15:03 amalloy: furd: for example, A could be faster at small numbers while B is faster at large numbers

15:03 for your particular functions i don't know if that's the case, but it's easily possible

15:04 but also your most recent gist times sum-divisors the first time, and abundantlist the second, so you can't draw any strong correlations between the two input sizes

15:06 ibdknox: scottj: yeah I'll get to adding those sorts of things eventually :)

15:06 furd: amalloy: A is faster until about 5, and then B becomes faster and faster as time goes on

15:07 amalloy: Timing the two different functions was to see sum-divisors in isolation vs a function that uses sum-divisors

15:08 amalloy: when using filter on a range it should be just like using the function on one number, just over and over right?

15:10 ddwwk: it would be cool to edit cljs from http://www.ymacs.org/demo/

15:21 furd: Hmm so I printed out the times for individual numbers in a range and yeah, it seems that specific numbers are much faster with B than A and some numbers are much faster with A than B. Fun.

15:21 Thanks for the help, sorry for the newbie ridiculousness.

15:23 simard: do I need to install/load SLIME before M-x clojure-jack-in ? and where should I run that command from anyway, core.clj ?

15:23 (should I actually unload/uninstall SLIME before trying M-x clojure-jack-in ?)

15:23 hiredman: just run clojure-jack-in

15:25 amalloy: furd: i just noticed (let [sum (reduce * ...)]). is that really what you meant? it seems so implausible that you can get a meaningful sum by multiplying a bunch of numbers

15:25 simard: if I C-x C-e I get: Symbol's function definition is void: lisp-eval-last-sexp

15:25 hiredman: what version of emacs?

15:26 simard: 23.3.1

15:26 hiredman: wait

15:26 C-x C-e what?

15:26 furd: amalloy: Its a method of getting the sum of all the divisors of a number by finding the prime factors and multiplying them together

15:26 hiredman: new to emacs?

15:26 M-x clojure-jack-in

15:26 simard: hiredman: C-x C-e anything from a Clojure buffer

15:26 say.. a string

15:26 or a number, or anything

15:27 hiredman: did you run clojure-jack-in?

15:27 simard: yes :)

15:27 hiredman: and what happened?

15:27 simard: I do have that *swank* buffer, that says a server is listening on port 63217

15:27 furd: amalloy: http://planetmath.org/encyclopedia/FormulaForSumOfDivisors.html has a breakdown of the algorithm

15:27 hiredman: do you have a slime buffer?

15:28 amalloy: furd: the prime factors of 10 are 5 and 2, which multiply to 10. the sum of the divisors of 10 is 5+2+1=8, right?

15:28 simard: no, not right now

15:28 the core.clj only has the Clojure mode on

15:28 hiredman: so for some reason it failed to conenct

15:28 M-x slime-connect

15:28 simard: hum prolly my .emacs then

15:28 hiredman: localhost

15:28 63217

15:28 simard: yeah it works

15:29 amalloy: furd: thanks for the link, looks interesting

15:29 furd: amalloy: You take the exponents of the primes, increase it by one, subtract one from that total and divide it by the prime - 1

15:29 simard: isn't clojure-jack-in supposed to do that though ?

15:29 hiredman: yes

15:29 but it failed for some reason

15:29 simard: ok, I'll clean up my .emacs a little

15:29 perhaps some slime configuration there that's messing with clojure-mode

15:30 furd: amalloy: It works a bit quicker than simply getting the divisors in a lot of cases as it turns out but I'm still not well versed in clojure enough for my implementation to seem very clean

15:34 Somelauw: #python-forum

15:40 amalloy: furd: i made it a little more readable, i think, at https://gist.github.com/1181797 - i don't understand what the (if) test is for, or i think it could be made nicer

15:44 furd: amalloy: Awesome, thanks!

15:45 amalloy: The if statement was because I needed the sum of "proper" divisors

15:45 amalloy: And that algorithm includes the number itself in the count of divisors which ins't proper

15:46 amalloy: so just subtract the number itself at the end?

15:46 furd: amalloy: So I had it remove the number from the total, unless it was 1 (in the case of primes)

15:46 amalloy: Maybe I should have it just do a prime check at the start instead, I'll compare the speed difference

15:46 amalloy: furd: sorry, i meant the first if

15:46 the one inside the map/for

15:47 furd: amalloy: Oooh

15:47 amalloy: Just another section of that algorithm that isn't listed on that site. If the prime only has one occurrence in the list of prime factors

15:47 amalloy: You can get the number by adding one to the number instead of doing the other calculations

15:48 amalloy: I'm really terrible at knowing what would be faster/slower so if actually doing that check is slower than just computing it every time that could be removed I suppose as it still gets you the same result

15:49 amalloy: no, it's got to be faster with the test

15:49 Pisketti: Paredit is driving me crazy. Is there really not a way to delete (move) a single paren without disabling paredit? Help!

15:50 amalloy: Pisketti: stop trying to delete/move parens, and use the paredit commands for sexp editing

15:50 hiredman: Pisketti: why would you do that?

15:50 amalloy: what form do you have now, and what do you want?

15:50 Pisketti: Sometimes it's easier to move a single paren than some big chunk of stuff inside the parens

15:50 amalloy: Pisketti: that's only true if you don't know how to do things with paredit

15:50 hiredman: M-s or M-r

15:51 Pisketti: that's probably very true

15:51 dnolen: Pisketti: select the paren and cut it out. but there commands for moving the left/right paren

15:51 amalloy: Pisketti: so if you believe it's true, then learn how to use paredit instead of looking for escape hatches to do stuff the hard way

15:53 (which is why i prposed you tell us what you have and what you wish you had: then you can learn the right way)

15:53 Pisketti: amalloy: Ok. I'll do that. Do you have any tips for where to look for enlightenment? :)

15:53 amalloy: yes, in #clojure or #emacs or #lisp or http://www.emacswiki.org/emacs/PareditCheatsheet

15:54 Pisketti: Well, one specific example. I have a list and I want to remove the parens altogether. How do I proceed?

15:54 amalloy: like hiredman said, M-r

15:54 er, M-s

15:55 Pisketti: okay, I missed that. Thanks both of you.

15:58 Netpilgrim: Pisketti: I'm also in the process of learning to use paredit. It's great but doesn't work in slime-repl without some rebinding of keys (e.g. M-s).

16:00 Pisketti: Netpilgrim: You've overcome the moments when you just want to turn it off?-)

16:03 rata_: hi

16:03 Netpilgrim: Pisketti: I have turned it off before in the repl because I was to lazy to rebind the keys. But I already don't know how I ever edited clojure source buffers without it. You basically don't have to think about parens at all anymore.

16:03 rata_: Netpilgrim: rainbow-parens? paredit?

16:04 Netpilgrim: rata_: paredit; what's rainbow-parens?

16:04 rata_: you must see it

16:04 Netpilgrim: rata_: O wait, I think I've seen it somewhere. It colors corresponding parens, right?

16:05 rata_: yes

16:06 I love it... clojure code seems a little bit plain otherwise

16:06 Pisketti: Netpilgrim: I'm sure paredit is great once you learn to use it. Currently my biggest problem is ignorance.

16:07 Netpilgrim: rata_: Perhaps I'll give it a try but I think it might be too intrusive – too much color for things I don't really have to see with automatic indentation and paredit keeping everything in order.

16:07 rata_: Netpilgrim: you see them less actually

16:07 because colors have been rightly chosen

16:08 or maybe I'm just used to it

16:08 Netpilgrim: Pisketti: Just keep the cheat sheet handy and look commands up when you need them. Probably the same way you have learned to use emacs, at least I have.

16:09 duck1123: There's always C-h m as well

16:10 Pisketti: Netpilgrim: Yeah. Fortunately learning paredit is only a minor annoyance compared to the learning curve of emacs

16:12 Netpilgrim: Pisketti: O just think how much fun it is to learn something new. That's why I changed from vim to emacs – just seeing how other people live. (And I liked it.)

16:13 rata_: Do you use rainbow-delimiters.el?

16:14 Pisketti: Netpilgrim: The fun of learning something new was the main reason I got into Clojure in the first place.

16:14 amalloy: Pisketti: it's a trap! now you have to learn five more new things!

16:15 Pisketti: I knew it!

16:15 rata_: Netpilgrim: no, rainbow-parens.el

16:16 Pisketti: The whole lisp experience has been the most eye opening experience for a long time

16:17 Netpilgrim: Pisketti: Yeah, there are parallels for me between working with vim and trying out emacs, and working with Java and trying out Clojure. Just the thought that there is a way to do something familiar in a very different way.

16:18 Pisketti: I'd love to work with Clojure instead of Java. Someday maybe.

16:20 Netpilgrim: Does anybody else have the urge to improve on your own sentences after the first draft like sourcecode? (second draft: “a very different way to do something familiar”) :)

16:24 Speaking of improving. I have a working solution for 4clojure problem 43 (http://4clojure.com/problem/43) here: https://gist.github.com/1181919 But there must be way to do it without the ugly loop, or isn't there?

16:25 4clojure is great by the way!

16:33 amalloy: Netpilgrim: there's always a way :)

16:34 my first solution was something like (for [offset (range n)] (take-nth n (drop n coll)))

16:34 &(let [coll (range 1 10), n 3] (for [offset (range n)] (take-nth n (drop offset coll))))

16:34 lazybot: ⇒ ((1 4 7) (2 5 8) (3 6 9))

16:35 amalloy: but someone tweeted a much nicer solution: ##(let [coll (range 1 10), n 3] (apply map list (partition n coll)))

16:35 lazybot: ⇒ ((1 4 7) (2 5 8) (3 6 9))

16:37 Netpilgrim: amalloy: Now, those two look more pleasing than what I've written. And I have to study clojure.core, I did know neither take-nth nor partition.

16:37 amalloy: <3 partition

16:38 Netpilgrim: see also ##(doc split-at), which would improve your existing solution a little

16:38 lazybot: ⇒ "([n coll]); Returns a vector of [(take n coll) (drop n coll)]"

16:38 Netpilgrim: amalloy: Basically partition does exactly what my loop was for.

16:39 amalloy: O, so many useful functions. :)

16:39 amalloy: Netpilgrim: it will do a lot more, if you ask nicely

16:39 &(partition 2 1 (range 5))

16:39 lazybot: ⇒ ((0 1) (1 2) (2 3) (3 4))

16:40 Netpilgrim: amalloy: Hm, looking at your last example, I think I've actually used partition in one of the earlier problems to find identical neighbors in a seq. I must have forgotten about it.

16:42 amalloy: No, I did something like (map coll (rest coll) ...) there.

16:42 amalloy: &(doc partition-by)

16:42 lazybot: ⇒ "([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions."

16:42 amalloy: &(partition-by identity '(a b b c a a d))

16:42 lazybot: ⇒ ((a) (b b) (c) (a a) (d))

16:44 Netpilgrim: amalloy: This is just great. Now i want to go back and redo all my solutions to the 4clojure problems. :)

16:44 amalloy: you should! it's good for you

16:45 simard: I have a fresh install of emacs24, a clean .emacs, added marmalade to package list, installed clojure-mode, make sure I had "lein upgrade" and "lein plugin install swank-clojure 1.3.2", and then from a project did M-x clojure-jack-in : the server starts in the *swank* buffer, but there's nothing connecting anywhere

16:45 note that I don't have slime anymore, but it seems clojure-mode has it bootstrapped

16:45 (hence I cannot do M-x slime-connect now)

16:45 what went wrong ?

16:47 amalloy: Netpilgrim: that said, (map f coll (rest coll)) is a nice little idiom i always forget to use because i love partition so much. eg, (map + coll (rest coll)) is nicer than (map (partial apply +) (partition 2 1 coll))

16:47 but i'm sure i'd write the latter

16:49 st3fan: what is marmalade?

16:50 amalloy: $dict marmalade

16:50 lazybot: amalloy: noun: A clear, jellylike preserve made from the pulp and rind of fruits, especially citrus fruits.

16:50 amalloy: (rimshot)

16:50 Netpilgrim: BTW: Is there a collection of design patterns for functional programming somewhere? (Surely, there must be.)

16:50 st3fan: Netpilgrim: funny, i was just thinking, hey i can do a lot of 4clojure problems much better with those tricks

16:50 well they are not really tricks, ust good usage of the lib

16:50 amalloy: st3fan: it's like elpa. pre-packaged elisp

16:51 technomancy: spreadable elisp

16:51 st3fan: i shall look into it :)

16:51 technomancy: it's basically clojars for elisp

16:51 amalloy: Netpilgrim: if you search for "functionap programming design patterns", you'll mostly find people saying stuff like "design patterns are an indication your language is not powerful enough to *actually* abstract things for you; patterns in functional programming are just functions"

16:52 i don't think they're 100% right there, but they're not crazy either. who needs the Visitor pattern when you have map and reduce?

16:53 simard: so this should have been working out of the box right..

16:54 Netpilgrim: amalloy: Perhaps I'm still too new to the language to easily see how to approach typical problems

16:55 amalloy: On the other hand there are things like using mutual recursion with trampoline to implement a finite state machine (just read about it in JoC) which I think is a fantastic pattern, but perhaps that's too specific.

16:57 rata_: do you know which characters are printed as _ by the repl aside the underscore?

16:58 hiredman: none

16:58 Netpilgrim: rata_: In emacs it might be a non-breaking space, usually in a different color though.

16:59 rata_: it doesn't have a different color

16:59 do you know how to delete/catch them?

17:00 hiredman: is this clojure or clojurescript?

17:00 rata_: clojure

17:01 Netpilgrim: rata_: Where does this character come from?

17:01 hiredman: are you good for unicode across the board?

17:03 rata_: hiredman: no

17:03 Netpilgrim: it comes from a html

17:04 I was wrong, it wasn't the repl, it was emacs as Netpilgrim said

17:04 in the repl it is printed as a space

17:04 I'm using enlive

17:04 to do screenscraping

17:05 how can I replace those non-breaking spaces by simple spaces?

17:06 Netpilgrim: rata_: Why would you want to? They are usually there for a reason. Otherwise just do some search and replace. (I don't know how to do it in Clojure.)

17:07 rata_: Netpilgrim: I want that because #"\s" doesn't catch it and I need it to do so

17:08 Netpilgrim: Why don't you just include it – [\s ] instead of \s?

17:09 rata_: Perhaps you could even redefine \s.

17:10 rata_: Netpilgrim: because [\s ] wouldn't catch it either

17:10 amalloy: i seriously doubt you could redefine \s

17:11 Netpilgrim: rata_: Why wouldn't [\s ] catch it? The space in there is of course the non-breaking space.

17:11 rata_: how do you write the non-breaking space?

17:12 Netpilgrim: rata_: Just use [\s\u00a0].

17:12 rata_: Netpilgrim: oh thanks! =)

17:13 and do you know how to redefine \s?

17:13 Netpilgrim: rata_: No problem. I love the non-breaking space and use it all the time.

17:14 rata_: No. And how amalloy said (who has way more knowledge about this than I do) it's probably not possible.

17:14 rata_: ok

17:15 Netpilgrim: rata_: I guess \s is hardcoded somewhere in the implementation of java.util.regex.Pattern.

17:17 rata_: But in generell

17:17 rata_: But in general the non-breaking space can be a bit of a problem because it's not seen in the source code (except in emacs and perhaps some other editors).

17:18 rata_: A few weeks ago I broke an application at work because I added some non-breaking spaces in an XML config file and the parser choked. :)

17:19 rata_: hahahaha

17:19 Netpilgrim: rata_: The diffs were a bit problematic because apparently there were no differences.

17:20 rata_: yes, it's a hatable char

17:20 *hate-able?

17:23 Netpilgrim: rata_: Thinking about it, I can understand why it’s not included in the whitespace characters. Whitespace by it’s very definition denotes a place where you can break text.

17:25 rata_: Which raises the question if you are correct in including the character in your pattern.

17:25 rata_: I want to remove them as my regex doesn't work well in some cases

17:25 Netpilgrim: rata_: What’s the regex supposed to do?

17:28 rata_: take some info from some <p>...</p> in the html

17:29 Netpilgrim: rata_: You want to match what's between the tags?

17:29 rata_: no

17:29 I use enlive to extract the text

17:35 Netpilgrim: rata_: Enlive looks interesting. Does it work with sloppy HTML 4, or does it need well-formed XHTML?

17:36 rata_: it works with sloppy html 4

17:36 afaik

17:37 raek: it uses tagsoup, so it even understands 90's street html

17:38 Netpilgrim: raek: Street HTML is a nice description for what I've seen in the 90's (and later).

17:40 * Netpilgrim bookmarks the TagSoup website. (This will come in handy at some point.)

17:42 wwmorgan: What is the library or contrib function that takes a predicate and a collection and returns [(filter p coll) (remove p coll)] ?

17:42 rata_: wwmorgan: separate?

17:42 amalloy: well, clojure.contrib.seq-utils/separate, but a shorter name is (juxt filter remove)

17:43 rata_: amalloy: you still in love with juxt?

17:43 wwmorgan: thanks! rata_, amalloy. I'll pick one of those

17:43 rata_: =P

17:43 amalloy: rata_: we haven't set a date yet, but we're definitely getting married, yeah

17:44 rata_: hahahahaha

17:48 simard: could anyone get penumbra to work ?

17:51 here is the problem: http://pastebin.com/cfhGE5yp

17:59 rata_: is there a way to split a regex in several lines?

18:00 (using the #"" reader macro)

18:06 Somelauw: For 4clojure, I would really like it to see alternative solutions. I would like to see ways to improve my solutions.

18:06 stirfoo`: rata_: isn't there a flag to allow that?

18:07 amalloy: no

18:07 Somelauw: please feel free to start a forum or something, somewhere on the web, and i'll link to it. it's not really part of what i'm good at, and i don't want to deal with moderating it either

18:08 rata_: stirfoo`: you mean multiline? that's for another thing

18:09 amalloy: $javadoc java.util.regex.Pattern

18:09 lazybot: http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

18:09 amalloy: rata_: http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#COMMENTS and http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#compile(java.lang.String, int)

18:10 stirfoo`: rata_: no I was thinking something like Python's verbose flag: re.X

18:10 amalloy: the clojure reader macro does not expose the /x modifier, but java does

18:10 stirfoo`: amalloy: ah

18:16 arohner: ibdknox: in noir, is there any way to get access to the request (not just params) in a normal defpage? looks like the only way to do so is with a pre-route

18:17 specifically, I need the :body to handle a POST

18:18 duncanm: sigh, 2 hours i've been battling JRuby

18:19 and i finally realized, i've been programming Ruby's Hashes like they're Clojure maps

18:19 and other than clojure (and i guess Scala), no one else has immutable dictionaries

18:19 amalloy: coughaskellcough

18:19 duncanm: oh right

18:20 and now i'm really confused: what's the point of having #collect, #select, #inject if the data structure is not functional?

18:20 i don't even know how i'm supposed to use those APIs now

18:21 ibdknox: arohner: there was a thread on this on the mailing group

18:21 yeah, here we go

18:21 arohner: https://groups.google.com/forum/#!topic/clj-noir/M5qCktV3CPU

18:23 coopernurse: arohner: there was another noir thread about this too. there's talk of generalizing access to the request object in the future

18:24 ibdknox: coopernurse: maybe even by tonight ;)

18:24 coopernurse: ibdknox: nice!

19:22 srid: challenge -- find the algorithmic complexity of the hamming number solution here: http://def-learn.blogspot.com/

19:23 use of set and conj seems like cheating. i was trying to come up with an optimal version.

19:23 Somelauw: what is up with the netsplit?

19:25 hiredman: srid: you should move the lazy-seq to be around the whole fn body instead of just the tail of the fn

19:28 amalloy: srid: easy, n*logn

19:28 srid: btw, that blog is not mine

19:29 amalloy: what is n?

19:29 amalloy: finding the first n elements

19:29 srid: ok, but this solution will iterate till 1000th number, which is not same as 1000

19:29 hiredman: well good, it's the same dumb blog that I saw in the planet clojure feed that puts a vector into a LinkedList then calls seq fns on it

19:30 http://def-learn.blogspot.com/2011/08/programming-praxis-reverse-sublists.html <-- dumb

19:30 amalloy: hiredman: yeah, i actually wrote an angry letter to planetclojure about how bad that one was and can we please not publish this

19:30 not that one, actually. the one about...a sorted ring or something

19:31 http://def-learn.blogspot.com/2011/08/programming-praxis-cyclic-sorted-list.html <-- at least as bad as the one hiredman points to

19:31 hiredman: the hilarious thing is the first comment on http://programmingpraxis.com/2011/08/26/reverse-every-k-nodes-of-a-linked-list/ the page he links to, has a a clojure solution sans the stupid linked list

19:31 srid: heh

19:31 amalloy: srid: you say "but", but you don't seem to be disputing anything anyone's said

19:32 srid: amalloy: you said n*logn. but the 'n' in this complexity is not the N in "first 1000"

19:32 amalloy: yes it is

19:32 to find the first N items in the hamming sequence takes n*logn time

19:33 srid: ok, let's find it out. what is the complexity of `conj` on a set of size k?

19:33 amalloy: logk, because it's a sorted set

19:34 srid: and how many times is conj called for finding the Nth number? N times, correct?

19:34 amalloy: mhm

19:34 srid: now what is the upper bound in the set 's'? (hint -- it is not N)

19:35 upper bound in size of set 's'

19:36 amalloy: one upper bound would be 3N. there may be an upper bound that is not so high, but it will be a constant factor

19:40 srid: so what are you getting at? is log(N) a bound on the size of s, somehow, or something like that?

19:42 srid: hmm, yes .. 3N is the upper bound for size of the sorted set. so, it is n*lg(n)

19:45 amalloy: there might well be a proof that, for large N, the number of items *actually added* to the set for most iterations averages out to something pretty small. because when you're looking at small numbers like 30, it's quite likely that 60, 90, and 150 have all been added already

19:46 if |S| could be bounded at log(N) for large enough N, you could convince me that the running time is smaller than N*log(N)

19:46 tomoj: does it matter whether you actually add something?

19:46 amalloy: tomoj: not for the current iteration. but if you don't, it makes future iterations faster

19:46 ibdknox: any thoughts on why tools.namespace.find-namespaces-on-classpath returns empty when in a war file?

19:46 tomoj: ah

19:47 hiredman: ibdknox: war files tend to be run in more complex (classpath wise) environments

19:49 my guess those tools are worthless the minute you leave a simple repl behind

19:49 ibdknox: hiredman: it works nicely in jars

19:49 hiredman: just seems to break with war files (so far)

19:50 hiredman: jars are not complex

19:50 ibdknox: sure, I was just saying it does make it past the repl :) Maybe not much further haha

19:50 hiredman: you've never used jars on the repl?

19:51 there is nothing complex abouts jars on the classpath at all, or wars for that matter

19:51 the complexity arises via the interactions between classloaders

19:52 ibdknox: righto

20:03 hiredman: something like (.getResource (.getClassLoader clojure.lang.RT) "clojure/lang") is your best bet

20:05 where clojure.lang.RT is replaced by some class that most likely got loaded by a loader that knows where your resource is

20:05 and "clojure/lang" is replaced with the dir prefix from the namespaces you want to load

20:21 polypus74: anything special have to be done to call variable arity java ctors?

20:21 i'm getting an error when i try the usual (MyClass. ...)

20:21 mudge: anyone heard what rich hickey is doing lately?

20:22 hiredman: polypus74: variable arity is a java language fiction, it really takes an array

20:23 polypus74: hiredman: ahh, so from clojure i should pack into array first? ty

20:24 icey: mudge: I heard he was starting an Iron Maiden cover band and they're planning on touring Europe

20:24 but i might have misheard

20:24 mudge: icey: wow, that is a change

20:25 polypus74: i heard britney spears myself

20:25 mudge: icey: i didn't know he was into music like that

20:25 icey: mudge: yeah, i guess that's why he's been growing his hair out

20:25 mudge: icey: ohhhh, that explains a lot

20:25 hiredman: I heard he was laying in a hammock when irene hit and is now somewhere over the atlantic

20:25 coopernurse: just pushed an oauth wrapper for signpost that works with appengine: https://github.com/coopernurse/clj-appengine-oauth

20:27 mudge: hiredman: i hope he is okay

20:27 hiredman: his brain is still functional

20:27 ~rimshot

20:27 clojurebot: Pardon?

20:27 hiredman: clojurebot: jerk

20:27 clojurebot: Excuse me?

20:28 mudge: hiredman: thank goodness, sounds like his head is pretty immutable

20:28 hiredman: heyo

20:33 mudge: hey, is there a way to clean out all namespaces in a running clojure program and then reload all the namespaces?

20:33 this way I could change source code, delete all the namespaces, then reload all the namespaces in the same running process

20:34 technomancy: mudge: C-c C-l in slime forces a reload of the current buffer as well as all the namespaces it requires

20:34 not quite the same but possibly close enough

20:36 mudge: technomancy: that's cool, but I want to do this outside develpment, see i push new source code changes to a remote server via git, and don't have a connection to it in emacs

20:36 i have jetty running on a remote server and I push changes to the clojure source code to it through git

20:36 hiredman: sounds horrible

20:36 mudge: hiredman, why?

20:37 technomancy: from what I've heard tomcat can do restartless reloads with classloader magicks

20:37 hiredman: ^-

20:37 technomancy: but I have never used tomcat, so don't trust me

20:37 mudge: i have a website running on a remote server and after I am finished with some development it is easy to push those changes to the website

20:37 hiredman: use a feature created for the functionatility you want, don't abuse other mechanisms

20:39 mudge: hiredman, Heroku uses git to delpoy websites, i'm doing the same thing

20:39 hiredman: a. heroku bluids a slug and deploys that and b. git is not a deploy tool

20:40 (and c. I don't care what they do)

20:40 http://devcenter.heroku.com/articles/slug-compiler

20:45 mudge: hiredman: i also have an automatic mechanism for extracting the application source from git and deploying it once it is on the server

20:45 hiredman: do you have any websites that you need to make changes to from time to time? curious how you might do it

20:47 hiredman: content changes should be made to the content source (some database, static files, whatever) application changes require an app restart

20:47 I doubt you have an automatic mechanism because you are here asking about implementing such a mechanism

20:48 devn: "Fuck it, we'll do it live."

20:49 mudge: like Heroku I use a git hook to check out the source code without the git repository and put it in the right place on the server

20:49 hiredman: yes, still working on it, but some of it is done

20:49 hiredman: nah, github uses a git hook to build a slug, and then the slug gets deployed, if you want to go that route, setup tomcat, have a githook build a war, and deploy the war

20:50 (this is not an endorcement of tomcat in anyway)

20:50 coopernurse: one thing to note about tomcat hot deploy

20:51 eventually you will probably run out of JVM PermGen space

20:51 devn: note the eventually

20:52 hiredman: heck, have you git hook restart jetty

20:52 your

20:52 coopernurse: this article explains the issue well, but it's a little tl;dr http://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java

20:52 devn: tl;dr

20:52 ;)

20:52 hiredman: boring;dr

20:52 * devn whispers 'hipster' for the full effect

20:53 mudge: hiredman, yea, good idea, that's what I was thinking, butttt, when i restart jetty my website goes down and I don't like the slow start of java when starting up jetty -- which is why i want to keep jetty running, and just wipe out and reload all the namespaces from the source code which might have changes

20:53 coopernurse: it would be interesting if clojure based webapps fare better in this regard, as they tend to have fewer dependencies..

20:53 mudge: changed*

20:54 devn: mudge: You could just edit in a running REPL?

20:54 Setup a remote REPL?

20:54 hiredman: mudge: how many users do you have?

20:55 devn: Stage your changes locally and then in the REPL make the relevant changes

20:55 hiredman: :(

20:55 devn: Then do a full deploy later on

20:55 mudge: hiredman, not enough users to justify this on a basis of users

20:55 hiredman, i just want to do it

20:55 devn, yes a remote repl would be nice

20:55 devn: mudge: suggestion: anything is possible, however ugly it may be -- go for it

20:55 hiredman: mudge: then build a proper classloader based hot redeploy

20:56 if you are doing it for fun

20:56 devn: mudge: or do the "good enough"

20:56 and just hack the shit out of it -- bailing wire, tinfoil and duct tape

20:56 mudge: hiredman: yea, that sounds great, i have no idea how to do that, i guess i can check google

20:56 devn: yea, sounds fun

20:57 devn: mudge: use what you know. if that seems overly complicated then do what you can to get closer to the ideal world you've concocted. :)

20:57 mudge: okay

20:57 devn: mudge: my advice is very non-specific, but I think you will be surprised at some of the cleverness you can get away with

20:58 make a mess and then clean it up :)

20:58 coopernurse: mudge: how many wars do you have deployed in jetty? just one?

20:58 mudge: i just wondered if there was a simple way to clean out all the clojure namespaces and reload them, i know that ring has wrap-reload that reloads namespaces but it doesn't get rid of old names

20:58 i don't deploy wars, i embed jetty in my web apps

20:59 devn: mudge: so, old names, like you want to rebind a function of the same name or something?

20:59 hiredman: mudge: that is the first thing that'll have to go

20:59 devn: like (defn foo [] (+ 1 1)) => (defn foo [] (+ 1 9))

20:59 mudge: devn: i want to change the source code and then have the running clojure program pick up the changes of the source code, but also get rid of names no longer referenced in the source

20:59 hiredman: build a war using lein-war or lein-ring or whatever, use jetty-runner to run the war

20:59 devn: Because you could fuel that whole thing from a remote REPL with a bit of hackery

21:00 I need to run -- best of luck mudge

21:00 mudge: thanks devn

21:00 hiredman: mudge: it more less seems like you want to do things the way people do them with ruby, but this is not ruby

21:01 coopernurse: off the wall idea: if you want to avoid downtime, you could spin up a new instance of your app on another port, and either have a proxy (nginx) flip forward rules, or (easier) flip a iptables port forward rule

21:01 mudge: coopernurse: interesting idea

21:02 coopernurse: something like: iptables -t nat -I PREROUTING --src 0/0 --dst 0/0 -p tcp --dport 80 -j REDIRECT --to-ports 8080

21:02 and then flip: iptables -t nat -I PREROUTING --src 0/0 --dst 0/0 -p tcp --dport 80 -j REDIRECT --to-ports 8090

21:02 probably not a _huge_ bash script to do the startup / port flip

21:02 devn: ^not a bad idea

21:04 coopernurse: would make a nice recipe to share.. common problem on the jvm (slow start)

21:04 and I've had too many strange issues with JVM classloaders to recommend hot deploy.. at least on the sun/oracle vm

21:04 devn: coopernurse: Clojure programmers don't write their apps in clojure. They write the language they use to write their apps in clojure.

21:04 err @ mudge

21:05 Remember that. Whens someone tells you no. Tell them yes.

21:05 The world is your oyster, yadda yadda. Okay, definitely running now. Later

21:05 coopernurse: me too. g'night guys

21:05 mudge: coopernurse: yea, definitely, reminds me, I've been looking at jark for clojure shell scripting, it provides a persistent jvm

21:20 zakwilson: I want to apply a function to a user-supplied symbol referring to a value in my program, e.g. (some-fn (eval (read-string user-data))). Aside from the user being able to supply a symbol name that would expose data that users shouldn't get, what could possibly go wrong?

21:22 chouser: if they're only supplying the symbol, you can be safer and faster by avoiding eval

21:23 zakwilson: They supply the symbol as a string. How do I get the associated value without using eval?

21:23 chouser: (some-fn (resolve (symbol your-string)))

21:23 or maybe: (some-fn (deref (resolve (symbol your-string))))

21:24 zakwilson: Yeah, deref is needed, but I think resolve is what I wanted. Thanks.

21:29 amalloy: deref shouldn't actually be necessary, should it? when called as a function, the var will forward to the function

21:31 zakwilson: It appears to forward the equivalent of (var the-symbol).

21:35 Meh. It works in the repl, but when I tried doing it in my app, I kept getting NPEs. Since I'm just using this to serve appropriate stylesheets, I'll just keep a map of names of stylesheets. It's not cool and lispy, but it's probably safer.

22:16 simard: (pmap #(* % %) (range 100)) why does this result in a java.util.concurrent.RejectedExecutionException ?

22:19 tomoj: swank?

22:19 clojurebot: swank is try the readme. seriously.

22:19 tomoj: hmm http://stackoverflow.com/questions/7004292/rejectedexecutionexception-and-clojure-concurrency

22:20 for me deleting swank-clojure from ~/.lein/plugins and reinstalling 1.4.0-SNAPSHOT was the fix

22:23 simard: ok I'll try that

22:26 tomoj: worked like a charm, thank you :)

22:40 * srid is bored with his first clojure project https://github.com/srid/notaskinnerbox#readme and thinking of moving on to something involving more algorithmic thinking

22:51 mudge: srid: looks cool

23:01 solussd: how do you efficiently trim characters off the end of a string?

23:06 amalloy: solussd: ##(doc subs)?

23:06 lazybot: ⇒ "([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."

23:10 solussd: is that going to be more efficient than a drop-while reverse drop-while reverse str?

23:16 amalloy: about a hundred times more so, yes

23:16 (estimate comes with no warranty explicit or implied)

23:21 solussd: ah, but I need to trim arbitrary characters in a set. E.g. "/blah/ " => "blah" (removing characters in #{\/ \ })

23:22 tomoj: didn't this happen yesterday

23:23 oh, not quite

23:24 amalloy: solussd: so walk the string, decide what indices to drop from, and do the drop all at once, if you care about efficiency

23:25 tomoj: yesterday it was a guy named jblomo diong exactly the same thing. a bit weird if it's a coincidence

23:26 michaelr525: hello!

23:26 solussd: k.. I was surprised that trim, ltrim and trim exist but nothing that trims an arbitrary set of characters.

23:26 easy enough. thanks!

Logging service provided by n01se.net