#clojure logs

2015-06-08

02:15chr15mHello! Is it an uncommon thing for people to invoke cljsbuild to build for a static client-side-only web app? For example an app that will run in a Phone's browser with no server component, or an app that lives on a github pages page, or one that talks to some non-clojure backend.
02:15chr15mI can't figure out how to easily get cljsbuild to do this by default. Everything seems to be structured around creating an "uberjar".
02:53TEttingerchr15m, I'm curious about this too
02:53TEttingerI'm sure there's a way, unless cljs specifically needs a server side component for some features, but I don't think it does
02:59oddcullywouldnt `lein cljsbuild once <prod/min/whateveryoupicked>` generate you the stuff to send to your docroot?
03:07chr15moddcully: i am using the reagent template and it doesn't include such a build identifier. it has one called 'app' but that builds in development mode without doing the optimisations or minification. i guess i'll just have to write my own.
03:10oddcullychr15m: copy that one down and change the optimizations to advanced. this at least gives me one blob of a .js file with the figwheel-template that runs fine with a python SimpleHttpServer (i am using rum btw)
03:11chr15moddcully: was just doing that and got the same result, thanks :)
03:11oddcullyand btw there is also #clojurescript
03:11chr15moh! sorry, yes.
03:11chr15mi will check out rum too
03:11oddcullyno problem at all
03:11oddcullyjust to let you know
03:27zotto turn {:a [1 2 3], :b [4 5 6]} -> [:a 1] [:a 2] [:a 3] [:b 4] [:b 5] [:b 6], i have (for [[k vs] m, v vs] [k v]); is there something better? (feels like for loops often should be last resort…)
03:32TEttinger,(mapcat (fn [k vs] mapcat (partial vec k) vs) {:a [1 2 3], :b [4 5 6]})
03:32clojurebot#error {\n :cause "Wrong number of args (1) passed to: sandbox/eval25/fn--26"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: sandbox/eval25/fn--26"\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 [clojure.core$map$fn__4551 invoke "core.clj" 2...
03:32TEttinger,(mapcat (fn [k vs] (mapcat (partial vec k) vs) {:a [1 2 3], :b [4 5 6]})
03:32clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:32TEttingergah
03:32TEttinger,(mapcat (fn [k vs] (mapcat (partial vec k) vs)) {:a [1 2 3], :b [4 5 6]})
03:32clojurebot#error {\n :cause "Wrong number of args (1) passed to: sandbox/eval73/fn--74"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: sandbox/eval73/fn--74"\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 [clojure.core$map$fn__4551 invoke "core.clj" 2...
03:33zotTEttinger: i feel your pain :)
03:33TEttinger,(mapcat (fn [[k vs]] (mapv (partial vector k) vs)) {:a [1 2 3], :b [4 5 6]})
03:33clojurebot([:a 1] [:a 2] [:a 3] [:b 4] [:b 5] ...)
03:36TEttingerzot: ^
03:36zotthanks for the persistence :) as a medium-seasoned clojure user, do you find that more readable than the for version? i suspect that my many years of C-ish languages allows me to read the for loop more readily, so i can't ditch my own bias :)
03:36zoterrr
03:36zoti'm the medium seasoned
03:36zotbad rewording
03:36TEttingerI think m wasn't actually declared in the for loop
03:36TEttingerso it was kinda hard to see what you meant
03:37zotit is, before the comma
03:37zotbut it's just an m, and hard to see
03:37TEttingerbut what is m's value?
03:37zota map, just like the data example i wrote before
03:37TEttingeroh ok
03:38TEttingerthen vs?
03:38zoti guess my idiom: if i have a v, and a sequence of vs, i use vs for the sequence
03:38zotas in, plural of v
03:38TEttingeryeah, I get that, but the thing is, there's a "to turn" but no "(def ..."
03:39TEttingerso I don't know what the values you're using for m and vs are
03:40zotgotcha. should have been (def m <LHS of the expr>). next time i'll gist it :)
03:40TEttingeryah, no prob
03:40TEttingerI still don't actually know what you meant by vs there though
03:41TEttingerit's a second loop, effectively...
03:42zotyep, you get it. double loop iterating over keys, then values to unroll the value sequences.
04:57mercwithamouthdoes anyone here practice writing data structures from scratch over and over? say if studying for a class. repetition?
05:15wasamasaI'm pretty sure one of the reasons of providing a wealth of built-ins and records and easy access to java data types was to not have to do that again :>
05:16mercwithamouthwasamasa: lol i just mean as a method of learning...i'm wondering how well repetition works with becoming a better developer =P
05:17wasamasaI'm sure that's an individual thing
05:20amalloymercwithamouth: doing the same thing over and over is a good way to build muscle in your fingers, but it's hard to believe you really learn a lot by implementing the same data structure in the same language more than twice
05:20amalloythe first time, you're learning how it works. the second time, you're fixing all the mistakes you made the first time and clarifying your thoughts. after that, what are you gaining?
05:20amalloyfind something new to do
05:58mercwithamouthwhat in the hell? (reduce [r x] (+ r (* x x))) [1 2 3])
05:59pepperpotDownload either SEO Analyzer full script, Website Value Calvulator Full Script, or Ajax Star Reviews script, all fully tested and working, download them for your website, you're welcome! https://www.criosphinx.net/forum/forumdisplay.php?fid=20
06:00oddcullyyay! calvulation for everyone
06:00mercwithamouthlol
06:02TEttingermercwithamouth: ? what about (reduce [r x] (+ r (* x x))) [1 2 3])
06:02TEttingeris [r x] your function there?
06:03mercwithamouthTEttinger: i'm trying to figure out...for say the first iteration what gets assigned to r and whats assigned tox
06:03oddcully,(doc reduce)
06:03clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
06:03TEttinger,(reduce (fn [r x] (+ r (* x x))) [1 2 3])
06:03clojurebot14
06:03amalloylooks like he forgot the (fn ...) wrapping around that
06:03TEttingerninja!
06:03amalloyit's just sum-of-squares, implemented somewhat opaquely
06:04amalloyand badly, i guess, because it only works if the first item in the list is either 0 or 1
06:04TEttingerhehe
06:04mercwithamouthhmm also good to know
06:04TEttinger,(reduce (fn [r x] (+ r (* x x))) [3 4 5])
06:04clojurebot44
06:04TEttinger,(reduce (fn [r x] (+ r (* x x))) 1 [3 4 5])
06:04clojurebot51
06:04TEttinger,(reduce (fn [r x] (+ r (* x x))) 0 [3 4 5])
06:04clojurebot50
06:04TEttingerhm that seems to work
06:04amalloyyou want 0 there
06:05mercwithamoutho_O
06:05TEttingerwasn't sure if I wanted additive or multiplicative identity,or to fall asleep
06:05mercwithamouthmy lisp virgin eyes
06:05amalloythey all "work" in that they evaluate to something, but only your last one evaluates to 3^2 + 4^2 + 5^2
06:05mercwithamouthi think i have to write that one on paper and do the steps
06:06TEttingerthe easy way to get the steps:
06:06TEttinger&(reductions (fn [r x] (+ r (* x x))) 0 [3 4 5])
06:06lazybot⇒ (0 9 25 50)
06:06mercwithamouthahhHH
06:06TEttingerbecause 25 == 9 + 16
06:06mercwithamouthi assume that works for all lisp functions? cool
06:07TEttingerreductions is just reduce that keeps intermediate steps in the sequence it returns
06:07mercwithamouthwell wait.. 'reductions' and not 'reduce' still cool so you can see each value returned as it progresses
06:07TEttingerinstead of only returning the last thing
06:07oddcully,(reductions + [1 2 3])
06:07clojurebot(1 3 6)
06:07mercwithamouthnice....
06:08mercwithamouthwell that clears that up. now i see =P
06:08mercwithamouthalright..going to play with reduce for the night...or well morning
06:08ionthas_I have a function that mutates a vector with a given provability. I want to implement a test to know if it's working right. Any ideas in how to test that?
06:08ionthas_(I'm using midje)
06:10kastermaionthas_: Run the operation many many times, see the fraction of times the modification happens is approximately correct.
06:10kastermaIf running on continuous integration (don’t want false positives) fix the random seed.
06:12ionthas_thanks kasterma, good point with the random seed.
06:41crocketAfter learning clojure, I'm afraid to deal with javascript and java again.
06:41crocketI'm afraid that other programmers mutate my javascript objects.
06:42crocketThere is almost no guaranteed invariant that I can depend on in javascript.
06:44katratxocrocket: try https://swannodette.github.io/mori/
06:46spaceplukcrocket: you can also freeze the objects I guess
06:47spaceplukit's slow though
06:58thedavidmeisterhi
06:58thedavidmeisteri'm new to clojure and getting some cryptic errors
06:59thedavidmeisteranyone have a bit of time to help?
06:59oddcullythedavidmeister: put your code and error on refheap.com or some other place so someone can have a look
07:00thedavidmeisteroddcully: kk
07:01thedavidmeisteroddcully: https://www.refheap.com/102286
07:05thedavidmeisteroddcully: any idea what i did wrong?
07:09Kneivathedavidmeister: what "docker ps..." is supposed to return? and is that directly applicable to "docker rm"?
07:13thedavidmeisterKneiva: docker ps returns (fa5e01a1cd46 403d6b4bd8a4)
07:13thedavidmeisterKneiva: when i println - which are hashes of docker containers
07:15thedavidmeisterKneiva: if i do (docker "rm" "-f" "fa5e01a1cd46") that works
07:16crocketkatratxo, That's not going to fix javascript.
07:16crocketspacepluk, That's also not going to fix javascript.
07:16crocketIn a multi-person project, javascript is going to leak.
07:16oddcullythedavidmeister: well i don't know conch. the error would indicate to me, that the result of main should be an number and your docker function there returns an obj. can you try (:exit-code (docker ...)) ?
07:18thedavidmeisterhmm (docker "rm" "-f" '("f772acef31c3" "403d6b4bd8a4")) breaks
07:19Kneivathedavidmeister: was just suggesting to try that =)
07:19thedavidmeisteris conch a normal way to be trying to do shell stuff?
07:19thedavidmeisteror is there a different library i should look at?
07:20thedavidmeisteroddcully: hmm, what is :exit-code supposed to do?
07:21thedavidmeisterKneiva: these docs made it look like i could use a sequence https://github.com/Raynes/conch
07:21thedavidmeisterKneiva:
07:21oddcullyunder the assumption, that you docker call there is the last thing in your code, it's return value would be "the return"
07:21thedavidmeisterKneiva: or did i just mis-read it?
07:21oddcullylooking at the GH page there suggests, that the returned object there holds an :exit-code
07:21oddcullyso (:exit-code (...)) would fetch that out of it
07:22thedavidmeisteroddcully: (println (:exit-code (docker "rm" "-f" '("f772acef31c3" "403d6b4bd8a4") {:throw false})))
07:22thedavidmeisteroddcully: i got nil back
07:23Kneivathedavidmeister: does (docker "rm" "-f" "f772acef31c3" "403d6b4bd8a4") work?
07:24thedavidmeisterKneiva: it did
07:24thedavidmeisterKneiva: so how do i turn a sequence into a bunch of string arguments?
07:25Kneivaapply
07:26oddcully(apply (partial docker "rm" "f") theresult)
07:28Kneiva&&(+ 1 2 [3 4]) &&(apply + 1 2 [3 4])
07:28lazybotjava.lang.RuntimeException: Unable to resolve symbol: & in this context
07:28Kneivano, how was it?
07:29Kneiva,(+ 1 2 [3 4])
07:29clojurebot#error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers add "Numbers.java" 128]}]\n :trace\n [[clojure.lang.Numbers add "Numbers.java" 128]\n [clojure.lang.Numbers add "Numbers.java" 3640]\n [sandbox$eval25 invoke...
07:29oddcullyonly one & or , or ##
07:29Kneiva,(apply + 1 2 [3 4])
07:29clojurebot10
07:31thedavidmeisterkk, give me a sec
07:33thedavidmeisterah cool
07:33thedavidmeister(apply (partial docker "rm" "-f") (docker "ps" "-aq" {:seq true}))
07:33thedavidmeistertotally worked
07:33thedavidmeisterwoo
07:33thedavidmeisterthanks
07:34thedavidmeisterso, is there something better than conch around for doing shell stuff?
07:35oddcully(inc Kneiva)
07:35lazybot⇒ 1
07:37Kneivawohoo \p/
07:39thedavidmeisterah, i g2g
07:39thedavidmeisterthanks for helping
07:39oddcullywell there is clojure.java.shell. but conch looks actually good to me
07:40thedavidmeister(inc Kneiva)
07:40lazybot⇒ 2
07:40oddcullywill definetly have to play around a bit with it
07:40thedavidmeister(inc oddcully)
07:40lazybot⇒ 9
07:58ksauaHi, is there a function that will do the following: (somefunc (1 2 3 4 5)) = ((1 2) (2 3) (3 4) (4 5)) ?
07:59oddcullyksaua: ,(let [p [1 2 3]] (zipmap p (rest p)))
08:01oddcullyoh you want lists. ,(let [p [1 2 3]] (map list p (rest p)))
08:01ksauayeah, sorry
08:01ksauaHi, is there a function that will do the following: (somefunc [1 2 3 4 5]) = [[1 2] [2 3] [3 4] [4 5)] ?
08:01ksaua:)
08:02oddcullys/list/vector/
08:03schmirksaua: partition-all
08:05schmiror rather partition
08:05oddcullyyeah partition
08:06oddcully,(partition 2 1 [1 2 3])
08:06clojurebot((1 2) (2 3))
08:06ksauathanks!
08:18oddcullyshouldn't give me (parition 2) back a transducer in 1.7?
08:19puredangerI think only partition-all
08:20oddcullytrue
09:39bjacan I pass in a DataSource (ala c3p0 connection pool) to clojure.java.jdbc/with-db-transaction?
09:40justin_smithbja: I've had issues with c3p0 and transactions, but it could have been a configuration issue, we never got around to sorting it out
09:42bjac3p0 has been working okay for me in most regards, but I'm trying to use prepared statements for a server-side cursor with postgres
09:42bjaand now I think I'm passing the wrong thing into with-db-transaction
09:43bjaoh
09:43bjathat's nasty. just figured out from reading the source, that add-connection is how you get something with-db-transaction wants to use
09:44justin_smithit's just fundamentally incompatible with pooling?
09:45bjawell, it seems as though you have to check out a connection first
09:46bjapass that into add-connection to create a map that with-db-transaction understands
09:46bjathis seems to work
09:46justin_smithweird!
09:46justin_smiththanks, that should be useful
09:50joegalloi'm just some guy in the peanut gallery, but that doesn't sound quite right to me... we've been happily using c3p0 with c.j.jdbc for quite some time. are you trying to use with-db-transaction outside the context of a with-db-connection or something? because it seems to me that with-db-connection does the add-connection type stuff on your behalf.
09:52joegalloor, of course, it's also possible i don't understand your use case, etc.
09:54justin_smithjoegallo: oh - so your method would be (with-db-connection (with-db-transaction ...))
09:56crocketIs there an alternative to gogs and gitlab written in clojure?
09:56crocketor haskell?
09:56crocketNeither Go nor Ruby is my preference.
09:57ionthas_I'm looking for a fast random number generator for clojure. Anyone knows if there is some SFMT implementation?
09:57sg2002bja: Here's what I used: https://www.refheap.com/102289
09:58justin_smithionthas_: I don't know, but I'd look for the java impl (which I am sure must exist) and use that via interop
09:58crocketIt seems I have bitbucket for private repos.
09:58sg2002bja: As far as I remember you need make-pool? false or with-db would try creating a new pool.
10:18H4nsi knew i've asked this same question a few months ago, but maybe it has changed since then. i find myself spending obscene amounts of time whenever i see conflicts in my :dependencies. we've moved to depending on all libraries explicitly which has made the process a little more manageable, but it is still ours how running "lein deps :tree" and then creating more exclusions and dependencies
10:19H4nsit is so painful. any cure in sight?
10:19H4nswith :pedantic? abort, of course. maybe we should just switch that off and live on the other edge.
10:50kaffeeboehnchenHi. :)
10:51kaffeeboehnchenHow can I make '("abc" "def") to "abcdef"?
10:51stuartsierrakaffeeboehnchen: apply str
10:52kaffeeboehnchenstuartsierra: nice, thanks! :)
10:53stuartsierraYou're welcome.
10:54gfredericksdoes anybody know what it is about cider/clojure-mode that doesn't parse foo' correctly and if it's fixable?
10:55gfredericksmaybe it's not foo'
10:55gfredericksit's something to do with funny-quotes though
10:57gfredericksmaybe it's a syntax highlighting thing
10:57gfrederickscertainly :foo'bar seems to be highlighted wrong
10:58gfredericksthis probably only matters when test.check is generating keywords for you
10:58gfredericks(def foo'bar nil) also highlights wrong
10:58gfrederickspresumably this has nothing to do with cider
11:17clgvhi, which leiningen plugin do you recommend for the "expectations" library?
11:19clgvthere are at least "lein-autoexpect" and "lein-expectations"
11:44Shayanjmhas anyone done distributed computing with clojure here?
11:44Shayanjmtrying to figure out the best way to distribute 950k API requests to a cluster with throughput throttling
11:54justin_smithShayanjm: I don't think I know the answer, but is that 950k a second? a day?
11:55Shayanjmjustin_smith: 950k total. It needs to be throttled to x requests/second for each 'account' used to query
11:55Shayanjmi'm thinking i'll set up each worker machine with a separate API account so we can throttle to just the box
11:55ShayanjmI think it's something like 20 req/sec
11:56Shayanjmthe question is - should I just split up the 950k requests at the top of the funnel (i.e: 950k/# of worker machines), or should I just add each query to a queue and have the machines grab them in round-robin fashion?
11:56ShayanjmThere's overhead in reading/writing to a queue, so it might make sense to batch them, but I don't know if I'm eating considerable overhead somewhere with that approach
12:04justin_smithShayanjm: you don't need round robin - with the right queue they should be able to grab the items (pull) as needed
12:04ShayanjmThat's true. it doesn't necessarily have to be round-robin since order doesn't necessarily matter
12:04Shayanjmthe results will be deduped somewhere anyway
12:05justin_smithright, round robin would be a way to split them up when pushing
12:05justin_smithbut pull can use the processes more efficiently
12:06kaffeeboehnchenwhat is the best way to get the values in the if? https://paste.xinu.at/ljNj/
12:06justin_smithmy naive / straightforward version would be to have a gateway machine that just queues requests and provides them to workers as the workers pull tasks
12:07justin_smithShayanjm: then upgrade to batching as an optimization and see what empirically has the best throughput
12:07Shayanjmfair enough. Thanks justin_smith
12:07justin_smithkaffeeboehnchen: why are you calling the first (get-box ...) result with the second as its arg?
12:08justin_smithI mean that could be valid but it looks weird
12:08justin_smithwas that meant to be a do?
12:09kaffeeboehnchenjustin_smith: well, thats a ) I forgot
12:09kaffeeboehnchenwait, the first (get-box) does not get the second
12:10justin_smithkaffeeboehnchen: that's false
12:10kaffeeboehnchenjustin_smith: sorry, i cant follow you
12:10justin_smiththe parens clearly show that the first (get-box ...) is called as a function, with the result of the second (get-box ...) as an arg
12:11justin_smithperhaps instead of ( (get-box ...) (get-box ...)) you meant (do (get-box ...) (get-box ...))
12:11kaffeeboehnchenah, ok
12:11kaffeeboehnchenthanks! :D
12:11justin_smithor alternatively (if ... (get-box ...) (get-box ...))
12:11winkwhy doesn't this work? (def x (java.util.HashMap<Integer, Integer>.))
12:12justin_smithwink: generics are a lie
12:12justin_smiththey do not exist
12:12winkI know, I tried to test something
12:12oddcullylike the cake
12:12justin_smithwink: you can't test them because they don't exist
12:12winkdamn.
12:12justin_smithI mean sure you can use the java compiler if you want to use them
12:12kaffeeboehnchenjustin_smith: so, i fixed that, how do i get the results now as a return for get-body?
12:12justin_smithwink: but on a bytecode level there is no such thing
12:12winkI ususally skip making a bogus 20line test program in java
12:13justin_smithheh
12:13winkbut in this case I have to :P
12:13justin_smithwink: there is nothing to test though, there is nothing in the compiled output that corresponds to a generic
12:13winkhmm
12:13clojurebotTitim gan éirí ort.
12:13winkit's about Integer, Integer and int, int in this case.
12:14justin_smithkaffeeboehnchen: the result of get-body will be the lazy-seq generated by for, which will be made up of calls to get-box
12:14winkso either there really is not a difference... or it's tedious
12:14winkthanks anyway
12:14justin_smithwink: int cannot be used in a HashMap
12:14winkthat explains a lot :)
12:14winkthanks even more
12:14justin_smithonly Object can be used as a key or val :)
12:14justin_smithso Integer would be auto-substituted if you tried to use an int
12:15winksee, that's what a quick repl line usually creates insight for
12:15justin_smith,(type (ffirst (java.util.HashMap. (int 1) (int 1))))
12:15clojurebotnil
12:15justin_smithhmm
12:16TimMcH4ns: Is your goal just to manage unexpected changes in dependencies?
12:16justin_smith,(type (ffirst (into {} (java.util.HashMap. (int 1) (int 1)))))
12:16clojurebotnil
12:16justin_smithahh!
12:16justin_smith,(type (ffirst (into {} (doto (java.util.HashMap.) (.put (int 1) (int 1)))))))
12:16clojurebotjava.lang.Integer
12:17justin_smithwink: ^ does that help?
12:17winknot more than what you previously wrote, because it was enough ;)
12:17justin_smithahh, OK
12:17winkautoboxing and unboxing still surprises me a little at times, even after all those years
12:17justin_smithit's a little weird
12:18wink8/10 it's smarter than I'd expect. at least
12:22justin_smithkaffeeboehnchen: also, after taking another look at your code I wonder if you know about let?
12:22justin_smithkaffeeboehnchen: because the code could be simpler imho if you used let to bind things like ((nth positions i) :y) or at least (nth positions i)
12:23wasamasakaffeeboehnchen: why are you using str on an side-effectful function?
12:24wasamasaguess it's for debugging what happens
12:28Shayanjmjustin_smith: what're the ramifications of clojure's STM in a distributed environment? At that point it'd make more sense to write to a database rather than keep things in memory on worker nodes, right?
12:28Shayanjmand try to sync/stitch all the data from the workers?
12:30justin_smithShayanjm: yeah, stm is per vm, and doesn't really help across process boundaries
12:31ShayanjmYeah that's what I figured
12:31Shayanjmthere's stuff like avout which offers a distributed STM
12:31Shayanjmbut I'm thinking that'd introduce more overhead than it's really worth in this case
12:32kaffeeboehnchenwasamasa: I am a noob :D
12:32kaffeeboehnchenjustin_smith: I'd be happy to use let in that case if you can show me how. see ^
12:32justin_smithShayanjm: well, having a single box control the queue is a compromise - stm can help manage the queue, and then all the other boxes work in isolation
12:33kaffeeboehnchenwasamasa: Btw, not using str anymore already ;)
12:33justin_smith,(let [a 0 b 1] (+ a b)) ; kaffeeboehnchen
12:33clojurebot1
12:33justin_smith(doc let)
12:33clojurebot"([bindings & body]); binding => binding-form init-expr Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein."
12:33justin_smithkaffeeboehnchen: it's how we do "local variables" (though in our case they can't vary)
12:34kaffeeboehnchenI'll try to change it. thanks :)
12:34ShayanjmCool, thanks justin_smith
12:36kaffeeboehnchenok, one strange thing … with (count (re-matches #"[0-9]" (str (nth hash i))))) I get an integer, but (> 0 (count (re-matches #"[0-9]" (str (nth hash i)))))) is always false for me?
12:36justin_smithkaffeeboehnchen: ##(> 0 9)
12:36lazybot⇒ false
12:36justin_smith,(> 9 0)
12:36clojurebottrue
12:37kaffeeboehnchenm(
12:37justin_smithpolish notation takes a little while to get used to for the comparators (it did for me)
12:37justin_smithkaffeeboehnchen: this might help ##(> 9 2 0 -2)
12:37lazybot⇒ true
12:37justin_smithso think of that version
12:37kaffeeboehnchenthanks!
12:37justin_smith,(< -100 0 100 1000)
12:37clojurebottrue
12:38kaffeeboehnchensorry, I get confused all the time. VB.NET and python in the job, c#, c++ and java at the school. :(
12:38masebwhat’s the diff between clojurebot and lazybot?
12:39ToxicFrogmaseb: one is the real one and the other is its evil twin from an alternate timeline.
12:39ToxicFrogWe can't figure out which, so we just let them both stick around.
12:39maseb!
12:39masebA calculated risk.
12:39justin_smithmaseb: they both do clojure eval, lazybot does karma and is capable of inline eval, clojurebot lets you use def / defn and has factoids
12:40masebjustin_smith: neat, thanks
12:41justin_smithlittle known fact, buddhists tend to intentionally give wrong answers for every right answer they provide in this channel, so that they don't accumulate karma
12:42masebjustin_smith: /rimshot
13:05xemdetiaI like to think they are dating
13:05TimMcaw
13:05H4nsTimMc: my first goal is to make sure that all libraries that are loaded are at the expected version level. then, i want to be able to add new libraries easily, with a reasonable way to keep the dependency list clean.
13:09TimMcH4ns: So your first goal is to make sure that what explicitly appears in :dependencies is accurate?
13:10H4nsTimMc: ideally, i would only put into :dependencies what i want to use, and at the versions that i want to use, yes.
13:11H4nsTimMc: so far, what i have learned is that if libraries a and b both depend on c, but with different versions, i need to explicitly depend on c with the version that i would like for both a and b, which blows up my dependency list and moves me away from that ideal state.
13:11H4ns(and which certainly has the potential for disaster if a or b can't work with the newer version of c that i'm now depending on)
13:20justin_smithH4ns: at this point, you might save effort if you just constructed your classpath by hand and manually downloaded the artifacts...
13:21H4nsjustin_smith: that sounds, erm, with all due respect, awful.
13:21justin_smithH4ns: but probably simpler than what you are describing
13:23H4nsjustin_smith: i wonder, am i alone with this? how do you deal with projects that have more than one or two library dependencies?
13:25justin_smithH4ns: I try to be selective about deps, and avoid ones with big transitive deps lists. But even if my lein deps :tree shows potential conflicts, I don't stress it unless I see errors
13:25justin_smithH4ns: this might be naive, but it also saves me the stress of linearizing everything
13:25jleglerAnd generally, you don't run into many problems unless your project has a huge dependency list.
13:25jleglerIt hasn't bitten me yet thankfully.
13:26sveriHi, any thougths on silk vs bidi vs compojure for routing?
13:26justin_smithjlegler: in my experience the pain point is when something changes its outward facing api - otherwise I can just use the latest
13:26hiredmanwe have a service at work with around 65 dependencies in its project.clj
13:27H4nshiredman: that is about what we have. do you have :pedantic? :abort in your project.clj?
13:27hiredmanno
13:27H4nswell, maybe that is our problem. :D
13:27H4nswe should probably just ignore that we could be in trouble
13:29justin_smithsveri: I don't know silk at all, but to me there is a definite benefit to being able to do reverse routing. I am one of the devs of polaris, which combines reversible routing with declarative edn based route definition (there is a cljx port and I hope to make a cljc version soon)
13:29hiredmanthat list of deps is really stable and some of the clojure libraries are relatively old, for example it is still on slingshot 0.9.0
13:29bjasveri, I suppose that depends on what you want to do. I've yet to need to actually reverse urls or want to compose them in any significant way, and thus compojure has been fine for me
13:30hiredmanso part of the reason it is fine is it never is changed or updated
13:30justin_smithbja: my use case for reverse routing is generating relative links in templates - it decomplects the url (which the customer might want changed for aesthetic reasons) from app logic
13:30H4nshiredman: i fear that approach. it pushes the burden to when you need to do the maintenance.
13:30hiredmanour biggest dependency headaches with it are when we slice part of it out as an independent library dealing with the old deps
13:31hiredmanH4ns: I dunno, does it?
13:31sverijustin_smith: bja I am looking for a routing library to deliver with closp, compojure has worked so long for me, but I like to have routes as data separated from the service
13:31H4nshiredman: sure, because if you then want to change the software so that it uses the latest version of some dependency, you'll get to update all dependencies, more or less.
13:32jjttjjanyone else have the problem where they try to work in another lang after using clojure for a long time and the non-clojure code just seems so ugly it's hard to get into the project
13:32hiredmanH4ns: well, we very rarely do that
13:33sverijustin_smith: using polaris, is there a way to pass down arguments the handler chain? (routes -> route-definitions -> handler)
13:33hiredmanthis is a mature bit of software so we really value stability over bleeding edge
13:34hiredmanI newer service has around 40 deps, mostly the same as the old service, some newer versions of the same libraries, etc
13:34hiredmana
13:35justin_smithsveri: the route definitions are edn (so they could be a static data structure or get pulled from a db or generated by some code), and yeah, there is a facility for parsing parameters out of the route
13:35justin_smithsveri: if I understand your question
13:35H4nshiredman: okay, so from your experience, incompatible pieces of library dependencies do not happen, so :pedantic? :abort is not worth the trouble?
13:35bjajustin_smith: ah. I don't reverse routes ever, since the link to pieces of content comes in form of UUID (content type, content_type_version, and id) and thus is looked up by caller according to how they resolve content types
13:35bjaI don't know that I actually have any apis that are large enough to refer to themselves
13:35bjajust a bunch of tiny ones
13:36hiredmanI think the only dependency there to deal deps that require different versions of transtive deps was for slingshot
13:36justin_smithbja: yeah, this is about generating links on an actual web page in my case
13:36hiredmanH4ns: I guess, we've never used it
13:36H4nshiredman: thanks!
13:36bjayeah. I mean if you're trying to build html links, reversability seems like a must have
13:37hiredmanH4ns: the old project predates :pedantic?, and by the time the new project kicked off we were set in our ways
13:37sverijustin_smith: I think I mean something different, I am currently using the component system so that I can pass a database instance around, this way I can also pass down the db connection to the actual handler. something like that: (defn routes [config] (compojure/routes (GET "/" [] (index-page (:db config))) and then (defin index-page [db]... where index-page is the handler I am talking of
13:38hiredman(to get technical the old project predates lein, as I never tire of pointing out)
13:40hiredmanI suspect had :pedantic? existed when the project was started it would have been turned on, and who can say what the out come of that would have been
13:40justin_smithsveri: oh, yeah, you can float or sink middlewares onto subroutes
13:41justin_smithsveri: the extra args are attached to the request map rather than being a separate explicit arg though
13:42justin_smithsveri: or maybe it would be more clear to say we provide extra data like a db from a component via a middleware on the route, or a parameterized function that returns the handler, constructed at component start
13:43TimMcH4ns: I have the beginnings of a lein plugin that will at least allow you to notice when you've changed a transitive dep unexepectedly.
13:43TimMcThat might help you from the other end.
13:45sverijustin_smith: I see, as always there are several options, putting them into the request map seems like the "easiest" solution. Is there a chance that polaris gets a cljs port any day soon?
13:45justin_smithsveri: cljx exists in a fork by quile, cljc will definitely happen (not sure how soon)
13:45H4nsTimMc: if you want to share that, i'll gladly look at it. it might be that i can build on it.
13:47sverijustin_smith: ok, thank you very much, as usual, very helpful :-)
13:47sveri(inc justin_smith)
13:47lazybot⇒ 261
13:50TimMcH4ns: There's nothing really there yet, but if you want to follow the project: https://github.com/timmc/lein-diff
13:51H4nsTimMc: thanks, watching it now
13:51hiredmanhehe
13:52hiredman:pedantic? :abort causes lein to npe for me when trying to print out exclusions
13:53TimMcH4ns: The first pass will be git-specific and assume that the :depdendencies list is all there is to see, no plugins, etc.
13:53TimMcLater versions will be fancy in whatever direction seems necessary. :-P
15:42m1dnight_is it me, or doesnt the ant simulation actually work?
15:42m1dnight_I mean, after a while, all ants still run around over the entire map
15:47sveri1m1dnight_: I guess they got drunk so late at night?
15:49amalloym1dnight_: are they supposed to do something different?
15:54m1dnight_well, the intent of the ant simulation is that after N minutes/hours they all walk the same path and that would solve the shortest path problem
15:54m1dnight_but from whatI can tell they are yeah, drunk :p
15:56amalloyis that really what the ant simulation is about? i guess i never actually ran it
15:57m1dnight_yep, thats one of the things they use ant simulations for
15:57m1dnight_http://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms
15:58justin_smithm1dnight_: cool - we should make a modified version that includes stilts http://news.nationalgeographic.com/news/2006/06/060629-ants-stilts.html
15:58amalloyyeah, reading through it now i see what it's up to
15:59amalloyi always just sorta assumed it was a demonstration that in clojure you could have a zillion threads working on the same data at once without stepping on each other's data or locking
15:59m1dnight_yeah thats a nice demonstration of it
15:59m1dnight_however, if you take too many ants the transaction reach their limit though :>
15:59m1dnight_transactions*
16:01stuartsierraMaybe there's still randomness in the ants' behavior.
16:02m1dnight_that's my guess. the ant moves randomly unless it reached home or food
16:02m1dnight_my guess is that forward/backward should have a tad more priority
16:03m1dnight_Robert Johnson, an ecologist who studies ants at Arizona State University, considers the finding "cool."
16:03m1dnight_from that article you linked justin_smith :>>
16:03justin_smithhaha
16:03justin_smithI mean yea, it is cool
16:04amalloyi don't think there's any randomness in the ants' behavior aside from the inherent messiness of thread timing
16:04justin_smithm1dnight_: though the part about chopping off leg segments reminded me of a terrible manga
16:05justin_smithbut proof that ants count is awesome
16:05TimMc"count"
16:06justin_smithTimMc: obviously not in the way we learn to count - probably something closer to the kind of counting musicians learn to do
16:06TimMcJust like I count my footsteps like any normal person when walking around in my normal human neighborhood.
16:06justin_smithmore of an instinctive odometer-like thing
16:06justin_smithheh :)
16:06numberMumbleri like how they had to be careful when adding the stilts... meanwhile, they are chopping off other ants' legs
16:06justin_smithTimMc: a common side effect of musical training is to discover you now count all your steps whether you want to or not
16:07m1dnight_how do musicians count then?
16:08m1dnight_http://en.wikipedia.org/wiki/Counting_%28music%29 <-- like that?
16:08justin_smithm1dnight_: it's more of a "feel" - you know how many beats it's been, but you haven't been thinking each number consciously
16:08m1dnight_ah thats cool actually
16:09justin_smithm1dnight_: what you linked to is more about how that "feel" of the count is taught, not the counting that happens normally. But this is all *way* off topic.
16:10m1dnight_Ive just about finished my thesis (actors combined with stm) but my implementation in clojure is.. dirty.
16:10m1dnight_I hope nobody ever reads it :<
16:10m1dnight_I had to hack it together in a few days
16:11justin_smithm1dnight_: do you have an example problem like the ants?
16:12m1dnight_Yeah, im modifying the original ant program to use actors now
16:12m1dnight_or did you mean, a generic problem that can be solved using ants?
16:12justin_smithno, that's what I meant
16:12m1dnight_yeah im modifying it.
16:13m1dnight_But I still dont have transactions across actors, which is what my implementation is all about
16:13m1dnight_in short: messages are "undone" when a transaction aborts
16:13m1dnight_but maybe if I make the food piles actors
16:13TimMcjustin_smith: That's what I was trying to get at -- the ants are probably counting steps the same way we count seconds.
16:14m1dnight_working on it now :)
16:14justin_smithTimMc: ahh, right
16:14TimMcor distance
16:14TimMcNext project: Cut people's legs off at the knees and send them on errands. See if they go the right distance!
16:15justin_smithTimMc: 1/3 cut off at knees, 1/3 wearing stilts, 1/3 "unmodified", all blinded to avoid the interference of visual cues
16:15justin_smithTimMc: this is terrible, like some kind of GoT version of science
16:32csd_Is genclass the only option for exposing Clojure code to Java? Or is there a better alternative?
16:34justin_smithcsd_: well, a java program can use clojure.lang.RT to access vars (which can then be called via .invoke if they are functions...) so it depends on what the person on the java side is willing to do
16:35justin_smithbut RT is definitely the most powerful java->clojure
16:35csd_would that be substantially faster?
16:35justin_smithit's more flexible, less hassle for the clojure side
16:36justin_smithI don't know if there would be much meaningful difference perf wise
16:36csd_justin_smith: I'm really wondering what kind of interface to expose to Java, just thinking from the perspective of writing the CLJ
16:36justin_smithright, but gen-class typically makes things more brittle in my experience
16:36justin_smithso my ideal would be to use c.l.RT from java, and just find and invoke the parts of the clojure stuff I want to invoke
16:37csd_and all the java has to do is import c.l.RT?
16:38justin_smithcsd_: yeah, and then resolve and invoke require to get the ns, and resolve and invoke whatever it wants to call
16:38justin_smithso there's a few steps, but it gets full access to clj
16:38csd_well I imagine the ns would be known in advance
16:39csd_but sounds easy enough
16:39justin_smithcsd_: sure, but is it loaded?
16:39csd_dont follow?
16:39justin_smithcsd_: has the clojure compiler loaded and compiled the ns
16:39justin_smiththat's what require is ensuring
16:39csd_ok
16:40csd_Is there a better discussion of this than http://blog.jayfields.com/2011/12/clojure-java-interop.html ?
16:40Bronsayou should use clojure.java.api.Clojure.var rather than clojure.lang.RT.var
16:40justin_smithBronsa: oh!
16:40justin_smithBronsa: I had no idea, what's the difference?
16:40Bronsaone is public api the other is not :P
16:41justin_smithBronsa: is this a recent thing?
16:41Bronsa1.6 IIRC
16:41csd_ostensibly one is more prone to breaking
16:41kwladykaring and compojure: (def app (wrap-defaults app-routes site-defaults)) - how to add there wrap-params? I want get fields from form. Should i use wrap-params?
16:41TimMcOne is only in new clj and the other is what everyone uses.
16:41justin_smith(inc Bronsa)
16:41lazybot⇒ 112
16:41justin_smiththanks
16:41csd_Is there a better discussion of this than that jayfields blog post I linked above?
16:43justin_smithkwladyka: the simple answer is (def app (wrap-defaults (wrap-params app-routes) site-defaults)), but after a few middlewares I like to convert to (def app (-> app-routes (wrap-params) (wrap-defaults site-defaults))) which is equivalent but easier to change in the future
16:44kwladykammm i tried that and it didnt work
16:44justin_smithkwladyka: the next thing to try is to swap the order (much easier when you use the -> version)
16:44kwladykaanyway should i use wrap-params or something like (POST "/my_post_route" {params :params} ...)
16:44justin_smithsometimes the middleware only work when nested a specific way
16:44kwladykai triend in both way
16:44kwladyka*tried
16:45kwladykamaybe i did some mistake during this.....
16:45justin_smithkwladyka: what you just showed would require wrap-params as a pre-requisite, otherwise params would always be nil
16:45kwladykaoh...
16:45justin_smithremember that just reloading your code won't change the middleware, unless you pass #'app to your server
16:45justin_smithyou may need to restart the http server
16:47kwladykahmm or maybe i have to restart app after that?!
16:47kwladykai am ruining app by lein ring server
16:48kwladykaech still doesnt work
16:48kwladyka(wrap-defaults (wrap-params app-routes) site-defaults) <- this not work
16:49justin_smithdid you try (wrap-params (wrap-defaults app-routes site-defaults)) ?
16:49justin_smiththis is why -> makes this easier, it would be a question of swapping two lines if you do the reasonable thing and have one middleware on each line
16:49kwladyka(wrap-params (wrap-defaults app-routes site-defaults)) <- this doesnt work too...
16:50kwladykai am trying read :params by (ANY "/handler" [] handle-dump)
16:50justin_smithkwladyka: what arey ou doing to provide the params from the client?
16:50kwladykai have form with method POST and acotion /handler, i click submit button.
16:51justin_smithkwladyka: have you tried passing in the whole request, and then exploring what is actually coming in?
16:53kwladykawhat do you exatly mean?
16:53justin_smithkwladyka: I don't recall how it's done in compojure off the top of my head, but instead of providing the :params, you can provide the whole request object
16:54csd_justin_smith: would a project.clj be necessary for Java integration?
16:54justin_smithring takes a request from a client and turns it into a hash map, and that's what all the middleware use/modify, and then the final form is used to derive the data to pass to your handler
16:54kwladykain :params i have only :__anti-forgery-token so it works, but i don't have other fields
16:55justin_smithcsd_: it would help, my plan of action would likely be to create an uberjar that would become a part of whatever java thing, and the project.clj could help with that
16:55justin_smithbut another option would be to use maven directly (or whatever else) to resolve all the clojure deps
16:55csd_I think we'd go the maven route, most likely
16:56justin_smithcsd_: yeah, if you are using maven directly, no need for project.clj, you can just make a pom.xml for your clojure code
16:56kwladykajustin_smith, BTW do you use ring + compoure or something more complex?
16:56justin_smithsince java would be in the driver's seat
16:57justin_smithkwladyka: something less complex, compojure is weird imho :P
16:57csd_ok thx
16:57justin_smithI usually use ring+polaris, but bidi is also good
16:57kwladykajustin_smith, less? only ring?
16:58kwladykai was thinking about bidi to learn that in next step
17:03kwladykaoh no.... no ;( i have misspell in HTML ;(
17:03kwladykano... hours of my time ;(
17:09kwladykathank you as always
17:09kwladykaok its time to sleep, goodnight :)
17:27ghadishayban/msg bronsa (invoke-dynamic* "name"
17:27ghadishayban clojure.lang.Bootstrap/protocol-invoke
17:27ghadishayban method-type ;; [retclass argclasses..]
17:27ghadishayban ... static args)
20:41criosphinxlmfao!!!!!!!!! https://www.youtube.com/watch?v=XR_GkTLg
20:41criosphinxlmfao!!!!!!!!! https://www.youtube.com/watch?v=XR_GkTLg
20:41criosphinxlmfao!!!!!!!!! https://www.youtube.com/watch?v=XR_GkTLg
21:58binjuredwhat's an idiomatic way to do something like `(while (next foo) (:bar foo))' that collects results?
21:58amalloymap
22:00binjureddoes that work for random Java objects that use a `next() bool` method?
22:00weavejesterbinjured: If they implement an iterator, you can use iterator-seq to convert them to a seqence.
22:00weavejesterBut normally it just works with seq-able objects.
22:01weavejesterSo Clojure collections, and some basic Java types.
22:03binjuredweavejester: this object doesn't implement anything, just happens to use the next() idiom
22:03amalloyin fairness, a lot of java types
22:03amalloybinjured: that is a remarkably hostile object. are you sure?
22:04weavejesterYeah, most Java collections as well, tbh
22:04weavejesterbinjured: You can use iterate to convert it to a seq I believe
22:04binjuredamalloy: unless i forgot how to read api docs, which is totally possible: http://download.eclipse.org/jgit/docs/jgit-2.0.0.201206130900-r/apidocs/org/eclipse/jgit/treewalk/TreeWalk.html
22:04amalloyweavejester: only if it actually implements iterator
22:04weavejesteramalloy: No, not iterator-seq, iterate.
22:05weavejester(iterate #(.next %) blah)
22:05weavejesterUnless .next is side-effectful
22:05amalloyweavejester: it is
22:05amalloyand returns bool
22:05weavejesterAh, right
22:05binjuredweavejester: yeah, it is. next() basically just moves an internal pointer and returns true if it wasn't at the end.
22:06amalloythis jgit api is pretty awful
22:06weavejesterThere's another function I believe that deals with side-effectful sequences
22:06amalloyis there? i don't think there's anything smarter than iterate
22:07weavejesterOh, right, repeatedly. Duh me.
22:07amalloyi think the only thing you can do while still being correct is loop/recur, or a custom recursive function returning lazy-seq if you're returning a sequence
22:07binjuredall i've thought of is use loop/recur and transient to save some effort.
22:07weavejesterOh, except that still wouldn't work.
22:07weavejesterOkay, clearly my brain is too tired to think.
22:08amalloyweavejester: i mean, (repeatedly #(doto % .next) thingy) will generally work in practice
22:08amalloybut it's not guaranteed to work
22:08weavejesterYeah, I realised that when I said it :)
22:09binjuredamalloy: i'd prefer it were lazy, but i'm not clear on how to do that with the loop.
22:09amalloybinjured: are you returning something lazy?
22:09sdegutisJust use ->>
22:09amalloythat is, is your return type amenable to laziness (is it a seq)
22:10binjuredamalloy: my return type is whatever i want it to be, so yea ;) ... using loop/recur and conj it would just be a vector.
22:10amalloyokay. so you instead want (defn make-foos [thingy] (lazy-seq (when (.next thingy) (cons (.getwhatever thingy) (make-foos thingy)))))
22:11weavejester(defn f [x] (lazy-seq (cons (bar x) (f (doto x .next))))
22:11sdegutisJust use a lazy seq.
22:11weavejesteramalloy's version is better :)
22:11weavejesterI think it's time for me to go to sleep.
22:11amalloymostly because it actually stops when thingy runs out of nexts
22:11binjuredhaha
22:11binjuredthat is a plus...
22:12binjuredthanks, amalloy.
22:12sdegutisClojure is so funn!!!!
22:12sdegutisLet's get excited!
22:13binjuredis doall clojure's progn?
22:14binjuredoh, maybe it's just `do`
22:14amalloybinjured: it doesn't really exist in CL, because CL doesn't have lazy seqs
22:14amalloydoall doesn't, rather. do is progn
22:27binjuredamalloy: `(tree-paths (new-tree-walk repo (first (rev-list repo))))' much nicer than the jgit api ;)