#clojure logs

2011-09-20

00:01mindbender1technomancy: there's a similar complaint here: http://groups.google.com/group/clojure/browse_thread/thread/22139531e3abc663
00:09technomancysure, but no mention of contrib there
00:14mindbender1technomancy: thanks for you help but is there a way to uninstall and start afresh?
00:15technomancysee if it works on a fresh project from "lein new foo"
00:15technomancyif you still have trouble there you could try removing ~/.lein
00:20technomancypushed a new swank-clojure snapshot to clojars that does alter-var-root on *out* so it all goes to the slime repl buffer even from threads
00:20technomancyplz to try
00:21icefoxIn clojurescript is it not allowed to recur inside of a case statement ?
00:25amalloyicefox: it should be allowed, but it's possible that wasn't implemented. looking through the cljs source, i don't even see (case) being implemented anywhere; does it work?
00:26icefoxcase compiles, but if I put a recur inside of it produces a compiler error. Haven't honestly run it yet. Mostly fumbling around while putting off reading Programming Clojure :)
00:27icefoxFor example just dumped this into the hello.cljs sample http://rosettacode.org/wiki/Execute_Brain****#Clojure
00:30technomancywow, storm is on the top watched of the month even though it's only been public a day.
02:32mindbender1how do i abort an REPL session in emacs
02:35mindbender1because I get : "Starting swank server...
02:35mindbender1error in process filter: Symbol's value as variable is void: Process [2 times]" when I try to reconnect after disconnecting with quit()
02:41tomojquit()?
02:54amalloyhiredman, technomancy: at least one of you has some kind of scheduled-repeated-execution library, right? like, "do this every N seconds"?
02:59amalloydie-giester looks like it's not going in exactly that direction
03:02raekamalloy: what about a ScheduledExecutorService?
03:02amalloyraek: yes, i'm writing the code to do that myself at the moment
03:02amalloybut if someone can save me the trouble...
03:06raek(def exe Executors/newScheduledThreadPool) (.scheduleAtFixedRate exe #(println "hello") 1 TimeUnit/SECONDS)
03:07raekI think that basic usage could be as simple as that
03:08raek...modulo errors in my example (the factory method takes an additional arg)
03:08amalloyraek: yes. i'm not really happy with that level of detail; i've written it so i can write (schedule-task #(println "hello") 1 :s), and it uses the namespace's threadpool
03:08amalloybut of course it's not hugely burdensome either way
03:09raekI see. :)
03:10amalloyand it seems like the kind of simple wrapper someone would have written already
03:44clgvWhere can I set the size of the history for "lein repl"? I think it must somehow pass it to rlwrap.
03:47dbushenkohow is android? is clojure or clojurescript ready for android?
03:50clgvdbushenko: there was some talk on adjusted clojure for android. but you have to google for it.
03:50dbushenkothanks
03:57michaelr525hey
04:10clgvwhere in the leiningen source do I find the invocation of JLine or rlwrap? I didnt find anything when searching.
04:13raekclgv: it's probably in the lein shell script
04:14clgvraek: where do I find that one?
04:16clgvbtw. thats one of the things that really needs to be documented
04:18raekhttps://github.com/technomancy/leiningen/blob/1.x/bin/lein
04:19clgvoh its not in the regular git repo`
04:25teromclgv: you could try something like set history-size 500 in ~/.inputrc (if rlwrap supports that)
04:27clgvterom: I can. but I dont know if that will work
04:30clgvterom: I have to find the history file it uses to check if that had an impact
04:43clgvterom: no it does not seem to work
04:44teromclgv: ah, too bad. Then you just probably have to hack lein script. Options for rlwrap are defined around line 218.
04:45clgvterom: hm yeah, but it'll get lost when performing an upgrade, I guess
04:47teromclgv: yes, probably. Maybe send a patch?
04:48clgvterom: then I would have to find out how to make it a general option for lein - it looks as if it cant be done via project.clj
04:49teromclgv: true, since it's before the invocation of JVM...
06:35pauldoowhat's the syntax for specifying the type of a local in a let binding?
06:37khaliGpauldoo, #^type
06:37pauldoo(let [x #^java.lang.String "foobar"] .. )
06:37pauldoo ??
06:37lazybotpauldoo: Definitely not.
06:38khaliG(let [#^java.lang.String x ...] ..)
06:38khaliGalthough in your example it's redundant cos the compiler can see its a string :P
06:39pauldookhaliG: yes - it's an example
06:39pauldoothanks
06:39khaliGnp
06:43pauldoohm - it doesn't fail if the type is incorrect
06:43khaliGyea it's a hint not a type check
06:43pauldooahh - ok
06:44pauldoowhat's the idiomatic way to do a type check? (us a pre-condition?)
06:52cfahi all
07:00cfai have a style/idiom question re: macros -- is anyone around?
07:03thorwilcfa: don't ask to ask, just ask and you may see ;)
07:04clgvpauldoo: you can use instance? if you really have to. ##(doc instance?)
07:04lazybot⇒ "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
07:05clgvpauldoo: or 'cast if you want the check-and-fail behavior. ##(doc cast)
07:05lazybot⇒ "([c x]); Throws a ClassCastException if x is not a c, else returns x."
07:07cfathorwil: heh, okay
07:07cfa(wasn't sure whether anyone was around)
07:07cfasay i have something like this: http://pastebin.com/DPdeYGvZ
07:08cfais this considered good practice? since i'm def'ing in the macro, i need to unquote 'dir' in the doseq
07:09clgvcfa: you can do that - but why dont you use defn?
07:10cfaclgv: i had that originally, was just messing around here
07:10clgvcfa: ok then better stick to defn. Rule #1 of the macro club, dont write a macro. Rule #2 dont. ;)
07:11clgvthats from "Programming Clojure" if I remember correctly.
07:11cfaha ha
07:11clgvcfa: You should only use macros if you really need their features: deferred evaluation of params or code generation...
07:12cfaright
07:12clgvif you are just starting with clojure, then simply dont use macros now ;)
07:12cfaand since here my caller actually wants normal evaluation of the argument, macros are from the outset a bda idea?
07:12cfaclgv: i used to write quite a lot of (common) lisp
07:12cfaso i'm familiar with macros, though quite rusty
07:13cfa(sidenote: this example isn't for a "real project", it's just to dig into clojure's macro syntax)
07:13clgvcfa: I guess it's quite similar in CL with the suggestion to only use macros when your really need them
07:13cfasure
07:14clgvif you want to learn about clojure macros it's usefull to use them in examples ;)
07:14clgvbut your example looks like a poor defn replacement
07:14cfalet me rephrase the original question, then: if i were insane and decided to use a macro here, would my eval + syntax-quote approach be the sanest way of going about this?
07:14cfaclgv: yeah, for sure
07:15cfa(and i haven't overlooked your answer to my 'idiomatic' question, btw -- noted)
07:15clgvI guess I wouldnt use eval.
07:15clgvI would write another macro for the looping the just gets the seq '(north south east west)
07:16clgvs/the just/that just/
07:16lazybot<clgv> I would write another macro for the looping that just gets the seq '(north south east west)
07:19clgvthe neat thing about that is that at compilation time the 4 forms are literally written there for the compiler since the macro expanded to those 4 forms
07:19cfahmm, interesting
07:21cfaclgv: thanks for your help
07:31clgvcfa: np
09:40cemerickHi everyone; I've set up a Clojure 'scholarship' fundraiser for ambrosebs, like what helped get Raynes to the Conj last year. Please help if you can: http://wp.me/p10OJi-aX
09:41michaelr525cemerick: how old is ambrosebs :)
09:41michaelr525?
09:42cemerickmichaelr525: No idea :-) Maybe he'll answer, but I'll bet he's not awake at this point.
09:42ambrosebsmichaelr525: 21
09:42ambrosebs:)
09:42michaelr525good for you :)
09:43cemerickambrosebs: good evening! Here we go, huh?
09:43ambrosebscemerick: phew, exciting!
09:45ambrosebsi've got a test tomoz so i'll be around for a few hours yet :)
09:46cemerickwell, focus on that for sure :-)
09:47cemerick$3k is probably going to take a while, so don't spend time hitting refresh on the fundraiser status bar, etc.
09:48michaelr525cemerick: where are you located?
09:48ambrosebs:) I meant any more questions, just ask i'll be here
09:49cemerickmichaelr525: at strange loop in St. Louis right now. Usually Western Massachusetts.
09:49michaelr525So what time is it?
09:51cemerickmichaelr525: You mean where I am now? 8:53
09:51michaelr525oh
10:28fhdI'm not sure if I really want to do it (I.e. if it's the most elegant approach), but can I have instance variables with deftype?
10:28fhdThe thing is, I'm working on an app that supports several database backends, and I'm using defprotocol and deftype for that
10:28clgvfhd: you mean mutable attributes?
10:28fhdHowever, some backends need to open a connection initially, e.g. fleetdb
10:28fhdclgv: Yeah
10:29fhdclgv: I'd basically like to put a (def) inside a (deftype) and only have it executed if that is instanciated
10:29clgvfhd: yes, you can have that#
10:29fhdclgv: I kind of need a constructor
10:29steslaShould proxies always have unique class names?
10:30fhdclgv: How? I guess I could turn that connection into an attribute and instantiate it when I instanciate that type, but it doesn't seem right
10:30clgvfhd: see ##(doc deftype)
10:30lazybot⇒ "Macro ([name [& fields] & opts+specs]); Alpha - subject to change (deftype name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (m... https://gist.github.com/1229252
10:30fhdclgv: I read that, did I miss something?
10:31clgvyou can declare fields mutable. but you could also use atoms or refs as values
10:31fhdclgv: Oh sorry, that's clojure-contrib deftype. I didn't check that
10:32clgvfhd: no clojure deftype is what I talked about
10:32fhdclgv: Sounds good, thanks
10:33fhdclgv: Hm, then I can't see how I can initialise a field
10:33clgvfhd: when constructing the deftype
10:34clgvyou should have a construtor function for it
10:34fhdclgv: You mean like this? (MyType. (create-my-field))?
10:34raekfhd: the simplest way is probably to have a ref or an atom in an instance field. def will not work since it always defines a global ("static") variable
10:34raek(deftype Foo [f]) (defn make-foo (Foo. (atom 0)))
10:35clgvfhd: like raek said^^
10:35fhdraek: Yeah, I considered passing the thing in. Was just wondering if I could move that logic into the devtype
10:35fhdraek: Because it seems cleaner to me
10:36fhdraek: But since that doesn't seem to be supported, I'll take the simple way. Thanks :)
10:37fhdFor the record: clojure contrib has a deftype which supports an attribute map, so I guess I could do it like that. But I don't feel like confusing myself with a non-standard deftype
10:37clgvfhd: the factory function is fine. you shouldnt think too oop ;)
10:38fhdclgv: Yeah, following the KISS principle usually holds the OOP off :)
11:38arohneramalloy_: https://github.com/arohner/clojure-contrib/tree/1.3-compat
11:39drewrarohner: sweet
11:41arohnerdrewr: thanks
11:44TimMcshiny
11:45theignoratihow do I split a string by (?
11:47arohner,(doc clojure.string/split)
11:47clojurebotIt's greek to me.
11:47arohnerI'm useless without swank in front of me.
11:50theignoratiI don't really want to write a regex though
11:51theignoratiwhy doesn't (.split "foo" "(") work?
11:51arohnertheignorati: that calls java's method, which also takes a regex
11:52theignoratiit works with other characters though
11:52bhenry,(first (.split "?" "foo?bar"))
11:52clojurebot"?"
11:52arohnerright, but ( is a special char in a regex, it defines a grouping
11:52arohnertry \(
11:52bhenry,(first (.split "foo?bar" "?"))
11:52clojurebot#<PatternSyntaxException java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0
11:52clojurebot?
11:52clojurebot^>
11:52pdkregexes have control chars that have to be escaped to be used literally
11:53arohner,(.split "foo(?bar" "\\(")
11:53clojurebot#<String[] [Ljava.lang.String;@f353f9>
11:53arohner,(seq (.split "foo(?bar" "\\("))
11:53clojurebot("foo" "?bar")
11:53theignoratithanks :)
11:54arohnerso \ escapes characters, like \n
11:54arohnerbut \( is not a legal escape, and you want to end up with "\(", so you have to do \\ to get a single \
11:58TimMcIt is irritating that .split requires a regexp but doesn't allow a Pattern
11:58TimMcso you have to do extra quoting in clojure
11:59TimMc,(seq (.split "foo(?bar" (str #"\(")))
11:59clojurebot("foo" "?bar")
11:59TimMc^ how to use regex literals anyway
12:02Chousukeisn't the str redundant
12:02Chousukeor does .split not take a Pattern argument at all
12:02TimMc,(seq (.split "foo(?bar" #"\("))
12:02clojurebot#<ClassCastException java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to java.lang.String>
12:02Chousukehm :/
12:02arohner.split doesn't take a pattern at all
12:02TimMcThere is no variant for it.
12:03TimMcJava's core libraries are disappointingly sparse.
12:08terom,(seq (.split #"\(" "foo(?bar"))
12:08clojurebot("foo" "?bar")
12:16arohnerhas anyone gotten lein swank to run with clojure 1.3?
12:18pandeirois there anywhere with examples using clojurescript's clojure.browser.net IConnection protocol?
12:23choffsteinAnyone know if there is a way to get jetty (through ring) to just run on any port it can find above, say, 3000?
12:24manutterchoffstein: there's always the brute force method (try/catch inside a loop)
12:24choffsteinmanutter: yeah, I was hoping for something a little…sexier :D
12:24choffsteinlike I didn't know if jetty would automagically do it for me given a certain set of parameters
12:25teromchoffstein: https://github.com/weavejester/lein-ring perhaps
12:25choffsteinand then I could get the port by asking for a given attribute on the server object
12:27manutterI just googled "jetty 'first open port'" and got back "Full Text of 'Economic History of Manchuria'"
12:27terom:-D
12:27manutternot exactly what I was after...
12:29stand1manutter: Maybe you should read it, just to be sure.
12:29manutterI tell you what, it actually sounds a bit interesting
12:30winkmaybe the first port in manchuria wasn't much more than a jetty...
12:30manutterindeed
12:31manutterIt seems to be a scan/transcription of some book from "The Charles William Mason Collection on China and the Chinese," from the Cornell Univ. Library
12:31manutterI'll write some clojure code to parse the text for me and reduce it to a ring configuration.
12:35manutterchoffstein: All I'm getting from google (besides Chinese coal exports in 1915) is a passing reference to setting the port to zero to mean "first available port"
12:35choffsteinah, I'll give that a try. thanks :)
12:35manutterwhich doesn't satisfy the "above 3000" part you were asking for, but it might be as close to "sexy" as you're going to get
12:37TimMcIt will probably be above 3000.
12:37TimMcThe OS will pull a port from the "ad hoc" range.
12:38TimMc"ephemeral port range"
12:40TimMcIf you're on Windows, maybe not.
12:51choffsteinWell, 0 does the trick -- but retrieving the port seems trickier. When I request it back, I get 0 :D
12:51choffsteinThat's….less than helpful
12:52choffsteinAh, figured it out. getPort, getLocalPort … what's the difference :D
13:11duck1123Are there any functions / libraries that will recursively merge two hashes. (ie. if the value is a key, one is used, if it's a hash, they're merged, and if it's a seq, they're catted together)
13:12duck1123I can write one myself, but it sounds like something that others might have done
13:13duck1123I meant if the value is a string / number / some other object, then one wins
13:15altsridhas anyone implemented in-process message queues in clojure, with multiple producers and single consumer? i am looking for simpler alternatives to having the overhead of an external queue (e.g.: rabbitmq, redis)
13:15duck1123lamina
13:16antares__srid: zeromq can be used for very efficient in-proc communication as well
13:16_sridi was inadvertently implementing such a thing myself yesterday using agents and had to bail out due to inability to synchronously 'pop' from an agent queue.
13:17_sridby 'overhead' i mean development time, not so much cpu time :)
13:17clojurebotmultimethods is what separates the boys from the men.
13:17_sridwho was clojurebot responding to?
13:17duck1123antares_: if you have a handler on a zeromq queue, in which thread is the handler run?
13:18duck1123in lamina, the enqueing thread runs the handler, (from which you can pass that to a different thread)
13:19antares_duck1123: I am not sure
13:23_sridduck1123 have you used lamina in your projects?
13:24_sridlamina's wiki says "if we allow multiple threads to publish events, our event stream is no longer ordered" - but what about the ordering of events from one thread (among many)? are they out of order as well?
13:24_sridin my case, each publisher is tail'ing a log file from a server.
13:24_sridi don't care about ordering of the logs from *different* sources, but the ordering of logs from a *single* source should be the same as publishing order
13:25duck1123if you publish to a lamina channel, they should come back out in the same order
13:25duck1123I use both Lamina and the server component (Aleph) in my apps
13:27_sridduck1123 - what does aleph actually doing? the README is not very clear.
13:27_srids/doing/do/
13:27lazybot<_srid> duck1123 - what does aleph actually do? the README is not very clear.
13:28duck1123Aleph is a wrapper for Netty. So you can build web apps where you can send the response from a different thread as the request comes in on
13:28duck1123it also has an async http and redis client
13:29zippy314aleph is pretty cool. It's also built on top of lamina, which is a channels based async communication library.
13:29_sridi eventually want to process these log records, analyze them and host their 'stats' as a web app. would aleph help with that?
13:29duck1123Just the other day I posted about wanting to make a logger appender that posted to a lamina queue so that I could do fun things with it like sending it over a websocket connection
13:30_sridthink of multiple instances of an app running in various EC2 instances, and you are analyzing their logs, consolidating them and providing an unified stats interface to the user (via web browser).
13:30zippy314Does anybody know what's going on with clojurescript keywords? It appears that if you do (str :somekeyword) it returns a string with some odd non-ascii characters on the front that cause javascript to be very confused.
13:31duck1123_srid: Unless you can thing of a case where you want to perform work across different threads, you could probably get away with just using jetty. Thankfully, it's really easy to convert a normal Compojure/Ring app to Aleph
13:33TallAdamhello everyone in Clojure-land: does anyone know how to get my logging output to print to my repl, as opposed to into thin air (where its currently going). I'm using swank-clojure in emacs
13:36duck1123_srid: If you do checkout Lamina/Aleph/Gloss and you're using 1.3 and you run into problems, I've been maintaining 1.3 compatibility in my fork
13:38thorwili guess there's no alternative to the :as in a fn signature like [{:keys [foo bar] :as all}] that would bind a map with only the selected keys?
13:39TimMcTallAdam: What are you logging with?
13:39_sridduck1123 - thanks, I use 1.2. i am going to replace my incorrect agent-based queue implementation with a lamina based one.
13:39TallAdamTinMc: clojure.contrib.logging
13:40_sridnow, tools.logging, I guess
13:40_srid,where did contrib go?
13:40clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: where in this context, compiling:(NO_SOURCE_PATH:0)>
13:40_sridhmm
13:40duck1123_srid: what part of contrib are you looking for?
13:41TimMcTallAdam: Logging in the Java ecosystem is really irritating. I think clojure.contrib.logging pipes it all through to whatever logger you have on the classpath. Are you using log4j?
13:42TallAdamTimMc: I think so
13:48TallAdamalternatively, when using swank-clojure in emacs, how do I get a console buffer up (I assume my logging output is going there). I am using clojure-jack-in
13:49duck1123I thought that was what you had to give up by using clojure-jack-in?
13:50_sridduck1123 - in lamina, (enqueue …) blocks until all receive handlers complete running, correct?
13:50TallAdamduck1123: really?
13:50_sridand, does the receive handlers run in the same thread as the caller of (enqueue)?
13:51duck1123Yes, but you just make the handlers run with async
13:51duck1123It's an annoyance, I agree
13:52_sridduck1123 in my case, (enqueue) will be called from the 'worker' thread (each worker thread tail'ing a log file from a server).
13:52_srid.. unless there is a way lamina can abstract the worker threads
13:53duck1123hey, if you're doing "workers" feel free to check out my Ciste library
13:53duck1123I'm doing similar stuff
13:54duck1123https://github.com/duck1123/ciste/blob/master/src/ciste/workers.clj
13:54TimMcTallAdam: Are you sure log4j isn't just suppressing all your log messages? I've had a devil of a time trying to get log4j.properties just right.
13:55_sridok. duck1123 - so lamina doesn't spawn threads at all? it does everything in the same thread?
13:55TallAdamTimMc: don't think so - am using the standard console appender
13:55duck1123_srid: no, it leave it to you to spawn the threads as needed
13:57raekTallAdam: have you looked at the top of the *swank* buffer?
13:58chewbranca/j# emacs
13:58chewbrancabah
13:58TallAdamraek: bees - there it is
13:58TallAdambees = jees
13:59TallAdamraek: what it doing there? can I nuke the rest of the stuff in that buffer?
14:00duck1123That's why I prefer to have a real console running in a screen session
14:00raekdunno
14:01TallAdamraek: thanks a bunch :)
14:01nkozalamina is like python twisted?
14:04duck1123does twisted have the http part, or is it just messaging and async?
14:10schlechtvIn ClojureScript master as of today: when I start a browser repl env, I get a prompt straight away, without waiting for a connection. Regardless of whether a browser connected or not, it then hangs at evaluating anything. Any ideas? Anyone got the browser repl working on master?
14:20_sridduck1123 - lamina, in conjunction with future, turns out to do what I needed
14:23pandeiroWhen using Leiningen, is there a way to simply run `clj core.clj' and have the right classpaths? I am doing some basic webserver tutorials and I can't get them to work outside of the lein repl because of classpath
14:24pandeiroschlechtv: I have the Browser REPL working, and it always shows the Server on port 9000 message before the ClojureScript:user> prompt
14:26schlechtvpandeiro, so it doesn't wait for the client to connect?
14:26schlechtvpandeiro, when you do a netstat, does it show the connecting ESTABLISHED?
14:26pandeiroit will show the prompt without a browser even being open, yes, but eval will just hang if that's the case
14:27schlechtvpandeiro, ok, so then that's just a glitch in the docs (they say the prompt should only come once a browser is connected)
14:27pandeiroit appears regardless, yes, in my exp
14:30schlechtvpandeiro, and the TCP connection between browser and repl is kept alive?
14:30pandeiroyes once the browser is started and the connection is made
14:32schlechtvstrange... mine goes straight to TIME_WAIT
14:45TimMcpandeiro: Regarding lein, I don't think so. How would it know which clojure.core (and maybe contrib) version to use?
14:48TimMcHowever, it might be nice to be able to invoke `lein path/to/file.clj` from within a project and have everything work.
14:56pandeiroTimMc: i am new so bear with me... I see some examples and I don't know how I am supposed to run them... eg https://gist.github.com/585921 (a basic ring example)
14:57_sridwhy is there no "def-"?
15:02schlechtvpandeiro, that example as it is, will only run from a repl of sorts
15:03pandeiroyeah i don't even understand how it would be invoked at the repl, in-ns or something?
15:03schlechtvpandeiro, no, copy & paste :-)
15:04schlechtvor if you have it in your classpath, type (ns ring.example.hello-world-2)
15:05pandeirook so if it were in a file, just ns'ing it would invoke that server function at the bottom?
15:06schlechtvpandeiro, sorry, you'd need (require), not (ns) ... and yeah, I guess require'ing would, unless someone here proves me wrong
15:06pandeiroah ok, thanks
15:20theignoratihey I was benchmarking my compojure site and I found out 80/2434 requests fail because a function that uses SimpleDateFormatter fails. The page loads a file from disk and parses it. The file doesn't change, nothing is dynamic, any ideas how this happens and/or how to solve it?
15:21tomojthey're not threadsafe, could that be it?
15:25theignoratiyeah thanks!
15:28pauldooI have a sorted-set of vector-tuples of strings.. E.g. (sorted-set ["a" "a"] ["a" "zzz"] ["b" ""]). How can I use subseq to find all entries which begin with a given string, say "a".. ? I imagine (subseq coll >= ["a" ""]) would find where the interesting elements start..
15:28pauldoobut what is the end test ?
15:38_sridis it possible to update an incanter 'view' in realtime (via code, not UI)?
15:40joegallopauldoo: (subseq s >= ["a" ""] <= ["b" ""]) seems to work here
15:41joegallopauldoo: this reads better to me, though, it is probably less efficient (filter #(= "a" (first %)) s)
15:41pauldoojoegallo: but in general "a" will be a more complicated string, say "monkey"
15:41pauldoo, so how would I figure out the stop string in that case..?? "monkez" ?
15:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: so in this context, compiling:(NO_SOURCE_PATH:0)>
15:42pauldooI'm thinking an easier way will be to append the null character to the "a" string...
15:42pauldoo(subseq t >= ["a" ""] < [(append-null "a") ""])
15:48fliebelI'm running the Ring Jetty adapter, and it gives a 500, but does not show any stacktrace. What to do?
15:49theignoratiI'm running the ab benchmark tool against my compojure app the first 3 times it keeps getting better results, how do I replicate this effect in production?
15:50fliebeltheignorati: What do you want in production? I think the improvement is due to Java optimizing stuff.
15:50theignoratiI want it to immediately be that fast :*
15:51theignoratiI don't really want to run a benchmark tool against production to warm up the jvm
15:51fliebeltheignorati: The thing is, JIT can only do its most powerful optimizations by analyzing the runtime performance.
15:52fliebelSo you can lower the JIT barrier with some JVM opt, but 'warming up' is really the only way to go afaik.
15:53Chousuketheignorati: if the app will be running for a long time, you'll get nice performance eventually
15:53Chousukeit's a bit difficult to predict exactly how fast your code will become though
15:53ChousukeProviding you don't make any obvious algorithmic blunders :P
15:54theignoratieventually could be a long time considering the difference between 'cold' and warmed up jvm is more than a second
15:54theignoratino opts though
15:55Chousuketheignorati: if the app will be running for more than 5 minutes you'll surely get the boosts :P
15:55theignoratiwont I need visitors though
15:55theignoratiI don't get that many on this site
15:56Chousukenot really
15:56Chousukeif you don't get much visitors then slower code will do just fine
15:56theignoratino
15:56theignoratispeed is a major feature
15:56Chousukeyou don't understand
15:56Chousukeonce the JVM notices it's actually doing work, it will start optimizing
15:57Chousukeand until you do work, you don't even need the speed
15:57hugodor write some post deploy verification tests for your site, that also warm up your site…
15:57theignoratiok
15:57Chousukeusually the most important factor to speed will be your algorithms anyway.
15:57theignoratihugod: that's what I was considering, was hoping there was a better way but I guess this that will do
15:58Chousukethe JIT will optimise memory allocation and other things but it can't turn an O(n^2) algorithm into something sane :P
15:59theignoratiwell I'm parsing a horribly formatted page with Enlive and string splitting, not a lot of algorithms involved
16:31pandeirois there anywhere with examples for using ClojureScript's clojure.browser.net IConnection protocol?
16:40scottjmaybe the browser repl
16:43pandeiroscottj: yah problem is i don't grok the IProtocol syntax or how to call the methods it adds on to Closure's XhrIo
16:44pandeirowhen I inspect the XhrIo object I see clojure.browser.net adds on some namespaced methods like $clojure$browser$net$transmit but i imagine that can't be the way to call them
16:46scottjpandeiro: I haven't seen any open sourced projects that use it
16:48_sridduck1123 - in regards to aleph, is there a library that makes writing websocket clojure apps even easier?
16:51duck1123I got websockets working with jquery, but I recently re-wrote all of my script in clojurescript, and I've yet to get that part working again
16:52duck1123Closure has a Websocket class, but it's not in the latest release yet
16:52kzarI'm learning how to use Enlive and I'm a little unsure what to make as templates and what to generate with Hiccup. Say I'm doing a personal webpage that includes an about page, a portfolio and a blog. Would you have three seperate template html files that pretty much look as the sections will look, duplicating the generic parts of the layout in each? Or would you have one template file, called something like layout.h
16:52kzartml that just contains the part of the layout that's constant and generate the rest with Hiccup? Alternatively I figured I could make a layout.html and have three additional templates, each containing the page specific layout.
16:54duck1123I would have the layout template accept params for each of the sections, and then generate those sections with a different template
16:54duck1123That's basically how I do it, at least
16:56kzarduck1123: OK, yea makes sense to me
17:48amalloy_srid: http://groups.google.com/group/clojure/browse_thread/thread/affca6fa1e777f51
17:55_sridI have a lazyseq like this [a1, b1, b2, c1, d1, a2 …]. ?1 is "start" event, and ?2 is "end" event. i want to process this seq (remember, its lazy) into [(a1, nil), (b1, nil), (b1, b2), .. (a1, a2)]. what is the best way to achieve this?
17:55_srid"map with memory"?
18:00tomojmuch easier to answer if you show actual clojure data
18:00tomojI'm thinking map + reductions but I don't really understand what you want
18:01mdeboardAnyone here integrating Solr & Clojure?
18:01mdeboardOh well lookee here
18:01mdeboardhttps://github.com/mikejs/clojure-solr
18:01_sridtomoj lazy seq of 'events' as they happen. events can be of two type 'start FOO' and 'end FOO' and I want to group the events into ranges (start, end) for each FOO.
18:02_sridevents can be interleaved
18:02_srid[start-a, start-b, end-a, start-c, end-b] => [(start-a, nil), (start-b, end-b), (start-c, nil)] (at the point of realizing 'end-b')
18:03_sridonly calculate for last N events in the seq.
18:03_sridwell, I suppose then I can simply cache the realizations and directly work on them. duh.
18:07Chousuke_srid: couldn't you make a map?
18:07_sridChousuke - not sure how you would 'map' the above sequence to produce the one after =>
18:08_sridmay reduce will work
18:09Chousukewhen you get a start event, conj a nil with that event as the key. then later conj the end event
18:09Chousukehm, I guess that's not very easy to do since you need to find the start event somehow :/
18:10Chousukewell I guess the FOO could act as a key too.
18:10Chousukeif it's unique
18:12Chousukeoh well, I need to go to sleep :P good night
18:14_sridChousuke - yea, which is why reduce would probably work as I can feed the result back to f
18:14amalloywow, i'm surprised. ##(keyword 1) is nil? not :1, or even an exception? that seems cruel
18:14lazybot⇒ nil
18:21_sridwhat is the reason for wrapping variables with STAR? e.g.: (def *something* 42). is it a convention for global variables?
18:21amalloy$google clojure earmuffs
18:21lazybot[Conventions, Style, and Usage for Clojure Constants? - Stack ...] http://stackoverflow.com/questions/3579063/conventions-style-and-usage-for-clojure-constants
18:22amalloy_srid: ^
18:22_srid"ear muffs", heh.
18:29_sridhmm, looks like clojure re has no named group support. java6 doesn't either.
18:36amalloy$google cgrand regex
18:36lazybot[Milestones - cgrand/regex - GitHub] https://github.com/cgrand/regex/issues/milestones
18:36mdeboardI have a really oblique question that I swear is relevant to the channel: Anyone here familiar with Django Haystack?
18:37amalloymdeboard: i'm tempted to bust out ~anyone, but i'm curious where you're going, here
18:38mdeboardamalloy: I'm implementing Haystack at work, which is Django's most ubiquitous search plugin, fronting a Solr backend. Just wondering if there would be any performance gains switching rebuilding & updating the index from Haystack to straight-up Clojure (since Solr does run on the JVM after all)
18:40amalloysee, i have no idea how to answer your question, but i tricked you into actually asking it, so that perhaps someone else will answer :)
18:41mdeboardYou crafty devil
18:41brehautisnt all the heavily lifting in that a) the DB b) solr, with haystack just acting as the go between glue ?
18:41mdeboardbrehaut: Yeah it's just Python -> Solr bindings
18:42mdeboardBUT
18:42mdeboardHaystack does a lot of abstraction, and it's tied to the Django ORM
18:42mdeboardSo it can be extremely slow
18:42mdeboardafaik, anyway.
18:45tomoj_srid: I meant that (a,b) isn't clojure and start-a/start-b etc is opaque
18:46_sridtomoj start-a = {:name a, :type "start"}
18:47tomojthat's better. I'm going home, though. sorry :)
18:50mdeboardI guess there wouldn't be any real gain since I can already use multiprocessing to run multiple concurrent tasks
18:50mdeboardthough I bet there are higher-level advantages that I'm not experienced enough to see.
18:51brehautmdeboard: the answer to your question is, nobody knows your code so use your own profiler
18:51mdeboardbrehaut: I don't really have a question, just blabbering.
19:06neroothI have a (if my-test (do (x) (y) (z)) do-smt-else), when my-test=true it only executes z. How can I get it to execute x, y, and z?
19:07neroothLooks like I misunderstood the do function. What is the function I'm looking for called?
19:09neroothTo clarify: x, y and z are html snippets (field generators) that I want to be rendered in html.
19:14_sridusing atoms for the first time, I hope swapping large data structures is a O(1) operation.
19:14arohnernerooth: (do) returns the value of the last expression evaluated
19:14arohnersince you want to return the value of x,y,z, put them in a list
19:14arohnerdo (list (x) (y) (z))
19:15neroothAh, neat. Thanks.
19:15arohnerand it has to be a list, because hiccup interprets a vector as a single html tag
19:15neroothWould (do (html x y z)) work as well?
19:16arohnermaybe
19:16arohnerare (x) (y) returning "unevaluated hiccup", or strings?
19:16arohneri.e. are they calling hiccup themselves?
19:17neroothno, they are partials
19:18neroothas in, they return a string with html code
19:32ibdknoxnerooth: (html) will work fine in either case, and I think is clearer
19:32ibdknoxnerooth: it's typically what I use
19:40neroothibdknox: Alright, will use that. Nice to see the creator of Noir here :)
19:41ibdknoxI'm usually around more but have had a lot of stuff going on lately, so I've been a bit scarce :)
19:41_sridibdknox while you are here, may I ask what the best way is to go about writing websocket-like apps in clojure? (I just want to push some things from server to browser)
19:42ibdknox_srid: how much do you care about fallbacks?
19:42_sridwhat are 'fallbacks'/
19:42_srids///?/
19:43ibdknoxwhen a browser doesn't support websockets
19:43_srids/\//?/
19:43ibdknoxyou could fall back to polling, htmlfile, etc etc
19:43_sridibdknox - i don't care if it doesn't work IE, for instance. it will be an internal for now. assume firefox or chrome
19:43ibdknox_srid: just use aleph then :)
19:44_sridthe first time i looked alpha, things looked twisted to me. i'll take another, but patient, look.
19:44ibdknox_srid: if performance or fallbacks become important, you'll want something like socket.io
19:44_sridi hate osx auto spell correction
19:44_sridi thought socket.io is nodeJS specific?
19:44ibdknox_srid: I have a netty version of socket.io, but it's getting a bit out of date
19:44ibdknox_srid: typewire.io is built on it
19:45_sridgenerally I want to go via the least resistant route, as the 'web part' is only a minor part of the overall app.
19:46ibdknox_srid: that'll be the easiest route :)
19:47_sridi already use lamina in the backend, btw
19:48_srid.. prior to which I used to hack around agents in futility.
19:48ibdknoxhaha
19:51carllercheWhat's the idiomatic way to handle specific exceptions in clojure (since it seems difficult to create custom exception subclasses)?
20:08scgilardithere's been a lot of discussion about that. here's some of it: http://dev.clojure.org/display/design/Error+Handling . you might get some use out of http://github.com/scgilardi/slingshot .
20:15_sridaleph is broken. cannot find lamina.trace -- https://gist.github.com/1230803
20:17_srid.. fixed by upgrading lamina to beta (clojure needs a correct package dependency management system)
20:26tomoj_srid: don't specify lamina directly and you'll get the one aleph says it needs
20:37_sridduck1123 - distributed social network in clojure? :-)
20:59duck1123Yeah, basically it an OStatus compatible microblog
21:00duck1123I originally started it as a implementation of the OneSocialWeb protocol
21:21technomancyhmm... clojars should reject uploads that contain unresolvable deps
21:21technomancy(y/n)
21:45ambrosebsdnolen: Have we cut a release to core.match? what's the new leiningen string?
21:46dnolenwe have not, now that I'm done w/ Strange Loop I'll some head space for closing the bigger bugs.
21:46ambrosebsis there a SNAPSHOT for core.logic?
21:47ambrosebshow did the mapping dilemma go?
21:47dnolenit always SNAPSHOT in the project, I use hudson to cut a release.
21:47ambrosebsthe readme is a bit out of date, that's all. been getting msgs
21:48ambrosebslinks to wrong snapshot
21:48dnolenmapping dilemma went great! seemed like a lot of people in the audience (close to 200?)
21:48ambrosebswicked!
21:49dnolenSussman was cheering me on I heard :)
21:49dnolenambrosebs: problems in the readme we should just fix right away, no need for release.
21:50ambrosebsdnolen: I tried to add a suggestion for usage, via (use '[clojure.core.match :only [match]]) , but then realized the leningen string still points to the old release
21:51ambrosebsso that's the only issue atm
21:51ambrosebsdnolen: maaaaaan did you get to talk with Sussman?
21:52dnolensadly didn't get a chance too, was awesome to see him everywhere tho.
21:54dnolengot a chance to talk / listen on a lot of cool conversations - had dinner w/ Allen Wirfs-Brock and talked on the finer points of JS / Smalltalk. Listened to Erik Meier defend dynamic typing (!)
21:54dnolenall around an incredible conference
21:55ambrosebsI don't know how you'd top that
21:55ambrosebsamazing
21:57dnolenambrosebs: oh you mean the version on Clojars is old?
21:57ambrosebsapparently
21:57ambrosebswhich makes sense, since the artifact id would have changed
21:57ambrosebsprobably org.clojure/core.match or something
22:00dnolenlatest match pushed to clojars
22:01ambrosebssame leiningen string?
22:06ambrosebsdnolen: any another appearances of logic programming at strangeloop?
22:06ambrosebswell, any at all?
22:07dnolenambrosebs: yeah just match for now. gonna try to prioritize match so we can cut an official release ASAP.
22:07dnolenambrosebs: sussman preso was basically art of the propagator which is very much about logic programming - constraint logic programming.
22:07dnolenrhickey gave an amazing presentation and of course he plugged the logic programming approach as well.
22:09ambrosebswell, two keynotes will do :P Def have to check them out ...
22:16ambrosebsdnolen: update on core.logic + fresh ?
22:18dnolenambrosebs: I have 2 high priority todos: 1) core.logic exist -> fresh 2) core.match backtracking, will probably get started on them tomorrow.
22:19ambrosebsgood to know
22:36st3fanhmm is there a way to filter and modify? i need to select a bunch of maps from a list and add a value that i use for the filtering
22:36st3fani don't want to filter and then run the operation again
22:37symboleIs there a way to do automatic importing in clojure-mode? Hitting some key would create appropriate :import declaration in the namespace.
22:41st3fani would like some combination of map and filter i think
22:42symbolest3fan: Doesn't "for" provide filtering capabilities? So you can exclude things in the generate sequence.
22:52st3fanlet me check for
22:53technomancysymbole: slamhound does that
22:54technomancywith a few caveats
22:56symboletechnomancy: I'll give it a wirl.
22:56st3fanoh for is nice!
23:14simardI have a function drawline that knows how to use a function *transform* to transform its points before the drawing actually gets done. before calling it, I do a binding on *transform*. now I want to define a polygon out of lines and later use it along with a transform, how can I do that ? ie.: how do I post-pone the execution of drawline until the right moment ?
23:15simardI'd like to get that data is code thing right, but I don't see how to do it correctly
23:17tomojyou'd probably have more luck showing some code. that doesn't make any sense to me, at least.
23:17brehauti second tomoj
23:18simardok :)
23:24simardhttp://pastebin.com/ejh8tX00
23:24simardthat's what I was talking about
23:24simardit's working fine right now.. but I'm not sure that's as good as it gets
23:28tomojdon't understand the question about postponing execution in that context
23:28simardyeah it doesn't make any sense does it
23:29simardthe key is I was thinking about def'ining data structures
23:29simardinstead of using defn (functions)
23:32tomojone thing I would suggest is not to println this stuff
23:32simardI'm listening
23:32simardwhat would you do ?
23:34tomojwell, hmm. just looking at gerber-linear-interpolation, simply removing the println makes the function look OK to me. then you have to do the rendering differently, though, and not sure what to tell you about that
23:36tomojit might also return something like {:type :linear-interpolation :x .. :y .. :exposure ..}, to be rendered by another function (and maybe eventually replaced with a deftype and corresponding GerberRenderable or whatever protocol but not until that looks useful..)
23:38simardhum centralizing the rendering function sounds neat
23:38tomoja 'gerber' function with [& args] might take each arg, call 'render' on it, and return a seq of lines
23:38tomojgenerally you want to isolate the side-effects like printing to the smallest part of the code as possible, and make everything else just pure function calls returning data
23:39simardyes I'm aware I was breaking that rule but I wasn't sure how to fix it
23:39simardin the end, the idea is that I'd like to create an object from a series of function calls, and then instanciate that object again later.. a bit like it's possible to do with an opengl display list
23:39simardso using your approach would work find
23:39simardfine*
23:40simardie, I could def'ine a shape as a list of {:type ...}
23:40tomojit also occurs to me that transformations could be applied to data like {:type :linear-interpolation ...} directly (possibly leading to a Transformable protocol or some such)
23:40simardand even transform it as much as I want, and in the end, render it
23:40tomojyeah
23:40simardwhat are protocols ?
23:41simardare they some clojure idiom ?
23:41simardor a more general programming concept ?
23:41brehautsimard: http://clojure.org/protocols
23:42tomojI wouldn't bother with them yet though, best to start with just maps, especially if you're new to protocols/clojure
23:42simardalright, I'll bookmark that .. :)
23:43simardbut I'll read it tonight anyway, I can't think much more so I won't write good code.
23:43simardthanks for the tips
23:44tomojyou may find multimethods useful sooner
23:44tomoje.g. render as a multimethod dispatching on :type
23:45simardneat
23:47tomojbtw, the 'gerber' function I described above would be just (defn gerber [& shapes] (map render shapes)) :D
23:48simardI love this language
23:48simard:)
23:51tomojI suppose render could also have a method for seqs so you just get (render shapes)..
23:51tomojeh
23:52simardone day I will use my own PCB editor written in Clojure :D