#clojure logs

2012-07-30

00:00ivanright, it's ported from http://en.literateprograms.org/Fibonacci_numbers_%28Haskell%29#Infinite_Lists
00:00ivanthe Clojure version is made of lies, though, because it creates tons of lazy-seqs
00:01ivan&(take 40 ((fn fibs [] (concat '(1 1) (lazy-seq (map +' (fibs) (drop 1 (fibs))))))))
00:02lazybotExecution Timed Out!
00:02uvtcCrazy. :) But seems to follow that same pattern of a function returning the value you want, cons'd/concat'd with the rest...
00:03Frozenlockivan: I did exactly the same thing in my REPL
00:03FrozenlockStill waiting...
00:03uvtcThe repl just really wants to make you happy and show you results. :)
00:04FrozenlockYeah... I didn't think that through before hitting enter
00:04FrozenlockSilly me
00:04FrozenlockStill waiting
00:04uvtcYup. I've done it a bunch of times too.
00:04muhoowhat's the most recent version of lein-cljsbuild that'll work with clojure 1.4, i.e. that doesn't require clojure/instant__init.class ?
00:04uvtcFrozenlock: sounds like your terminal is either frozen, or locked, or both.
00:05ivan40 will never finish in reasonable time
00:05uvtcFrozenlock: Perhaps some sort of "frozen-lock", if you will. ;)
00:05FrozenlockOh snap
00:06muhooemezeske: actually i should have slung that question over your direction
00:07FrozenlockWell, I think I will need to kill it. Any shortcut to kill the java instance from emacs? (And only this one, I have other java stuff running)
00:07muhoops fax |grep java |grep clojure , pull out the process id, then kill that?
00:08ivanFrozenlock: ctrl-\
00:08FrozenlockOh wait : GC overhead limit exceeded
00:08ivaner, never mind, I didn't read
00:08Frozenlockjava.lang.OutOfMemoryError
00:10Frozenlockmuhoo: yep, that would have worked, thanks
00:13muhooRaynes: have you any interest in the ability to have comments/discussions on refheap pastes?
00:15muhoojust saw a gist where someone posted a stacktrace, and in the comments, was the solution how to fix the damn thing. it was a lot more helpful than just a lonely paste with no solution, which is unfortunatley what google turns up too often these days.
00:16emezeskemuhoo: I don't know what clojure/instant__init.class is.
00:16emezeskemuhoo: You should be fine with clojure 1.4 if you just use the latest lein-cljsbuild.
00:29muhooemezeske: thanks, works with 1.4, great
00:32emezeskemuhoo: Sweet.
00:35muhooSuccessfully compiled "resources/public/main.js" in 29.359273107 seconds. :-)
00:35emezeskemuhoo: Hah, is that with :advanced optimizations?
00:36muhoo:whitespace :-P
00:36emezeskemuhoo: Wow! Big project?
00:36muhoo(.log js/console "hello world")
00:36muhooon a eee netbook
00:36emezeskeAhhh
00:36emezeskeIf you do "lein cljsbuild auto", subsequent compiles should be a bit faster
00:37muhooyes, that's very awesome. i've got lein cljsbuild auto, trampoline repl, and it works
00:37emezeskenice!
00:37muhooemezeske: thanks again for this lein-cljsbuild!
00:48muhoopretty cool. hello world is 126kb in advanced mode. holy crap, i'm using cljs now.
00:52Raynesmuhoo: Not particularly, no. But if someone else implemented it then I'd accept that patch (you know, as long as the patch didn't suck of course).
00:53Raynesmuhoo: Only for logged in people though. I don't need more spambait. :p
00:53muhooRaynes: yeah, that'd be included under "not suck"
00:54muhoodoes lein support multiple parallel tasks?
00:54RaynesParellel? No.
00:54RaynesYou could easily add that functionality, I do believe.
00:54RaynesJust add a parallel version of its 'do' task.
00:54muhooit'd sure be nice to do "lein cljsbuild auto & trampoline repl " or similar
00:54muhooand have both run
00:55RaynesWell, you can do 'lein do cljsbuild auto, trampoline run" I think
00:55RaynesBut they'll run one at a time and not at the same time (parallel).
00:55muhooi can, but the trampoline repl blocks until auto completes, which is never
00:56RaynesThen yeah, you want parallel.
00:56muhooi'll put it on my list of things to do
00:56Raynesmuhoo: I bet technomancy would accept a patch to add that functionality. Not sure if it should be a new task, or...
00:56RaynesProbably just want to make an issue about it and see what he says.
00:56RaynesI think it'd be great.
00:56muhoothanks, will do. it'd come in handy for cljs hacking
00:57RaynesI'd even go so far as to do it myself if he says he wants it.
00:57muhoook, will see what he says
00:58muhoo0 open issues on leiningen :-O
01:00Raynesmuhoo: Closer to 31.
01:01muhooah, i had some kind of filter on, apparently
01:01muhoo32 now :-P
01:21jcao219bah, i can't install swank-clojure on windows
01:22jcao219i came across https://github.com/technomancy/swank-clojure/issues/98
01:37emezeskemuhoo: You don't actually want to be able to run the auto build in the background of your repl
01:37emezeskemuhoo: Imagine having a form half-typed-out in the repl, and then the auto build triggers and spits out a bunch of warnings
01:37emezeskemuhoo: Or even just the "Completed in ..." message
01:38emezeskemuhoo: Having stuff asynchronously barf into your repl is not fun, and you don't want to just hide the auto build output
01:39emezeskemuhoo: I suggest just running autobuild in one terminal tab, and the repl in another (or separate windows, etc)
02:24muhoowell, actually, i don't type in the same terminal
02:24muhooso i'd rather have them both in the same terminal. i access the repl using telnet via emacs (and eventually nrepl once i get that set up)
02:24muhooi generally run the repl headless.
02:25Raynesmuhoo: There is no set up.
02:25muhooset up?
02:25Raynesup set.
02:25emezeskemuhoo: But, how does the telnet do I/O with the REPL?
02:25emezeskemuhoo: AFAIK the REPL is just stdin and stdout
02:25muhoothere's a repl-port
02:26muhooin lein2, it's nrepl. in lein1, it's just telnet
02:26emezeskeUh, I mean the clojurescript repl
02:26muhoothat part i'm still figuring out. looks like it runs on port 9000
02:26emezeskeNo, that's not what that port does
02:27emezeskeThat's the port that talks to the browser and sends javascript off for evaluation
02:27emezeskeThe clojurescript REPL is stdin, stdout.
02:30muhooah, i see, when run from lein cljsbuild repl-foo. hmm
02:30emezeskemuhoo: It is a totally different thing than "lein repl"
02:30emezeskemuhoo: Related only in name
02:30muhoowell THAT repl i'd probably want to run from somewhere else, true, and i'll have to figure out how to connect that to emacs. hmm.
02:31emezeskeYep.
02:31emezeskeI have no emacs experience, unfortunately
02:31emezeskeI think I've heard about people getting that to work, though
02:31muhooi'll play around with it. this week is cljs week for me, it seems.
02:33emezeske:)
02:33muhooi've been running the cljs repl from inside the project, via that (repl-env) stuff
02:34brainproxymuhoo: the cljs repl can be used in emacs via inferior lisp
02:34muhoogreat, that's good to know
02:35brainproxyhttps://github.com/michaelsbradleyjr/prelude/blob/master/personal/cljs-repl-in-emacs.txt
02:35brainproxy^ I use the "lein trampoline cljsbuild repl-listen" option
02:35brainproxydon't forget to put the quotes around it
02:40muhoothis is interesting. i end up with 3 java processes running: one for my project repl, one for the cljsbuild auto, and one for the cljs repl
02:41muhooi still would personally rather have the cljs repl running headless and connect to it via nrepl rather than running it as an inferior lisp, but that'd work for now.
02:41emezeskemuhoo: I'd gladly accept a pull request for something like that
02:42emezeskemuhoo: The existing repl stuff for clojurescript is *very* basic.
02:46muhoocool
03:34gunsI am trying to play with core.reducers, but my copy of Java 7 SE (from Oracle) doesn't include jsr166y.jar
03:34gunsbut it does seem to be in ~/.m2
03:34gunsHow do I get leiningen to load the jar on jvm boot?
03:34hiredmanguns: the jsr166y jar is for backwards compat
03:35hiredmanjava 7 includes the forkjoin framework
03:35gunshiredman: hmm. core.reducers fns are returning java.lang.NoClassDefFoundError: jsr166y/ForkJoinPool
03:35hiredmanguns: I suggest making sure you are actually using java 7
03:35hiredmanjava -version
03:35gunsjava version "1.7.0_05"
03:35gunsI know very little about java tbh
03:36gunsI thought I could make it through life without looking at Java class docs, but here I am
03:37hiredmanguns: and what does (System/getProperty "java.version") say from the same place you are trying to load the reducers framework from
03:37guns"1.7.0_05"
03:37gunsI downloaded the Oracle version for OS X.
03:38hiredmanhow recent is your clojure jar?
03:38guns1.5.0-alpha3
03:38gunsShould I be on a SNAPSHOT build or something?
03:38hiredmanthat is effectively a snapshot
03:39hiredmanare you trying to use some other clojrue library?
03:39gunsI am in a bare leiningen project with no extra deps
03:40hiredmanwhat happens if you run (Class/forName "java.util.concurrent.ForkJoinTask") ?
03:40gunsjava.util.concurrent.ForkJoinTask
03:40gunsthat's something eh
03:41hiredmanwhat does `lein version` say?
03:41gunsLeiningen 2.0.0-SNAPSHOT on Java 1.7.0_05 Java HotSpot(TM) 64-Bit Server VM
03:41hiredmanguns: yeah, reducers checks for the existence of that class when deciding to use the backwards compat jar or not
03:42gunsSo my java claims to have the class, but doesn't actually?
03:42hiredmanno it does
03:43gunsThis is opaque to me. Is there something I can grep in java home?
03:44hiredmanguns: the class is there, but the detection in reducers is failing for some reason
03:45gunshiredman: Ah, that's more clear. I'll dive into the reducers source then
03:45gunshiredman: thanks for the help
03:47gunshiredman: It seems to work from a source-built clojure jar. Guess it was a bug in alpha3
03:50hiredmanguns: looks like alpha3 is broken
03:51hiredmanthe compiled code has a hard coded reference to the classes from the fall back jar
03:51clojure-newcomeroh dear, lein/mvn seems completely borked today, working fine till now… OverConstrainedVersionException on pretty much all my projects… can anyone help ?
03:52hiredmanthe decision to use the fallback jar or not is happening at compile time, so if you compile your own version of clojure you won't need the jar
03:53gunshiredman: I see. Can I install a clojure version locally and use it from leiningen?
03:53hiredmanyes
03:53gunsThis is some kind of maven incantation I imagine...
03:54hiredmanif you checkout the source from github you can run 'mvn install' and it will installing something like clojure-1.5.0-master-SNAPSHOT in to your ~/.m2
03:54hiredmanand if you change your clojure version in your project.clj to 1.5.0-master-SNAPSHOT it will use your snapshot
03:55gunshiredman: Oh that's quite easy. I thought it would be one of those 200 character mvn install commands
03:56clojure-newcomerI'm guessing something's corrupted in either my local mvm or lein settings, but unsure where
04:05muhooclojure-newcomer: clean 'em both out and try over?
04:06muhooclojure-newcomer: local mvn is in ~/.m2 and lein is in ~/.lein
04:06clojure-newcomermuhoo: I tried that… guessing a proxy somewhere is in a borked state ? can I avoid connecting to 'central' for example ?
04:08muhoowhat exactly is it telling you?
04:10clojure-newcomermuhoo: I've pasted it in here : http://pastebin.com/aZDaYAEK, but its happening across all my projects atm, different libraries, and versions etc
04:11muhoooh!
04:11muhoothe version spec may not be right in your project file
04:11muhoocan you paste your project.clj ?
04:12clojure-newcomermuhoo: this is just the standard noir-blog project.clj : http://pastebin.com/2ZCDXg1w
04:13muhoolooks ok
04:14muhoowhy is it looking for version 1.2.0 of clojure (if i'm reading that error right)?
04:14clojure-newcomermuhoo: I was guessing it must be a transitive dependency
04:16clojure-newcomermuhoo: hoping its not a Mountain Lion upgrade related problem :-)
04:17muhoono, but it also doesn't look the same as my Noir-blog
04:18clojure-newcomermuhoo: so yours runs fine
04:18clojure-newcomertempted to go run it on my parallels partition
04:18muhooah, no it's the same. i'd added something to mine
04:19clojure-newcomeryes, think I will go try it on a different machine
04:19clojure-newcomermuhoo: right, ok, so your noir blog is borked in the same way ?
04:19muhoonope, i just ran lein deps on mine, no problems
04:19muhoothen again, i already have all that stuff in my cache
04:19muhooso lein/mvn isn't going to try to download it from clojars/central/etc
04:20clojure-newcomermuhoo: yeah, I think somethings broken in one of those, so the proxy is poisoning my dependencies
04:21muhooif you have a totally clean vm to try on, that seems like a good idea
04:21clojure-newcomermuhoo: yeah, I've got something I can use
04:21clojure-newcomerwill have a go
04:21clojure-newcomerthanks for trying to help
04:22muhoonp. it may be a strange central borkage, so if you still have trouble, quite a few people will notice
04:23muhoothere was one a month or so ago at central.
04:24muhoohttp://grokbase.com/t/gg/clojure/126bx7z0jy/central-screwup
04:24muhoobut that doesn't appear to be the problem now
04:28clojure-newcomermuhoo: the suggestion detailed in the link you gave has fixed my issues : :repositories {"sonatype" "https://oss.sonatype.org/content/groups/public/"}
04:34muhooweird. central has some problem then.
04:38muhoonice, i have a working cljs browser repl
04:40clojure-newcomermuhoo: sounds cool, how capable is it ?
04:52muhooclojure-newcomer: it's an interesting hack, https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
04:57clojure-newcomermuhoo: thanks, just reading now
05:05muhoonice, the cljs compiler also translates clojure function comments into javascript comments
05:27ro_stwhat's the right way to do indexed array access in cljs?
05:27ro_sti have a NodeList with one element in it that i need to get
05:27ro_st(first nl) ain't doin' it
05:28clgvro_st: `nth` like in clojure?
05:29ro_stit says it's not ISeqable
05:30clgvro_st: a javascript array?
05:30ro_styes, pretty much
05:31clgvsomething like `aget` in clojure?
05:32ro_stah i found a util in enfocus
05:32ro_sthttps://github.com/ckirkendall/enfocus/blob/master/project/cljs-src/enfocus/core.cljs#L37
05:39ro_sti'm trying to scroll the body element to the bottom. therefore, i need to set .scrollTop on the body element in the DOM. how do i do this?
05:40ro_stnothing in http://himera.herokuapp.com/synonym.html is jumping out at me
05:41ro_stfound it, sorry
06:19jaleyreducers are awesome. deleted 30 lines of code, 25% performance improvement
06:25hyPiRionjaley: The new ones?
06:29emlNoir question: Can I somehow add attributes to the <script> tag that (include-js) generates? Actually a hiccup question. :)
06:30ro_steml: looking at the src, probably not directly
06:30jaleyhyPiRion: err yes, quite new. in 1.5.0-master
06:31tzarwhat's a fun problem to think about/learn from in clojure? I'm trying to get more familiar with the language, last thing I messed around with was chess (not chess ai, just chess)
06:31ro_steml: https://github.com/weavejester/hiccup/blob/master/src/hiccup/page.clj#L71
06:31jaleytzar: have you tried 4clojure?
06:31emlro_st: Dang.. thanks for the help though! :)
06:32tzarjaley: I have not! Will have a look
06:32jaleytzar: http://www.4clojure.com/
06:32jaleytzar: you can create a login, solve problems, then see other people's solutions as you solve them
06:32jaleytzar: this has the inevitable drawback of descending into code-golf
06:33jaleytzar: but it's a good learning tool
06:34tzarjaley: yep found it through google :) sounds good. I've got my intro so far by reading "Programming Clojure" + I used to do common lisp, do you think it's still a good level? I guess I'll try it and find out
06:34ro_steml: nothing stopping you using [:script {:type "text/javascript", :src (to-uri script)}] and adding your own sprices
06:34bj0erntzar: www.projecteuler.net
06:35jaleytzar: the problems are organized by difficulty, so you might find it super-easy to start with but could skip ahead
06:35tzarjaley: cool, thanks for the help
06:36jaleytzar: no problem
06:39tzarbj0ern: messed around with project euler before in other languages, never really got the same moments of clarity from it that I have from building larger things or tools - engineer mind deficiency maybe? But thanks for the suggestion
06:40tzarbj0ern: could also be that I lost interest before I got to the more interesting problems as there are so many of them
06:42bj0erntzar: I know what you mean :)
06:42ro_sttzar: what manual process in your own work env/toolchain can benefit from automation? start there
06:42ro_stor improvement or reworking
06:42ro_stbecause it's a jar, it's trivial to put into place on a machine you control
06:43ro_sti did this, it worked out really nicely for me. wrote a schema+data conversion tool for a mid-sized mysql to mongo.
06:44ro_stand after that, a publishing tool that takes content (xml+html) source docs from git and packages them up for production. this was a reworking of an ant/ruby/php lashup
06:45tzarro_st: I like to do that too - my last (and only clojure) one of those was something to work out my tax year accounts, but that was when I was still in early stages of book so struggling greatly
06:45tzarnow I'm struggling to find something that I haven't already hacked together in ruby, and it's hard to justify the jvm startup time when you're talking about simple scripts which are launched a bunch so refactoring those maybe not
06:46ro_stnext we have a ruby json api + resque messaging system to rework
06:46emlOn second thought I don't think Hiccup will do for me. Which template libraries would you recommend if I want to write my templates in .html with some sort of template language mixed in?
06:47tzarit sounds silly, but back when I was learning lisp, one of my biggest "oh" moments was when I was messing around with queues and trying to apply C pointer type thinking to lists, and someone told me to try make a queue built only out of lists
06:47ro_styes. i ran into that issue too. it made me think about how to keep a jvm warm when using these tools. db conversion can be easily compiled and run from the repl, and the publishing one is part of a jenkins job, where it doesn't matter
06:47tzaror rather, out of stacks
06:47ro_steml: check out enlive
06:48ro_styou make .html files, and then read them in at runtime and apply transformations using a [css-selector] (transforms) pattern
06:48ro_sttranforms occur on-demand as you call for templates. you can opt to compile the html in at compile time if you prefer
06:49tzarit's that kind of thing that I'm thinking about here - it really helped expand the way I think a lot and get the language, and it's not the kind of thing you'd find for example on project euler because it's not i/o related
06:49ro_stwe don't, so that we can continue to do static-file markup work in chrome dev tools easily
06:50emlro_st: Cool! Thanks :)
06:50ro_stthe project euler/4clojure etc stuff is fun for stretching your brain
06:50ro_stand you need that
06:50ro_stbut for me, i need it to be applicable *now*
06:50ro_stso that i give it the proper attention it deserves
06:50tzarwith the chess example, I got to think about how I'd model the different pieces + board in clojure, I ended up with something quite odd and javascripty using multimethod dispatch and the clojure set library, it was a lot of fun
06:51ro_sti can well imagine
06:51tzarro_st: yeah, I like applicable too :)
06:53hyPiRionjaley: Ah. I like it from a performance point of view, but I wonder how similar it is to normal reducing and mapping. Would code need major refactoring to use the new reducers?
06:54clgvhyPiRion: 0-arg and 1-arg implementations for used functions are needed
06:54jaleyhyPiRion: for my problem I literally deleted a a pma-
06:54jaleyhyPiRion: gah, new keyboard
06:55jaleyhyPiRion: deleted a pmap-partition trick, which was bad, and replaced with (r/fold merge-function (r/map worker-function (vec data)))
06:56jaleyhyPiRion: my merge function didn't have identity forms, which was arguably a bug anyway, so i added one, which was simple
06:57hyPiRionSo it's not too much of a hassle to go from one to another then. That's great, though I would love it if you could switch the namespace and get the new function.
06:57hyPiRion/s/function/functionality
06:58hyPiRionBut I suppose that's like wishing for a sufficiently smart compiler :(
07:02jaleyhyPiRion: heh. i think it's already about as close to that as you'd want
07:02jaleyhyPiRion: probably not a good idea to just replace every map with r/map
07:09clgvjaley: that rule already applied to pmap ;)
07:12jaleyclgv: heh, i don't think it would take long to realize that's a bad idea with pmap
08:27XPheriorHas anyone ever used Lein with multiple projects under the same project root?
08:29ro_stXPherior: you mean multiple project.clj files?
08:30XPheriorro_st: Hm, not really. We're refactoring a PHP project and phasing in Clojure as restful web services.
08:30XPheriorSome of the services aren't really related, but they might share common code and so should probably be in the same project
08:31XPheriorAlso, ro_st. Turns out that with-redefs-fn, you can assoc a new test database with a defentity.
08:38ro_stah nice
08:39ro_sta blog post / tut i'd LOVE to see is how to do code sharing between clj projects using git
08:39ro_stit's probably really easy, but it'd be nice to see an end-to-end how to
08:39Horofoxgood morning everyone.
08:42ToxicFroglein git-deps?
08:45XPheriorI'll give it a go soon, @ro_st.
08:53cshellro_st: arent' you supposed to share code dependencies via artifacts rather than code sharing?
08:54ro_stprobably :-)
08:54cshell:)
08:54cemerickro_st: read about lein's checkout dependencies.
08:54ro_stbut when you're working on both in parallel, that can become tedious quickly
08:54cshellYou reminded me of the old ant days when everything was in one big source tree
08:54dnolencemerick: btw, what were you using the core.logic unifier for the other day?
08:54ro_stbe nice to be able to temporarily drop to code, do your work, and then switch back to artifacts and pushall
08:55ro_stcemerick: will do
08:57cemerickdnolen: generating sane test queries for a datalog impl.
08:57cshellro_st: can't you just depend on a snapshot dependency?
08:57cshelland build it when you switch?
08:58ro_stcshell: i've not actually tried to do this yet, so i'm not clear on what you're suggesting
08:59goodieboyanyone here familiar with deploying a clojure app to tomcat?
09:00dnolencemerick: cool - something you'll be putting out?
09:00cshellro_st: Basically, in your lein file you have it generate A-0.0.1-SNAPSHOT.jar, then in Module B, you have a dependency on A-0.0.1-SNAPSHOT.jar - when you build A, it will be installed in your local repository, then when you build B, it reads the dependency from there as well
09:01ro_stah that sounds good. does this local repo automatically exist as a consequence of using lein?
09:02ro_stso building stuff with lein makes it available in a local repo somehow
09:02cshellro_st: yes, but it's the .m2 repository, which is the same one that maven uses - typically ~/.m2
09:02cemerickdnolen: Probably not, at least not soon. It's in the bowels of a new service I'm working on.
09:02cshellif you've built anything with maven/lein you should have it
09:03cemerickdnolen: You probably hear that a lot; I'll bet it gets mighty frustrating. :-(
09:03ro_stthat's clever
09:03cshellro_st: you'll have to run lein install in your A directory
09:03cshelland it will do it
09:03ro_stso i guess to replicate that whole lot on a build server, that build server would have to be building all the deps that are private in this manner, in order?
09:04dnolencemerick: haha pretty much :)
09:05dnolencemerick: though the number of open source projects using core.logic may be approaching 5 :) So I'm hopeful.
09:05cshellro_st: Typically, on a build server you publish your artifacts to repository other than the local (in case of build servers on different machines)
09:06cshellro_st: so, a shared repository - the build tools (ie Teamcity and maybe Jenkins) can detect when snapshot dependencies have changed and start building any dependent projects
09:09ro_stawesome. i hope to hire a tame java developer shortly who can make all this work nicely
09:09ro_sthe's very happy he'll be doing clojure instead of java
09:10cshellI can imagine so :)
09:10cshellro_st: the dependency management paradigm is very common nowadays, so he should be familiar with it
09:11cshellro_st: unless he's been stuck in academia
09:12ro_stnope. he's just got out of a job with a bank-owned company here in SA
09:12ro_stwhere they prefer to hire deployment engineers rather than automate builds
09:12ro_st*barf*
09:12cshelllol
09:12cshellWhat's SA?
09:12ro_stgithub.com is blocked on their firewall. end-of-discussion, so long and thanks for all the fish.
09:12HodappSomething Awful?
09:12ro_stsouth africa
09:12cshellah, cool
09:33wmealing__ive got an odd question, maybe because I dont entirely understand the scope of what i'm asking. I'm currently building a lot of the page via html and then acting on decisions made to do further json requests which then javascript ends up building more of the page, can i perverse clojurescript on the server side to pass down js ( for the browser to run ?) or am i looking at it wrong ? How should I be doing it ?
09:40hyPiRionwmealing__: So you want to write cljs instead of js?
09:40wmealing__i think so
09:40wmealing__if i can get away with it, i dont want to write any js at all
09:41hyPiRionWell, this looks highly relevant: http://cemerick.com/2011/10/11/writing-couchdb-views-using-clojurescript/
09:42wmealing__i will take a look
09:43hyPiRionI don't know too much about it though, but it seems like you want some couchdb-functionality.
09:44hyPiRionSo if you're searching for "couchdb clojure" or something, I believe that should give you something (?)
09:45wmealing__ideally my plan was validation server side, along with the same (duplicated ) validation code client side.
09:45wmealing__and also some basic dom manipulation
09:45wmealing__hide this, fetch this json, do x with it
09:48cshellare there any libraries for removing html markup (ie to stop cross site scripting attacks)?
09:49wmealing__could you just escape it ?
09:49cshellby doing just a replace on < with \<?
09:52wmealing__or whatever the &gt; or what have you
09:52wmealing__for html
09:53wmealing__i think there is a good doc on taking input from users
09:53wmealing__but in short, i pretty much reject it if it contains anything that i consider special characters
09:53wmealing__other than what i expect
09:59goodieboyis there something in clojure, that is similar to Ruby's "ensure"?
10:00craigbro(try ... (finally ...)
10:01goodieboycraigbro: ahh right, thanks
10:03cshellwmealing_: that sounds like a good approach, thanks!
10:37achengpartial works on fns with more than one arg list i.e. [a b] and [a b c] ... nice!
10:43babilenacheng: Think of it as (partial (partial (partial f first_arg) second_arg) ...
10:56mdeboardHow would I add a dependency for a package that doesn't have, that I can find, a maven repo? ghost4j specifically
10:57michaelr525hello!
11:01duck11231mdeboard: that's annoying, especially since they're obviously using maven to build it
11:01mdeboardI agree
11:02ohpauleezmdeboard: You can add it to a local repo, and add the local repo to your list of repos for your project
11:02ohpauleezOr, build the package, release it on clojars
11:02ohpauleezand then you'll be all set
11:02mdeboardohpauleez: That's what I'm looking at doing right now (clojars), just not sure how to go about doing that. No experience with poms etc, seems easy to screw up.
11:03ejacksonmdeboard: you need to install the jar into your local maven repo (or something like nexus, if you havet it)
11:03ejackson16:02
11:04ohpauleezYou grab the pom, grab the jar, and scp them to your clojars account. You'll want to change the name of the project a little so it goes to your clojars group-name
11:08mdeboardohpauleez: When you say 'the pom' are you presupposing the download of the jar itself comes with a POM? Because it doesn't.
11:08ohpauleezmdeboard: No you'll have to grab the pom from the source tree
11:08ohpauleezit'll be in the top level
11:09mdeboardI see
11:09ohpauleezyou'll want to grab the source, change the pom, build the jar, and then scp the pom and the jar over to clojars
11:09duck11231if you just checkout that particular tag, and do mvn install, it should install for you, but that's not good fot repeatability
11:09ohpauleezor you can just install the jar as is into a local maven repo
11:11pendlepantsdoes anyone know how to use jmagick in a leiningen project? I've got [jmagick/jmagick "6.2.4"] in my dependencies, but am getting an UnsatisfiedLinkError when I try to import anything that inherits from magick.Magick.
11:11pendlepantsthough I can import magick/ImageMagick just fine.
11:14mdeboardOk, I'll give this a go
11:18mdeboardhey I did it https://clojars.org/net.sf/ghost4j
11:20ohpauleezmdeboard: congrats!
11:22antares_pendlepants: JMagick needs imagemagick installed
11:23antares_pendlepants: possibly a particular version. That's why the Java part loads but then fails to link against the native code it relies on. Maybe check that you have imagemagick installed?
11:23antares_sorry if JMagick is something pure Java, I am under the impression it is imagemagick bindings
11:24Frozenlockmdeboard: you can do PDFs with ghost4j?
11:26pendlepantsantares_: thanks. I've got imagemagick installed, but JMagick not finding it makes sense. I'll start looking at that.
11:35michaelr525pendlepants: when i needed to manipulate an image i just ran the imagemagick cmd utils from clojure by executing an external program
11:36pendlepantsmichaelr525: sorry for being dumb, but how you do you do that from clojure?
11:38nDuffpendlepants: Runtime/exec is the traditional approach
11:38nDuffpendlepants: ...I vaguely recall seeing a friendlier Clojure library for running external tools (w/ support for pipelines and such), but don't recall its name offhand.
11:38michaelr525pendlepants: first you need to add conch to your project
11:39michaelr525pendlepants: then check this https://www.refheap.com/paste/3883
11:41gtrakapache commons exec and wrappers were pretty ok for me
11:41pendlepantsthanks nDuff/michaelr525.
11:42FrozenlockIs there a way to make an alert popup with only clojure? (no seesaw and alike)
11:42gtrakFrozenlock: from http://clojure.org/getting_started (javax.swing.JOptionPane/showMessageDialog nil "Hello World")
11:43gtrakyou can also sometimes do something with command-line utilities, like kdialog on kde
11:46augustlperhaps there's an applescript/clojure bridge around for OS X ;)
11:47Frozenlockgtrak: Nice! Thanks! The ~9mo "hello world" from seesaw was scary :)
11:49gtraknp
12:16edwtechnomancy: Thanks for turning me on to nrepl. Have you noticed that it seems to have broken Paredit's '{' treatment?
12:22technomancyedw: yeah, there's an open ticket for it
12:23technomancyedw: it's due to the fact that clojure-nrepl-mode is a major mode instead of a minor mode; I think there's actually an open pull request fixing that
12:25technomancyedw: in the mean time there's (define-key clojure-nrepl-mode-map "{" 'paredit-open-curly)
12:26mdeboardFrozenlock: I guess so
12:31edwtechnomancy: Ah, thanks.
12:32cch1Quiz: why doesn't this work:
12:32cch1(defmacro d [a] (let [b (into clojure.lang.PersistentQueue/EMPTY a)] `~b))
12:32cch1(d #{:a})
12:33cch1Hint: I've just had my mind blown by the dependency of macros on literal representation of data.
12:40ToxicFrogcch1: absent the `~, I'd say "because the macro needs to return an AST and instead it's returning a PersistentQueue"
12:40ToxicFrogBut I'm not clear on how they interact when conjoined like that.
12:41cch1ToxicFrog: you can change the macro to
12:41cch1(defmacro d [a] (let [b (into clojure.lang.PersistentQueue/EMPTY a)] `(list ~b)))
12:41cch1with the same result
12:41michaelr525hello!
12:42ToxicFrogcch1: in that case, I've got nothing
12:44ToxicFrogI would expect (and macroexpand confirms) that it expands into (list <value bound to b>)
12:44cch1ToxicFrog: I'm pretty sure the root of the problem is in the fact that there is no literal syntax for a PersistentQueue.
12:44cch1ToxicFrog: the expanded macro can't be processed by the reader perhaps...
12:44ToxicFrogOh.
12:45ToxicFrogI wouldn't have expected that it would need one.
12:45cch1ToxicFrog: me either, but I have no other explanation. The same macro structure works fine for any "supported" data structure -but not PQs
12:45edwHas it occurred to anyone to have nrepl-mode insert accurate lineno and filename metadata into forms when they're evaled in a buffer? That seems like it might be a fun weekend project for me if no one else has taken it.
12:47gfrederickscch1: whatever a macro returns is supposed to be eval'd
12:47gfredericksor compiled rather
12:47gfredericksand there's no reason that the compiler should know what to do with a queue
12:47gfredericksalso `~b could be simply b
12:47technomancyedw: that'd be great
12:47cch1gfredericks: yes, I think that sums it up nicely
12:47technomancyedw: personally I've been conditioned to only use C-c C-k
12:48edwtechnomancy: I was about to say the same thing.
12:48technomancyregion-level eval isn't worth the trouble
12:48technomancyso far anyway; no reason it couldn't be made to work
12:48edwC-x C-e and C-M-x would be at least 90%.
12:49edwI get so sick of NO SOURCE FILE in stacktraces.
12:49technomancyso I told the barista I was programming and he was all "you mean you're like ... making programs yourself? wow."
12:50ToxicFroggfredericks: the bit that surprised me is that I would have expected the RV from the macro to bypass the parser entirely, being a raw AST, and thus it wouldn't matter if values with no text representation are "directly" bound into it.
12:50technomancydo you actually use C-x C-e on defns?
12:50ToxicFrogtechnomancy: occasionally I wonder where most people think programs come from, if not programmers.
12:51gfredericksToxicFrog: it bypasses the reader
12:51gfredericksbut the reader never returns a queue
12:51gfredericksso the compiler isn't equipped to deal with them
12:52edwIf one more person says, "Oh, like IT?" I will kill them when I tell them that I am a programmer/program.
12:53edwNo, NOT like Geek Squad, no, not like Geek Squad at all.
12:54gfredericksedw: throughout my undergrad years in CS, my dad (a quasi-programmer) repeatedly asked me if they were teaching me to build my own computer
12:54technomancyedw: I don't know about you, but I travel exclusively by B&W volkswagen
12:54cch1gfredericks ToxicFrog: I'm wondering if a nice workaround can be constructed in 1.4 with homegrown literal support for PQs
12:54gfrederickscch1: a workaround? what on earth would you need this for?
12:55ToxicFroggfredericks: fun thing, I actually did that
12:55ToxicFrog(CPU design course)
12:55ToxicFrogLoads of fun.
12:55gfredericksToxicFrog: oh I think he meant physically
12:55cch1gfredericks: I want to write a macro that constructs a PQ at expansion time and provides it into some more complex form to be evaluated at runtime.
12:56cch1(defmacro d [a] (let [b (into clojure.lang.PersistentQueue/EMPTY a)] `(complex-stuff ~b)))
12:57gfrederickscch1: is this a performance concern or a code-simplicity concern?
12:57cch1gfredericks: If I create the PQ at runtime, I can get around the problem....
12:57cch1(defmacro d [a] `(let [b# (into clojure.lang.PersistentQueue/EMPTY a)] (list b#)))
12:57cch1gfredericks: performance -because I can work around the problem as above
12:57gfrederickscch1: if you create the queue at the top level, it should only get created once at compile-time
12:58cch1gfredericks: ewww
12:58gfrederickse.g., (let [my-queue (into ...)] (defn my-func ...))
12:58edwOf course, I'm all over the "yeah, I can fix your computer" if it's an attractive, intelligent girl.
12:58gfrederickscch1: or you could complect compilation with data-structure caching O_O
12:58gfredericksdef a gensym! :)
12:59gfredericksthat's the first compelling use for def-nesting I've heard of
12:59cch1gfredericks: I've spent the last six months at my job convincing everyone else that def-within-def is evil -I'll be damned if I'll ever admit to there being even one valid use case.
13:00cch1ever
13:01edwcch1: How about for defining a sentinal value for identifying missing values in a map?
13:01edwSentinel, even.
13:01cch1edw: let works in all the contexts I can think of off the top of my head...
13:02cch1(feeling nervous having dogmatically staked out an extreme position :))
13:02edwBut why LET for every invocation? You only ever want one of them?
13:03cch1edw: depending on where the map comes from, there's a context around it that is a nice place for a let. And if the map is top level, then a surrounding let is only going to be evaluated once anyway.
13:05ToxicFrogedw: yeah, for me...if they aren't (a) family, (b) romantically involved with me or (c) running linux and willing to pay, no tech support.
13:06cch1edw: (let [sentinel :a] (defn myfun1 [] ..work-with-map..) (defn myfun2 [] ..work-with-map-some-more))
13:07edwcch1: I mean something like this: https://gist.github.com/3208379
13:08edwThe metadata shouldn't be there: I just moved that DEF inside the DEFN.
13:09cch1edw: https://gist.github.com/3208387/931db496276133009887aabc5ae1cac158cf61be
13:11edwThat seems a bit unnatural. Yes, you can do that, but you have a nested DEFN!
13:11edwOr a non toplevel one.
13:11edwWhich is really the stylistic "problem" IMO.
13:12cch1edw: I most definitely do not have a nested defn -I have a let-over-lambda -a beautiful more-private-that-private closure
13:13edwI'm all about the LET over LAMBDA--love the book too--but this is a LET over a DEF you're showing me.
13:13cch1edw: the problem with the nested def is that you leave top-level residue in the namespace instead of encapsulating the local (!) concept of a sentinel
13:14edwI hear you.
13:14cch1edw: (defn is a macro that writes lambdas)
13:14cch1cch1: edw (just had to double check that...)
13:14edwAmong other things.
13:15edwAnd those other things are what make nesting it a stylistic "problem."
13:16edwI've read SICP, Scheme is my preferred language, I know what you're saying.
13:17edwI'm just too old for religion.
13:18edwSeen too much.
13:18uvtcAdded a non-clever iterative solution to the end of http://rosettacode.org/wiki/Fibonacci_sequence#Clojure .
13:18cch1edw: sounds reasonable. I can appreciate a preference for having a top-level defn of your function.
13:20edwThat said I wish there were an idiomatic to define something a la C's function-scoped static vars.
13:20edws/an idiomatic/an idiomatic way/
13:43hugodwrapping a fn definition with with-local-vars might come close, but is still not idiomatic
13:44llasramI think (let [...] (def/n ...)) is perfectly idiomatic
13:51jtoyhow do I add a change (if (nil? json) [] ( map json ["id" "description"])))) to (if (nil? json) [] ( vector( map json ["id" "description"]))))) if I am at here: (if (nil? json) [] ( HERE map json ["id" "description"])))) with paraedit?
13:53raek"(vector <C-right> <C-right> <C-right>" is one way
13:54raeksorry, that's not right.
13:54ejacksonyup, you said it was C-right
13:55raekC-b (vector <C-right>
13:56raekejackson: hm?
13:56jtoycontrol-right ?
13:56raekyes
13:56ejacksonsorry, long day, poor jokes :|
14:00jtoyrabbler: how do I know what c-right is? I've never really understood paraedit, trying to learn it now
14:01rabblerjtoy, what made you ask me? I haven't a clue as to anything about paraedit.
14:01metellusC-thing means ctrl+thing
14:01mattmosshttp://emacswiki.org/emacs/PareditCheatsheet
14:01jtoyraek: how do I know what c-right is? I've never really understood paraedit, trying to learn it now
14:01jtoyoh
14:01raekjtoy: use C-h k <some key> to leatn what it does
14:01jtoyI'm on vim though, sorry, forgot to mention that
14:02raekjtoy: and use "C-h m" to learn about the key bindings of the current buffer (as well as other mode documentation)
14:02raekjtoy: oh. my utterances were for emacs.
14:02technomancyit seems like a bit of a problem that all these alternate paredit implementations self-describe as simply "paredit"
14:02jtoyraek: cool, i heard they are almost the same, ill try to figure it out..
14:03emezeskejtoy: You should call it "paredit.vim" when you ask questions, to avoid confusion
14:03raek(I thought "paraedit" was just a misspelling of "paredit")
14:03jtoysorry, i thought everyone uses vim :)
14:04raekhttp://chart.apis.google.com/chart?chxl=0:%7C0%7C81%7C162%7C243%7C324%7C405%7C1:%7COther+%E2%80%94%C2%A05%25%7CCommand-line+REPL+%E2%80%94+20%25%7CVim+%2B+vimclojure+%E2%80%94+21%25%7CTextmate+%2B+textmate-clojure+%E2%80%94%C2%A05%25%7CNetBeans+%2B+Enclojure+%E2%80%94%C2%A05%25%7CIntelliJ+%2B+La+Clojure+%E2%80%94%C2%A09%25%7CEmacs+%2B+SLIME+%E2%80%94+61%25%7CEmacs+%2B+inferior-lisp+%E2%80%94%C2%A07%25%7CEclipse+%2B+Counterclockwise+%E2%80%94%C2%A
14:04raekyikes, what an URL...
14:04scriptordoesn't work :/
14:04emezeskejtoy: So, if you moved your cursor on top of the paren just to the left of "HERE", and typed "<LocalLeader>W" in normal mode, you would wrap the whole (map ...) form in new parens, then you could add vector
14:04scriptorLocalLeader?
14:05raekhttp://goo.gl/BDfk4
14:05raeksource: http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/
14:05emezeskescriptor: Type ":help LocalLeader" into your vim.
14:06scriptoroh, vim
14:06jsabeaudryraek, only 61%... can't wait to see the result for 2012
14:06technomancyI wonder if there's still anyone using textmate
14:09jtoyemezeske: that worked! i need to read the doc a couple more times, i don't really get it when I read it before
14:11emezeskejtoy: It takes a while to get it into your fingers. I definitely recommend just playing with the various commands; sometimes they don't make sense from their descriptions, but once you try them it all comes together.
14:14technomancyseancorfield: late to the party, but I just noticed jsql and the notion of a compiler that targets SQL here: http://dev.clojure.org/display/design/java.jdbc and am very interested in where this is going
14:15technomancyis jsql still too experimental for general consumption?
14:16scriptorso, I'm going through the arguments to a function call and building a new list out of it
14:17scriptorwould it be better to use a regular list, conj onto it, and then reverse that (to preserve the original order of the arguments)
14:17scriptoror try to append to a vector so there's no need to reverse it at the end?
14:19S11001001scriptor: are you using map?
14:19scriptorS11001001: reduce, because it's not really a 1-to-1 mapping from the original arguments to the new one
14:20scriptorsome of the args need to be specially processed and then aren't included
14:20S11001001scriptor: is each output element built from knowledge garnered from only one element of the input?
14:20scriptorS11001001: yep
14:20scriptoreach output element is directly tied to only one input element
14:20S11001001scriptor: are said output elements in the same order as the relevant input elements?
14:21scriptorS11001001: they should be, yes
14:21S11001001scriptor: then you can use mapcat, which is simply map followed by apply concat
14:22S11001001,clojure.pprint/cl-format
14:23clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.pprint, compiling:(NO_SOURCE_PATH:0)>
14:23S11001001,(require 'clojure.pprint)
14:23clojurebotnil
14:23S11001001,clojure.pprint/cl-format
14:23clojurebot#<pprint$cl_format clojure.pprint$cl_format@2410a383>
14:24S11001001,(mapcat (fn [n] (if (odd? n) [n (cl-format nil "~R" n)] [])) (range 10))
14:24clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: cl-format in this context, compiling:(NO_SOURCE_PATH:0)>
14:24S11001001,(mapcat (fn [n] (if (odd? n) [n (clojure.pprint/cl-format nil "~R" n)] [])) (range 10))
14:24clojurebot(1 "one" 3 "three" 5 ...)
14:25S11001001scriptor: in that example some inputs produce 2 outputs, some produce 0
14:25scriptorS11001001: yep, so just return [] if you want the element to be ignored?
14:26S11001001indeed; in fact, if your problem is more constrained than my example above, there are yet more alternatives
14:26S11001001,(doc keep)
14:26clojurebot"([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."
14:30scriptorhmm, f might print stuff, so I probably can't use keep
14:30S11001001scriptor: don't worry too much about it; if you need strictness, use doall
14:31S11001001scriptor: regardless it might be worthwhile to arrange things such that prints are encoded in the resulting list
14:31S11001001which would make the decisions about what to print pure, and thereby trivially subject to unit testing
14:31scriptorS11001001: what do you mean by encoded? So that it won't immediately print them?
14:32S11001001scriptor: your result is a list, right? Well, some elements look some way, and elements that look like, say, [::print "blah"] encode a request to print "blah" followed by a newline
14:33scriptorS11001001: right, so that it doesn't use an actual call to print, but can be processed later on?
14:33S11001001scriptor: indeed
14:34scriptorwell, the tool is a basic debugging helper, so that it prints certain values when the specific line is reached
14:34S11001001yes?
14:34clojurebotyes isn't is
14:34S11001001thanks clojurebot
14:35scriptorsomething like (debug + 1 :dbg-print 2) where 1 would be printed
14:35scriptorso the resulting list should be just (+ 1 2)
14:36scriptorbut in the repl or whatever environment it's run in, it would print 1 before it is evaluated
14:36scriptorso the printing can't be done lazily, I think
14:36S11001001don't you want, then, to insert the prints into the generated code?
14:37scriptorS11001001: but that'd result in something like (+ 1 (prn 1) 2) or (+ 1 [::print "blah"] 2) wouldn't it?
14:37scriptorwhich would result in an error
14:38S11001001(+ 1 (do (prn 1) 2))
14:38scriptorah
14:38scriptordoes do not return anything, not even null?
14:39ToxicFrogscriptor: check the parens - it evaluates all of its args and returns the last
14:39S11001001,(do 1 2)
14:39ToxicFrog,(do 1 2 3)
14:39clojurebot2
14:39clojurebot3
14:39ToxicFrog,(do (prn 1) 2 3)
14:39clojurebot1
14:39clojurebot3
14:39scriptoroh, dammit
14:40ToxicFrogAlso, totally stealing this idea for debug tracing in my lexer
14:40scriptorToxicFrog: help me make it somewhat decent first :) https://github.com/Scriptor/clj-here
14:40clojureboteg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging
14:41ToxicFrogscriptor: is it slime-specific as the readme impies?
14:41scriptorToxicFrog: yep
14:41scriptorToxicFrog: well, break is
14:42scriptor:dbg-prn-last isn't
14:42ToxicFrogI may have some difficulty helping given that I don't use slime, then :P
14:42scriptorinferior-lisp?
14:42clojurebotinferior-lisp is a lot like http://www.penny-arcade.com/comic/2011/09/28
14:43scriptoralso, S11001001: what happens if there aren't any arguments after the print, so (foo 1 (do (prn 1)))
14:43scriptorwhere you only want to call foo with one parameter
14:44S11001001(foo (do (prn 1) 1))
14:44S11001001or (do (prn 1) (foo 1))
14:44scriptorhmm, so it'd have to detect when there aren't any arguments left
14:45scriptorotherwise it can just put the next argument in the do
14:45scriptoralthough, this is still assuming mapcat wouldn't work, which I think it would
14:47ToxicFrogscriptor: inferior-lisp?
14:48scriptorToxicFrog: what do you use instead of swank-clojure?
14:48ToxicFrogIDEA.
14:48scriptorah
14:48ToxicFrog+ lein for build and dependency management.
14:49scriptoris there any way to manually invoke the debugger in iDEA?
14:51ToxicFrogProbably, but to be honest, I've never tried
15:21eggsbyhey clojurites, I'm having trouble with a transformation: https://www.refheap.com/paste/3894
15:21eggsbyI feel like I want to partition by some function, but I can't quite understand what the function should look like
15:23joegalloyou can do it with reduce, and a vector of vectors serving as an accumulator.
15:24hiredman(fn f [es] (lazy-seq (when (seq es) (cons (cons (first es) (take-while #(.startsWith % "\t\t") (rest es))) (f (drop-while #(.startsWith % "\t\t") (rest es)))))))
15:24joegalloare you only worried about two levels of nesting?
15:24scriptoreggsby: also look into http://clojuredocs.org/clojure_core/clojure.core/partition-by
17:21Raynesmuhoo: https://github.com/Raynes/lein-pdo
17:22Raynesmuhoo: Seems to work for your cljsbuild auto case.
17:23emezeskeRaynes: I actually talked to muhoo a bit more and I think I convinced him that running cljsbuild auto and repl in the same terminal is a bad idea.
17:23akhudekThe Java VisualVM sampling feature sure can give misleading results compared to doing full sampling.
17:23akhudekerr profiling.
17:23Raynesemezeske: Why is that?
17:23emezeskeRaynes: He was under the impression that the repl listened for telnet connections on some port
17:24emezeskeRaynes: But really it just talks to stdin/stdout, and so it will be clobbered by the auto build output
17:24emezeskeRaynes: (telnet or nrepl or something)
17:25Raynesemezeske: It would be useful to be able to run cljsbuild auto and a headless repl to connect to from nrepl.el.
17:25RaynesPretty sure input and output of leiningen is irrelevant in that case.
17:25emezeskeRaynes: Most definitely. I told muhoo that I'm very receptive to pull requests to that effect :)
17:25RaynesI'm not sure what you would need to do.
17:25RaynesIt works fine with pdo, doesn't it?
17:26RaynesAnyways, pdo seems useful in general.
17:26emezeskeThe clojurescript repl?
17:26emezeskeYeah I agree that pdo is cool in general, I can think of a couple uses for it
17:26RaynesI guess I just don't know what you're saying you'd accept a pull request for.
17:26emezeskeThe clojurescript repl talks to stdin and stdout, and that's it
17:27RaynesI was under the impression that his use case was to run cljsbuild auto and start a headless nrepl server in one go, which should be completely fine with pdo.
17:27RaynesI probably just misunderstood him.
17:27emezeskeI believe that his particular use case was "cljsbuild auto, cljsbuild repl-listen", but he probably was running an nrepl server as well, so pdo would help with that
17:28hiredmanhttps://github.com/hiredman/nrepl-cljs-middleware
17:28RaynesThat wasn't the example he gave me when I talked to him. His example was a trampolining repl.
17:28RaynesHe is a complex man, that guy.
17:29emezeskeHeh, it sounds like there's some confusion in general. Anyway, pdo is cool for sure.
17:29RaynesI'm sure at least one person will find a use for it some day.
17:29Raynes:p
17:29akhudekhas anyone ever seen sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run() while profiling?
17:30akhudekit somehow always crops up and ends up taking 95% of the cpu time
17:30akhudekeven though this application doesn't do any TCP
17:30emezeskehiredman: That is interesting; I'm not sure if that would integrate with the command line repl, though (based on my cursory glance)
17:30akhudekalso, sun.* is in the do not profile list
17:30akhudekdrives me crazy
17:46muhoothis guy?
17:46emezeskemuhoo: We've been talking about you :)
17:46muhoomy ears been a-burnin
17:47muhoolooks like you made a thing, and it is good
17:48muhoothat's pretty amazing, and fast!
17:49Raynesmuhoo: wut
17:50muhoopdo, fantastic, thanks
17:50muhooonce i get through with today's chores, i'll have a look at a headless cljs nrepl
17:50muhoowhich, would require me understanding and possibly doing a lot of copy/pasting from your repl.clj in leiningen
17:51pandeiro_is it possible to use phantomjs/casperjs through clojurescript?
17:51emezeskepandeiro_: You mean to write the driver script for phantomjs?
17:51pandeiro_emezeske: yeah, write it in cljs?
17:52emezeskepandeiro_: I expect that it might be possible, although I haven't tried it
17:52emezeskepandeiro_: The interop stuff should all just work
17:52pandeiro_emezeske: yeah i know those use require('stuff') semantics...
17:53emezeskepandeiro_: It would definitely need to have the minimum :optimizations turned on so that it was one file
17:53emezeskepandeiro_: *at least the minimum
17:53muhoomy ultimate use case is this: a one-liner leiningen invocation, that can launch my noir project as a headless nrepl, the cljsbuild as a bg task, and a cljs repl as headless nrepl.
17:53pandeiro_ah so it's all just right there
17:53muhoopdo gets me 60% there. now i just have to deal with that nrepl cljs bit
17:53emezeskepandeiro_: It should be pretty easy to get a "hello world" compiled with ":optimizations :whitespace" and throw that at phantomjs
17:54pandeiro_emezeske: gonna try that one of these days, i'll report back
17:54emezeskepandeiro_: Awesome! In the lein-cljsbuild advanced example project, I use regular javascript to drive the tests
17:55emezeskepandeiro_: I want to change that to clojurescript eventually; if you're successful I'll be more motivated
17:55emezeskenDuff: This is something else
17:55pandeiro_emezeske: cool, let me take a stab at it
17:57nDuffhrm.
17:58muhooemezeske: just to be clear, yes, i understand why i don't want to run a repl in the same terminal as the auto cljsbuild, but i *do* want to run my repl headless, along with the noir project, and the cljsbuild auto, all in the same terminal and in the same process if possible.
18:00emezeskemuhoo: Yeah, we're on the same page. Obviously that's ideal.
18:00emezeskemuhoo: All I wanted to communicate is that it's not possible without some elbow grease, which you seem to be ready to supply :)
18:00augustlis there a generic library for recursively watching for changes in the file system in a certain directory?
18:01muhooemezeske: i'm game for trying. i'll probably be annoying Raynes with lots of questions along the way.
18:01emezeskemuhoo: :)
18:01RaynesWhoa, what do I have to do with anything cljs related?
18:02muhoonot cljs related, but nrepl/lein related
18:02muhooi'm reading lein-pdo, it's like one function, and it looks like complete magick and wizardry to me
18:02RaynesWhoa, what do I have to do with nrepl and lein?
18:02Raynes:p
18:03RaynesOh, you must have seen me commit some headless server stuff to lein. Damn it! I should do my work under assumed names.
18:03muhooheh. there's no faking it. i see yer name all over repl.clj :-)
18:03RaynesI wrote the original version of it.
18:03RaynesIt has since been heavily modified, but I generally know how it works.
18:03RaynesSo I'll help you as much as possible.
18:04muhoothanks, i'll try to puzzle out as much of it as i can on my own
18:15muhooRaynes: might might to mention in pdo docs that it requires lein2.
18:15muhooon lein 1.7.1: leiningen.pdo Problem loading: java.io.FileNotFoundException: Could not locate leiningen/do__init.class or leiningen/do.clj on classpath: (pdo.clj:1)
18:15RaynesI like surprises.
18:18_zachAnyone have any tips on debugging clojurescript macros?
18:18emezeske_zach: I tend to use a regular-clojure repl to macroexpand them
18:18muhooRaynes: surprise! https://www.refheap.com/paste/3899
18:18emezeske_zach: And then you can look at that output to see if it is what you expect
18:19_zachemezeske: That's what I've been doing, but I've run into the problem of everything working in clojure-jvm, but failing to compile in cljs
18:19_zachemezeske: The expanded version of a form, however, will analyze and compile without error
18:19_zachso something in cljs.analyzer/macroexpand-1 (I think?) is causing me trouble.
18:19emezeske_zach: What kind of error are you seeing?
18:20_zachemezeske: something along the lines of "multimethod
18:20_zach"multimethod 'emit-constant' doesn't know how to dispatch on value: class clojure.lang.LazySeq"
18:21emezeske_zach: Interesting, I guess your macro returns a lazy-seq?
18:21emezeske_zach: Sounds like returning a non-lazy list might work around the problem
18:22emezeske_zach: And it sounds like the compiler needs to have support added for emitting lazy-seqs
18:22_zachemezeske: That's the confusing part, though... the macro isn't explicitly returning a lazy-seq
18:22emezeske_zach: Can you paste it?
18:23augustlhow do I fix this? "Exception in thread "main" java.lang.IllegalStateException: Compiler already refers to: class clojure.lang.Compiler"
18:23augustlit happens when I import com.google.javascript.jscomp.Compiler
18:23_zachemezeske: Give me a couple minutes and I'll ping you
18:23emezeske_zach: Sure.
18:26CheironHi, when defining an anonymous function with #() , is it ok to write #(and () ()) or we have to #((and () ())) ?
18:27augustlapparently "ns-unmap" is a way to fix it
18:28_zachCheiron: The first version is okay. #(form) expands to something like (fn [..args] (form))
18:28augustlany suggestions?
18:28_zachCheiron: Notice that it wraps the form in a set of parens
18:28Cheironeye c
18:29_zachaugustl: I'm trying to do some research. The problem is that you can't have two Compiler's in the same namespace, so you have to somehow either unmap it (which you did), or alias the import
18:29_zachI'm not sure if the latter is possible
18:29Cheironany quick function to check that something isn't nil?
18:29emezeskeCheiron: You can just use if or when
18:30emezeske,(when 42 (println "not nil"))
18:30clojurebotnot nil
18:30Cheironi need it with and form
18:30metellusemezeske: won't that kind of thing also catch false?
18:30emezeskemattmoss: Derp. Yes it would.
18:30Cheiron(and (not-nil) (another condition))
18:31metellus,(nil? nil)
18:31clojurebottrue
18:31augustl_zach: how do I alias an import?
18:31metellusCheiron: (not (nil? foo))
18:31_zachYou can just say (and value (another condition))
18:31_zachand if the value is nil, it wont execute (another condition)
18:32_zach,(and nil (println "not printed"))
18:32clojurebotnil
18:32_zachCheiron: ^
18:33_zachemezeske: https://www.refheap.com/paste/3900
18:33metellus,(and false (println "not printed"))
18:33clojurebotfalse
18:33Cheiron_zach: I see, thank you :)
18:34_zachemezeske: umm... let me post an example of its use as well
18:34Cheironclojurebot: (or 'iOS 'android')
18:34clojurebotNo entiendo
18:34_zachCheiron: I recommend using http://tryclj.com/ to test stuff out
18:35_zachemezeske: https://www.refheap.com/paste/3901
18:36Cheiron_zach: cool!
18:36_zachemezeske: forms are executed after all continuations have been called by the binding forms
18:36emezeske_zach: Maybe syms is the problem?
18:36emezeske_zach: It is built from map, and then unquoted into the let form later
18:37_zachemezeske: Yeah, this is the thing we had the most trouble with...
18:38emezeske_zach: try changing it to "syms (vec (map first bindings))" -- any difference?
18:39_zachemezeske: that sounds like a great idea... trying now
18:45_zachemezeske: That worked! Thank you for taking a look!
18:46emezeske_zach: Great! That is definitely a bug in the clojurescript compiler; could you open a case on the clojurescript jira, with the details about your problem and the workaround?
18:46emezeske_zach: The fix is probably pretty easy
18:46augustlhow do you create "JSSourceFile[]" from clojure with java interop? More specifically, what do you do with a JSSourceFile to make it into JSSourceFile[]?
18:47xeqi&(doc into-array)
18:47lazybot⇒ "([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class ... https://www.refheap.com/paste/3902
18:47_zachemezeske: Yes, I will open a ticket later :). Thanks for the support.
18:48augustlseems like passing a vector works too
18:48emezeske_zach: Yeah, no problem, I'm happy to see bugs like that get caught before they bite me. :)
18:49_zachaugustl: Native clojure data structures implement a lot of java interfaces
18:49_zachaugustl: If you can, use the clojure structures.
18:52augustland how do you access fields from Clojure? :) foo.bar type fields, not a method call.
18:52augustl_zach: I see, thanks
18:54xeqiaugustl: (foo/bar)
18:54xeqi&(System/out)
18:54lazybot⇒ #<PrintStream java.io.PrintStream@1f9ef0c>
18:55augustlI'm getting "no such namespace foo" for (foo/bar)
18:55augustlfoo is an instance, if that matters
18:57xeqioh, then I think (.bar foo) should work
18:58augustlwhat if there's a method with the same name?
18:58_zachaugustl: http://clojure.org/java_interop explains a lot of this, if that helps
18:59aperiodicunless the method doesn't take any args, the compiler will be able to figure out which thing you want
18:59_zachaugustl: what do you mean by a method with the same name?
18:59aperiodicif it's a no arg-method, you'll need to use the explicit field access in 1.4 (.-bar foo)
19:01augustl_zach: can't there be methods and fields with identical names?
19:01augustlaperiodic: ah, I see
19:02_zachaugustl: I see what you're saying now. refer to aperiodic :)
19:20aphyrNeat, so clj-http.client/get on a uri that takes a long time to respond will spike *all 8 cores* of the repl to 90%
19:20aphyrlooks like jline.internal.nonBlockingInputStream.read() and Reflector.getMethods()
19:23technomancyaphyr: ouch! can you report that as an issue on the reply project?
19:24aphyrSure
19:24aphyrUh... actually, where? Github?
19:24aphyrThink this is the first bug I've caught in clojure, haha
19:24technomancyyeah, here we go: https://github.com/trptcolin/reply/issues/new
19:25technomancyassuming it's from `lein repl`
19:25aphyrAwesome. Yeah.
19:26technomancycool
19:33antares_aphyr: you are using preview6, any reason to not use preview7?
19:33antares_aphyr: I believe there were reply bugs fixed between preview6 and 7
19:34aphyrUh, I just wasn't aware preview7 was out. lemme upgrade.
19:35antares_technomancy: this reminds me, we need a twitter account for leiningen. seriously.
19:35technomancybut https://mobile.twitter.com/leiningen is taken =\
19:37antares_technomancy: yup, but we can use clojureleiningen
19:37antares_it sucks a bit but will be easier to google and there are far worse usernames on twitter
19:37RaynesGod no.
19:37casionhas or does anyone here use clojure on android?
19:38casionI'm curious how viable it is in general
19:38antares_whoops, Raynes is unhappy :) (doall (map abandon plans))
19:38gfredericks(doseq [plan plans] (abandon plan))
19:39technomancyI'd rather just publish http://leiningen.org/news.atom or something
19:39technomancypeople are probably just interested in seeing a link to NEWS.md every time there's a release
19:40emezesketechnomancy: What about making lein occasionally check for updates and print out a message if a newer version is available?
19:40emezesketechnomancy: (or maybe it already does that?)
19:41technomancyit does that if you install via apt-get =)
19:41emezeskehaha
19:41emezeskedo you have a PPA set up (or whatever)?
19:41antares_Raynes: what about leiningenreleases?
19:41antares_or leinreleases
19:42technomancyemezeske: no, it just goes straight into sid
19:42emezesketechnomancy: ah, nice
19:42technomancyI guess a PPA would be nice for backports
19:42technomancybut 2.x is still a long way away from being packaged
19:42emezeskesure
19:43technomancymaybe once we have something ready I'll see if anyone can help with the Ubuntu side
19:43emezeskemaybe I'll create an AUR PKGBUID eventually for those rare arch users out there :)
19:44technomancyemezeske: 9% according to http://lein-survey.herokuapp.com/results
19:44technomancythere's an arch package out there, but it's pretty broken IIRC
19:45emezesketechnomancy: 9%! whoa!
19:46aphyrCan confirm CPU spin is still present in preview7
19:46aphyrThough it appears reduced to 60%
19:47technomancyemezeske: well compared to 62% for apt-get
19:48emezesketechnomancy: I was expecting like <1%, so 9% is a win.
19:48technomancyit's ... higher than fink I guess
19:49technomancyand gentoo
20:08augustlhow do you set the value of a field on an Java object instance?
20:12xeqi(doc set!)
20:12clojurebotCool story bro.
20:12xeqi&(doc set!)
20:12lazybotjava.lang.SecurityException: You tripped the alarm! set! is bad!
20:12xeqiblah
20:12technomancyhehe
20:12xeqi&(doc (symbol "set!"))
20:12lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
20:12emezeskeaugustl: A lot of java interop questions are answered here: http://clojure.org/java_interop
20:13emezeskeaugustl: Search that page for set!
20:13aphyrIs there a recommended way to include data files in clojure programs?
20:13antares_augustl: https://github.com/michaelklishin/monger/blob/master/src/clojure/monger/core.clj#L143-170
20:14antares_aphyr: resources
20:14aphyrLike, I know jars have space for arbitrary resources, just haven't figured out what part of clojure exposes it
20:14antares_and then clojure.java.io/resource that shit
20:14antares_and you can slurp resources, for example
20:15aphyrOh, sweet. Ugh, can't wait until the clojure 1.2 results disappear from google, haha
20:15antares_aphyr: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L61, typically I use src/resources for all resources
20:15i_sanyone know how to insert default values into a table using clojure.java.jdbc?
20:16antares_aphyr: and if you have src/resources/csv/1.csv, load it as (slurp (io/resource "csv/1.csv")), that's about it
20:18augustlemezeske, antares_: thanks
20:21antares_aphyr: we now have @leinreleases for announcements ;)
20:21i_sah, you just dont include it in the insert statement. never mind.
20:21aphyrantares_: woot
20:56pandeirobest way to remove an item from a vector by index?
20:56gfrederickscan't be done efficiently unless it's at the end
20:57gfredericksthus there's no convenient API for it in clojure.core, because by doing that you make your explicit use of vectors questionable
20:57gfredericksbut you can whip it up yourself with (vec (concat (take (dec n) v) (drop (inc n) v)))
20:58gfredericksmaybe something cleverer
20:58gfredericksbut definitely first question whether you really need vectors
20:59gfredericks,`[~@(range 3) ~@(range 5 7)]
20:59clojurebot[0 1 2 5 6]
20:59gfredericksand there's that if you want to be really goofy
20:59pandeirowhoa
21:00pandeiroi am modeling ordered pages in a collection and i want to be able to insert and delete by index... is there something better than vector to hold them?
21:00emezeskepandeiro: Sounds like a possible use for a map
21:01emezeskepandeiro: (Or perhaps a sorted-map if that's important)
21:02pandeirohuh, and the keys would just be the indices?
21:02emezeskeYeah
21:02pandeiroin my head i thought that's kind of what vectors were (javascript background rears its head)
21:02gfredericksyeah, that doesn't give you the shifting behavior you may or may not have wanted
21:02emezeskegfredericks: good point
21:02gfredericksvectors are like maps from ints to things, but with very specific performance constraints
21:03gfredericksyou can update anywhere, but can only add/remove at the end
21:03pandeirohmm, filterv
21:04emezeskegfredericks: I think that you're right about the vector performance contract
21:04emezeskegfredericks: But, I think that in practice they are more efficient at middle insert than you'd think based on the contiguous-array model
21:05gfredericksemezeske: afaik it should be at best linear in the number-of-things-to-the-right
21:05emezeskepandeiro: There's also subvec, which is maybe faster than take/drop for vectors
21:05pandeiro,(filterv (complement nil?) (assoc [:a :b :c :d :e] 2 nil))
21:05clojurebot[:a :b :d :e]
21:05emezeskegfredericks: I think vectors are actually implemented as trees in clojure
21:05emezeskegfredericks: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
21:05emezeskegfredericks: Although that article is old
21:05gfredericksemezeske: yes but everything lives in a length-32 array
21:06gfrederickswhere its position corresponds to its absolute position in the vector & 31
21:06emezeskegfredericks: Ah, I reread your last comment, it makes sense
21:21pandeiroemezeske: hello world with casperjs driven by cljs successful, as you predicted. now to the fun stuff :)
21:33FrozenlockTaking a chance here: anyone knows if it's possible to get `every other' item in a mongodb collection? (With congomongo or directly with the shell)
21:34ThatOneGuydoes (take-nth) work on the return seq from queries?
21:35FrozenlockWell, yes, but I want this to occur on the server. For example, take every 1/100th of a collection with thousands of items.
21:36FrozenlockWhat I'm trying to do here is to avoid filling my jvm when I really don't need everything.
21:47dnolenk core.logic seems like it can solve sudoku problems nearly as fast as Norvig's very clever custom Python solution ...
21:50ohpauleezdnolen: Sick!
21:51ohpauleezI just made an async bus (re: reactive - rfp) - it's wins all around tonight
21:51dnolenohpauleez: haha, cool :)
22:51brainproxyneat ... just realized I can have mutliple repls open in emacs to the same/one swank server embedded in my project
22:51brainproxydon't know why I didn't try that before :p
22:53kwertiibrainproxy: how do you open the additional ones?
23:04dnolenpretty darn succinct sudoku solver, http://gist.github.com/3213107
23:04uvtcWhere can I find the source for Rich's "ants" demo? Did not see a repo for it at https://github.com/richhickey .
23:04uvtc~ants
23:04clojurebotants is http://clojure.googlegroups.com/web/ants.clj
23:04uvtc{sigh}
23:04uvtcOh, that's not it, actually.
23:05uvtcClojurebot, do you have a newer link for that?
23:05shokyuvtc: https://gist.github.com/1093917
23:06uvtcOooh. Thanks a bunch, shoky. :)
23:07uvtc~ants-demo
23:07clojurebotI don't understand.
23:07uvtc~ants-demo is https://gist.github.com/1093917
23:07clojurebotIn Ordnung
23:07uvtc~ants-demo
23:07clojurebotants-demo is https://gist.github.com/1093917