#clojure logs

2013-03-08

00:00n_band I assume that means last is eager as well?
00:03alandipertn_b: correct
00:05jeremyheilerHeh. It looks like peek and first + rseq pretty much do the same thing internally.
00:13RazWellesAnyone know what this is? -> ArgumentTypeException expected EventHandler`1, got EventHandler .CallSite.Target (:0)
00:18seangroveI can't get lein to run a project on my server, works locally though
00:19seangroveRunning `lein trampoline with-profile prod run -m zenbox.realtime.worker/start-working` gives an error: "Exception in thread "main" java.lang.ClassNotFoundException: zenbox.realtime.worker/start-working"
00:19seangroveI'm pretty damn certain it's there
00:20hiredmanseangrove: have tried to load that namespace from the repl?
00:21seangrovelet me see
00:21hiredmanmost likely there is some error in it, and lein is helpfully trying to run it multiple different ways and failing
00:22seangroveSeems like it's working: this is from `lein repl` zenbox.server=> (require 'zenbox.realtime.worker)
00:22seangroveWARNING: list already refers to: #'clojure.core/list in namespace: chinpu.export, being replaced by: #'chinpu.export/list
00:22seangroveMar 7, 2013 9:23:34 PM com.mchange.v2.log.MLog <clinit>
00:22seangroveINFO: MLog clients using java 1.4+ standard logging.
00:22seangroveWARNING: read already refers to: #'clojure.core/read in namespace: taika.core, being replaced by: #'taika.core/read
00:22seangroveMar 7, 2013 9:23:35 PM clojure.tools.logging$eval117$fn__123 invoke
00:22seangroveWARNING: (:mailchimp :webhook-url) isn't a valid config
00:22seangroveResque configuration: {:host nil, :port 6379, :namespace "resque:Zenbox", :max-workers 20}
00:22seangroveWARNING: test already refers to: #'clojure.core/test in namespace: zenbox.realtime.worker, being replaced by: #'zenbox.realtime.worker/test
00:23seangrovesorry, paste vs kill ring...
00:23seangroveMeant to paste https://www.refheap.com/paste/90df986fde178710c065edf40
00:23seangroveWhich is obviously redundant after flooding :P
00:25seangroveAny reason why it would think the class isn't there?
00:26seangroveAnd for some reason, it works locally, but not on a remote server
00:27hiredmanand when you run start-working?
00:28seangroveTrying on the server now...
00:30seangroveah, yes, I see an error now
00:31seangrovethanks hiredman, I think it comes down to a :source-paths config in project.clj
01:40danneu1 /quit
01:40pppaulno
01:40pppaul(quit)
01:44frozenlockIs there an idiomatic way to get a random element from a collection?
01:44frozenlockI was thinking (nth coll (rand (count coll))), but it feels kinda icky.
01:45frozenlockOh...
01:45frozenlocknvm...
01:45frozenlockThanks nrepl autocomplete :P
01:46frozenlock#(source rand-nth)
01:46frozenlock,(source rand-nth)
01:46clojurebot#<SecurityException java.lang.SecurityException: denied>
01:46frozenlockDamn you bot!
02:09vurmaSo, whats the best way to currently execute commandline processes from clojure?
02:10vurmaIv found some old blog posts, but i asked just to see if there is anything new on that front.
04:31tomojhmm, when I try to get a browser repl now it seems to load itself recursively
04:36tomojhuh, went away
04:36tomojI must have been doing something stupid
04:36tomojhurray, in-ns works!
05:40ro_stis there a way i can lazily sort-by?
05:40ro_sti've got a 300 map seq which i'm using sort-by on, with a depth of three sort keys
05:41ro_stand it's taking 12 seconds to sort
05:42ro_stoh, wait. a lazy seq is being passed to the sort. nevermind.
06:15NeedMoreDesuCan i REload .class files? I've tried using load with no success.
06:15noidiNeedMoreDesu, no
06:15noidifor that you'll need http://www.jrebel.com/
06:17NeedMoreDesuThat's the only option? Commercial lib?
06:18noidithat's a limitation of the JVM
06:18NeedMoreDesuWhich is somehow dealt with that lib?
06:19pwnedthey have a way of reloading classes in torquebox/jruby, perhaps they also support that in immutant/clojure
06:20pwnedactually the reloaders are in sinatra and rails
06:20pwnedin ruby you just call load to reload the class
06:21tomojhmm, noone noticed that clojure.browser.dom spews logs to the console?
06:36clgvNeedMoreDesu: you could do something like that with classloader artistic ;)
06:37clgvNeedMoreDesu: you can use that lib as starting point https://github.com/flatland/classlojure
06:40borkdudequestion: does anyone ever use letfn instead of let?
06:42cemericktomoj: always been like that AFAIK. Clearly just an experiment or something.
06:43clgvborkdude: only when definining only functions and more than one.
06:47NeedMoreDesuclgv: Wow, that's nice. I should try that.
06:49corecodeis there a better idiom than (apply hash-map (mapcat fn hash))?
06:55borkdudecorecode smth like this?
06:55borkdude,(zipmap (keys {:a 1 :b 2}) (map inc (vals {:a 1 :b 2})))
06:55clojurebot{:b 3, :a 2}
06:56borkdudecorecode you can also use into here: http://stackoverflow.com/questions/1676891/mapping-a-function-on-the-values-of-a-map-in-clojure
06:57noidiinto + for is a very common idiom
06:58corecodeyea
06:58corecodei noticed
06:59corecodein the end i used ->>, map, into
07:00corecodeis there something like #(->> % ...)? something that will take the passed arguments and apply in sequence? comp is close, but doesn't allow for partial functions
07:19NeedMoreDesuclgv: Yeah, I can have new clojure in clojure now. Bad thing, is that they don't reload inside classlojres.
07:20clgvNeedMoreDesu: my idea was that you do reloading by using a new classlojure with the same classpath - this way you should end up with the most recent class
07:21clgvNeedMoreDesu: and you always eval in the current classlojure...
07:22NeedMoreDesuclgv: Yeah, that sounds like it can work that way.
07:22NeedMoreDesuBut I'm afraid of one thing: is it gc'd right?
07:24NeedMoreDesuI'll try to loop to check this out.
07:24clgvNeedMoreDesu: humm, that boils down to the question whether a classloader that is not referenced anymore gets gc'ed with all its classes and objects...
07:24jcrossley3NeedMoreDesu: you might look at Byteman as an open-source alternative to jrebel: http://www.jboss.org/byteman
07:24jcrossley3not exactly the same, but possibly helpful
07:24NeedMoreDesuOutOfMemoryError PermGen space java.lang.ClassLoader.defineClass1 (ClassLoader.java:-2)
07:25tomojis there some way not to have all the internal protocol fns in cljs.core?
07:25clgvNeedMoreDesu: humm? what exactly did you do?
07:25tomojI guess I mean, not to have them auto-referred in all user namespaces
07:25NeedMoreDesu(loop [l 50000] (eval-in (classlojure "file:/D:/end06/cloj-reload/target/the.jar") '(do (load "/tratata") (eval 'tratata/nya))) (if (< 0 l) (recur (- l 1))))
07:27clgvok, you do not hold references to them in this code explicitely. does it work with a (System/gc) in every iteration?
07:32NeedMoreDesuclgv: nope, it still hits the memory limit.
07:34clgvNeedMoreDesu: hhmm its pretty likely that you need to remove the classloader from its parent
07:34NeedMoreDesuMaybe thats because (System/gc) is not forcing gc, and it dies as soon as it have no memory.
07:34NeedMoreDesuHuh, how do I do that?
07:35NeedMoreDesuBut well, no, it's not late gc problem.
07:36clgvNeedMoreDesu: classlojure.core/ext-classloader is the parent
07:37ro_stis there a clojure core fn that does this? (fn [bool] (if bool 1 0))
07:38clgvro_st: dont think so
07:38clgv$findfn true 1
07:38clgv$findfn false 0
07:38lazybot[]
07:38lazybot[]
07:38ro_stthanks
07:38clgv&(clojure-version)
07:38lazybot⇒ "1.4.0"
07:40NeedMoreDesuclgv: So I need to write something to remove it from the parent? Is that possible?
07:41clgvNeedMoreDesu: I dont know. afaik you might be forced to write a classloader yourself that can remove its children. but that is just guessing...
07:41clgvNeedMoreDesu: what is your exact use case?
07:42clgvclojure's dynamicclassloader allows redefinition of classes which is used for deftype and such...
07:43clgvNeedMoreDesu: http://stackoverflow.com/questions/148681/unloading-classes-in-java
07:43NeedMoreDesuI want to have some extension points in code, and to be able to hot-update those.
07:44clgvand the extensions are provided by java classes and not clojure files?
07:44NeedMoreDesuBy .class files.
07:44NeedMoreDesuYes, .clj would be easy.
07:44clgvclojure files would have been trivial ;)
07:45llasramYou can't ever *really* replace a Java class -- just load a new one with the same name
07:46clgvllasram: right. you notice that when your previous deftype instances don't work anymore after reloading the namespace with the deftype^^
07:47llasramOr at least you can't without doing especially crazy stuff. I think there are some commercial dev-oriented tools for hot-patching code in a running JVM
07:47llasramclgv: Ah, right. I should read more than a few lines of context before piping up
07:53NeedMoreDesuHm, maybe I need to read classlojure code closely to find out what can be done.
07:55clgvNeedMoreDesu: I think you need the own classloader that can remove its child classloaders. then you could put that one between classlojure.core/ext-classloader and the classloaders created by classlojure
07:56clgvNeedMoreDesu: but what llasram said remains true, existing objects wont be hot-patched and not even accessible in the new classlojure classloader
07:59NeedMoreDesuYeah. I've just tested that. eval-in returns strings.
07:59clgvNeedMoreDesu: huh?
08:00NeedMoreDesu(eval-in (classlojure "file:/D:/end06/cloj-reload/target/the.jar") '(do (load "/tratata") tratata/nya)) returns "#<tratata$nya tratata$nya@d81e23>"
08:01clgvNeedMoreDesu: ah ok they implemented that to work around the issue that you cannot return custom classes...
08:01clgvbut you can serialize resultdata to string^^
08:01NeedMoreDesulol
08:09clgvNeedMoreDesu: well, it seems as if classlojure serializes to string and reads from it again if possible
08:16NeedMoreDesuclgv: suddenly: (eval-in (classlojure "file:/D:/end06/cloj-reload/target/the.jar") '(do +) 1 2 3) => 6
08:18kittylystAm having trouble with a restructuring form:
08:18kittylyst(defn map-from-httpd-logline [l]
08:18kittylyst (for [[full ip j1 j2 datetime req retcode size] (re-seq logline-regex l)]
08:18kittylyst (let [[f2 base params] (re-seq uri-regex req)] {:f2 f2 :ip ip :datetime datetime :req req :retcode retcode :size size :uri-base base :uuid ()})))
08:19kittylystbase ends up null, and f2 ends up with the entire vector
08:19kittylystAny ideas what I'm doing wrong?
08:21stuartsierrakittylyst: Check that the return value of `re-seq` is what you think it is.
08:22kittylystAha! So it is returning a vector, and needs to be wrapped in an (nth)
08:22kittylysts/vector/lazy seq/
08:23stuartsierraYou may want `re-find` instead of `re-seq`.
08:30kittylyststuartsierra: That's cleaned it up a bunch - thx. Good to see you btw.
08:31stuartsierrakittylyst: Same to you
08:35NeedMoreDesuclgv: (loop [] (let [^URLClassLoader cl (url-classloader ["file:/D:/end06/cloj-reload/target/the.jar"] ext-classloader)] (.loadClass cl "clojure.lang.RT") (eval-in* cl '(+ 2 3 4))) (System/gc) (recur)) -- (eval-in* cl '(+ 2 3 4)) is causing memory leaks
08:36NeedMoreDesuAnd there was '(require 'clojure.main) there
08:36clgvNeedMoreDesu: that was what I was talking about. you need an own classloader to be able to remove "old" classloaders you do not need anymore...
08:37NeedMoreDesuIt works totally fine without that eval
08:37NeedMoreDesuNo leaks
08:37clgvNeedMoreDesu: hence the initial comment of "classloader artistry" ;)
08:38clgvNeedMoreDesu: the "leak" is due to the fact that you do not remove that classloader from the classloader tree
08:39NeedMoreDesuWhen is it added there?
08:39clgvNeedMoreDesu: I am interested in this as well. but I have no spare time in the next days...
08:40NeedMoreDesuOh, ok, sorry.
08:40clgvNeedMoreDesu: it is added in the `url-classloader` call
08:40NeedMoreDesuclgv, yet its totally ok to (loop [] (let [^URLClassLoader cl (url-classloader ["file:/D:/end06/cloj-reload/target/the.jar"] ext-classloader)] (.loadClass cl "clojure.lang.RT")) (System/gc) (recur))
08:41NeedMoreDesuIt loops with no leaks.
08:43clgvNeedMoreDesu: thats because nothing is done. when you write it like that the class clojure.lang.RT is already loaded
08:48clgvNeedMoreDesu: hmm forget that last statement. it is loading the RT class
09:14ambrosebsDoes this chrismgray happen to be around? https://github.com/chrismgray
09:14ambrosebsIn the chat I mean.
09:17corecodeshould i be using (line-seq (java.io.BufferedReader. *in*)) or (iterate read-line)?
09:31stuartsierracorecode: I don't think it matters.
09:32stuartsierraBut eventually you'll run into trouble if you're trying to read STDIN during a REPL session.
09:32corecodeyea
09:48jcromartiesomeone help me stop overthinking everything
09:48jcromartieI just want a simple web API that keeps state in memory and writes it to disk when it changes
09:48jcromartieso, let me think out loud here
09:48jcromartieI'll have a web namespace, a data namespace, with top-level vars holding refs for the things that change?
09:49jcromartiewhere to put the refs, should I pass them explicitly to the functions that add/remove/update the data model?
09:49jcromartieshould I just rely on bindings?
09:49jcromartieI don't want to be a pure-functional weenie
09:50stuartsierraStep One: no top-level Vars.
09:50stuartsierraPass the refs through your entire application.
10:03solussdcould someone tell me why (binding [*ns* (create-ns 'another.namespace)] (defn blah [x] (println "hi"))) doesn't define another.namespace/blah, but instead adds it to my current namespace?
10:04stuartsierraAll `def` forms use the *ns* binding in effect when they were *read*, not when they were evaluated.
10:04stuartsierraIf you want to create Vars in another namespace, use the `intern` function.
10:04solussdah, thanks a lot.
10:04stuartsierranp
10:15NeedMoreDesuclgv: http://www.everfall.com/paste/id.php?ksikmr2fd38y thats where I'm now. I've dug those things and found out that commented line causes memory leak.
10:17jtoyis there a way i can see what version of library is loaded?
10:18jtoyor does lein 1.x automatically install a newer version if i just do lein repl ?
10:19NeedMoreDesuDefinetely no, because you can use old features.
10:21jtoyi founde some really f*cked up clojure/json issue, when i load some certain json with chesire, it interprets the data as an integer
10:21stuartsierrajtoy: With Leiningen 2.x you can call `lein deps :tree`. There was a plugin for that in lein 1 I think.
10:22jtoystuartsierra: hmm, I just did lein repl and it installed the newer dependencies, weird
10:22stuartsierrajtoy: Are they -SNAPSHOTs? Those get updated automatically.
10:24solussdstuartsierra: is it possible to associate metadata with the var that is created with intern? If I use meta instead of defn I'd still like to associate a docstring in the var metadata
10:24jtoystuartsierra: my project has snapshot in it: "1.0.0-SNAPSHOT" but I jsut changed [cheshire "4.0.0"] to [cheshire "5.0.2"]
10:24stuartsierrasolussd: Yes, see the docstring of `intern`.
10:25stuartsierrajtoy: So when you change the dependency, Leiningen downloads it the next time it runs.
10:26jtoystuartsierra: thanks for the explanation
10:26stuartsierranp
10:27solussd stuartsierra: thanks again- i misunderstood the first time I read the doc. :)
10:27stuartsierranp
10:30jtoyI need to do type checking for some of my data, bc im finding bad data coming into my system, is it idiomatic to be doing (= (type data) clojure.lang.PersistentArrayMap) ?
10:31jtoythe data is coming from cheshire json, sometimes I get bad json and cheshire parses it as an integer instead
10:31stuartsierrajtoy: You can usually use predicates like `list?` and `map?` more easily.
10:32jtoystuartsierra: yes, a lot more concise, thx
10:45clgvNeedMoreDesu: humm afair thread local data could be the problem - there should be initialized thread local bindings when you load clojure
10:48clgvNeedMoreDesu: http://immutant.org/news/2012/05/18/runtime-isolation/
10:50solussddoes anyone know what happened to clojure.core/protocol?
10:54clgvsolussd: you mean defprotocol?
10:56solussdclgv: no, the predicate "protocol?", which tested if something was a protocol
10:57clgvsolussd: did no know that it existed
10:58tomojwith the current protocol impl, that would be a very odd predicate
10:58solussdtomoj: did the implementation recently change?
10:58tomojsince a protocol is just a hash-map from clojure code
10:58tomojI dunno
10:58solussdCompilerException java.lang.IllegalStateException: var: clojure.core/protocol? is not public
10:58solussdstill there.. just can't use it. :/
10:58tomoj(boolean (:on-interface maybe-p))
10:59tomojlike I said, very strange
10:59tomojthere's a reason it's private :)
10:59solussdi wondered about doing that, but it probably wouldnt work in clojurescript, given the lack of interfaces
10:59tomoj(that is the implementation of protocol? btw)
11:00solussdbut they took it away from me! I was using it
11:00algernonit never was public, as far as I can see in git history
11:00solussdinteresting.. I have some macros that do different things based on whether you pass them a protocol or otherwise.
11:00solussdeven more interesting... wonder how I was ever using it. :/
11:00tomojthose macros sound evil
11:00tomojmaybe I misunderstand
11:01solussdit's a conspiracy- the clojure.core team is rewriting [git] history!
11:01solussdtomoj: they're not, let me assure you. :)
11:01clgvsolussd: dont they use signed commits?
11:01tomojyou resolve the symbol yourself and check if it's a protocol?
11:01solussdno more evil than the 'defrecord' macro or 'extend-protocol' or 'extend-type'
11:02solussdclgv no idea, I was just kidding
11:03tomojthey don't use protocol?
11:03tomojextend does, which is a function, not a macro
11:04tomojoh, do you mean you just call protocol? in the code the macro expands to?
11:07borkdudeIsn't this old news on hackernews about the clojure reader
11:11mpfundsteinis it possible to tell lein/clojure which java sdk to use? i have boht installed jdk 1.7 and 1.8 and need to use 1.8 for some project while 1.7 for another
11:12nDuffborkdude: Yes, very -- that's why we have EDN.
11:14trptcolinmpfundstein: you can set the environment variable JAVA_CMD
11:15trptcolinafaik it's not possible to specify in project.clj - it'd be a bootstrapping problem
11:17jcromartiestuartsierra said, a while back, that I should pass the refs through the app, and not have any top-level vars
11:17jcromartiebut what about a web app, where the request only has the context of what came into the server?
11:17jcromartiesurely I would have to "inject" the right refs into my functions inside the handler
11:18jcromartiebut it does make sense… so, lilke, (defn add-foo [db foo] (dosync (alter db conj foo)))
11:19jcromartieand in the future, if db is an actual DB spec, I can change add-foo to do the relevant SQL calls
11:19jcromartieseems like a sane way to do it
11:20jcromartieand just use dynamic bindings around the handlers to access the refs?
11:20danneuwhat's the most popular way to generate sql with clojure?
11:20jcromartiei.e. (GET "/foos" [] (get-all-foos *db*))
11:21tomojyou can't really extend a protocol to functions
11:22tomoj:(
11:22nDuffHrm.
11:23papachanif i do (def n (25)) (println (/ n 2)) my output result is 25/2
11:23papachanwhy not my result?
11:24nDuffpapachan: That _is_ your result. If you want to cast it to a float, you need to do that explicitly.
11:24papachannDuff thank you
11:24tomojhttps://www.refheap.com/paste/94cd84ee74f05fed4e634b9a9
11:24papachanis there a math.ceil o math floor in cloj?
11:24nDuff,(type (/ 25 2))
11:24clojurebotclojure.lang.Ratio
11:25nDuff,(java.lang.Math/ceil (/ 25 2))
11:25clojurebot13.0
11:25papachanclojure.lang.Ratio
11:26papachanwaow, clojurebot is the repl here in irc?
11:26borkdudepapachan I tend to use ##(int 132.32)
11:26lazybot⇒ 132
11:26NeedMoreDesuclgv: thats integesting. I think I should have a look on their project.
11:26tomojoh, and functions with metadata always apply in cljs..
11:27clgvNeedMoreDesu: unluckily they do not seem to use the removeThreadLocal function they define...
11:28corecodei'm trying to learn clj by processing some data i have, but it is being really slow (compared to a ruby implementation). could somebody give me some feedback on how to improve the code? https://gist.github.com/5117660
11:28solussdtomoj: yeah< i just call protocol? in the expansion
11:31NeedMoreDesuclgv: isn't using their runtime is enough?
11:31clgvNeedMoreDesu: probably not since they are doing something quite similar to classlojure...
11:31llasramcorecode: Monolithic contrib is dead post version 1.2, which is ancient by this point. You should be able to just use (line-seq *in*) though
11:32tomojsolussd: so hopefully it's not reasonable to pass a non-protocol map with :on-interface key to that function?
11:32corecodellasram: fair enough.
11:32tomoj/macro-missing-a-function
11:32clgv NeedMoreDesu: but you can try. let me know if you succeed
11:32corecodellasram: i doubt that's the cause for slowness tho
11:32solussdtomoj: yeah, it isnt-- I'm just nitpicking at this point. :)
11:32tomojthen I retract my 'evil' estimate
11:33llasramcorecode: I somehow missed your mention of an apparent performance problem... How large is the dataset? Are you sure the slowness isn't just JVM startup time?
11:33solussd;)
11:33corecodellasram: 2 million lines
11:34corecodellasram: i couldn't wait for it to finish yet
11:35corecodellasram: i'm doing roughly 1000 lines per second, which is just way too slow
11:36llasramcorecode: I'm not sure if this has performance implications, but is `:hosts` vs `names` a bug?
11:36nDuffHrm.
11:36corecodeah i renamed stuff
11:36corecode:/
11:36llasramcorecode: And FYI, `name` is the name of a `clojure.core` function. Aliasing works, but is a source of potential confusion/bugs
11:36corecodeit was slow anyways
11:37corecodeline-seq *in* doesn't work :/
11:38fbernierso, let's say I fall on a lib on github and I'd like to give it a quick try in the REPL, how is this possible?
11:39fbernierdo I need to create a new project, add it as a dependency, lein deps, launch the repl, import it and use it?
11:40tomojI note that prismatic's graph works by putting metadata on fns
11:40tomojand relies on extending protocols to Fn
11:40llasramcorecode: Is it a requirement to use *in* BTW? It's generally more common to operate on explicit file paths vs using stdin, although that may just be a side-effect of REPL-based development
11:41blrmfbernier: that is what I would do, yeah
11:41corecodellasram: not strictly
11:47corecodellasram: https://gist.github.com/5117884
11:47corecodellasram: still very slow :/
11:49jweiss-afkif i update a function in a var, i notice other functions calling it from partial do NOT use the new version, whereas functions calling it from #() or (fn ...) do get updated. why?
11:49llasramcorecode: Hmm. I don't see anything obviously slow about the code :-/
11:51llasramjweiss: When you call partial, you pass the function as a value, which the returned function holds a reference to as a lexically-scoped local
11:52llasramjweiss: When you call the function via its var in an function created with fn (or #()), the new function references the original function via its var, which is updated with the new value on recompilation
11:52papachanoh my
11:53ystaelllasram: is this ultimately a syntactic distinction between the head slot and other slots of an application form? or does it come from some other feature of the context?
11:54jweissllasram: it was not at all obvious to me that fn used the var and not the value
11:54corecodellasram: odd, odd
11:55jweissi think this totally reverses my preference for partial over fn. crap
11:55jweisspartial doesn't generate new classes when you precompile, so i thought that was good enough reason for me to use it
11:56jweissbut clearly it is less dynamic, i hadn't realized that
11:56corecodellasram: oh could it be that println is super slow?
11:56llasramystael: Other. `partial` is a function, and when passed something as an argument, receives the value, which is what the created function has available to reference. `fn` is a special form (well, `fn*` is anyway), which creates a new JVM class, the code of which references everything resolving to vars via those vars
11:57tomojsymbol-macrolet with regexes. evil?
11:57ystaelllasram: i see, thank you!
11:57jweissarrggghh. why did it take me so long to realize this
11:57llasramcorecode: It's possible. println -> prn -> pr -> print-method, which is a multimethod. Calling (.write *out* (str from-id " " to-id " " link-count "\n")) instead is something to try
11:58corecodei mean, that printing is in part just debugging
11:58corecodebut i didn't realize it would be that slow
11:58llasramcorecode: Oh. Hells yeah. IO is always slow. Especially in w/ strings Java vs other languages, because you always have UTF-16 -> whatever conversion
11:59llasramjweiss: You can always explicitly pass the var to partial: ##((partial #'+ 2) 2)
11:59lazybot⇒ 4
11:59solussdnothing is evil if 1. you know what you're doing, 2. it is the "best" way to do it- best defined by these three things, in this order: 1. reduces repetition in your codebase so changes in the future don't require hunting down a bunch of duplication, 2. follows idioms of the language, 3. is readable to user's of the language. ;; made up on the spot. :D
11:59nDuffHrm. avout's setRef and alterRef don't handle transactions in RETRY state so well...
12:00clgvNeedMoreDesu: yourkit java profiler points to the thread local variables as well. I profiled that one: (loop [] (eval-in (classlojure "file:///home/gv/.m2/repository/org/clojure/clojure/1.3.0/clojure-1.3.0.jar") '(clojure-version)) (recur))
12:00corecodellasram: write is equally slow
12:00corecodeinteresting.
12:00corecodethe read seems to be quick
12:00jweissllasram: interesting, seems like most clojure programmers eschew partial, i liked it ... until now. i'll have to decide if using the var is uglier than just using fn or #()
12:01solussdi love partial and comp- I try to avoid anonymous functions when possible
12:01TimMc(:refer-clojure :rename {partial pl}) or somethign
12:02llasramcorecode: *out* is a line-buffered PrintWriter... You could try writing to a file via a fully-buffered io/writer instead.
12:02papachanwhy i cannot pass arguments to my function through script args?
12:02papachanhttps://www.stypi.com/papachan/main.clj
12:03corecodellasram: i'll try that.
12:03llasramcorecode: Now that you've mentioned it, I have noticed that writing to *out* has seemed to be slower than I'd expected in the past
12:03corecodeit is incredibly slow
12:03llasramcorecode: But I didn't investigate further
12:03corecodei bound *flush-on-newline* to false (dunno if that is the right way to do it)
12:03tomojsolussd: hmm, regex-based symbol macros certainly don't follow the idiom
12:03corecodebut that didn't help either
12:04solussdthat's the second requirement though. :D
12:04tomojalthough datomic cares about the prefix of symbols in query data
12:04tomojbut that's just data..
12:05tomojincidentally I think a regex symbol macrolet could let you get syntax quote for datomic queries without breaking vars?
12:28jtoywhy can you only do 2 arguments?
12:28jtoy(if-let [x false y true] "then" "else")
12:28corecodellasram: yes, *out* seems to be extremely slow.
12:28jtoyand is there a better way to test with multiple variables? instead of multiple if-let's ?
12:29technomancyjtoy: there's never been consensus on whether the two logical values should be anded or ored together
12:31jtoyi want to do multiple lets where there next variables are bui previous, so that would be an and, can i still do that with one if-let ?
12:31jtoymy terminal looks messed up
12:31jtoyi dont think i can do it though
12:32clgvjtoy: just write your own `if-let-all` - then semantics are clear and you get what you want
12:33TimMcjtoy: https://github.com/timmc/handy/blob/develop/src/org/timmc/handy.clj#L8
12:33jtoyyeah, i will do that later, im not at the level where i feel comfortable writing my own macros
12:33jtoynice TimMc
12:36ivanif-all-let should AND and if-any-let should OR
12:36jtoyivan: agreed!
12:36TimMcI've never wanted if-any-let.
12:36ivanright. I suspect no one would use it.
12:41frozenlo`"HN: Clojure's Default Reader is Unsafe "http://www.learningclojure.com/2013/02/clojures-reader-is-unsafe.html#post-body-2898830171141471587
12:42frozenlo`Hey got #=ed :P
12:42frozenlo`Well, not a 'real' situation, but still.
12:43solussdcould someone tell me why, on line 9 of this paste, x# cannot be resolved? (happens when you call the macro) https://www.refheap.com/paste/87d84be6d7ed8d1f3af54d677
12:44Bronsasolussd: lexical bindings don't work in defrecord/deftype AFAIK
12:45cctennanthey everyone, question about try/catch. I've got a try/catch around a cassandra cql statement execution inside compojure/ring. an (expected) exception gets thrown deep within netty, but I can't catch it — it appears to blow right past my (catch Throwable e) and shows up in my log file as a WARN: An exception was thrown by an exception handler.
12:45solussdwell crap.
12:46solussdwhere is that documented. :P
12:46Frozenlocksolussd: In #clojure, the official clojure doc.
12:47Bronsasolussd: "Note that method bodies are not closures, the local environment includes only the named fields, and those fields can be accessed directy."
12:48Bronsain the docstring of defrecord
12:50llasramcctennant: Are you sure the exception is being thrown where you think it's being thrown from? Lazy sequences in particular can result in evaluation not actually occurring in the obvious lexical scope
12:51cctennantthat's an excellent point. I have seen that before, with lazy seqs getting evaluated much later. in this case though I can see from the stack trace (which is getting dumped by something at WARN level) that the exception is happening where I think it is
12:52cctennantI went so far as to code this: (try
12:52cctennant (cql/execute-raw (str "use \"" keyspace "\""))
12:52cctennant (catch Throwable e (println "caught exception inside binding " e) (throw e)))
12:52technomancyasync error handling is a nightmare =\
12:53cctennantthe exception is getting thrown at the (cql/execute-raw.. line, from the stack trace. but that Throwable doesn't catch s..t.
12:54mpenetit's datastax driver? anyway it's very likely to be an encoding/decoding issue
12:55cctennantyeah. datastax with some mods, it's not quite ready from prime time yet. driver works great — app is working, I'm just having this problem here.
12:55mpenetcctennant: most of the times you're better off using prepared statements with this driver, it will handle the encoding stuff for you and prevent these kind of errors
12:55mpenetnot to mention you dont pay for the query parsing everytime this way
12:56mpenetcctennant: shamless plug: check https://github.com/mpenet/alia , it handles error nicely in asyn mode at least (you can provide an error callback)
12:56cctennantsure, but that still doesn't explain why it's not catching the exception. surely that's a straight up clojure/java problem? an exception is being thrown, but it's not being caught. it shouldn't matter what's throwing the exception (which is actually a java.util.concurrent.RejectedExecutionException fwiw, again, expected)
12:56llasramcctennant: Hmm. Is the exception being thrown from the same thread?
12:57cctennantaha
12:57cctennantthat may be it.
12:57cctennantnetty and async io.
12:57cctennantdoh.
12:58cctennantthank you.
12:58corecodellasram: https://gist.github.com/5118449
12:58corecodellasram: how does that look?
12:59llasramcctennant: eyes, bugs, shallow, etc
13:01llasramcorecode: Did replacing *out* speed things up? Idiom-wise -- you rarely/never want to call functions in namespaces you haven't yourself `require`d; and although (doall (map ...)) works, arguably `doseq` would be more clear, expressing the side-effect only intent
13:02corecodellasram: yes, writing to a file is enormously faster
13:03corecodellasram: i just replaced it with dorun; how would i use it with doseq?
13:03corecodeuse (doseq [... (->> ...)] ...) ?
13:04llasramExactly
13:04corecodethat sort of inverts the logical flow of operation though
13:04corecodeor at least rips it up
13:05llasramThat's true. I caged with "arguably" :-). Using `dorun` is probably the way to go
13:05corecodeyea
13:05corecodethanks
13:05jtoywhat is the proper way to convert this data to numbers? (map #((Long. %)) ["123" "543"])
13:05llasramcorecode: np. I'm glad you figured out the perf problem
13:06TimMcjtoy: Yo uhave tto many parens around the Long. constructor.
13:06corecodellasram: that's scary stuff. who would have thought that java stdout is so extremely slow?
13:06llasramjtoy: usually Long/parseLong
13:06TimMcAnd I have keyboard issues.
13:06jtoywhat is the proper way to convert this data to numbers? (map #(Long. %) ["123" "543"])
13:06corecodeusing writer System.out does not help either
13:06jtoyI see, is it better to use parseLong or Long is fine?
13:07neotykgood morning everyone
13:07llasramcorecode: Yeah... I'm not really sure where that would come from. *files away to investigate in the future*
13:09TimMcjtoy: People generally use parseLong.
13:10llasramjtoy: Depends on context... If you might be able to use a primitive, parseLong does return the primitive. Auto-boxing (or explicitly calling Long/valueOf instead) may introduce optimizations by making use of an implementation cache of Long objects frequently-used numbers
13:12llasramThis may not be true, but at least naively, calling the Long. constructor directly will always yield an entirely new object
13:20kencauseyDoes it make sense that searching duckduckgo for clojurescipts returns https://github.com/emezeske/clojurescript/ as the canonical URL?
13:20jcrossley3Bronsa: why is aot compilation required for clojure.tools.reader?
13:20kencauseys/clojurescripts/clojurescript/
13:20Bronsajcrossley3: clojure.tools.reader.impl.ExceptionInfo needed for clojure 1.3 compatibility
13:21Bronsaand that's the only namespace that needs to be AOT compiled actually
13:22jcrossley3but there are a lot more in there than that
13:22jcrossley3class files in the jar, i mean
13:27Bronsajcrossley3: I don't think you can AOT compile only a namespace with maven like you can do in lein
13:29Bronsajcrossley3: it looks like you actually can, I'll try to figure out how
13:29jcrossley3Bronsa: is aot the only option for 1.3 compat? could you reify j.l.Exception instead maybe?
13:29BronsaException classes MUST get AOT compiled
13:30Bronsammh
13:30hiredmanyou cannot reify Exceptions
13:30hiredmanExceptions have no interfaces
13:30hiredmanyou have to gen-class
13:30hiredmanjcrossley3: what version of clojure?
13:30hiredmanhave you looked at ex-info/ex-data ?
13:31Bronsahiredman: he was asking regarding of my AOT compiling in tools.reader
13:31hiredman:(
13:31hiredmanaot compiling libraries is horrible
13:32hiredmanlocks them to a single clojure abi
13:32jcrossley3yeah, i'd like to use tools.reader in immutant, but the aot classes are yielding strange errors in our runtime (which might support any version of clojure since 1.3)
13:32Bronsathat's the only way I can provide support for clojure 1.3 without giving up on ex-info/ex-data
13:32jcrossley3i need to dig in further. just trying to understand the reasoning behind them being there.
13:33Bronsajcrossley3: I'll release another version with only ExceptionInfo AOT compiled once i can figure it out
13:33technomancywhy not spin off ex-info-1.3 into its own lib?
13:33jcrossley3Bronsa: thx
13:33technomancyyou're probably not the only one to want it
13:33hiredmantechnomancy: cause this is contrib, and doing that kind of thing is a pain
13:33technomancyoh
13:33technomancywelp
13:34Bronsathat :(
13:34abp propose ex-info-1.3 as contrib library. :)
13:35hiredmanit would be great if you could just slingshot, since it takes care of this for you
13:48jtoyshould this work: (for [x iterable] (println "EACH" x)) I dont see anythig when I do that
13:49nDuffjtoy: it creates a lazy sequence
13:49nDuffjtoy: so it won't print anything until you realize it.
13:50nDuffjtoy: ...if you want side effects, use doseq instead of for.
13:50alandipertjtoy: 'for' is lazy, see 'doseq'
13:50jtoyok
13:50frenchypare there native clojure projects to interact with avro and hadoop, or do they wrap the java api?
13:51Bronsajcrossley3: I think i got it
13:52papachanis it this correct? -> https://www.stypi.com/papachan/main.clj
13:52jcrossley3Bronsa: cool. this will be 7.3? soon-ish?
13:52Bronsajcrossley3: as soon as I see test-matrix passes :)
13:53jcrossley3sweet
13:55RaynesWow.
13:55RaynesHow many pastebins are there?
13:55clojure-newHello, how can achieve this: (update-in {:entries '(1 2 3)} [:entries 0] inc) => {:entries '(2 2 3)}?
13:56RaynesAs soon as I think I know them all, someone finds another one to use.
13:56technomancyclojure-new: needs to be a vector, not a list
13:56RaynesYou really don't want to update a list by index.
13:56clojure-newtechnomancy: Yay, thanks.
13:57corecodeshould i be using (. method obj args) or (.method obj args)?
13:58cemerickcorecode: the former is generally only emitted by macros, if that
13:58corecodeah ok
13:58corecodeor rather (.. obj (.method args))?
13:59cemerick.. is a specialized threading macro for interop purposes; -> has taken its place except for rare circumstances (e.g. involving static method invocations)
14:00cemerickIf you just want the transliteration of object.method(args), then (.method object args) is it.
14:01jtoywhat is the correct way to convert clojure.lang.PersistentVector$ChunkedSeq to a string? I do (str variable) but it adds chacters to it
14:02Bronsa, (.getName clojure.lang.PersistentVector$ChunkedSeq)
14:02clojurebot"clojure.lang.PersistentVector$ChunkedSeq"
14:02corecodecemerick: thanks!
14:03jtoythe string I am starting from is : "45\tyes,45,no,20" and I do (clojure.string/split (next (clojure.string/split string #"\t") #","))
14:03Bronsajcrossley3: released 0.7.3, let me know if it works for you
14:04jcrossley3Bronsa: wdm
14:04Bronsajcrossley3: it's not on central yet though
14:04jcrossley3i can install locally
14:05jtoythis is what I'm trying to do: (clojure.string/split ( next (clojure.string/split "1081\tyes,45,no,20" #"\t") ) #",")
14:07jtoyand if i explicitly turn it into a string, gargage gets added: (clojure.string/split ( str ( next (clojure.string/split "1081\tyes,45,no,20" #"\t") )) #",")
14:09dabdis there any tail file utility for clojure that anyone is willing to share?
14:11chronnojtoy: (clojure.string/split "1081\tyes,45,no,20" #"\t|,")
14:12jtoychronno: i guess I could do it that way, but it would be useful to understand why the other way doesnt work
14:15chronnojtoy: you are passing a ChunkedSeq as the first argument to split. What you want is to split the elements inside the sequence, no the sequence itself
14:15chronnochronno: in this case, the first element should be enough
14:16chronnojtoy:^^
14:16chronnojtoy: (clojure.string/split (first (next (clojure.string/split "1081\tyes,45,no,20" #"\t"))) #",")
14:16amalloyreally if you want to split a string into "first part" and "rest part", pass string/split the extra optional numeric arg telling it how many splits to do
14:17cemerickjtoy: What's the question? next returns a seq, not a string.
14:17amalloy(-> "1081\tyes,45,no,20" (string/split #"\t" 2) (second) (string/split #","))
14:18cemerickholy laggy irc! :-P
14:19NeedMoreDesuClojureRuntime.class.getClassLoader() -- how do I write this in clojure?
14:20NeedMoreDesu(. ClojureRuntime class) don't work
14:20arcatannow that *read-eval* is in the news, in what kinds of situations it's useful?
14:20technomancyNeedMoreDesu: I think calling .class in Java is just a weird quirk of the language since it's difficult for some reason to refer to classes directly.
14:21technomancyNeedMoreDesu: in Clojure you can refer directly to the class without the extra call
14:21NeedMoreDesutechnomancy: oh, really. Thanks.
14:21auserhey all
14:21technomancyJava is so weird
14:22stuartsierraarcatan: *read-eval* lets you construct arbitrary data structures at read-time, which is what makes *print-dup* possible.
14:23stuartsierraThe #= macro was never officially documented, but widely known.
14:24amalloytechnomancy: it's easier to refer to int[][].class in java than in clojure :P
14:24drewc"the #1=(programmable . #1#) programming language"
14:24NeedMoreDesustuartsierra: mostly besause it is causing security problems.
14:25stuartsierraIt's just like what we went through with JSON, then YAML.
14:25stuartsierraIt will doubtless happen again.
14:25technomancyamalloy: again with the weird thing
14:25technomancystuartsierra: JSON?
14:25gozalaDoes clojure exports all the top level definitions by default ?
14:26technomancyYAML at least had it documented from the outsed
14:26technomancyoutset
14:26stuartsierratechnomancy: Yeah, back in the dark ages when people used to call `eval` in JavaScript to "read" JSON.
14:26hiredmangozala: nothing is "exported"
14:26technomancystuartsierra: that's not JSON though; that's JSONP
14:26hiredmangozala: you can refer things from other namespaces if you want
14:26stuartsierraYeah, we know that NOW...
14:26guestttthi there, I was curious - why does clojure employs macros and eager evaluation instead of implicit quoting and optional evaluation (as rebol does for example)
14:29gozalahiredman: ok so I meant you can import / use top level definitions form other namespaces ?
14:30`fogusguestttt: Clojure's heritage is more in Common Lisp and Scheme rather than something like Kernel.
14:30gozalaif so what's ^:export for ?
14:30hiredman^:export is a clojurescript thing
14:30gozalahiredman: yeah that's why I'm confused :)
14:30hiredmanit tells the google closure compiler not to mangle the name so it is callable from other javascript libraries
14:31gozalaoh I see
14:31hiredmanthe name mangling only happens if you do advanced optimizations I believe
14:32TimMcstuartsierra: The funny thing is that JSON has *never* been a subset of JS, so eval is a broken way of doing things anyhow. :-P
14:32stuartsierraAll software is broken. Some of it is useful. ;)
14:33TimMceval is fine for JSON config files.
14:33stuartsierraAnd `clojure.core/read` is fine for .clj config files.
14:34TimMcyep
14:35TimMcIf you start using user data, though, sooner or later you will run into U+2028 or U+2029 and eval chokes.
14:35gozalahiredman: thanks
14:35RazWellesis there a way to dump a clojure list to a file?
14:36rabbit_airstrikespit?
14:36RazWellesesp if it contains anonymous functions and defrecord's
14:36technomancyRazWelles: you can't serialize regular fns; you have to use serializable-fn
14:37gozalahiredman: although I'd expected to mangle names for defn- not the others
14:37RazWellestechnomancy, ohh I didn't even know that existed
14:37guestttt`fogus: thx for response - ok, so again - from talks I saw Rich seems to be VERY pragmatic, I can hardly disagree with him on anything. If anything, it would be oop (offtopic for now) - so I am curious if there was a reason why lisp macros were preferred over smalltalk way of dealing with control structures (for example)
14:37hiredmangozala: the google closure compiler is a whole program optimizer, unless told otherwise it assumes it can do whatever it wants
14:37RazWellestechnomancy, one more question- how do I put a directory into my load-file path? So i can load-file other clj source files?
14:38technomancyRazWelles: there is no reliable way to do that
14:38guestttt`fogus: smalltalk does solve control structures using blocks passed as arguments (and so it is form of lazy evaluation)
14:38gozalahiredman: no sure but it's possible to assume ^:exports in all top level forms unless opt-ed out via ^:private or defn-
14:39RazWellestechnomancy, x.x so how do you split a clojure program into several files?
14:39arcatani wonder if there's a case where it matters whether *read-eval* is true/false
14:39nDuffgozala: There's more control with the current approach: Whether a cljs function is visible from other namespaces is separate from whether it's visible from javascript after the program has been compiled into a blob.
14:39nDuffgozala: ^:private thus provides distinct semantics from a lack of ^:export
14:39borkdudeWhen I search a function name like this with apropos: (apropos #"\?$") I get among other blank? as a result
14:39technomancyRazWelles: oh, I thought you meant at runtime. you can set your classpath during the JVM boot just fine
14:39amalloyRazWelles: don't use load-file. use the namespace form, with require
14:39guestttt`fogus: anyway, thank you very much for that hint on kernel, I was not aware of that before!
14:39nDuffgozala: ...and, bigger-picture, having the defaults this way leads to much more tightly-optimized programs.
14:39borkdudehow can I know from which namespace this function comes (probably string or smth, but that's not my point)
14:39RazWellestechnomancy, ohh ok- well I'm using clojureclr...
14:39technomancyRazWelles: oh, no idea, sorry
14:40RazWellesI'll see if amalloy's require suggestion works in clojureclr then
14:40amalloyRazWelles: probably best to mention that *first*. you don't want to get a bunch of car-mechanic advice and then say "btw i'm riding a motorcycle actually"
14:40technomancyheh
14:41RazWellesamalloy, ahaha sorry
14:41gozalanDuff: oh right so it's just for js
14:41nDuffgozala: Exactly.
14:41gozalaI get it know thanks nDuff hiredman for insights
14:41RazWellesI'm so used to looking through java-based solutions and trying to find the corresponding solution in clojureclr, that's been my tactic all last night with google
14:42`fogusguestttt: I talk about just that thing in my Necronomicon talk. Gotta run for now, but maybe that will answer your question if you have time. http://blip.tv/clojure/michael-fogus-the-macronomicon-5970233
14:43borkdudeisn't the output of apropos a little useless if the namespace isn't prefixed?
14:43guestttt`fogus: thank you! will have a look
14:45RazWellesOh, does anyone know how to remove an event handler in clojureclr?
14:48borkdudeRazWelles dunno, via interop?
14:49borkdudeRazWelles was it added via add-watch? there's also remove-watch
14:49RazWelleswell I found ClojureCLR created .add_<fn_name> methods and .remove<fn_name> methods, but I don't know how to sue the remove counterpart
14:49RazWellesI tried doing .remove and supplying the same function, or even doing it on its own
14:49RazWellesI don't know what it expects as an argument
14:50borkdudeRazWelles you should probably not pass the function, but the var
14:50borkdudeRazWelles because function values have no equality,
14:50RazWellesright even when I passed the function's symbol it didn't work
14:50borkdudeRazWelles var isn't the symbol
14:50RazWellesahh what is it then?
14:51borkdudeRazWelles #'+ is a var, + is a symbol
14:51RazWellesohhhh ok
14:51borkdudeRazWelles var is the mutable storage location itself
14:51RazWellesI'll try that thanks
14:51RazWellesso I'd do something like `(fn-name)?
14:51borkdude#'fn-name
14:52RazWellesborkdude, thanks I'll try that :)
14:52borkdudeRazWelles it's just a guess… good luck
14:52RazWellesty x.x
14:53chilleniousHi folks. I have something I don't quite understand. If you look at my paste here https://www.refheap.com/paste/12293, the first code fragment which includes a dummy arg (or however you'd call that) just to print doesn't work as expected, but as soon as I remove the line, it does work. But I don't understand why this is. Any hints?
14:55hiredmandoseq is sort of a side effecting for
14:55nDuffWhat's a more idiomatic way to write (every? (true? (for ...)))
14:55hiredmanprintln returns nil, which is also accepted as an empty seq
14:55hiredmanso everything after the println is being done once for every item in an empty seq
14:55hiredman(never)
14:55chilleniousah, that makes sense, thanks!
14:56borkdudenDuff (every? identity (for ..)) ?
14:56borkdudenDuff or apply every?
14:56borkdudeno
14:57borkdude(every? identity ["Dude" "Dude"]) => true, (every? identity ["Dude" nil]) => false
15:00nDuff*nod*. Originally wrote it as every? identity, but the code is meant to be read by Java developers, so I changed it to every? true?. Was hoping there would be a single construct that would have that effect, though.
15:02borkdudenDuff how about
15:02borkdude,(not-any? nil? ["Dude" nil])
15:02clojurebotfalse
15:11papachansomebody can help me?
15:12borkdudepapachan just ask your question
15:12jeremyheiler~anyone
15:12clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
15:12nDuffpapachan: If you can't ask a specific question, you're beyond help.
15:12papachansure nDuff
15:12borkdudenow let's not get all grumpy ;)
15:13papachani trying to understand why i cant have the output of a simple function which do a loop
15:13papachanat this moment i have this -> https://www.stypi.com/papachan/main.clj
15:13jeremyheiler*gumble grumble* :-P
15:13nDuffpapachan: using def inside a function is bad news.
15:13nDuffpapachan: def creates vars; vars are global to your namespace.
15:13papachanok
15:14papachanif i am inside of let
15:14nDuffpapachan: ...and I don't know what you're trying to do calling "0" as a function.
15:14Bronsaalso where is create-line defined?
15:14borkdudepapachan first of all, ("0") isn't valid
15:14borkdudetoo late
15:14jeremyheilerThat site is neat.
15:14nDuffpapachan: ...so, an explanation of what you want your code to do would be helpful.
15:14papachanoh i see i have too many errors
15:15papachani am trying to get a list of "0"
15:15papachanand get the middle position with 1
15:16borkdudecan everybody collaborate on that piece of code on that site?
15:16borkdudeI saw test written :)
15:16jeremyheilerborkdude, I just typed "Test" into the document.
15:16papachani think yes
15:16borkdudecool]
15:16papachanyes
15:18jeremyheilerpapachan, Could you describe what you're trying to do with this program?
15:19papachansomething basic, i am beginning with clojure
15:19borkdudeif i is a range, how can you compare it with a number?
15:19papachantrying to have a list of "0"
15:19Bronsaborkdude: i is not a range, it's a number
15:19papachanand at middle position, change it for 1
15:19Bronsait's inside an or
15:19Bronsafor*
15:19borkdudeah sorry, misread it
15:20borkdudeI read let instead of for, doh
15:20papachani have remove the "def" inside my let statement
15:20jeremyheilerpapachan, If you want a literal list, you need to quote it like this: '(1 2 3) so that it doesn't try to evaluate it as a function invocation.
15:20Bronsaheh
15:20papachanit compile goog
15:21borkdudepapachan what is the point of deffing n if you don't use it as a result
15:21borkdudewhich should be in a let, which is now the case in your oce
15:21borkdudecode
15:22Bronsapapachan: try it out now
15:22papachani am trying
15:23BronsaI'm not even sure :main true is a thing in gen-class
15:24borkdudeBronsa it is (looked up the docs)
15:24Bronsaborkdude: oh, ok
15:24borkdudeBronsa but I didn't see it before, maybe it's the default
15:25papachanit works
15:25papachani understand now the code
15:25papachanthank for your help
15:26durka42any core.matrix people around here?
15:26borkdudepapachan I can call the function -main now like this: (-main 3)
15:27borkdudepapachan but note that when called from the cmd prompt, the arguments will be passed a strings
15:32FoxboronAnything recommended for parsing HTML with Clojure?
15:34corecodeFoxboron: ems...
15:34corecodewhat was the name
15:35jeremyheilerFoxboron, Laser. https://github.com/Raynes/laser
15:36borkdudehttps://github.com/davidsantiago/hickory
15:36Foxboronawsome
15:36Foxboroni'll look at those :)
15:36Apage43i was going to say I typically just use Jsoup
15:37borkdudeLaser uses hickory if I'm not mistaking. Laser = templating, hickory = parsing
15:37Apage43hickory uses Jsoup though so =)
15:37borkdudelol
15:37borkdudetransitive dependencies ;)
15:38Apage43Jsoup is pretty nice if you want to use css-like selectors
15:38nDuff(at least in the Python world, BeautifulSoup abandoned their old parser in favor of lxml.html -- and that decision was very much for the better).
15:40Apage43i think it's a more from scratch thing, at least as of their HTML5-compliant version
15:41Apage43you get a "real" DOM, as it were.
15:44neotykFoxboron: enlive works great
15:44Foxboronneotyk: i feel its kinda heavy for just parsing.
15:45FoxboronWhich laser seems to be the solution for.
15:46neotykFoxboron: have to look at laser than
15:47Foxboronneotyk: what i am doing :) It was suggested above.
15:54zakwilso1There look to be four database schema and migration libraries for Clojure that are somewhat active. Has anybody done a comparison recently or have information that would help me pick one faster than trying them all?
15:55danlarkinzakwilso1: yeah use migratus
15:55danlarkinit's pronounced maig-rah-toos
15:55jimkcarlol
15:55pjstadigmig-great-us
15:55pjstadiger
15:55pjstadigmi-great-us
15:55pjstadigwhatever
15:56danlarkinno
15:56danlarkinmaig-rah-toos
15:56pjstadigdanlarkin: maybe your fork is pronounced that way
15:56hiredmanmahi-grah-tous
15:57hiredmanmy great house
15:58danlarkinit's a nice library no matter how you pronounce it (maig-rah-toos)
15:59zakwilso1danlarkin: do you have anything to say in its favor relative to the others aside from "I like it"?
16:00danlarkinit's just straight sql
16:00danlarkinwhich I like
16:01yazirianbah weep grah nah weep migratus
16:03papachanthank you borkdude just recent read your messages
16:04zakwilsonI see that as neutral. I dislike SQL as a language, but whatever-to-sql compilers aren't always awesome.
16:07pjstadigzakwilson: the principles behind migratus are: 1) just use SQL (a database DSL) instead of inventing yet another database DSL, 2) be compatible with git based workflow
16:07pjstadigmostly
16:08pjstadigmigratus also frames its transactions differently than ragtime so that with a database that supports transactional DDL (like postgres) you get the maximum projection
16:08pjstadigi think ragtime does not wrap a transaction around both running the migration and updating the these-migrations-have-run-table at the same time
16:09pjstadigdrift's migrations are not compatible with git workflow
16:09pjstadigi don't really know much about others
16:10pjstadigtechnomancy will tell you to just use functions https://github.com/ato/clojars-web/blob/master/src/clojars/db/migrate.clj which i would also recommend to you, if that works for you
16:10zakwilsonI think yet another DSL would be of use if it shared code with a query library like Korma.
16:11pjstadigthat's a fine idea, and not one i support, so migratus may not work for you
16:12zakwilsonIt's good to have a clear sense of what your project should and should not do.
16:14zakwilsonI might end up using migratus; drift doesn't seem to have great docs, ragtime seems similar to migratus, but nobody has said anything in its favor yet and Lobos' website is pretty out of sync, at least in terms of version numbers.
16:15pjstadigwe use migratus at sonian
16:15pjstadigso it is being put to actual production use, and i have a vested interest in it
16:15pjstadigif that makes any difference
16:15jaen1a
16:16zakwilsonThat does suggest it won't go away quickly. This is for a client project, so stability matters.
16:16jcrossley3Bronsa: 7.3 looks much better, btw. it didn't solve my problem, but i think it's something on our side.
16:17zakwilsonAnother point in its favor: the author is easy to find in IRC if I need someone to choke.
16:17Bronsamh
16:18Bronsawell jcrossley3 just let me know if you think I can do anything about it
16:18jcrossley3Bronsa: cool, thx
16:18pjstadigzakwilson: hehe
16:19tboythttps://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments this article has some sample code for setting up a browser-based repl using the (require) function. but when i try to use this function in a clojurescript file, the function is apparently nonexistant ("cannot call method 'call' of undefined"). is there something i need to do to be able to access (require)?
16:19sshackAre there any decent references for data munging/cleanup in Clojure? (I'm cleaning up the contents of some CSV imports)
16:20zakwilsonOk, migratus it is, unless someone wants to try to talk me in to something else in the next ten minutes or knows of something that ties in with Korma.
16:20hiredmantboyt: that is clojure code meant to be run in a clojure repl
16:21tboythiredman: not according to the sample's original src: https://github.com/clojure/clojurescript/blob/master/samples/repl/src/repl/test.cljs#L29
16:22zakwilsonnDuff: rant if you like. I haven't used it in a while, but I liked it when I did.
16:22hiredmantboyt: that is in a comment
16:22tboythiredman: …i just noticed that as you said it. blegh. you'd think there'd be special syntax highlighting for a comment like that :p
16:23tboytstill, though, i have zero idea how to get a working browser repl up and running with cljsbuild. is there some tutorial i'm missing?
16:23nDuffzakwilson: Short form: Korma is sufficiently dependent on macros that it's not at all friendly to function composition.
16:25tomojoh, nice
16:25zakwilsonnDuff: do you have something better to suggest?
16:25tomojI thought I didn't like it just cus I'm prejudiced against sql
16:26nDuffzakwilson: Wrote my own, but (1) it's unreleased, and (2) it's only good enough for my own use cases, and nothing more -- and I haven't evaluated the other public alternatives in detail. So, short form: No.
16:26zakwilsonI like the idea of relational databases, but SQL feels like it's from 1974.
16:27zakwilsonnDuff: you should release it so other people can hack on it. In the mean time, I will use Korma for this project.
16:27danlarkinsql perfectly represents its domain
16:27danlarkinI don't understand the haters it attracts
16:28nDuffdanlarkin: If I can't use function composition to build queries, I'm hamstrung.
16:28nDuffdanlarkin: ...and "perfectly" is a stretch. Extending korma to cover new syntax is much more of a pain than it has to be.
16:28hiredmandanlarkin: imagine if you had to glue together javascript statements as strings to query some database
16:28zakwilsonSQL isn't composable, and SQL schemas are imperative.
16:29nDuffzakwilson: I can even do composition with SQLAlchemy's query builder easier than with Korma.
16:29zakwilsonAlso, really irritating mix of prefix, infix and postfix.
16:29nDuffzakwilson: Can, and _have_.
16:30zakwilsonSQL is somewhat composable using external tools. That may solve the problem, but I still see it as a valid complaint against the language.
16:30hiredmanat an sql prompt writing sql is great, but when you have a 20 sql statement checked in as a string it is gross
16:30hiredman20 line
16:30scottjis clojureql better than korma in this respect (using function composition to build queries)?
16:30technomancyoh come on, composability by string manipulation works great for metaprogramming in ruby; how bad can it be?
16:31zakwilsonGlue together JS statements for queries? Isn't that half the "nosql" (I hate that term) databases out there?
16:31sshackzakwilson: It's fair to say SQL hasn't adapted with the times. It's suffered from crystallization.
16:31pjstadigwith migratus you can modify sql in sql files, but of course that doesn't help with writing queries
16:32technomancyI would actively warn against drift and lobos because they trick you into thinking you can swap out the underlying DB implementation without changing actual code, which is not true
16:32sshack"I know what I know, and I don't want to change!"
16:32pjstadigif you want a functional take on databases then you should use datomic
16:32pjstadigif you're used an RDBMS, then SQL is the way to go
16:32hiredmanyou can run `lein check` to see if your code has any compilation errors, what do you do to see if your sql strings match your schema?
16:32pjstadighiredman: you want static typing?
16:33sshackpjstadig: Yeah. Trick is people think RDMS=SQL. Nothing wrong with RDMS's, SQL just hasn't kept up.
16:33hiredman~#35
16:33clojurebot35. Everyone can be taught to sculpt: Michelangelo would have had to be taught not to. So it is with great programmers. -- Alan J. Perlis
16:33hiredmanhmmm
16:33hiredman~#34
16:33clojurebot34. The string is a stark data structure and everywhere it is passed there is much duplication of process. It is a perfect vehicle for hiding information. -- Alan J. Perlis
16:33pjstadigi guess generally you'd right tests to see if your queries match the schema
16:33pjstadigs/right/write/
16:33hiredmanyeah
16:34hiredmanyou would parse the queries, figure out what columns of what tables they reference then see if they exist
16:34zakwilsonIt would be really awesome to have a new RDMS that doesn't try to be backwards-compatible. It would probably never catch on.
16:34pjstadigzakwilson: datomic?
16:34sshackzakwilson: You are an oracle. We've reached a local optima. That's a hard rut to break out of.
16:34nDuffpjstadig: http://www.datomic.com/
16:35pjstadighiredman: if you're parsing sql statements and trying to figure out what columns would exist at runtime you are in the same position as you are with static typing
16:35pjstadigyou're trying to simulate the program with out actually running it
16:35pjstadigso just write tests against the db
16:36hiredmanpjstadig: it is similar
16:36zakwilsonpjstadig: probably not. That seems like a higher-level layer (and I think it's implemented that way).
16:37zakwilsonsshack: it just needs to solve somebody's problem satisfactorily.
16:37zakwilsonSome problem that has people setting their hair on fire, that is.
16:37sshackzakwilson: Well, that gets you an internal tool.
16:37sshackNow you have to get it to the public, and drive it.
16:38sshackzakwilson: Not trying to put you off or anything.
16:39sshackSo are there any clojure tools/references for cleaning up messy imported data (CSV files, in this case)?
16:40zakwilsonWell, I'll get around to it just as soon as I create a replacement for C in which to write it.
16:41sshackzakwilson: Haskell?
16:41sshackBut not strict not lazy.
16:41zakwilsonHaskell will do as soon as I find a good source for LSD.
16:46sshackTried licking a toad?
16:47abpTwice, they taste like earth, don't understand the hype.
16:49zakwilsonI'll take your word for it and not try.
16:50zakwilsonI do want to make something kinda like C with Lisp syntax. Yes, I know people have done that sort of thing before.
16:51rabbit_airstrikewhere do you live that toads secrete LSD?
16:52zakwilsonYou could genetically modify a toad to secrete LSD, perhaps.
16:58sshackrabbit_airstrike: There are some breeds of toads that secrete some sort of slight poison people use to get high.
16:59sshackApparently, those types of toads are invading the area around me.
16:59sshackI don't know though. The only drugs I take are Lambda's.
17:04Foxboron,#java.io.FileWriter["hello_from_ljos"]
17:04clojurebot#<SecurityException java.lang.SecurityException: denied>
17:05Foxborondamn. It worked with my sandbox. hmm
17:05Sgeo_Try the other one
17:05Sgeo_&#java.io.FileWriter["hello_from_ljos"]
17:05lazybot⇒ #<FileWriter java.io.FileWriter@1ff5f75>
17:06ljoswait, that doesn't look good :D
17:06rabbit_airstrikesshack: but they're not secreting LSD :)
17:07rabbit_airstrikemost of those poisons are likely deliriants, not psychedelics
17:07Foxboronhahaha
17:07Foxboroni think lazybot uses the same sandbox i am using
17:07sshackrabbit_airstrike: No, not technically. But would you really care? You'd still get high.
17:07RaynesFoxboron: clojail?
17:07RaynesIf so, then yes.
17:07Rayneslazybot is mine and amalloy's. Turns out we are also the authors of clojail. Small world.
17:09rabbit_airstrikesshack: there are serious qualitative differences between deliriant and psychedelic experiences. Psychedelics can be conducive to mathematical thinking, whereas deliriants will make you stupid for the duration if they don't kill you
17:09sshackrabbit_airstrike: The lesson here is to never go tripping with me.
17:10FoxboronRaynes: i digged into the source. It dosnt use the default secure-tester i used. But it still evals the same line it did on my bot :)
17:10netrealmHey, what testing frameworks are people currently recommending?
17:10Raynesclojure.test, midge, speclj.
17:10FoxboronRaynes: its clojure, it is a small world IMO :)
17:10RaynesIn that order.
17:11RaynesFoxboron: There are nearly 600 people in here.
17:11Raynes$max
17:11lazybotThe most users ever in #clojure is 578
17:11netrealmRaynes: Cool, thanks.
17:11RaynesYeah, I should fix that.
17:11Rayneslazybot is a huge liar.
17:11amalloyFoxboron: it actually isn't evaluating, it's just reading. it's definitely a security hole, but you can't *do* anything with that filewriter once you've created it
17:11durka42maybe it's just lazy
17:11eggheadis there a way to get lein test failure to result in a non-zero exit code?
17:12llasramegghead: I'm pretty sure it does that already?
17:12eggheadhm
17:12Foxboronamalloy: hah. Yeah i see. Might wanna patch the secure-tester if ya can. Else i gotta dig into how to make it skip the java.io stuff.
17:12amalloyFoxboron: nothing to do with the secure tester. we just have to upgrade to 1.5 and use edn/read
17:13amalloyor perhaps do our reading inside the jvm sandbox, which would be harder
17:13llasramegghead: Yeah -- exit code should be the number of test errors + failures
17:13eggheadllasram: maybe I need to update
17:13eggheadhttps://www.refheap.com/paste/07abe22fcb473e0b028b14796
17:14eggheadi'm on Leiningen 2.0.0-preview10 -- probably just an old version thing
17:14llasramNo, that should be good
17:14llasramYour project does't :eval-in :leiningen, does it?
17:15eggheadnah, very simple boilerplate project.clj
17:15llasramegghead: hmm. That's very odd. OUr CI system works w/ that version of lein just fine
17:16llasramegghead: Unfortunately I need to take off, but good luck sorting it out
17:16ljosamalloy: you can't do anythinh with the filewriter afterwards, but it is destructive if I hit a file that I know is there.
17:16eggheadcheers llasram
17:16amalloyi know, ljos. i told you it's a hole
17:16amalloyjust instantiating it is dangerous
17:17FrozenlockLazyness and database are a bad combination :(
17:18technomancylaziness and dynamic scope in particular
17:18technomancylooking forward to a c.j.jdbc release that doesn't force dynamic scope on you =\
17:19eggheadah, the error seems to be specific to expectations
17:19FrozenlockIndeed... I've been bitten once by dynamic variables... now I try to simply *never* use them.
17:20FrozenlockThey are hard to debug...
17:28jtoyis there a way to no im inside of the repl as opposed to a compiled jar from inside of clojure
17:28jtoyknow
17:32mikerodDoes `extend-type` not support adding a doc string to the protocol method implementations? e.g. (extend-type SomeType SomeProto (proto-method "Impl for proto-method" [this] this))
17:32mikerod e.g. (extend-type SomeType SomeProto (proto-method "Impl for proto-method" [this] this))
17:33Frozenlockjtoy: could re-ask your question, but this time with other words? :P
17:33Frozenlock*you
17:36zakwilsonI find it interesting that Clojure and the community in general doesn't seem to rely a lot on macros. I used them and saw others use them a lot more in Common Lisp.
17:37jtoyFrozenlock: can clojure know if its running code from a repl vs a jar ?
17:41RaynesWhy would you want to do that, jtoy?
17:42devnyogthos: you around?
17:42devntechnomancy: how big of a pain is it to shell out to something like pygments from a clojure app on heroku?
17:42devnRaynes: ^ Are you hosting on heroku?
17:42zakwilsonIs it the general consensus that slime/swank isn't the way to go anymore and we should all use nrepl?
17:43devnzakwilson: it seems that way
17:43Raynesdevn: I moved off of Heroku recently.
17:43technomancydevn: assuming python programs are installable via something similar to rubygems, pretty easy
17:43Raynesdevn: However, shelling out to pygments was easy on heroku.
17:43zakwilsonMeh. More change.
17:44Raynestechnomancy, devn: pygments always got pulled in by my 'bootstrap' script, so pygments ended up in the slug. It's easy.
17:44technomancyzakwilson: if you have a setup with slime that works, keep using it till it doesn't.
17:44devnRaynes: word
17:45Raynestechnomancy: I think that's terrible advice. "Oh, just wait until it breaks and then, even if you're busy with something else, move to nrepl and learn on the spot."
17:45jtoyRaynes: I want to know that so I can make my code have different defaults depending on where i am
17:45RaynesIt makes more sense to me to just go to nrepl now and save yourself problems later, or at least plan for it.
17:45amalloyzakwilson: i'm clinging to slime for dear life, but you start using clojure 1.5 you'll have to either fix slime/swank or switch to nrepl
17:46technomancyI thought tcrawley fixed the 1.5 issues?
17:46zakwilsonWell, I just tried it with 1.5 and it didn't work, so I guess I'm switching.
17:47amalloytechnomancy: maybe. my version of slime/swank is probably about a year old
17:47zakwilsonI guess that'll make it easier to use slime with CL though.
17:47Raynestechnomancy: Don't encourage him.
17:48technomancyRaynes: not my problem any more... you have no idea how good it feels.
17:48technomancyanyway, upgrade whenever you want
17:48zakwilsonI get the impression slime-related code has been a pain in the ass to maintain.
17:49technomancyunless you want to take over maintenance of swank-clojure or something
17:49technomancyzakwilson: yeah, I used to have semi-regular rants on the subject
17:49tcrawleyzakwilson: last time I used it, the latest swank-clojure worked with 1.5
17:49tcrawleybut I can't tell what version that was, because https://clojars.org/swank-clojure gives an error
17:49technomancyzakwilson: http://p.hagelb.org/slime-cvs-rant.txt
17:50tcrawleyand if swank-clojure is broken now, I'm not going to fix it :)
17:52trmswI have a namespace that's supposed to act as an API: a small number of public functions and a lot of horrible details. I've split the horrible details into several files - it seemed like a good idea at the time. That means lots of "(load x)"s in the main file and an "(in-ns 'api)" in every part file. Is there a better way?
17:53n_btrmsw: Look at clojure.org/libs
17:53tjgilliesis there anything like http://reactivemongo.org/ for clojure?
17:53n_bYou want to be using the :use and :require parts of the ns macro
17:55n_bQuestion of my own: Is there some reason the api-key in Line 26 seems to refuse to load from secrets.txt?
17:56n_bCode: https://www.refheap.com/paste/12305 - I've tried putting it in a (do) using (defonce) instead, but unless it's in the env var, it will not work
17:56n_bIt seems to function at the REPL, but not when loaded in my Compojure handler
17:58trmswn_b: I want callers to be able to use / require a single namespace (my-api), but the functions provided by that namespace are defined in several files / sub-namespaces, including a core that is used by all the others.
17:58n_bI'm not sure I follow; can you put up a gist or similar?
18:00zakwilsonnrepl looks to be working, so I'll just stick with that.
18:03jtoyhow can I load a string to be evaled in the current context and not in its own context? the docs day load-string "should any form have an effect on that var (e.g. `in-namespace), the effect will unwind at the completion of the load"
18:04trmswn_b: https://gist.github.com/tomsw/5120775
18:06jtoyah, read and eval
18:07n_btmarble: Why can't you do in gui.clj (ns myapi.core.gui (:require [myapi.core :only (foo bar)])) ?
18:07amalloyjtoy: you cannot evaluate a form in any non-null lexical environment. you can bind *ns* to whatever you want to make vars available, but you can never make locals available
18:09n_btrmsw: Like this: https://gist.github.com/nickbarnwell/5120788
18:11trmswn_b: I see what you mean. But that effectively means duplicating all the public functions
18:11n_ber
18:11n_bwhat
18:12n_bjust require or :use what is needed
18:15trmswn_b: I have a client namespace that wants to use my api. It should just be able to use / require a single namespace, myapi, to get access all the public functions in my api. These functions might not all live in the same place - eg myapi.gui, myapi.forms etc.
18:17n_bIf you want all your functions to be in one namespace, they should be in one namespace.
18:20trmswn_b: ok, so one namespace, several files = load + in-ns
18:21FoxboronRaynes, just gotta mention. Reading your blog and discovered you are actually as old as me. Very inspiring to read :)
18:21yogthosdevn: sort of :)
18:22RaynesFoxboron: So you're how old then?
18:22FoxboronRaynes: 19 in june.
18:22Foxboronjuly*
18:22Foxboroni mess up those dates -.-
18:22RaynesSo you're slightly younger than I am.
18:22RaynesVery slightly.
18:23ivaraase1Raynes: you have the most awesome accent by the way
18:23Raynesorly
18:23RaynesDid you listen to an interview or something, ivaraase1?
18:23FoxboronRaynes: indeed :) i did have an impression after hanging here a while that you where older :P
18:24RaynesWell, I'm only… 5 months older.
18:24FoxboronRaynes: hah, an IRC bot is also my first Clojure project :P
18:24FoxboronRaynes: and a few years more programming experience :)
18:24Foxboronand tons of other languages
18:25FoxboronNo but really, inspiring read. Keep up the work ^^
18:25ivaraase1Raynes: correct
18:25RaynesFoxboron: So you've got more years of experience than I?
18:25RaynesGet out of my internet.
18:25RaynesI bet you're wrong about the languages part though.
18:26RaynesI've used enough languages that I forget which ones I've used occasionally.
18:26Raynesivaraase1: Which one? :D
18:26FoxboronRaynes: noooo vica versa
18:26Raynesoic
18:26Foxboronhah, sorry if i pharsed it wrong :)
18:26RaynesI know people who started hacking when they were like 7 though.
18:27ivaraase1Raynes: it was some time ago, but I believe it was Mostly Lazy
18:27RaynesSo I'm certainly not the standard for starting ages.
18:27RaynesYeah, that was the most recent thing.
18:27FoxboronStarted at like... 16 with batch :/
18:32ivaraase1I started programming at 14 I think
18:32ivaraase1but I think discipline is more important than when you start
18:34patchworkHow do I access values from my project.clj from within my app?
18:34patchworkSeems like this should be simple, but I can't find any docs on it
18:36technomancypatchwork: project.clj is isolated from runtime
18:36technomancytypically that kind of config is done through environ or carica
18:37jodarowow
18:37jodaroweird
18:38jodaroi was just looking at immutant docs about accessing the :project in the registry before i switched into this window
18:38patchworktechnomancy: I see, is either one preferred?
18:39patchworkenviron seems to use the system environment, while carica seems to be more programmatic
18:41hiredmanI think carica is a clear winner for large amounts of configuration
18:42patchworkPart of my issue is I have a variety of environments the app runs in, each with its own config for things like db, s3 buckets etc
18:42patchworkI was hoping to use lein profiles for this
18:42patchworkbut I guess that is not an option
18:42hiredmansure, we do all that in carica at work
18:43patchworkAh, so how do you select among the different configs?
18:43hiredmanthere is a set of default configs checked in that get built in to the final artifact (a jar) and then chef writes overrides to the filesystem for different stacks
18:44hiredmancarica merges configs found on the classpath
18:44jodarohttps://github.com/typesafehub/config
18:44patchworkAh, so you have another tool for that
18:44jodaroi used that for configs for a bit
18:44jodaronot clojure specific obviously
18:44jodarobut it was pretty easy to wrap what i needed in just a few lines of clj
18:50alexbaranosky1hey, does anyone know how to use leiningen to build a jar from Java source files, that will include the .class files?
18:51hiredmanalexbaranosky1: https://github.com/sonian/Greenmail does that
18:51hiredmanthen mail thing is the lein javac task, and :java-source-paths in your project.clj
18:51hiredmanmain
18:52alexbaranosky1we're doing it like this: https://www.refheap.com/paste/b043c987a06e74941407f0ae6 and it only includes the Java source files for some reason
18:52hiredmanbecause lein by default includes src/ (assuming src is clojure source) in the jar
18:53hiredmanand you are not running the lein javac task I bet
18:53alexbaranosky1ahhh… so if we change our source directory to be another location?
18:53hiredmanif you change your java-source-path you shouldn't get java source in the jar
18:53hiredmanbut the main thing is the javac lein task
18:53hiredmanotherwise the java isn't compiled
19:00technomancypatchwork: depends on your existing deployment infrastructure. environ is slightly simpler but only supports with string values; no nesting.
19:00technomancyalso carica supports reloading much better
19:00technomancypatchwork: both environ and carica support switching by profiles
19:02alexbaranosky1@hiredman, thanks man, you're the man
19:02alexbaranosky1that worked
19:11FrozenlockGod my old code is awful. I'm sure I'll say the same thing in 10 months about my current code, but really... (when-not (empty? var) var)
19:14amalloyFrozenlock: what's wrong with that?
19:14amalloyaside from demonstrating that you don't know about the not-empty function
19:15FoxboronOne thing i kinda find...interesting with clojure, compared too other langs. There are functions for everything.....
19:15Foxboronwhich also relates too: thank god for auto-completion.
19:15dxehthere are functions for everything in a lot of languages, you just probably don't know em all :p
19:15Frozenlockamalloy: exactly that. `seq' is much more compact. The more I learn clojure, the more I find it so incredibly dense.
19:16amalloyFrozenlock: seq doesn't do exactly the same thing
19:16rabbit_airstrike<3 the cheatsheet
19:16amalloywhich is why i said not-empty, not seq
19:16Foxborondxeh: well, comming from python where you got....12'ish builtins, and tons of libs its kinda new.
19:16amalloy&((juxt seq not-empty) "abc")
19:16dxehFoxboron: ah, i know many languages but python isnt one of em yet ;p
19:16FrozenlockReally? It really _seems_ like it's the same thing :s
19:17lazybot⇒ [(\a \b \c) "abc"]
19:17FrozenlockO_o
19:17FrozenlockGod my current code is awful
19:17amalloyindeed
19:17Foxborondxeh: Python is cake. But Python got tons of stuff in its standar library, the problem is tho that they are either hard too use or a fuckload of OO stuff. Where Clojure got small neat functions for everything.
19:17metellus&((juxt seq (comp list not-empty) "abc")
19:17lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
19:18technomancyFrozenlock: FWIW I find empty? to be more readable than using seq as a predicate
19:18metellus&((juxt seq (comp list not-empty)) "abc")
19:18lazybot⇒ [(\a \b \c) ("abc")]
19:18brehautFoxboron: ironically the priority queue implementation in pythons standard lib is more like a clojure lib, and its worse than the big OO soup :P
19:19Foxboronbrehaut: hahahahahaha. urllib tho....huge mess.
19:19brehautblerk ಠ_ಠ
19:20FrozenlockEh after looking at `not-empty' source, `seq' really isn't that far away.
19:21FrozenlockStill, I'll try to use not-empty instead of seq, it's more readable as pointed out by technomancy.
19:22technomancythe "official" recommendation is to use seq as a predicate. I just don't think it's a good recommendation.
19:22TimMc&((juxt seq not-empty) "")
19:22lazybot⇒ [nil nil]
19:24amalloyFrozenlock: no, use seq instead of not-empty for the predicate. i'm pointing out that (when (seq x) x) or your actual (when-not (empty? x) x) is just (not-empty x)
20:30ToBeReplacedis https://gist.github.com/michalmarczyk/468332 currently the best way to implement a DefaultMap ? I'm looking for a solution to (merge-with conj a b) when a might be nil
20:32ausercurious… what's the difference between {:name "World"} and :name "World" ?
20:33xeqi&(merge-with (fnil conj [] []) {:a []} {:b []})
20:33lazybot⇒ {:b [], :a []}
20:33xeqi&(merge-with (fnil conj [] []) {:a [1] :b [1 2]} {:b [3 4] :c [1]})
20:33lazybot⇒ {:c [1], :a [1], :b [1 2 [3 4]]}
20:34xeqiah, not quite
20:37amalloyauser: one of those is a single value (a map), the other one is two separate values
20:37auserinteresting...
20:38amalloyToBeReplaced: a DefaultMap that behaves like that really breaks several promises of the map interface
20:38ToBeReplacedxeqi: fnil is cool, i hadn't looked into that before
20:39amalloyauser: it's about the same as the difference between [1 2] and 12, i suppose. one is a number, and one is a list of two numbers
20:40ToBeReplacedamalloy: yeah. i don't think i fully appreciate those issues yet, but it is much simpler to just write a merge-with-conj since that's the only use case i'm talking about
20:40ausergotcha amalloy
20:40ToBeReplacedespecially since you have to make an assertion anyway as to the datatype of the coll to conj to
20:41auseramalloy: I'm attempting to get this string interpolation working for maps https://gist.github.com/auser/7776f3c507d78823da7c
20:41hiredmanthat is not a map
20:42hiredman#{} is a set
20:42auseroh yes
20:42auser(new)
20:43xeqi~contrib
20:43clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
20:44auserhm
20:44xeqialso, clojure.contrib.* namespaces have been deprecated and split up. looks like strint ended up in [org.clojure/core.incubator "0.1.2"]
20:44auserhm, basically I just want to do string interpolation using a map
20:47auserhm, anyone doing string interpolation using a map and clojure.contrib.strint?
20:48RaynesI'd probably do ##(apply format "foo %s bar %s baz %s" ((juxt :foo :bar :baz) {:foo 1 :bar "a" :baz "hi"}))
20:48lazybot⇒ "foo 1 bar a baz hi"
20:48RaynesString interpolation wouldn't occur to me.
20:48RaynesNot that there is anything wrong with strint.
20:48ToBeReplacedif I wanted more sophisticated string interpolation, i'd prob use clostache
20:48RaynesNever used it, so I wouldn't know.
20:48auserinteresting
20:48Rayness/clostache/stencil/
20:49RaynesToBeReplaced: https://github.com/davidsantiago/stencil
20:49ToBeReplacedwhat makes stencil preferable over clostache?
20:49RaynesFaster.
20:50ToBeReplacedfair enough
20:50RaynesI also know the guy who made stencil. He lives a few miles from me. :p
20:50auseroh yeah?
20:53auserthanks Raynes
20:55ToBeReplacedamalloy: re merge-with-conj... or even better... don't do that, because that makes little sense for multiple maps
20:55ToBeReplacedi think a good rule for me would be "if you think you want to do something that isn't already very easy, convince yourself why you don't"
20:56RaynesToBeReplaced: Well, with that rule no nice things would ever be created again.
20:59yogthoshehe I'm still a fan of clabango myself :P
20:59yogthosmustache can get very mustachy :P
20:59ToBeReplacedmy comment is within scope of course... and i probably should have said simple rather than easy
21:01RaynesI'm a fan of that cool laser lib.
21:01yogthoshehehe
21:01RaynesI was thinking of giving a talk about it at the next LA Clojure meetup.
21:01yogthosdo it!
21:01RaynesNot sure I want to write a talk though. The conj talk I did was brutal.
21:02yogthosit's a lot of work
21:02RaynesAnd it has been long enough since I used keynote to make it very possible that I've entirely forgotten how to use it.
21:02yogthosI want to do a luminus presentation at dev TO http://www.devto.ca/contact-us/
21:02yogthosbasically, build a simple app in 15 min and put it on heroku :)
21:03yogthospeople like it when things work out of the box like that
21:03yogthos20 min is tight though :)
21:04RaynesMy problem is more along the lines of figuring out interesting things to say about laser for 40 minutes to an hour.
21:04yogthoswell you do some background, then some examples, and before you know it :)
21:04yogthosplus you have some q/a right
21:04RaynesThat's true.
21:04RaynesI actually ran way out of time at the conj.
21:04yogthos40 min goes by pretty fast
21:06yogthosbut yeah the reason I'm liking the clabango thing specifically is cause it's familiar to noobs
21:06yogthosit's like check this out, it's stuff you already know, definitely helps get interest :)
21:12amalloyRaynes: that won't be a problem at all. i'd worry a lot more about accidentally taking more than 90 minutes
21:13FrozenlockRaynes: Did you talk this year, or are you refering to previous conjs?
21:13amalloyprevious
21:13amalloyhe gave a clojail talk in 2011
21:14ToBeReplacedyogthos: that was why i brought up mustache... because people who are used to built-in string interpolation from, say, python, can use it right away.... templating as its own topic feels religious
21:15yogthosToBeReplaced: my only problem with it is that it takes the whole no logic in the templates business a little too seriously :
21:15yogthos:)
21:15yogthosToBeReplaced: the django style templating seems a bit more pragmatic in that respect
21:16amalloyToBeReplaced: python's built-in string interpolation is just ##(doc format), right? i don't know why you'd involve mustache
21:16lazybot⇒ "([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
21:16amalloy&(format "%s is bigger than %s" 10 5)
21:16lazybot⇒ "10 is bigger than 5"
21:16FrozenlockOh that's gold "a new massively parallel, ...uhm... concurrent, ...uhm... AI-driven, ...uhm... ToDo list application." https://www.youtube.com/watch?v=ROor6_NGIWU
21:17amalloylike, i could see the argument for rubyists, who have some inline string interpolation
21:18ToBeReplacedamalloy: you can also do "Hello {name}".format(name='amalloy') in python
22:12dabdI'd like to write a simple program to continuously tail a log file with something like (take-last 10 (line-seq (clojure.java.io/reader "some file")) .How should I wrap this tailing function? in an agent?
22:31twilesI'm trying to write some code to parse some emails, does anybody know how I could save a jpg attachment that looks like it's some kind of BASE64DecoderStream?
22:32twilesHere is where I'm stuck:
22:32twiles(.getContentType (.getBodyPart (.getContent (get-message email-5)) 1))
22:32twiles--> "image/jpeg; name=\"tinyvices_wayne.jpg\""
22:32twiles(.getContent (.getBodyPart (.getContent (get-message email-5)) 1))
22:32twiles--> #<BASE64DecoderStream com.sun.mail.util.BASE64DecoderStream@419e74>
22:33RaynesSince it is a stream, you can probably clojure.java.io/copy it to a file.
22:34RaynesSomething like (clojure.java.io/copy (clojure.java.io/reader your-stream) (clojure.java.io/file "your-file.jpg"))
22:36twilesoh word
22:36technomancyexcept don't use reader for binary datas
22:38Raynestechnomancy: Eh?
22:39technomancyRaynes: reader assumes it's working with data that can be safely round-tripped to/from UTF-16
22:39technomancywhich is not true of jay pee gee files
22:40RaynesOh, right. I didn't think about what we were reading here.
22:40twilesyeah technomancy that's correct
22:40twilesit didn't work out
22:40RaynesI think you can just copy the stream directly.
22:41RaynesI'm don't think it is necessary to actually have a reader in between.
22:41technomancyyup
22:41Raynestwiles: ^
22:41RaynesI'm just so used to wrapping everything in reader.
22:41Raynes:p
22:43twilesdo I have to do any decrypting? I'm not 100% sure how the attachment file is stored, and it looks like the output file didn't get written correctly
22:44twilesI tried: (def stream (.getContent (.getBodyPart (.getContent (get-message email-5)) 1)))
22:44twiles(copy stream (file "/tmp/delme.jpg"))
22:44twilesreturned nil
22:44twilesbut then the /tmp/delme.jpg file doesn't open
22:46twilessorry *decode, not *decrypt
22:47hiredmanthe body part of an email is almost certainly not a jpg
22:48hiredmanemail messages and attachments can be nested in all kinds of creative ways
22:50twilesyeah, I think I've taken care of that nesting issure here: (.getContentType (.getBodyPart (.getContent (get-message email-5)) 1))
22:50twiles-->"image/jpeg; name=\"tinyvices_wayne.jpg\""
22:52hiredmanI would try .writeTo then, and look at the output
22:55RazWelleshow do I set the clojure.load.path variable?
22:58technomancyRazWelles: I don't think anyone in here knows clojure.clr
22:58RazWellestechnomancy, damn :\
22:59RazWelleshow do you set it from inside the java clojure repl?
22:59RazWellesmaybe its the same
22:59technomancyyou don't; you have to set it before the process boots
22:59technomancyjava -cp ...
22:59RazWellesahh I see
23:01FrozenlockIs clojure.clr a complete clojure?
23:10Frozenlock*crickets*
23:10FrozenlockI guess there clojure.clr isn't that popular :P
23:11ambrosebsIIRC it's not too popular but there are people using it in production
23:11ambrosebsNo personal experience though.
23:11ambrosebsIt's certainly active.
23:23RazWellestechnomancy, I discovered the solution, you have to create an environment variable called CLOJURE_LOAD_PATH and add your project directory there for 'require to work
23:35RazWellesI don't suppose offhand anyone knows the general frequency for the formation of an inhibitory synapse
23:55technomancyRazWelles: depends on whether you can reverse the polarity of the neutron flow
23:57RazWellestechnomancy, whoops, that was meant for another channel but, I never heard of neutron flow in terms of synapses o.o
23:57technomancywell once the tachyons are emitted of course there's a much greater range of flux
23:58RazWellesok now you're just being silly :P
23:58FrozenlockThat wouldn't work anyway; the warp drive would fail before that, cause the dilithium crytals couldn't handle this change.
23:58RazWellesxD
23:58FrozenlockBut you could ask Q.
23:58technomancyhttps://en.wikipedia.org/wiki/Third_Doctor#.22Reverse_the_polarity.22
23:59FrozenlockWhat about the tachyons?
23:59RazWellesI still need to watch the older episodes of dr who