#clojure logs

2015-11-05

00:03gfredericksmaybe that will help me sleep extra effectively
00:04gfredericksgoodnight internet
00:04rhg135Night
00:04justin_smith(Human/sleep (* 8 60 60 1000))
02:15owlbirdWARNING: get already refers to: #'clojure.core/get in namespace:
02:15owlbird(:require [console.app :as app])
02:16owlbird(app/get "xx") is still conflict with clojure.core/get, how to fix that?
02:16opqdonutit shouldn't
02:16opqdonutperhaps you're also use'ing console.app?
02:18owlbirdafter 'lein ring server', api works fine, server only shows a warning message
03:05owlbirdhow to call a 'get' func of current *ns*, not clojure.core/get ?
03:07TEttinger,(defn get [coll k] "hey guys!")
03:07clojurebot#error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...
03:07owlbirdI (defn get [code] ...) and call is like (if (get code) ...), but it failed
03:07owlbirdArityException Wrong number of args (1) passed to: core/get
03:08TEttingeryou can call it with your current ns
03:08owlbirdit seems called clojure.core/get, not my 'get'
03:08TEttinger,*ns*
03:08clojurebot#object[clojure.lang.Namespace 0x7b36f42a "sandbox"]
03:08TEttinger,(defn reductions [f coll] "hey guys!")
03:08clojurebot#error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...
03:08TEttingersigh
03:09TEttingerI don't know what it denies, but I guess "everything"
03:09TEttingerhm
03:09TEttingerthat core/get
03:09TEttingerthat doesn't sound like clojure.core/get
03:09TEttinger,(get {})
03:09clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/get"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/get"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval91 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval91 invo...
03:09TEttingernvm
03:10TEttingerbut you can call it with your own ns
03:10TEttinger(my.namespace.core/get {})
03:11owlbirdthat's too long, i mean, is there some namespace indicator? like :: in c or dot in python?
03:12TEttingerwhat is your ns here?
03:12TEttingeryou can also alias an ns
03:12TEttingeror alias your get fn
03:12TEttinger,(alias get2 get)
03:12clojurebot#error {\n :cause "Unable to resolve symbol: get2 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: get2 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: get2 in this co...
03:12TEttinger,(doc alias)
03:12clojurebot"([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."
03:13TEttingerwhat am I thinking of...
03:13owlbirdOK I know why
03:13TEttingeralso, why does it need to be called get?
03:13owlbirdI'm using ac-cider in emacs, and *ns* is user>
03:13TEttingeruser/get ?
03:15TEttinger,(alias cs clojure.string)
03:15clojurebot#error {\n :cause "Unable to resolve symbol: cs in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: cs in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: cs in this context"...
03:15TEttinger,(alias 'cs 'clojure.string)
03:15clojurebotnil
03:15owlbirdwhen I call a function, which then call 'get', it failed
03:15TEttinger,(cs/join " " [:hey :people])
03:15clojurebot":hey :people"
03:15owlbirdac-cider's default ns is user
03:15TEttingeryour ns should never be clojure.core I Think
03:16TEttingerthat
03:16TEttingerthat's used for the clojure language
03:16owlbirden, that's right
03:17owlbirdthen, it's ignoring to switch ns, if I want to test a function in repl after executing C-c C-c in emacs
03:24adamzHi. Im using a clojure application (Riemann) and it defines an internal variable as `defonce`. I was wondering it it was possible to redefine a `defonce` variable, as odd as that sounds?
03:27kungiadamz: As far as I know you can only redefine vars with the ^:dynamic metadata.
03:27adamzdarn
03:31schauehokungi: not true
03:31kungischaueho: Ok? Enlighten me?
03:31schauehoyou can only rebind vars that have ^:dynamic
03:31schauehoalso, calling defonce twice will not lead to a re-definition
03:32schauehobut you can, of course, call def again
03:32schaueho,(defonce onceonly 123)
03:32clojurebot#'sandbox/onceonly
03:32schaueho,onceonly
03:32clojurebot123
03:32schaueho,(def onceonly 125)
03:32clojurebot#'sandbox/onceonly
03:32schaueho,onceonly
03:32clojurebot125
03:33adamzinteresting…
03:33adamzi went looking for crazy solutions and it might be really simple
03:34schauehoall the caveats of http://http://clojure.org/special_forms#def apply, though
03:39adamzthanks, that worked
05:14jonathanji'm having some trouble figuring out bidi route parameters in conjunction with liberator parameterized resources
05:17tdammersquestion here; is there a difference in how dynamic variable binding works in the context of deftype vs. defrecord?
05:18tdammersbecause I have this codebase here where it seems like a dynamic variable binding is resolved at definition time for a defrecord, but at method call time for a deftype
05:21jonathanji have a bidi route something like: ["/foo/" {[:id] my-resource}]
05:22jonathanjand a liberator resource defined like: (defresource foo [x] ...)
05:22jonathanjbut trying to access /foo/1234 in my browser results in an error i don't understand: java.lang.ClassCastException: documint.handler$session_resource$fn__10377 cannot be cast to clojure.lang.Associative
05:26tdammerswait, nm
05:27tdammersthe binding is resolved at call time for both
05:27tdammersis there a way to have it happen when the constructor is called instead, without explicitly passing it to the constructor?
05:29amalloyno
05:30tdammersdayum
05:30tdammerscan I have optional constructor args?
05:39mpenetfor records kinda using map->Foo, and types just pass nil and wrap this in a function to hide the ugly
05:40mpenetI mean use a function wrapper to handle this stuff
05:41jonathanjoh... my bidi handler has to be something like: (fn [req] ((foo (get-in req [:params :something])) req))
05:42jonathanji don't know if there is a better way of writing that, but it's kind of ugly
05:43tdammersmpenet: yeah, that's what I'm setting out to do now
05:43tdammersmpenet: having some trouble wrapping it in a macro though
05:44tdammersI want to generate something like `(fn [& args] (apply new ~class-name *my-dyn-var* args))
05:45tdammersbut new isn't a fn, so I can't apply it, can I
05:50mpenetwhy a macro?
05:51mpenetjust use a fn
05:54tdammersI want a macro that I can use instead of deftype
05:55tdammersso that I don't have to write the boilerplate for 16 types by hand
05:55tdammersthat macro is supposed to do two things: one, pass everything to deftype to generate the type, and two, generate the fn that does the "capture dynamic var and pass it implicitly as the first arg"
06:00mpenetthen you don't need apply in your macro template, you can just have the macro generate the proper (new ... ) call for you
06:02tdammersthen the macro needs to know the arity of the constructor
06:03tdammersbut nevermind, I found a solution
06:03tdammersI just use the ->TypeName factory fn that deftype generates
06:05mpenetif you generate the deftype with the macro you know the arity :], but good that you found an alternative, it sounded hairy
06:05tdammershehe, no, I don't know the arity - the entire macro is (defmacro defnode [class-name & args] )
06:06tdammersand I just pass args to deftype unchanged
06:06tdammersI could, like, inspect the first element of args, count its elements, and generate a suitable (new), but this is much easier
06:37Glenjaminare there any libraries which provide higher-level assertions than (is) ? Someone on our team was asking if there's an AsserJ equivalent
06:38Glenjamintheir example was having (is (= 2 (count some-vec))) showing the vector contents if the count is wrong
06:43noncomGlenjamin: haven't seen anything like that, but i too would like to know if that exists...
06:44noncomhowever, if it doesn't, there won't be a big problem implementing it....
06:44noncoman interesting approach would be to use core logic for that, although i still could not verify that it is stabile enough for production
07:48rhall` /who #clojure
08:00dnolenGlenjamin: test.check does stuff like that
08:01Glenjamindnolen: oh, good point
08:01Glenjaminwait, hang on - it'll show you inputs
08:01Glenjaminbut not derived outputs in assertions?
08:01dnolenit will show you the minimal failing value for your test (= count 2)
08:02Glenjamineg (= 1 (count (function-under-test input))) ; if that fails, i won't be shown the value of (function-under-test input)
08:02Glenjaminbut i can still call it myself once i know the input, outside the test
08:02dnolenah the return value no it won't
08:13jonathanjwhy would i choose to use core.async over something like Manifold deferreds?
08:14jonathanjthe common "call f with the value when it arrives" case seems to be a lot more boilerplatey with core.async
08:18jonathanjam i right in saying that the spelling of "call f with the value when it arrives" in core.async is (go (while true (let [[v ch] (alts! [c1])] (f v))))?
08:21stainwhat about (async/map f c1) ?
08:42mpenetin both libs there are many ways to do this
08:42mpenetex: (go-loop [] (f (<! ch)))
08:43mpenetmanifolds seems to have more "knobs" (ex: with the use of the underlying thread)
08:44jonathanjhow do you construct a processing pipeline with core.async?
08:44jonathanjlike, to build up several functions that process the result sequentially
08:45jonathanjthis seems like a really long way of going about it: http://www.braveclojure.com/core-async/#Escape_Callback_Hell_with_Process_Pipelines
08:46mpenetyou can use transducers to do this
08:49jonathanjso how would you write that example with transducers?
08:50jonathanjit's not clear to me how you turn clojure.string/upper-case into a transducer
08:50mpenet(map clojure.string/upper-case)
08:51mpenetyou can then pass it to the chan constructor directly or via other c.c.async function ex pipeline if you want it connected to another chan
08:53jonathanjso in that example the xform is (comp (map s/upper-case) (map s/reverse))
08:54jonathanjbut what is the reducing function?
08:54jonathanjmaybe i don't want to call (transduce)
08:55jonathanjmaybe (sequence xform [...])?
08:55mpenetyou don't have to
08:55mpenetthis is the signature of `chan` for instance ([] [buf-or-n] [buf-or-n xform] [buf-or-n xform ex-handler])
08:56mpenetyou can create a chan that will transform it's input as you feed to it
08:56mpenetor as I said connect it to another chan and have the transformation done when msgs move from one to antoher
08:56mpenetvia pipeline
08:58jonathanjdo i just pass nil for any of those parameters i don't want to specify?
08:58jonathanjlike if i wanted to pass ex-handler without xform or buf-or-n
08:58mpenetex: (def c (clojure.core.async/chan 1 (map clojure.string/lower-case)))
08:59mpenettry without the buff-size but I think it will throw
09:03jonathanjokay, so buf-or-n must be supplied if you have a transducer, but you can pass only ex-handler by filling the others with nil
09:05mpenetthen this example is with map, but you can fold over values, filter, etc...
09:08jonathanjthis still doesn't really help me understand why to choose core.async over manifold
09:08jonathanjor vice versa
10:06jjttjjanyone know if there are any idioms for working with arithmatic with NAs in incanter, similar to how it's done in R? specifically, i want to add multiple columns of a dataset, where some will start later than others but are backfilled with NAs (nils?), and i want the result to have NAs/nils in these spots. Seems like this should be a fairly common problem but I can't really find a "standard" way to do it? should i just wrap the inc
10:32jonathanjis there a comprehensive core.async guide that goes through some of the more obscure parts? like (mix) etc.
10:40jonathanjhttp://martintrojer.github.io/clojure/2014/03/09/working-with-coreasync-chaining-go-blocks/ :(
11:08sdegutisHow do you sort by two things? Like, if you wanted to sort [[1 2] [2 1] [3 3] [2 3] [3 2]] by first and then second, so you would get [[1 2] [2 1] [2 3] [3 2] [3 3]]?
11:09llasramsdegutis: yes. be warned though of the surprising-to-me behavior that Clojure vectors sort first by length, *then* by successive elements
11:09justin_smithsdegutis: sort
11:09justin_smith,(sort [[1 2] [2 1] [3 3] [2 3] [3 2]])
11:10clojurebot([1 2] [2 1] [2 3] [3 2] [3 3])
11:10justin_smithllasram: or sort-by #(take 2 %) - good point
11:10sdegutisNo but I mean technically I'm sorting by :queued-email/date and then queued-email/priority.
11:10sdegutisSo that's what confuses me beyond reason.
11:10sdegutisThat's what `first` and `second` represent here.
11:11sdegutisBut f/s are easier to experiment with in samples.
11:11justin_smithsdegutis: (sort-by (juxt :queued-email/date :queued-email/priority) mails)
11:11cichli(sort-by (juxt :queued-email/date :queued-email/priority) coll))?
11:11sdegutiss/s/ex/g
11:11sdegutisjustin_smith: is that even right? will it truly work?
11:11justin_smithsdegutis: yes
11:11sdegutis,(sort-by (juxt first second) [[1 2] [2 1] [3 3] [2 3] [3 2]])
11:11clojurebot([1 2] [2 1] [2 3] [3 2] [3 3])
11:12sdegutis,(sort-by (juxt second first) [[1 2] [2 1] [3 3] [2 3] [3 2]])
11:12clojurebot([2 1] [1 2] [3 2] [2 3] [3 3])
11:12sdegutisNow I'm confusing myself by mixing sort with sort-by.
11:12justin_smith,(sort-by (juxt :a :b) [{} {:a 0 :b 1} {:b 3} {:a 12 :b 1}])
11:12clojurebot({} {:b 3} {:a 0, :b 1} {:a 12, :b 1})
11:12sdegutisGreat.
11:12justin_smithsdegutis: those results were all correct
11:12sdegutisThanks justin_smith.
11:12sdegutisYou're rock.
11:12justin_smithhaha, I try
11:15sdegutisOh I see justin_smith.
11:15sdegutisJuxt forces it to take advantage of how sort automatically sorts seqs in order with respect to all elements from left to right.
11:15justin_smithexactly
11:15clojurebotexcusez-moi
11:15sdegutis(IF THERE EVEN IS SUCH A THING AS LEFT TO RIGHT IN SEQS HAHA)
11:16justin_smithbeginning / end left / right, it works unless you're speaking Hebrew or Chinese or Japanese or whatever I guess
11:16justin_smiththey actually do have ttys that go right to left
11:16justin_smithor back and forth for Arabic
11:19jjttjjIs there a reason not to just use Double/NaN all over the place with clojure.core.matrix so i can do vector math with missing values? ie (add [1 2 Double/NaN] [1 1 1]) => [2 3 NaN]
11:21justin_smithjjttjj: iirc hitting a NaN tends to make things slower - like the math unit does more work when it hits a nan or something
11:21justin_smithjjttjj: maybe there is a sparse matrix lib that would work?
11:22jjttjjjustin_smith: cool thanks, I'll look into that
11:22justin_smithotherwise, if the perf is OK and it gives the right answer, go for it I guess?
12:23sdegutisjustin_smith: thanks
12:24sdegutisfor the helpful answer -- you are helpful as always
12:24sdegutisIs there something I can do to repay you for your generous help? Maybe you have a link I can advertise on my twitter account?
12:24justin_smithhaha, not really, but I appreciate the gratitude
12:25sdegutisAre you sure I have 13 followers
12:25sdegutisI think one of them still uses twittr
12:25justin_smithlol
12:30Weebz`I'm having trouble figuring out how to do interop with Node.js libraries, could someone explain why I keep getting a no such namespace/use of undeclared var with this?
12:30Weebz`http://paste2.org/6mx8AA1k
12:30Weebz`i know in js it would be new sql.Connection(...)
12:32Weebz`merp. doing (new sql.Connection ...) seems to work
12:47justin_smithWeebz`:
12:47justin_smitherr
12:47justin_smithWeebz`: (sql.Connection. ...) is more idiomatic though
12:53justin_smith,(java.util.Date. 0) ; vs (new java.util.Date 0)
12:53clojurebot#inst "1970-01-01T00:00:00.000-00:00"
13:13Glenjaminhi all, i'm experimenting with using clojure to write tests for a java app - is there any way to get leiningen to pull in dependencies from the "test" scope of a pom?
13:52Glenjaminis there any way to pass values created in clojure.test fixtures into tests
13:52Glenjaminor should i just use (binding) ?
13:59sdegutisI recently developed need for an email queue that runs in the background written in Clojure. However, I'm coming up with difficulties knowing how to communicate with such a background thread in a queue-like way.
14:00sdegutisIs there any such tools that help alleviate such technical difficulties of implementation for the burden of the developer?
14:00sdegutisMitigation of any difficulty would be appreciated. Thanks.
14:02sdegutisjustin_smith: do you ever write something like this and have recommendations?
14:05sdegutisOh. Looks like core.async helps with this I think?
14:06sdegutisReading https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj suggests so.
14:14jakedustsdegutis: I'd say core.async + channels
14:14sdegutisAre channels part of core.async?
14:14jakedustyup
14:14jakedustif you are familiar with Go channels, they are very similar
14:14sdegutisPerfect, thanks!
14:14sdegutisYep, I am.
14:14sdegutisNot 100% the same?
14:15jakedustI'm not knowledgeable enough to say if they are 100% the same, but I've never had problems so far assuming so
14:16sdegutisCool, thanks jakedust!
14:16jakedustthere's a lot more in core.async, but I basically just use goroutines and channels for everything
14:16sdegutisSounds like a good plan.
14:27carkhsdegutis: core.async is nice, but not the only tool. channels are blocking, there are also agents which are not, but provide no control on the size of the queue (afaik)
14:27sdegutiscarkh: I thought channels only block when unbuffered?
14:27carkhthey will block on the size of your lossless buffer
14:28carkhi mention agents because i find them easier than channels for many tasks
14:28sdegutisRealistically though, all I need to do is tell a continuous background job to do something. I literally only need to send half a bit (a full bit could mean true/false, I only need to send "hey you, do your thing"). In which case, are channels overkill?
14:28sdegutisSo maybe I do need agents.
14:29carkhyou only need a thread then =)
14:29sdegutisHow so?
14:29carkhwhy do you need a queue ? are you cosntrained by the possibility of too many "requests" ?
14:30carkhsometimes just fire and forget is enough
14:30sdegutisI just need to tell the background job "hey you got another job to do", and it knows where to find it. It'll keep doing jobs as long as there are some left. When there's none, it just waits for this message.
14:30sdegutisBut it has to do them sequentially.
14:30sdegutisThat's the difficult part. It can't do any of these jobs simultaneously, even though it can get simultaneous requests to do it.
14:31carkhwith agents you have the risk of filling the memory with more requests than you can process, but it's sequential all right
14:31norton-I want to create my own project which uses code from this project, https://github.com/adamtornhill/code-maat , but it seems like it's not available as a library on clojars. Is there a simple way I can use the code? Copying all code into my own project perhaps works but it feels like there should be a better way.
14:31carkhwith core.async you _can_ have backpressure
14:32lxsameeris it safe to derefrence an atom inside swap! of other atom ?
14:33tcrawleynorton-: you can deploy to clojars under org.clojars.your-user-name/code-maat and use that
14:34amalloylxsameer: it's safe in that you are guaranteed to get the current value of that atom. but it might well have a different value the very next instant, so any decision you make based on that value may be out of date
14:34lxsameerthanks
14:35carkhlxsameer: the best woudl be to deref outside of it though
14:35lxsameercarkh: awesome thanks
14:35norton-tcrawley: thanks
14:35carkh(swap! atom1 do-it @atom2) is correct
14:35tcrawleynorton-: my pleasure!
14:44jonathanjliberator allows you to return a map from a handler which it will turn into JSON in the case of application/json media, but it's not clear how you have it encode some non-standard value into JSON
14:44jonathanjclojure.data.json/encode requires an additional arg that you don't have access to when using liberator like this
14:44jonathanjcheshire has a way to add an encoder globally but liberator isn't using cheshire
14:59gfredericksjonathanj: I swear data.json has a similar global mechanism
15:19jonathanjgfredericks: i don't know if i'm looking in the wrong place then but there doesn't seem to be anything like that here: http://clojure.github.io/data.json/
15:20jonathanjmaybe JSONWriter? but what happens if i want to encode one of the existing types in a different way?
15:30jonathanji feel a bit stupid: i don't understand how to invoke to-hex-string with clj-uuid
15:31amalloycarkh: that has exactly the same problem as derefing inside
15:31jonathanj(clj-uuid/to-hex-string (clj-uuid/v4)) tells me: java.lang.IllegalArgumentException: No implementation of method: :to-hex-string of protocol: #'clj-uuid/UUIDRfc4122 found for class: java.util.UUID
15:32amalloyyou can't make a coordinated decision based on the instantaneous state of two different atoms: there is just no way to do it, because they are uncoordinated. if you need to do that, you want refs
15:32carkhamalloy: maybe for your concern, but the function should be pure, which it isn't when derefing inside
15:32carkhamalloy: true
15:33amalloyit's true you do avoid one problem by derefing outside, although it's not one that i find usually matters
15:33carkhamalloy: true again, i'm just blindly following the doc recommendation =)
15:45jonathanjgfredericks: so if i do something like: (extend java.util.UUID JSONWriter {:-write (fn [x ^PrintWriter out] (.print out (uuid/to-string x)))})
15:45jonathanjgfredericks: then i get json that looks like: {"foo": 1234-arst-uuid-goes-here}
15:46jonathanjand the "write-string" implementation in data.json is private
15:59jonathanj*oh* i have to import -write from clojure.data.json, that was not very obvious to me at all :(
16:02gfredericksjonathanj: yeah, or you can write the double-quotes yourself (which is what I did, but I like yours better)
17:28uptownin a cider REPL, can I hook namespace changes?
18:15Frozenlockuptown: hook namespace change?
18:17uptownexecute a function when the user types (ns some.ns) in the REPL
18:21Frozenlockuptown: Hmm... ns is a macro, so I'm not sure this will work: https://github.com/technomancy/robert-hooke/.
18:22FrozenlockOtherwise you can jump through some hoops and do something similar I did to redefine 'fn' in https://github.com/Frozenlock/force-serialize
18:23justin_smithand you can also switch namespaces via in-ns, which is not a macro, it's a special form I think
18:23justin_smithmaybe not
18:23justin_smithFrozenlock: uptown: put the hook on in-ns, ns calls in-ns
18:24uptownaha
18:24Frozenlockjustin_smith: hooks work with special forms?
18:25justin_smithFrozenlock: it's not implemented in clojure, but it's also not a special form, it's just a function
18:25justin_smithso you can totally hook on it
18:25amalloyi don't think you really want to hook in-ns
18:25justin_smithoh?
18:25amalloyi mean, that will impact every namespace that gets loaded
18:25justin_smiththat's true
18:27justin_smithamalloy: totally works though https://www.refheap.com/111402
18:28FrozenlockBtw, is technomancy still alive? I think the last time I heard of him he was moving to another country or something...
18:29justin_smithFrozenlock: he pops up in #leiningen sometimes
18:29justin_smithhe just dropped out of the high-pace #clojure lifestyle
18:29uptownfor clarity, the point of this is to print a count and abbreviated list of publics when i switch namespaces as a sanity / typo check
18:30justin_smithuptown: that should be pretty easy with alter-var-root if you don't mind a permanent change, but robert.hooke does it much more elegantly, if you don't mind this printing every time a namespace gets loaded
18:31uptownjustin_smith: i think the point is print it every time i change
18:31uptownwhich i understand would annoy most people but
18:32Frozenlockuptown: many editors will also autocomplete and offer the list of known functions/variables if you are worried about typos.
18:32uptowni seem to make enough typos to justify it
18:33uptownmy emacs setup seems not to do that for me? perhaps that's my real problem
18:33FrozenlockYeah, I'd check that first :-p
18:33FrozenlockCider?
18:34uptownan excellent point. got frustrated and started treating symptoms
18:34uptownyes, cider / emacs
18:36Frozenlockuptown: I'm using Cider with Company-mode: http://i.imgur.com/5aTa1N2.png
18:38FrozenlockSo I've got the dropdown menu as shown, TAB autocomplete, and in some cases hippie-expand (meta-/). I ain't got any typos :-p
18:38uptowncompany-mode offers me namespaces i've previously mentioned but does not expand to a list of funtions
18:39uptownbut you have fewer cider / nrepl warnings on startup than i do
19:02noncom|3i am working on a PC with limited caps, and eclipse is getting very hungry, it can eat like 400-800mb. i am thinking about moving to emacs on this machine, how do you think, will it be more feasible?
19:02oddcullyEight Megs And Constantly Swaping - should work fine then!
19:03Frozenlocknoncom|3: It will most probably work. The only question is 'are you read for Emacs?'
19:03Frozenlock*ready
19:03justin_smithemacs is much weirder, but yeah, it can also run with less heap
19:03noncom|3yeah, i got some experience with emacs
19:04noncom|3on my last emacs usage though, i remember the weirdness - the linum mode was taking up to 15% CPU !
19:04Frozenlocko_O
19:04noncom|3i remember discussing that on #emacs and people said, like yeah, well, linum eats that much
19:04noncom|3and i was like WTF
19:04noncom|3maybe even up to 25 CPU, i don't recall exactly.
19:04noncom|3i can check tomorrow
19:05noncom|3i got to know this by some inbuilt emacs profiler..
19:05noncom|3i dont remember how to call for it, but someone on #emacs guided me
19:05noncom|3that's the story..
19:06noncom|3*it was taking that much on scrolling
19:07noncom|3justin_smith: btw, what about that hang in your app? did you nail it down?
19:07FrozenlockHow do you use linum? I don't use it and I might be missing on some nice wizardry...
19:07noncom|3Frozenlock: i just hardcodely enable it in init.el for everything
19:08noncom|3you know, i like having line numbers everywhere
19:08FrozenlockBut it only shows the line number?
19:08noncom|3no, it shows a column of numbers to the left
19:08noncom|3like that: http://joxi.ru/82QVZ9eIYO4QAd
19:08noncom|3(it's eclipse)
19:09FrozenlockYes... what I'm asking is how do use that in your workflow.
19:09noncom|3for navigation, for stack traces
19:09noncom|3somehow i feel better with it
19:09oddcullyFrozenlock: some folks need that to see... others just tell the editor
19:09noncom|3tried to work without it, but found that i always turn it on
19:11FrozenlockI see. Yeah I just tell emacs to go to line when I have a stacktrace. 'M-g g'
19:12noncom|3i know, eclipse can do this too
19:12FrozenlockI hope so :-p
19:12noncom|3:D
19:27the_nonameguyhey, has anyone written a test.check generator based on a schema from the 1.0 prismatic/schema release?
19:30the_nonameguyhttp://blog.getprismatic.com/schema-1-0-released/
19:30the_nonameguyit states that it 'provides way to plug in custom generators', but I couldn't figure out how, based on the source
20:06gfredericksthe_nonameguy: haha I just figured that out today
20:07gfredericks(cgen/generator the-schema {SomeSchema some-generator})
20:41bluezoneOH my GOD. How on EARTH do I erase brackets around an expression in Cursive ?!?!
20:41cflemingbluezone: https://cursiveclojure.com/userguide/paredit.html :)
20:43bluezoneGOD BLESS YOU!
20:43gfredericks~GOD |BLESS| cfleming
20:43clojurebot'Sea, mhuise.
20:51TEttingerto the tune of god bless america: GOD BLESS G. FREDERICKS / TESTS CAN BE CHUCKED / MAKE EXPRESSIONS / AND DOUBLES / FROM THE NAN TO THE HASH DOUBLE QUOTE
20:52TEttingersorry cfleming, your name doesn't have the extra syllable to fit the scheme
20:53cflemingIt would have to be a fle-he-ming - worse things have been done to make something scan
20:53TEttingerphlegming
20:54TEttingerreally appreciate what you wonderful tools authors do
20:54TEttingerI'm so glad clojure has a good community of people making productivity better for everyone
20:57cflemingI notice that only gfredericks gets a song, though.
20:57cflemingI mean, I'm just saying.
21:05TEttingerto the tune of god bless america: GOD BLESS INTELLI J/ CURSIVE WE LOVE / USE PAREDIT / AND EDIT / ALL YOUR CLOJURE WITH C FLEMING'S HUG
21:06cflemingTEttinger: That's awesome. I'm going to make Cursive play that at startup.
21:06TEttingerhaha
21:07cflemingIt'll be like the pledge of allegiance
21:08cflemingI wonder if I could remix it to the tune of God save the Queen
21:08gkoIs there a way to have a Cursive REPL in a single window?
21:09cfleminggko: How do you mean, in a single window?
21:09gkoI mean not a "output window on top / input window at the bottom"
21:10gkoone window with both input and output
21:10gkolike most REPL
21:10gkolike in cider or SLIME
21:12cfleminggko: No, there isn't
21:12bluezonehttps://www.refheap.com/111403 I'm trying to have the function accept a vector. I believe I am doing something wrong :/
21:13cflemingIt's because in IntelliJ editors are strongly typed, so the input editor has to be a Clojure editor, but the output isn't actually Clojure, it's arbitrary text
21:13cfleminggko: So I have to separate them.
21:14cflemingThat said, it's actually quite nice, especially for editing multi-line forms.
21:14gkocfleming: oh, so if you insert random text it will actually try to parse the colors, etc...
21:15cfleminggko: Right. There's actually a problem with that, which is that if you try to (read) in a Cursive REPL, it currently won't work well.
21:15cflemingSince Cursive will always try to treat it as Clojure code.
21:17cflemingThere are some potential hacks to get around that, but I haven't implemented anything yet.
21:17gkoOK, too bad... fortunately, there's cider for the REPL side...
21:20gfrederickswow a lot of singing happened here while I wasn't looking
21:20bluezoneIt's telling me on line 7 that i'm passing 4 arguments https://www.refheap.com/111404
21:20bluezoneI'm just trying to pass [1 2 3 4 5] into the vect parameter :(
21:20gfredericksbluezone: that's not causing the error
21:20gfredericksit's happening on line 5
21:21cfleminggfredericks: It was great.
21:21bluezoneWhy doesn't the stack trace tell me that :(
21:21gfredericksbluezone: what's the stack trace look like? it ought to
21:22cfleminggfredericks: Are you going to be at the conj?
21:22gfrederickscfleming: absolutamente
21:22cfleminggfredericks: Muy bien
21:22cflemingWe can sing odes to each other.
21:22bluezonegfredericks: https://www.refheap.com/111406 (in my code, line 5 is line 7)
21:22cflemingTEttinger has given us some great material
21:22badatclojureHey guys! Quick question about multimethods. I'm wanting to dispatch off a map containing a certain property (params request in Compojure). Is there a good way to do that?
21:23gfredericksI'll sing you your song if you sing me mine
21:23badatclojurecertain key* sorry
21:23gfredericksbluezone: looks like the problem is you're not seeing the stack trace at all -- try typing *e at the repl
21:24bluezoneoh, heh nice
21:25gfredericksthis year will be my first conj since maybe the first one
21:25gfredericksor maybe the second one
21:25gfredericksthey were so long ago now I can't remember
21:30Frozenlockbluezone: the clojure syntax?
21:30bluezoneyes
21:31bluezonenever sure when to put brackets
21:32FrozenlockDo you have an editor that highlights the brackets?
21:32TEttingerunless you have ' quotes involved, () starts with a function to call and anything else in it is an argument
21:32TEttingerthat's most of it
21:32bluezonehmm
21:32badatclojurebrackets are basically used to separate functionality. In Java, you'd type something like cons(a,b). In clojure, you move the name inside the parens and drop the comma (cons a b).
21:32TEttinger(function or macro)
21:33FrozenlockIt's like math :-p
21:33bluezoneif I want to pass rest vect as one parameter I need to do (rest vect) ?
21:33badatclojuresame thing for deeper function stacks. Java: cons(a, something(b)) Clojure: (cons a (something b))
21:33TEttinger,(let [vect [1 2 3 4 5]] (map inc (rest vect)))
21:33clojurebot(3 4 5 6)
21:34bluezonehmm
21:35TEttingerinc is sorta like ++, it increments (but doesn't change any existing variables, things that do that are rare)
21:35bluezoneI think I'm just unaware of something special i need to do for recursion
21:35TEttinger,(let [vect [1 2 3 4 5]] (rest vect))
21:35clojurebot(2 3 4 5)
21:36TEttingerbluezone, usually you don't directly do recursion in clojure
21:36TEttingerthere's loop and recur, which are pretty much always used together
21:36bluezonewat
21:36Frozenlockbluezone: Don't listen to him, recursions are cool :-D
21:36badatclojureBluezone: Direct recurson doesn't happen much. You'll see loop and recur. Oh, and you'll see map a lot too.
21:36TEttingertail recursion can blow the stack if you don't use loop/recur
21:37badatclojureYeah, make sure to use loop/recur.
21:37TEttinger(also non-tail recursion)
21:37bluezoneI guess they aren't using java8? I think they removed that problem in java8
21:37badatclojureLearned that the hard way.
21:37TEttingernope
21:37TEttingerjava8 still lacks TCO
21:37bluezonejava8 still lacks a language
21:37badatclojureI dont really know when Java8 will have TCO.
21:37TEttingerit as under consideration
21:37TEttinger*was
21:37FrozenlockI use recursions when I know my dataset will be small-ish. loop/recur is... not pretty.
21:38jasonx2in some ways recur is nicer than tail recursion. you get a compile-time check if your function is tail recursive
21:38badatclojurePeople dont really write recursive Java to my knowledge though. Or really even try. Stateful recursion is scary anyways.
21:38TEttingerI strongly recommend trying to phrase things with map, filter, recur, and other common fns like that before you start doing loop/recur
21:38TEttinger*map, filter, reduce
21:39bluezoneI just don't understand why it's still passing 4 arguments https://www.refheap.com/111407
21:39badatclojureShameless self-plug. Could someone explain how to setup multimethods that dispatch off of a key existing in a map parameter?
21:40bluezonelike it takes the rest of vect, but instead of passing it as a vect it passes each value individually
21:40Frozenlockbluezone: https://www.refheap.com/111408
21:41FrozenlockAnd you don't need the 'apply', unless I misunderstood what you are trying to do.
21:41netrobyatmobilewho know how to compile Clojure code into Executable Binary ELF file?
21:42bluezoneWell
21:42bluezoneshit
21:43Frozenlock(first-element) is like calling the function 'first-element' which doesn't exist.
21:43bluezoneyeah, hmm
21:43bluezoneThanks
21:46TEttingernetrobyatmobile: you would need to get the JVM bundled in there too
21:47bluezoneSeems the solution works in my environment but not on 4clojure <3
21:47netrobyatmobileThanks, i hate JVM , it will takes more than 200MB space.
21:47netrobyatmobileDownload, Upload the whole distribution was huge packages.
21:47TEttingerthere's clojurescript and clojure CLR
21:47netrobyatmobileLong time to waiting it deliveried
21:48Frozenlockbluezone: link?
21:48bluezoneFrozenlock: https://www.4clojure.com/problem/19
21:49TEttingernetrobyatmobile: Pixie is similar to Clojure in lots of ways but doesn't use the JVM
21:49TEttingerit also is not very finished yet I think, though it's getting better
21:50Frozenlockbluezone: If you are not using 'defn', I suppose you are using 'fn'?
21:50bluezoneit tells me I tripped the alarm? O.o I dunno wtf
21:50FrozenlockAh ok
21:50FrozenlockSo yeah, you can't define functions.
21:50bluezoneerr
21:50FrozenlockBut you can create one that will be used immediately with 'fn'.
21:51Frozenlock"define function" -> defn | "function" -> fn
21:52bluezonewell How can i use recursion if I don't have the function name
21:52cflemingnetrobyatmobile: Check out Avian, it's an alternative lightweight JVM which can compile an executable
21:52Frozenlockbluezone: fn accepts an optional name.
21:52cflemingIt's not high performance, depends on your use case
21:52FrozenlockType (doc fn) in your repl.
21:53Frozenlock(fn last-e [vect]...
21:54bluezoneso what would be the difference between (defn last-e) and (fn last-e)
21:55bluezoneah
21:55bluezonenevermind, fn is used immediately I guess
21:55bluezonedefn creates a function for later use
21:59jakedustnot really that Clojure-related, but does anybody have any recommendations of readings/code on building "services"? i.e. I want to build a data processing service with a REST API for both task-related commands (do task A as soon as you can) and "lifecycle" commands (finish all the jobs you have right now and exit as soon as you can)
22:00jakedustmy original idea was writing everything around an event loop and core.async channels, but I'm not sure if that's a good idea or not, I'm really not familiar with this
22:01netrobyatmobileThanks /msg cfleming
22:10bluezoneWell this seems like a really sexy language so far
22:11bluezoneI love that-I-Can-do-this insteadOfThisCamelFatassAnnoyance
22:12jakedustbluezone: I have to confess that seeing * in names is confusing, but still lovely
22:20Frozenlockbluezone: be warned, this is a one way trip.
22:20bluezoneFrozenlock: away from what? java?
22:20FrozenlockIt's like going from 56k to broadband.
22:21FrozenlockAll-the-things!
22:22bluezoneeh, I don't care anymore lol. Prefer to be a bum than to fall asleep coding in boring languages
22:22jakedustFrozenlock: I've been bitten by the Clojure bug.
22:22Frozenlockjakedust: https://mlpforums.com/uploads/monthly_06_2015/post-20300-0-98845900-1435445700.jpg
22:23jakedustheh, I though it'd be a parasprite, given the URL
22:23jakedustbut yeah
22:24FrozenlockPff, that's URLism
22:24FrozenlockDon't judge based on URL dude.
22:26jakedustweirdly enough, it feels like I was on another extreme, using scalaz everyday
22:33bluezoneI keep tripping the alarm -.-
22:33bluezoneThey have so many restrictions on identifier names
22:35TEttingercfleming: does avian work with clojure now?
22:36TEttingerI tried it a while ago, it didn't support some java data structures clojure needed
22:36TEttinger(also, netrobyatmobile, there's zulu builds of OpenJDK that are much less than 200MB)
22:37TEttinger(and you are allowed to take stuff out of those)
22:44cflemingTEttinger: I believe it does, but you might have to use a different class library
22:44cflemingThe default one is very limited, but you can use OpenJDK classes or the Android ones IIRC
23:32jeaye,(-> [:foo] first name symbol list str)
23:32clojurebot"(foo)"
23:32jeaye^ is there a cleaner way to get the same result, given [:foo]?
23:34irctchi guys does anyone know how to run om-next-demo project
23:34irctchttps://github.com/swannodette/om-next-demo
23:34irctcI have managed to get all the deps working, it seems we need to run some kind of script instead lf lein run.
23:35irctcI have read this https://github.com/clojure/clojurescript/wiki/Quick-Start, but it's a bit confused. Any help would be appreciated.
23:38TEttinger,(map symbol [:foo])
23:39clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String>
23:39TEttingerhm
23:39TEttinger,(map (comp symbol name) [:foo])
23:39clojurebot(foo)
23:39TEttinger,(str (map (comp symbol name) [:foo]))
23:39clojurebot"clojure.lang.LazySeq@9e9a82cb"
23:39jeayeapply str
23:40jeaye,(apply str (map (comp symbol name) [:foo]))
23:40clojurebot"foo"
23:40jeayeah
23:40jeayeWell, maybe what I have isn't so bad then.
23:41TEttinger,(map #(str "(" (name %) ")") [:foo])
23:41clojurebot("(foo)")
23:42jeayeheh
23:42jeayeThere's a lot more syntax there.
23:42TEttinger,(apply str (map name [:foo]))
23:42clojurebot"foo"
23:43jeaye,(apply str (map (comp list name) [:foo]))
23:43clojurebot"(\"foo\")"
23:43jeaye,(apply str (map (comp list symbol name) [:foo]))
23:43clojurebot"(foo)"
23:43jeayeCorrect result, not any cleaner.
23:44TEttinger,(pr-string (map name [:foo]))
23:44clojurebot#error {\n :cause "Unable to resolve symbol: pr-string in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: pr-string in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: pr-st...
23:44TEttinger,(pr-str (map name [:foo]))
23:44clojurebot"(\"foo\")"
23:44TEttingerhm
23:45TEttinger,(pr-str (map str [:foo]))
23:45clojurebot"(\":foo\")"
23:45TEttinger,(pr-str (map (comp symbol name) [:foo]))
23:45clojurebot"(foo)"
23:52TEttinger,(apply str (nfirst (map name [:foo])))
23:52clojurebot"oo"
23:55TEttinger,(apply str (nfirst [:foo]))
23:55clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.lang.RT next "RT.java" 682]\n [clojure.core$n...
23:55TEttinger,(apply str (nnext (str [:foo])))
23:55clojurebot"foo]"
23:55TEttingerdamn
23:57TEttinger,(str "(" (name (first [:foo])) ")")
23:57clojurebot"(foo)"
23:57TEttinger,[(count "(str \\( (name (first [:foo])) \\))") (count "(-> [:foo] first name symbol list str)")]
23:58clojurebot[33 38]
23:58TEttingerso there's some teensy golf
23:58TEttingerthe list threw me off initially, so in my mind the explicit str with parens shows the end result