#clojure logs

2015-10-04

00:19python476 turns out after 1 hour, java throws a ThreadDeath exception.
04:04roelofHello, I have to put a initial value here (reduce (fn [counter] (inc counter)) [1,2,3]) but where do I put it ?
04:10expezroelof: this is a good site to help answer such questions: https://clojuredocs.org/search?q=reduce
04:11expeznot only do you get the docstring, but quite a few examples answering common questions as well as common gotchas
04:12roelofexpez: thanks, I have read them and as far as I understand it , it must be this : (reduce (fn [counter] (inc counter)) 0 [1,2,3])
04:13roelofbut then I see this error message : clojure.lang.ArityException: Wrong number of args (2) passed to: core/eval6230/fn--6231
04:13expezroelof: you are right, that's the right place ot put the seed value, but that's not related to the error you're getting
04:13expezroelof: the function passed to reduced must take two arguments, yours only takes one
04:14expez,(reduce (fn [counter _] (inc counter)) 0 [1,2,3])
04:14roelofthanks I will hit the book why counter needs two arguments instead of 1
04:14clojurebot3
04:15expezroelof: reduce reduces multiple values two a single value
04:16expezroelof: to do that the reducing argument considers two things: the accumulated value so far, and the value of the next element in the input sequence
04:16expezthe reducing function*
04:17expez,(reduce (fn [accumulator n] (+ accumulator n)) [1 2 3 4])
04:17clojurebot10
04:17expezthe final value is the value in the accumulator
04:17expezonce all inputs have been consumed
04:18roelofthanks for the explanation
04:19roeloffinnaly that challenge on 4clojure solved. Can this solution be improved : (fn [list] (reduce (fn [counter _] (inc counter)) 0 list))
04:20expezI take it the exercise is to re-implement count?
04:20roelofexpez: yes, I try to solve that exercise
04:22expezI think using reduce is a fine choice
04:23roelofexpez: so the solution cannot be shorter ?
04:24expez,(reduce #(+ %1 %2) (range 10))
04:25clojurebot45
04:26expezI thought this might work: (reduce #(inc %1) 0 (range 10)) but it doesn't :p
04:27expezso no, I don't think you can make it much shorter
04:30roelofexpez: thanks, now the next challenge, make Fibonacci Sequence. so again a nice one to think how to solve this. First thought something like map
04:31lumai guess you could (reduce + (map (constantly 1) list))
04:34expez(while true (future 1)) is fine, right? I'm not leaking any resources?
04:40amalloyif you don't mind forkbombing yourself
04:40amalloythis spins up threads as fast as your OS is capable of
04:41expezamalloy: obv that doesn't happen in practice, I tested this to find out if I leaked memory when I didn't use future-cancel or ever retrieve the value of the un-interesting futures.
04:42expezrunning the code above at the repl seems to only produce a cpu load, not a memory load
04:43amalloyyou don't leak anything permanent, but whether your thread demand outpaces supply is a matter of luck and/or system power
04:44expezgreat, thanks
06:05visofhi guys
06:06visofhow can i convert this haskell (fmap (fmap f) z) to clojure? (fmap #(fmap f %) z) ?
06:08expez,(map (partial map inc) [[1 2] [3 4]])
06:08clojurebot((2 3) (4 5))
06:08expezvisof: ^
06:09expezIs there a general version of subvec which works seqs?
06:12djcoinvisof: in which order are your argument?
09:04ob-sedhey this gu in ##hardware is complaining clojure uses up too much ram
09:13ob-sedi told him to shut his mouth the hell up
09:13ob-sedhis name is crocket
09:15oddcully><((((*>
09:19taylanubob-sed: that doesn't sound like a very friendly thing to do
09:19ob-sedtaylanub: yeah but he's been saying the same thing for an hour, like a broken record, how:
09:19ob-sed"<crocket> I just wanted to say that "RAM is cheap" is not an excuse for thinking that it's ok to consume 160MB for a daemon whose only task is to send an HTTP request regularly."
09:21oddcullyand then you /ignore:d it, right?
09:25crocketRAM is not so cheap.
09:25taylanubdo we have a !mods command? shall I invoke it?
09:26crocketIf RAM was cheap, it should be ok for every small linux daemon or every kernel driver to consume 160-250MB.
09:26crocketThen, linux won't fit in 16GB RAM.
09:26taylanubob-sed: crocket: get a room and leave the channel alone
09:27taylanub(I'm new here but I assume this is common sense.)
09:27crockettaylanub, you from ##hardware?
09:30crocketI came here to say it because some people in this channel said as if every program could afford to consume hundreds of MB. This is physically impossible.
09:40Bronsaob-sed: clojure doesn't fit all usecases, I wouldn't use it in memory-constrained embedded devices.
09:40Bronsaalso please don't bring issues from other channels here
09:40wasamasasome people are having a hard time just accepting that java was made for running a single application on a server
09:44wasamasaob-sed: generally, the channel to take such things to is #freenode
11:17gfredericksokay I might make a library that's a stupid datastore where it just appends edn events to a file and keeps a reduction of all the events in memory
11:17gfredericksunless somebody tells me it already exists
11:27gfredericksI think I should probably name it "webscale"
11:32sakallijoin #commonlisp
11:32sakallisry ;)
12:12xtreakHi, what is the difference between require and :require. require needs the vector to be quoted and :require doesn't need it. Saw them used interchangeably. Any difference?
12:37luxbockxtreak: require is the function that loads a namespace from the classpath, and because the namespace hasn't been loaded up yet you need to quote its argument as the symbols it uses haven't been defined yet
12:39xtreakThanks. Why do some tutorials use :require keyword for loading libraries. Any difference or is it a matter of preference?
12:40luxbockxtreak: so the `ns` that's used in the ns-declaration of a file is a macro, and it uses kind of a mini-DSL to create and reference other namespaces, and :require is part of that mini-DSL
12:40luxbockit gets translated to calling `require` in the end
12:41luxbockI don't know why it uses :require instead of just the symbol, probably because then it it would be even more confusing why one needs the quote and the other doesn't
12:42luxbockthe reason you don't need to use quote with :require is because it's a macro so the symbols inside don't get evaluated
12:43luxbockhttps://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L5529
12:43luxbockthis is what `ns` does for you :)
12:43xtreakYes. Its been confusing. I thought that :require is used to access the parts like a hashmap. But that doesn't make sense as its followed by a vector. Thanks for clearing that its a macro.
12:45xtreakI read up source for require as it does some apply operation along with filtering the keywords used in vector. Thanks for the reference :)
12:46xtreakAlso a question about the error messages in clojure really scare me away as I am a newbie. Is there a way to make runtime checks and throw some exceptions? Any project under development on that?
12:48luxbockxtreak: do you know about the pre and post -conditions you can add to functions?
12:48luxbockhttp://blog.fogus.me/2009/12/21/clojures-pre-and-post/
12:48xtreakLike take the second argument of map to see if its a function with (type f) and then throw up an error if not.
12:48luxbockthen there's Prismatic's Schema which is should fit into what you were asking quite well: https://github.com/Prismatic/schema
12:49xtreakOfcourse keywords can be used in maps too just wondering if its possible..
12:49luxbockif you use Emacs/CIDER, it sanitizes the stacktraces quite nicely
12:50luxbockother editors might do the same but I haven't used them
12:50xtreakPre and post? I came across constraint programming in D lang . not sure if its the correct term. It has precondition and post condition blocks. Is it similar?
12:51luxbockxtreak: check out the blog post I linked
12:52justin_smithgfredericks: that stream of events in a file thing? if you are allowed to format the edn via transit, it's called kafka, and I've found it pretty awesome
12:52justin_smithgfredericks: side effects of that stream of events in a file, is it works as a logged communication channel
12:52xtreakI use emacs too ;) I will try out cider. I mostly use lein repl . sure will give it a try. Will check out the blog post. Thanks a lot :)
12:54luxbockcider has this nice popup that pretty prints and allows you to filter the stacktraces which I find really helpful
12:54luxbocksometimes you want more and sometimes less details
12:55gfredericksjustin_smith: the use case is super casual though, where you don't want to run a separate process and you want to store the data in git
12:55xtreakRead the post. Quite similar to D lang. Cool to learn that :)
13:00xtreakDoes clojure lazy sequences create intermediate collections. The reason to create transducers where Rich Hickey says in strongloop video IIRC that they avoid intermediate collections. So when I say (map inc (filter odd? (range 10))). Does 1 from range collection pass through filter and to map in same call or filter creates an intermediate collection and feeds to map? If so how is filter lazy?
13:01justin_smithxtreak: yes, that map / filter / range creates three lazy seqs, and you use one of them
13:02justin_smithit's lazy because it creates its own collection, which doesn't need to realize as many inputs as its source does
13:03justin_smitherrr s/inputs/elements on the end there
13:04xtreakSorry. I couldn't fully grok that.
13:04justin_smithfilter walks along the collection that range created, making its own collection
13:05justin_smithit will create results only if its own collection is consumed
13:06xtreakWhen I say (range 10) it returns me a promise like thing to generate it when needed. Filter walks through but doesn't generate until consumed? Little confusing that it walks over the range collection but doesn't generate.
13:09justin_smithxtreak: it doesn't walk through the range until it needs to produce results
13:09justin_smithbut it might walk multiple elements of the range to produce one output
13:10justin_smithit's a promise like thing, just like range is
13:10xtreakSo transducers remove the intermediate collection by filter and make it as a single pipeline of different operations than making intermediate collections for each map/filter. Am i correct?
13:10justin_smithright, it composes operations without creating new collections in between
13:11justin_smithalso this means you can transduce on channels too (which are not even collections)
13:11justin_smithand one could define ways to transduce on other non-collection sources of input as well
13:11roelofwhy do I see this error message : Mismatched argument count to recur, expected: 1 args, got: 2 on this code : http://lpaste.net/142293
13:12xtreakIs the multiple elements mean 32 elements at a time? Sorry to be confusing. Read somewhere that clojure does that.
13:12justin_smithroelof: you start the loop with one value, and then try to recur with two
13:13justin_smithroelof: maybe you meant (loop [counter 2 n n] ...)
13:13justin_smithand you can ditch the let
13:14justin_smithroelof: loop is like let, where you declare a binding symbol, and an initial value, so you need two elements in the vector for each binding
13:15xtreakjustin_smith any place to study more about clojure lazy sequnces?
13:17xtreakThey look interesting. Am on sicp now.. Will be interesting to compare clojure implementation, streams in sicp and lazy sequences implementation in other languages.
13:17justin_smithxtreak: have you looked at the sequence docs on clojure.org? http://clojure.org/sequences
13:21roelofjustin_smith: thanks, now trying to find out why I see a null pointer exception here : http://lpaste.net/142297
13:21xtreakThey look a little hazy to me. From wat i understand they are an interface that are implemented by different data structures. Whats an ISeq?
13:21justin_smithISeq is the interface
13:22xtreakMaybe am trying to grasp too much being a clojure beginner still ;)
13:22justin_smithone implementation of ISeq is lazy-seq, if you use that function, the seq you are creating is lazy
13:23xtreakIs sequence a data structure or an implementation of ISeq interface. Sry little confused.
13:24justin_smithroelof: after the first recur, answer is not a thing you can use get to look something up in, it will be nil, because you are calling (assoc number number)
13:24xtreakIts a logical list says the link
13:25justin_smithxtreak: a sequence is some data that implements the ISeq interface
13:25justin_smithand the interface ensures that any implementation of ISeq can be used as if it were a linked list (regardless of implementation)
13:25roelofpff, what I try to do is summing the right numbers ( n -1) + ( n - 2) and adding it up to answer which will [ 0 1]
13:25roelofso again back to the manual
13:26justin_smithroelof: right, but in assoc, you only provide two args, and both are numbers
13:26roelofjustin_smith: oke, so I forget to mention answer :(
13:26justin_smithroelof: wait, no, do you even provide a second arg to assoc? don't you just want conj?
13:27justin_smithroelof: if what you want is to add to the vector, you don't want to use assoc there, you want to use conj
13:27justin_smithand you need to provide answer as the first arg to conj
13:27roelofoke, then im confusing those two
13:27justin_smithroelof: after the first recur, should answer be [0 1 1] or should it be [1 1] ?
13:28roelofjustin_smith: it schould be [ 0 1 1 ]
13:28roelofand after that [ 0 1 1 2]
13:29justin_smithOK, so your last arg to recur should be (conj answer (+ (get answer (- counter 2)) (get answer (- counter 1))))
13:29justin_smithyou also had the args to get backward
13:29justin_smith,(get 1 [0 1])
13:29clojurebotnil
13:29justin_smithwhich causes nil
13:29justin_smith,(get [0 1] 1)
13:29clojurebot1
13:30justin_smiththat's the version you want
13:30xtreakSo all data structures that implement ISeq allow themselves to be accessible like a linked list? When I say (seq x) it returns a sequence a linked list representation of the given structure to be precise.
13:31xtreak,(seq (into [] (range 10)))
13:31clojurebot(0 1 2 3 4 ...)
13:31justin_smithroelof: your code will be much easier if the (recur) were refactored to be a let block like (if (= counter n) answer (let [counter (inc counter) n n a (get answer (- counter 2)) ...] (recur ...)))
13:31xtreak,(seq (into {} (range 10)))
13:31clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\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.ATransientMap conj "ATransientMap.java" 42]\n [cloju...
13:32roelofjustin_smith: thanks, my first try to make fib numbers works :)
13:32justin_smithxtreak: yes
13:32xtreak:):)
13:32justin_smithxtreak: the into {} fails because {} expects each element to be a two element vector
13:32justin_smith,(seq [1 2 3])
13:33clojurebot(1 2 3)
13:33roelofjustin_smith: oke, so the calculation in the let block and the recur only with the variables you mean
13:33justin_smith,(type (seq [1 2 3]))
13:33clojurebotclojure.lang.PersistentVector$ChunkedSeq
13:33justin_smithroelof: right, instead of having so much logic on one line
13:33justin_smithxtreak: if you are ready for more complex details, there's the fact that vectors create a chunked seq
13:34xtreakThings make much better sense now. What will be the structure of a lazy sequence?
13:34justin_smithxtreak: the only thing that makes lazy sequences, is the function lazy-seq
13:34justin_smithcheck out the doc and examples for that function
13:34roelofcan I then do more then 1 thing after the false, Or schould I make it works with both in a ( ) ?
13:34justin_smithroelof: that's what the let does
13:34roelofoke, learned another thing :)
13:35xtreak,(type (seq #{1 2 3}))
13:35clojurebotclojure.lang.APersistentMap$KeySeq
13:35justin_smith,(if false :ORLY (let [a 0 b 1] (+ a b)) ; roelof
13:35clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:35justin_smitherr
13:35justin_smith,(if false :ORLY (let [a 0 b 1] (+ a b))) ; roelof
13:35clojurebot1
13:36justin_smithxtreak: also I hope you found this link on the sequence page http://clojure.org/lazy
13:36xtreakIs it really a linked list? sets return a different name :(
13:36justin_smithxtreak: it can act like a linked list
13:36justin_smiththe point is that vectors and sets and etc. each return a totally different type, adapted to their source data
13:37justin_smithbut they all use the same interface, the interface our sequence functions all use, so you can ignore the concrete type most of the time
13:37justin_smithbecause it's a sequence, and that's all that matters usually
13:39xtreakSo it doesn't matter to the consumer of the sequence too as they only traverse and perform the actions returning a sequence. Right?
13:39justin_smithright
13:39justin_smiththey are effectively using a linked list - even though none of these are a canonical linked-list type
13:40roelofjustin_smith: it this what you mean ; http://lpaste.net/142298 . It gives a error message on let but it produces the right output
13:41justin_smithroelof: the recur should be outside the binding vector
13:42roelofI saw it later, Did change that
13:42justin_smithalso, I think you want a + there, I was thinking you would do more like (let [counter (inc counter) n n a (get answer (- counter 2)) b (get answer (- counter 1))] (recur counter n (+ a b)))
13:43justin_smithroelof: also, notice that we can now tell n never changes, so it doesn't need to be a loop arg, and you could take it out of both loop and recur
13:43xtreakI looked into the lazy sequence link. Its a little heavy for me. I will go chunk by chunk. Please add other links too that will help me when I get stuck. Thanks a lot for your walkthrough bearing the newbie. Learnt a lot of things justin_smith . Is there any log of clojure channel available ? For my reference.
13:44justin_smithoh yeah, lazybot makes one when it is around, as does clojurebot - one moment
13:44justin_smithxtreak: http://clojure-log.n01se.net/
13:45Draco_I have a hashmap such as {"x" {"user" "stuff"} "user" "z" "y" [{"user" "K"} {"abc" "def"}]}, how do I extract all values of "user" to get a vector such as ["stuff", "z", "K"] ? I've looked at tree-seq, postwalk, but am really stuck.
13:46xtreakSweet :) accidentally closed my irc client and lost all the msgs. Thanks a lot :)
13:47roelofjustin_smith: when I do this : http://lpaste.net/142299 I see the null exception error again
13:49justin_smith,(keep #(get % "user") (tree-seq coll? seq {"x" {"user" "stuff"} "user" "z" "y" [{"user" "K"} {"abc" "def"}]})); Draco_
13:49clojurebot("z" "stuff" "K")
13:49luxbockroelof: you're trying to use `get` on a number, i.e. the sum of a and b
13:50roelofluxbock: so I have to change the arguments
13:50justin_smithroelof: yeah, remember it can't just be (+ a b) it has to be (conj answer (+ a b)) - that was my error
13:50Draco_sweet justin_smith! That really works. I can see how keep is useful in there.
13:50luxbockroelof: also binding something to itself like you do with `n` in the let doesn't really serve any purpose
13:50justin_smithluxbock: yeah, I mentioned that n wasn't really needed as a loop arg either
13:53roelofoke, changed the code to this : http://lpaste.net/142300 but still the same error, I could be easier if I could see what the values of a b and answer were
13:57luxbockroelof: it would help if you also showed how you are calling the function as it's impossible for us to know what `answer` is here
13:57justin_smithluxbock: it's [0 1]
13:57oddcullyyou could print them? wrap your block in a do, println first and keep the old code last in the do
13:57oddcullyor use a debugger
13:58roelofluxbock: I call it this way (fib2 [0 1] 5)
13:58roelofoddcully: does Lighttable has a debugger then ?
13:59justin_smithroelof: it's an off by one because you need to inc counter after calculating a and b
14:00justin_smithroelof: https://www.refheap.com/110257
14:01roelofjustin_smith: that was it. it's not working fine with this code : http://lpaste.net/142301
14:02justin_smithnot working fine?
14:03roelofits working fine. One thing I have to change I think and that is making it work only with n.
14:03justin_smithroelof: oh, you can do that with multiple arities
14:03justin_smithwhich is a cool feature, see if you can figure it out
14:04roelofI did it this way : (loop [counter 2 n n answer [0 1]]
14:04justin_smithoh that's legit too
14:04roelofand change fib2 to this (defn fib2 [n]
14:05justin_smithalso you can take n out of the loop bindings (as it doesn't change)
14:05roelofnext task. Look if I can make it work with map . I think its better then loop recur
14:05bendavisnccan anyone tell me how to disable auto indent in intellij with clojure?
14:05bendavisncmaybe i'm being dumb but i can't find it any where and it's driving me bananas
14:06justin_smithroelof: map would only make sense if you were mapping over some collection though... I don't think that makes sense here
14:06justin_smithroelof: but you could totally do it with iterate / drop-while
14:07roelofoke, in programming clojure is stated you almost never need loop reccur , Most things can be done with just the core things
14:07xtreakFib code with iterate is very elegant
14:08oddcullybendavisnc: ctlr-alt-a, enter indent and hope for the best?
14:08oddcullyroelof: dunno about lighttable. i don't use it
14:09xtreakhttps://en.m.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci
14:10bendavisncoddcully, ugh my alt is tied to my desktop, ubuntu, and still, that's no solution
14:11oddcullymine too, but i swapped it with super_l to i still have the old alt
14:11rhg135roelof: usually reduce can replace loop
14:12justin_smithrhg135: not for a generative thing like fib though
14:12rhg135Usually :-P
14:14roelofoke, thanks, a lot of things to try tomorrow
14:23luxbock,(reduce #(conj % (apply + (subvec % (- (count %) 2) (count %)))) [1 1] (range 10))
14:23clojurebot#error {\n :cause "Wrong number of args (2) passed to: sandbox/eval26/fn--27"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: sandbox/eval26/fn--27"\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" 36]\n [clojure.lang.LongRange reduce "LongRange.java...
14:24luxbock,(reduce (fn [x _] (conj x (apply + (subvec % (- (count x) 2) (count x)))) [1 1] (range 10)))
14:24clojurebot#error {\n :cause "Unable to resolve symbol: % in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: % 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: % in this context"\n ...
14:24luxbockbleh
14:24luxbockwouldn't that count as using reduce to replace loop?
14:29devangshahcan i destructure as well as pass exact params (i.e. without destructuring) to the functions?
14:30roelofjustin_smith: I like the iterate solution here : https://en.m.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci, Tommorow I want to look if I can make it work with a end argument instead of the whole map
14:46zimabluewhat's the recommended way to sandbox code? like allow a user to create a function with specified inputs and outputs and no side effects? I've seen clojail but it looks out of development, it basically gives you a whitelist capability?
14:47gfredericksdevangshah: I'm not sure what your question means, you might try giving an example
14:48justin_smithdevangshah: maybe two arities, one that provides every input as a separate arg, called by another arity that destructures a single input?
15:05trissso how would one find out what platform they're running on in Clojure?
15:05trissi.e. OS X/Windows/Linux
15:07justin_smithtriss: (System/getProperty "os.name")
15:07justin_smith,(System/getProperty "os.name")
15:07trissthanks justin_smith
15:07clojurebot#error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkPropertyAccess nil -1]\n [java.lang.System getProperty ...
15:07justin_smith:P
15:33rhg135what is the algorithmic complexity of clojure.core/sort ?
15:34rhg135O(n)?
15:35justin_smithrhg135: it uses java.util.Arrays/sort
15:35justin_smithrhg135: nlog(n) http://www.programcreek.com/2013/11/arrays-sort-comparator/
15:37justin_smithArrays/sort is quicksort for primitives, mergesort for Object
15:39rhg135I'm dealing with objects
15:40rhg135Is it okay to use a vector then sort it?
15:41rhg135I want a structure similar to a sorted set but with duplicates and I don't require lookup
15:43justin_smithyou could just conj then sort for each addition, that's fast for merge-sort
15:44rhg135I didn't know if it'd perform well. Thanks
15:52rhg135unfortunately, sort returns a seq
15:52rhg135not a vector
15:53rhg135I can deal with this I think, but it is an issue
16:00skeuomorfIs there a builtin function to test if something is an atom or not?
16:00skeuomorfor will I have to use `instance?`?
16:02justin_smithskeuomorf: I think instance? would be the thing, unless you'd prefer to test if it is a thing you can deref, or swap!, which would use satisfies?
16:03skeuomorfjustin_smith: I see
16:15arrdemping
16:21gfredericksjustin_smith: crap I think I made webscale https://github.com/gfredericks/webscale
16:23arrdemgfredericks: it's been done before https://github.com/clojure-grimoire/simpledb
16:24gfredericksarrdem: where were you three hours ago when I was asking about this
16:24arrdemgfredericks: afk same as I've been for about two months now
16:24arrdemish
16:24gfredericksarrdem: wait this isn't persistent?
16:24arrdemwhat isn't persistent
16:24gfrederickssimpledb
16:25gfredericksto disk
16:25gfredericksI mean
16:25arrdemit does persist... at a 2 minute clock tick
16:25gfredericksoh okay good I'm still original
16:26arrdemso simpledb uses one file for the whole damn thing...
16:26arrdemwhat's yours do?
16:26arrdemnote that simpledb is circa 2011 from ibdknox
16:26arrdemI just cleaned it up a bit
16:26gfredericksarrdem: webscale is about storing events on disk, not the current state
16:26gfredericksso it just appends events as they happen
16:27gfredericksand the in-memory state is based on a reduce function over the events
16:27arrdemgfredericks: that's kinda nice
16:27gfredericksarrdem: I've got like three different uses for it and was tired of implementing it over and over
16:28arrdemgfredericks: gotcha nice
16:28arrdemI may have to play with that later
16:29arrdemfake partial datomic implementation number....
16:29gfredericks:)
16:29gfredericksthe use case is basically whenever you say "I want my data to be human-readable and probably stored in a git repo"
16:30gfredericksthe first serious thing I'm going to do with it is to try to replace 4clojure's mongo usage
16:31arrdemhum....
16:31arrdemI don't think this'd be a net memory savings or I'd try to apply it to Grimoire as well
16:31arrdemI'm using simpledb right now to implement some server side analytics
16:31gfredericksdo you spit the whole state to a new file every 2 min?
16:32arrdemsame file but yeah
16:32arrdemwhat are append only logs
16:32arrdemwhy do I need those
16:32gfredericksis that a question?
16:32arrdemI'm being silly
16:32gfredericksI suspected
17:31lxsameerhey folks, I have a websocket server using Immutant, I want to put it under a heavy load and benchmark it, what solution do you suggest ?
17:31arrdemab for the win
17:32arrdemunless you have a number of URLs you want to test in which case you need something else
17:34sameerynhoarrdem: i don't have any url
17:35sameerynhoarrdem: and does ab supports websocket load ?
17:44monstaExcuseme, when I see a funtion that finish with a asterisk what is the meaning? (example: dosomething*)
17:44arrdemmonsta: the -* convention is for helper functions or implemenetations which the author didn't have a better name for.
17:45monstaIs there any online guide to this nameing convention that I can't refer too?
17:46arrdemnot really.
17:46arrdemgfredericks: is there one I don't know of?
17:47gfredericksoh actually
17:48monstaThanks you
17:48arrdemI know that the earmuffs convention is mentioned on clojure.org
17:49gfredericksthis might https://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
17:49arrdemnah only mentions _ and earmuffs
17:50arrdemand -?
17:52arrdem$seen yogthos
17:52arrdemlazybot wya
17:53rhg135he's on an indefinate vacation
17:54arrdemlame
17:54arrdemclearly I need to start running an instance in addition to Grim...
17:54rhg135indeed
17:55arrdemwell that's one way to get the $grim plugin justin_smith helped me build merged after a year of waiting :P
17:57kaphello, new to Clojure, how would I go about working with binary numbers? Do I need to convert them first? 0b1 throws an "Invalid number format" error, but hexes like 0xA works
17:58arrdemyeah so 0b1 doesn't wor, but 2r010 will be 2
17:58kapoh, 'r' for arbitrary radix?
17:58gfredericks,24r24 ;; e.g.
17:58clojurebot52
17:58arrdemI think it only goes up to 36r....
17:58gfredericks,36r1
17:58clojurebot1
17:59gfredericks,37r1
17:59clojurebot#<NumberFormatException java.lang.NumberFormatException: Radix out of range>
17:59kapexcellent, thanks :)
17:59gfredericks,(Long/parseLong "101010" 2)
17:59clojurebot42
17:59gfredericks,(.toString 42 2)
17:59clojurebot#error {\n :cause "No matching method found: toString for class java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching method found: toString for class java.lang.Long"\n :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]}]\n :trace\n [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]\n [clojure.lang.Reflector invokeInstan...
17:59gfredericks,(Long/toString 42 2)
17:59clojurebot"101010"
18:00kapis the recommended form to use 'r' for portability across clojures?
18:00gfredericksrather than what?
18:01kapparsing with java
18:02gfredericksoh well the use cases are different
18:02gfredericksI guess you could use read-string to do runtime stuff more portably
18:14qmmwhat's the reasoning in avoiding static types?
23:12cfleming,(into {} (partition 2 1 [["(" ")"] ["{" "}"] ["[" "]"] ["#{" "}"] ["(" ")"]]))
23:12clojurebot{"(" ")", "{" "}", "[" "]", "#{" "}"}
23:13cflemingSay whut
23:13cflemingHere (Clojure 1.7.0) I get "ClassCastException clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry"
23:14justin_smithcfleming: there's an error message bug
23:14justin_smithcfleming: it will complain about the first thing in the collection, instead of the type of the collection itself
23:15cflemingOk, now I'm confused, actually
23:15justin_smithcfleming: one moment, I will find the case that causes the error message bug
23:16cflemingMy first example should not work, because sure enough partition returns a seq of seqs, not vectors
23:16cflemingBut I have no idea what clojurebot is on about there, how did it get that map from that input?
23:16justin_smith,(into {} '(([a b] c))) ; the error message bug
23:16clojurebot#error {\n :cause "clojure.lang.Symbol cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.Symbol cannot be cast to java.util.Map$Entry"\n :at [clojure.lang.ATransientMap conj "ATransientMap.java" 44]}]\n :trace\n [[clojure.lang.ATransientMap conj "ATransientMap.java" 44]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 17]\n [...
23:16justin_smithoh it's fixed!
23:17justin_smith(locally it complains about persistentvector)
23:17justin_smith,*clojure-version*
23:17clojurebot{:major 1, :minor 8, :incremental 0, :qualifier "alpha3"}
23:17justin_smithCOOL
23:17justin_smith,(into {} '((a b) (c d)))
23:17clojurebot#error {\n :cause "clojure.lang.Symbol cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.Symbol cannot be cast to java.util.Map$Entry"\n :at [clojure.lang.ATransientMap conj "ATransientMap.java" 44]}]\n :trace\n [[clojure.lang.ATransientMap conj "ATransientMap.java" 44]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 17]\n [...
23:17justin_smithOK still not quite right
23:18cflemingOk, so this is actually what I want:
23:18cfleming,(into {} (map vec (partition 2 1 [["(" ")"] ["{" "}"] ["[" "]"] ["#{" "}"] ["(" ")"]])))
23:18clojurebot{["(" ")"] ["{" "}"], ["{" "}"] ["[" "]"], ["[" "]"] ["#{" "}"], ["#{" "}"] ["(" ")"]}
23:18IlieHello, I've developed a simple file named functions.clj that I'm trying to import in riemann.config.clj and I keep getting #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: get-owner-email in this context, compiling:
23:18cflemingNo idea how clojurebot got the result above.
23:18IlieI'm trying to use get-owner-email in riemann.config.clj (the file resides in functions.clj), I've tried to add it using (include "functions'clj") and (load-file "functions.clj") but I still have the same issue, can you please advise?
23:19justin_smithIlie: why not require by the full namespace?
23:19justin_smithif your PWD is in the same dir, it would be (load-file "functions"), but it's better to use require
23:20IlieI've created the files using leingen, the files are at the same level, I tried (require 'seiso') but it still doesn't work
23:20justin_smithIlie: that's not how clojure single quotes work
23:20Ilie#<CompilerException java.io.FileNotFoundException: functions (No such file or directory)
23:20justin_smithif the full ns name was (ns seiso ...), it would be (require 'seiso)
23:21justin_smithbut if the ns has a compound name, you need to provide the rest of the name, regardless of your working directory
23:23Iliehttp://pastebin.com/1aaG0F86
23:23IlieI don't have a ns in riemann.config.clj
23:25IlieI've tried now with (require 'seiso) but I get the same error
23:27justin_smithIlie: so why do you have this clj file at the top level of your project, outside the src/ tree?
23:27namraIlie: and the function.clj resides in the same directory as riemann.conf.clj?
23:28IlieI'm just starting out with clojure, adding it to src/ will allow me to use (require 'seiso) ?
23:28IlieWhat I want is to separate the functionality and to use functions in my riemann config
23:29justin_smithIlie: then why not make a clojure project, and require riemann as a library, rather than adding files to random places in riemann?
23:29namraIlie: how do you executed riemann, because by it'll look for the files within the same directory as riemann.config
23:29Ilielen run -- riemann.config.clj
23:29Ilielein*
23:30justin_smithIlie: and putting it inside src is more likely to work - source files are looked up on the classpath, and src/ will be on the classpath by default
23:31IlieThank you for the suggestions guys, really helpful, I'll try that now
23:31IlieI copied the file to src/seiso.clj and I'm using (require 'seiso) but I get the same error
23:32namramore likely src/riemann/seiso.clj
23:33IlieSame thing, I guess I'll just have to inline everything in riemann.config.clj
23:33justin_smithnamra: that would only work if the ns was riemann.seso
23:34justin_smith*reimann.seiso
23:34namrajustin_smith: oh thanks
23:34justin_smithnamra: the namespace is just a single element top level ns (which is discouraged, but newbies gonna newb)
23:35namrabut i think he might not need to put it into src, because all extra configuration for riemann is read at runtime (startup)
23:36namrathus when doing lein run on passes it the config option and provides the main configuration file. riemann than looks in the same directory as the main config for includes that are specified within it.
23:37justin_smithnamra: oh, I had no idea
23:37namraanything else would mean baking it right into riemann itself
23:37namracause i use it myself, but never from master. only prebuild uberjars
23:43IlieI copied the file in src/riemann and src/ and restarted riemann but I get the same error, not sure what to try next
23:54IlieI moved my folder to src/riemann/<my_folder> and it works now, thank you guys for the help
23:54justin_smithglad you sorted it out...
23:56namraIlie: and in the riemann.config.clj there's only an (include "functions.clj")?
23:56namraor do you use a proper namespace as justin_smith mentioned previously?
23:57Ilienamra, I don't have a namespace in riemann.config.clj (there is no namespace by default)
23:57IlieI tested again but I can't use the function I wrote so I'm just going to inline everything
23:58namrai mean in your functions.clj within src/riemann/<my_folder>