#clojure logs

2016-01-23

00:10tcrawleyjustin_smith: stapler: the public key was only used to verify artifacts so you could promote them to the releases repo, which wasn't really used by anyone, so it was removed this week.
00:11tcrawleysee https://github.com/clojars/clojars-web/issues/415 for details
00:11tcrawleywhere does it reference it in the lein docs?
00:13justin_smithtcrawley: when I said "documentation bug" I didn't know the feature was intentionally removed
00:13justin_smiththat resolves my questions at least
00:22staplertcrawley: interesting. has lein been updated to acommodate?
00:23stapleraccommodate*
00:28tcrawleystapler: lein doesn't require your key to be on clojars - all that needs to change on the lein side is the documentation in https://github.com/technomancy/leiningen/blob/stable/doc/GPG.md#clojars
00:28tcrawleythat entire section is now moot. I'll get that updated
00:29staplerIt still wants me to put a key in.
00:29tcrawleywhere does it want you to do that?
00:29staplerSee `lein help gpg` for how to set up gpg.
00:29staplerIf you don't expect people to need to verify the authorship of your jar, you
00:29staplercan add `:sign-releases false` to the relevant `:deploy-repositories` entry.
00:29staplerwindows by the way
00:30tcrawleythat's all on the client side - it wants to be able to sign the artifacts before deployment, and doesn't involve the server at all
00:30staplerright
00:30stapleri guess my point is that perhaps the client should be updated to uh
00:30staplernot require it
00:31tcrawleyso you either need to not sign the releases, or figure out how to set up gpg on windows
00:31stapleri would do it if i was experienced enough to not break everything
00:31tcrawleyyeah, I have no idea how to do it on win
00:32stapleri mean fix up lein
00:32staplernow about :sign-releases false
00:32staplerthis doesnt go in my project.clj does it?
00:32tcrawleyupdating lein to not require signatures is unrelated to the clojars change, but the value of signing can be debated
00:32justin_smithit's a per-project setting, but you can put it in profiles.clj to apply it generally
00:33stapleri was under the impression that it didnt take symbols
00:33staplerand then i tried it and didnt work
00:33staplermaybe i should try it again :o
00:33tcrawleyit's really only useful if there is tooling that verifies sigs against your web of trust
00:35justin_smithtcrawley: I can see the value of being able to check whether any two jars were signed by the same key - eg. can we check if the jar I am getting now is signed by the same key as the last version
00:35justin_smithwhich only helps so much, but it is something
00:35tcrawleytrue, but there is no automated way to do that currently, it's a manual step
00:35justin_smithright, still not an implemented thing
00:36tcrawleyI still sign all my releases in the hope that someday we'll get this figured out :)
00:36justin_smiththat's the spirit
00:37justin_smithtcrawley: when I get discouraged by security I remind myself of the times I gave up on an api because I found just one more weird thing I had to figure out.
00:37tcrawleyI hear ya
00:37justin_smithpoint being, just turning away most of the hackers is better than nothing
00:37justin_smithheh
00:51princesoI just parsed the --help of an app. Then i thought "what if we start making a --help-robot of our apps", some csv would be fine. :D
01:19devnfeels good when you find some clever code that turns out to be 3x slower than the equivalent simple thing
01:20devna lesson i've learned over and over again: don't get cute with your threads unless you can show it's faster when you write it
01:20justin_smith,((:clever :clever :clever) :clever ((:clever :clever :clever) (:clever :clever :clever) (:clever :clever :clever)))
01:20clojurebot:clever
01:22justin_smithdevn: measurement is king
01:22devnim actually a little bit surprised and not surprised at all
01:22devnin this particular case
01:23devn13 postgres tables, highly variable in size, a function which takes each table, and inserts datascript datoms for each table
01:24devneach table was a future, deref'd in a doseq
01:25devndifference of about 3.2min to 1.3min
01:26justin_smithdevn: what kind of db would you use for a collection that has millions of entries, each carrying an association by id to median 100 others
01:27justin_smithwhere you would expect simultaneously heavy read and write loads
01:27justin_smiththe data is actually small, there is very little there except the relations between items, each carrying an id that is correlated to an api
01:28justin_smithI mean the data in each entry is small
01:29devnwhen you say heavy read/write loads, what are you talking about?
01:29devnare you trying to do real-time?
01:29justin_smiththousands a second
01:29justin_smithso not so heavy
01:29justin_smithdevn: I want my heavy graph analysis to return in under 10 minutes, ideally
01:30justin_smith(for each user, ~100 concurrent users during higher load times)
01:31justin_smithdevn: current issue ends up being everything is really snappy until writes reach a threshold and then suddenly everything takes forever. This is with mongo.
01:31devnhm, kind of sad to admit it, but not really my area of expertise
01:31devnin light of the last thing we discussed, i would encourage you to measure it :D
01:31justin_smithOK, just a shot in the dark, I wonder what forum would be general enough for a question like that :)
01:32justin_smithdevn: yeah, it would be quite a thing to even make a test case that does that justice, but it's probably worth it for what I'd learn trying...
01:32devnI mean, simulating 100 concurrent users ain't no thang
01:33justin_smithdevn: one "task" is 4 to 30 minutes worth of api calls and number crunching
01:33justin_smitha lot of things to simulate....
01:33devnjustin_smith: could you get away with modeling just best/worst/average
01:33justin_smithdevn: I can't just simulate one part of it in isolate, each part performs great in isolation for our current db, it's when they all run and hit the same db that the exponential failure happens
01:33justin_smithhmm
01:34devni mean, another thing you could do is record the traffic and play it back
01:34justin_smithso I actually need to understand and/or accurately model usage patterns I guess
01:34justin_smithoh yeah, isolate db traffic...
01:34devncraig andera has a good talk IMO
01:34devnon performance testing
01:35devnhttps://www.youtube.com/watch?v=2XDg-C5y0Bc
01:35justin_smithlooking it up
01:35justin_smithoh, cool
01:35devnthough i'm probably biased because I've had a couple opportunities to work with him
01:35justin_smithtopic is exactly what I want, but I will watch it when not stoned, thanks
01:36devnhaha
01:36justin_smithit's so sad that I waited until it was legal, haha
01:37devn《〠_〠》
01:39devnjustin_smith: This is now officially OT, but I am actually heading to Paris->Amsterdam next month. First timer. Going out there to see Avishai Cohen play 3 shows in Paris at the Paris Philharmoic, then to Le Havre to see his trio play.
01:39justin_smithnice!
01:39devnPhilharmonic*
01:40justin_smithI went out to see the Jerusalem Quartet play Beethoven and Bartok last night
01:41devnInterested to see what Amsterdam holds. I've had good experiences with the dutch so far, expecting good things.
01:41devnThat sounds pretty rad. I had to admit I haven't listened to much Beethoven or Bartok
01:41justin_smithmaybe you can meet up with borkdude, some of hte other dutch clojurists
01:41devnWhole 'lotta Bach
01:42devnI was talking to Philipp Meier, trying to get him to join me. He invited me to stop over to S. Germany, but it's already going to be kind of a packed trip.
01:43devnThat said, I'm going alone. My fiance was not totally sold on seeing 4 days of Avishai Cohen shows, even if they are all different projects. :D
01:43devnA little torn because I'd kind of like someone to hang with here and there, but frankly, I'm looking forward to not being fluent and generally going quiet for a little bit.
01:43justin_smithhaha, that's how I got my ticket yesterday, friend had tickets to a full 4 concert series and his girlfriend could do 3 :)
01:44devnas evidenced by me hacking at ~12:30AM on a Friday night
01:45devn(I should note here that there is absolutely 0 expectation that I would do this. I'd probably go a bit further and say it's *dis*couraged.)
01:45devnbut when you get on a roll...
01:45justin_smithhell yeah, ride it as far as it can take you
01:46devni am pretty sure im at my end. feeling pretty satisfied about the performance bump
01:46justin_smithsomething that was huge for us was taking all our uses of futures and wrapping them in usage of claypoole
01:46devnjustin_smith: do you happen to remember (i could swear someone made one of these at one point) a github project that would analyze your clojure namespaces and build a call graph
01:46clojurebotNo entiendo
01:46justin_smithdevn: oh man I want to say that's ztellman...
01:47staplerdevn: where you at
01:47devni tried out claypoole a couple years ago, along with pulsar/quasar, annddd i think one more?
01:47justin_smithdevn: I hacked something to do that but it was super super hacky
01:47staplerjust curious
01:47devnstapler: WI
01:47staplersince you also seem to be in CST
01:47staplerdevn: ah, IL reporting in c:
01:47justin_smithdevn: https://github.com/actsasgeek/lein-gossip
01:47devnjustin_smith: meh, i think sed + awk might be enough
01:47staplersoutheastern WI?
01:48devnstapler: thereabouts
01:48staplermm
01:48justin_smithdevn: link above isn't my "super hacky" one btw, it's an actual good one from the looks of it
01:48staplerleaving out of ORD?
01:48devnstapler: nah, I fly out of MSN
01:48devncloser to home
01:49devnguarantees me another hop, but there's nothing worse than finding yourself in rush hour traffic after 12 hours of travel
01:49staplerah
01:50staplerdevn: if you do stop over at ORD, frontera grill is really good
01:50staplerintl terminal
01:50stapleralbondigas torta
01:50devnyeah, hit there last time. not cheap! but definitely some of the better airport food i've had
01:50devnMinneapolis has some pretty good airport food
01:50stapleroof, minneapolis was a bit rough honestly
01:50devnI went to a wine bar that had pretty good charcuterie
01:51stapleroh no. was it the one with the wine bottles for a chandlier
01:51staplerchandelier*
01:51devndon't know that one
01:51staplerso that and it made me shudder. just terrible.
01:51staplersaw*
01:51staplerjeez..
01:51devnthe one thing minneapolis has going for it generally, is that it's actually clean
01:51staplerif youre ever back
01:51staplertravail is really good and pretty affordable for what it is
01:52devnin MSP? or ORD?
01:52staplerminneapolis
01:52staplerits in a suburb
01:52devnnice. will have to check it out
01:52justin_smithlast time I flew through ohare I spent my layover taking an el ride to la pasadita on milwaukee to get a burrito for old time's sake
01:52staplerit's pretty insane
01:52devnthis is making me hungry
01:53staplermsp has good food
01:53staplerif youre ever hanging around chicago hit me up c:
01:53staplergot lots of restaurant recommendations too
01:53devnyeah, im in MSN. we have a few really standout places
01:54devna lot of stuff that i'd call "good" but nothing to write home about
01:54stapleris there kopps in msn
01:54devnnot that i know of, but i kind of stick to the downtown area
01:54staplernope, thats milwaukee
01:54staplershame
01:54staplerbest custard ive had
01:55devnl'etoile in madison is not cheap, but it's certainly _up there_
01:55justin_smithportland has amazing variety of unique food options almost to the point it is tiresome and I just have to get something boring eventually
01:56devnjames beard award winning chef. a friend of mine who just got back from france with his girlfriend said he went out of his way to go to some michelin star restaurants and said they didn't compare
01:56devnlast time i was in portland i ate at a FANTASTIC place, trying to find it now
01:56justin_smithyeah, "FANTASTIC" doesn't narrow it down much lol
01:57devnI think this was it: http://www.clydecommon.com/
01:58stapler1am and everything is closed
01:58justin_smithnice, that's about 6 blocks from my office, at most
01:58staplerexcept white palace grill i guess
01:58devnman, i start reading yelp reviews, and i... dont get it.
01:59staplerhttp://www.honeybutter.com/ this is absolutely fabulous
01:59staplergourmet chicken is also really good and a few blocks away
01:59devnso much evidence of people who unconsciously convey in their reviews that they are very sure about their place at the center of the universe
03:32shempity that the butter chicken place probably won't deliver to Oulu, Finland...
04:52montanstercatconsider this: have you ever seen hypah and trump in the same room?/
04:52montanstercatmt
04:52montanstercatsorry
05:43oracle123if I have many vector, and want to put them into a set, but want the equality based on the first element of the vector, is that doable?
05:44oracle12`e.g I have [1 2], [1,3],[2,3], and put them into a set, want to get back #{[1,3],[2,3]} which will treat [1 2] as duplication as [1 3]
05:47luxbockoracle12`: what should (#{[1 2]} [1 3]) return?
05:50oracle12`I need it to return [1 2]
05:50oracle123is it doable?
05:51luxbockI think you'd need to make your own set type backed up by regular sets
05:52luxbockor you could just make your own versions of the set API functions which might be easier
05:52luxbockfor what do you need this for?
05:55oracle12`I am pulling data from a web site. There is an id for each product, I used vector to store the id info, and a set of the product to check whether it's already pulled or not, but some info of the product could change and I don't want to pull again even it changed.
05:55oracle123so the id should be uniquely identify the product, but other attribute could be different.
05:56oracle12`Maybe I shold model it as a hash.
05:59luxbockcouldn't you just create a set of the ids like (into #{} (map first) data) and use that to do the same thing?
06:01oracle12`yes, it works. thanks very much
06:03luxbock:)
08:11tomphphi, can anyone help me with a stupid problem? - I'm trying to use figwheel and I've added :figwheel {:ring-handler myproject.core/handler} to my project.clj and I'm getting java.lang.ClassNotFoundException: myproject.core
08:11tomphpmyproject.core is definitely right as it's used in :main - I'm sure sure it's just something silly but I can't work it out
08:14tomphpscrap that - paren in the wrong place (what else could it be). 20mins of head scratching, ask here, solve it straight away - typical ;-)
08:24justin_smith,(sorted-set-by #(compare (first %) (first %2)) [1 2 3] [1 2] [2 3 4] [2 4]) ; oracle123 is gone, but this is a possible answer
08:24clojurebot#{[1 2 3] [2 3 4]}
09:13gfredericks,(let [[a :as [b :as [c :as [d]]]] (range)] [a b c d])
09:13clojurebot[0 0 0 0]
09:13gfredericks#protip
09:37spuzgfredericks, what exactly is going on there?
09:38gfredericksspuz: the purpose of :as is to let you give a name to the whole value being destructured
09:38gfredericksbut you can also use it to destructure the same value again
09:38gfredericksso I just destructured the same value four times
09:39spuzgfredericks, isn't there a nicer way to do that?
09:39spuzlike (let [[a:b:c:d] (range)] [a b c d]) ?
09:40gfredericksyou mean
09:40gfredericks,(let [[a b c d] (range)] [a b c d])
09:40gfredericksor something different?
09:40clojurebot[0 1 2 3]
09:40spuzthat's what I meant yeah
09:40gfrederickswell that code clearly does something different
09:40spuz(am new to clojure today)
09:40gfredericksand my code isn't meant to be nice, it's meant to be ridiculous
09:41spuzheh
09:42spuzgfredericks, right i get it
09:42spuzI think yours is equivalent to
09:42spuz,(let [[a] (range)] [a, a, a, a])
09:42clojurebot[0 0 0 0]
09:42spuzwoot
09:42spuzparsing skills ++
09:45gfredericksyep
09:52spuzwhat is the difference between :while and :when in the (for) function?
09:52justin_smithspuz: while takes everything until condition is not met
09:53justin_smithwhen selects only items for which that condition is met
09:53spuzthanks
09:53spuzbut why is that not documented here? https://clojuredocs.org/clojure.core/for
09:59kwladykaspuz mmm i see it is
09:59kwladykaSupported modifiers are: :let [binding-form expr ...],
09:59kwladyka :while test, :when test.
10:00kwladykaand their are examples bellow
10:00spuzkwladyka, i mean, why is the difference between when and while not given in the official doc string of the fuction
10:01kwladykaspuz beacuse it is quite obviously if you know better Clojure. There is function when and while - look at them.
10:01spuzkwladyka, ok thanks
10:02kwladykathere is also "let" function
10:03kwladykaand also when you see when-let function you can expect is work similar to let function and when function
10:06kwladykaspuz i can also share with you this 2 link "must to read" https://gist.github.com/john2x/e1dca953548bfdfb9844 https://github.com/bbatsov/clojure-style-guide
10:07spuzkwladyka, great thanks
12:59spuzI'm struggling with Cursive's structural editing. How do I wrap a selection in parens?
13:05benjyz1hello. I'm trying to seq'ing over a map like this https://www.refheap.com/113981
13:05benjyz1,(def clients (atom {}))
13:05clojurebot#'sandbox/clients
13:06benjyz1,(swap! clients conj "abc")
13:06clojurebot#error {\n :cause "java.lang.Character cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to java.util.Map$Entry"\n :at [clojure.lang.APersistentMap cons "APersistentMap.java" 42]}]\n :trace\n [[clojure.lang.APersistentMap cons "APersistentMap.java" 42]\n [clojure.lang.RT conj "RT.java" 652]\n [clojure.core$conj...
13:06benjyz1,(swap! clients conj {:name "abc"})
13:06clojurebot{:name "abc"}
13:06benjyz1,(doseq [a @clients] (println a))
13:06clojurebot[:name abc]\n
13:07ridcully_this error message looks rather unrelated to the code?
13:08ridcully_could it be from something else? tooling maybe?
13:08benjyz1I think I misused swap
13:08benjyz1,(swap! clients conj client)
13:08clojurebot#error {\n :cause "Unable to resolve symbol: client in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: client in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: client in t...
13:08ridcully_,(def clients (atom {}))
13:08clojurebot#'sandbox/clients
13:09ridcully_this is another error. the error you got the first time, is the "correct" one
13:09ridcully_clojurebot forgets all it knows every n minutes
13:52pilneso... a big part of optimizing clojure for numeric stuff is using let to force the use of primatives? that's smeggin sweet and easy (:
13:57Kamuelapilne: can you explain that to a Clojure noob? What about let causes the use of primitives?
13:58pilnepart 1 would be that it saves the runtime a lot of time, clojure being dynamic, but the jvm being static, means that without explicitly "let"ting the variable as a double, it has to figure out that it is using doubles (taking more time).
13:59pilneand primatives vs objects is a stack/heap memory location optimization
14:00pilnein java, double is the primative, and Double is an object wrapper around that primative so 'everything (can be) is an object'
14:00pilnejust like in java, it will be faster to explicitly use the primative, same goes with clojure (:
14:01pilnesorry if that was a craptastic explanation, i'm about 6 months back into a "programming renaisannce" after being mostly a python hack for silly shit on my computer (and a wow-addiction) for most of my life after college.
14:06KamuelaNo that makes sense I think you're just making me realize I missed the part of let that has you using explicit types
14:07pilnehttps://clojurefun.wordpress.com/2012/08/06/clojure-performance-tip-exploiting-primitive-casts-20/
14:09KamuelaInteresting. I haven't encountered casts yet
14:10pilnei google too much at work since i can't code much >.< so i end up with all sorts of reading that is way above my head, but i like that generally there *is* a good answer to even the most nit-picky "complaints" i've found about clojure (:
14:11pilneand the community is awesome and very motivated to make clojure awesome (:
14:11pilnenow if only i can get comfy with emacs...
14:12benjyz1has anyone done work in Clojure and P2P systems?
14:20qsysif I have a vector of maps (each only 1 key-value) [{:a "val1"} {:b "val2"} {:c "val3"} {:a 7}] and I want to merge/reduce the maps 'into' {:a ("val1" 7) :b "val2" :c "val3"}... obviously, into doesn't work (duplicate :a key)...
14:20qsys,(def v [{:a "v1"} {:b "v2"} {:a 7}])
14:20clojurebot#'sandbox/v
14:20qsys(require '[core.match :refer [match]])
14:20qsys,(require '[core.match :refer [match]])
14:21clojurebot#error {\n :cause "Could not locate core/match__init.class or core/match.clj on classpath."\n :via\n [{:type java.io.FileNotFoundException\n :message "Could not locate core/match__init.class or core/match.clj on classpath."\n :at [clojure.lang.RT load "RT.java" 456]}]\n :trace\n [[clojure.lang.RT load "RT.java" 456]\n [clojure.lang.RT load "RT.java" 419]\n [clojure.core$load$fn__5677 invoke ...
14:21qsys:p
14:22qsys,(->> v (map first) (reduce (fn [m [k v]] (update-in m [k] #(cons v %))) {})))
14:22clojurebot{:a (7 "v1"), :b ("v2")}
14:25pilnehmmm
14:26qsys,(apply merge-with #(match %1 [& _] (conj (keyword %1) %2) :else [(keyword %1) %2] v)
14:26clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:26qsys,(apply merge-with #(match %1 [& _] (conj (keyword %1) %2) :else [(keyword %1) %2]) v)
14:26clojurebot#error {\n :cause "Unable to resolve symbol: match in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: match in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: match in this...
14:27qsysah, damn'd, match... whatever, got it
14:28spuz,(= "foo" (map (fn [x] x) "foo"))
14:28clojurebotfalse
14:28spuzwhy does that not return true ^
14:30qsys,(map (fn [x] x) foo)
14:30clojurebot#error {\n :cause "Unable to resolve symbol: foo in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: foo in this conte...
14:30qsys,(map (fn [x] x) "foo")
14:30clojurebot(\f \o \o)
14:31qsys(= "foo" (\f \o \o))
14:31qsys,(= "foo" (\f \o \o))
14:31clojurebot#error {\n :cause "java.lang.Character cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval76 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval76 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval76 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.j...
14:31qsys,(= "foo" '(\f \o \o))
14:31clojurebotfalse
14:31qsysthat's why :)
14:31qsysa string is a collection of 'characters'
14:33qsysmap on a string takes one character at a time...
14:33spuzqsys, if a string is a list of characters then why does "foo" not equal '(\f \o \o)?
14:34amalloyit's not really
14:34kwladykapilne this performance is because of reflections
14:34amalloyit's just something you can treat as a list of characters
14:34qsysit's not really a 'list' of chars... I suppose? :p
14:35spuzso it's a collection, not a list?
14:35kwladykapilne if you are interesting in this topic you can read more about that here http://clojure.wladyka.eu/#avoid_reflections
14:36qsysa string is certainly not a list of chars
14:38qsysI'm rather sure it's a seq, though... (which is not a list, but can be threated as one, if I'm not mistaken)
14:39spuzqsys, ok thanks
14:39spuzwhat is the best way to map over a string character by character?
14:39qsysoh, damn'd, still looking for the right answer :p
14:40qsyswell, use 'map', that's character by character?
14:40spuzthe best I've found so far is (apply str '(\f \o \o))
14:41pilnety kwladyka
14:41qsys,(map #(str "done: " %) "ab")
14:41clojurebot("done: a" "done: b")
14:42qsystakes a first, than b
14:43kwladyka,(seq "foo")
14:43clojurebot(\f \o \o)
14:43qsysfrom: https://www.safaribooksonline.com/library/view/clojure-cookbook/9781449366384/ch01.html:
14:43qsys Because Clojure strings are sequences under the covers, you may substitute a string anywhere a collection is expected. When you do so, the string will be interpreted as a collection of characters.
14:44spuz"More often than not, after you’ve done some work on the characters within a string, you’ll want to transform that collection back into a string. Use apply with str on a collection of characters to collapse them into a string"
14:44spuzok that answers my question
14:44spuzthanks qsys !
14:45kwladykabut the point in Clojure is what you want to do with the data. In most cases you want use map, because you have some intention to do with this data.
14:45qsysmy pleasure :)
14:48TimMcqsys: This is wrong: "Clojure strings are sequences under the covers"
14:49TimMcRather, a Clojure string is a Java String, nothing more, nothing less.
14:49qsysalright... it's just from the book :p
14:49TimMcWell, the book is wrong. :-)
14:49qsysI'm fine with that, but can we treat a string as a 'sequence of chars'?
14:50TimMcYou can make a seq that is backed by a string.
14:50TimMcclojure.core/seq special-cases strings so that they can participate in the sequence abstraction.
14:51kwladykaI think TimMc has right from technical point of view and book saying how you can think about string in Clojure to use it :)
14:51TimMcHmm... you can *use* a string as a collection of chars, but it isn't backed by a seq.
14:52qsysI'm interested in both... so next time, I can give a more accurate answer... yeah
14:52kwladykaSo it should be "Clojure strings are Java Strings under the cover of sequences" :P
14:52qsys,(seq? "ab")
14:52clojurebotfalse
14:52qsys,(sequential? "ab")
14:52TimMckwladyka: Heh, sure. :-)
14:52clojurebotfalse
14:52TimMcThis is also wrong: "Clojure strings are backed by Java’s UTF-16 strings."
14:52TimMcjust s/backed by // and it's right
14:53qsys,(coll? "ab")
14:53clojurebotfalse
14:53TimMcSo... grain of salt with that section, and maybe that book.
14:53qsysit's all false :) - so well, they're not seq, sequential or collections
14:53qsysbut when used with 'map', they are treated as seqs, or something... funny :)
14:53TimMcmap calls seq, and seq special-cases strings
14:53kwladykaqsys technically ther are Java string, but you can use them as sequences
14:54qsysI'd say I'm confused, but I feel more 'enlightend' :)
14:55qsys*enlightened
14:56kwladykaClojure is intelligent and react for data types
14:56TimMcNo, you can't use a string as a sequence.
14:57TimMc,(class "foo")
14:57clojurebotjava.lang.String
14:57TimMc,(class (seq "foo"))
14:57clojurebotclojure.lang.StringSeq
14:57kwladykatechnically yes, but if you use it in for example "map" it will work the same as (seq "foo") even if you write only "foo"
14:58TimMcOne of those is a string, the other is a sequence.
14:58TimMcYou can create a seq *of* a string.
14:58TimMcI'm not just being pedantic here, there are times when the distinction between a collection and a sequence over the collection becomes relevant.
14:59TimMcHowever, most core functions that deal with sequences call seq on their argument so that you can pretend there's no distinction.
15:00qsysso, where is the string 'foo' turned into a (seq "foo") when we do (map #(println %) "foo")
15:00qsysah, in the source of map, of course :)...
15:01TimMcyes https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L2616
15:01qsys,(source map)
15:01clojurebotSource not found\n
15:02qsysthere it is the first time: (when-let [s (seq coll)]
15:02qsyseven more enlightened, a bit more and I'm Buddha :)
15:02TimMcheh
15:12TimMcqsys: You may find this useful: https://www.brainonfire.net/files/seqs-and-colls/main.html
15:13qsysyeah, it's on my list to 'read it again, and again, and again', so I'd never forget. And I always do :p.
15:38kwladykais any shortcut to create test file in Intellij for Clojure? I am doing this creating file manually, but maybe is it faster way?
15:39pilnenot sure, and at my last glance, the only clojure plugin for intellij isn't free, 30 day trial, yes, but free no >.< lein, atom, and a terminal window suffice me enough as of now.
15:41kwladykapilne intellij + cursive is really good. I recommend it :)
15:41kwladykaand learn use emacs only to back to use intellij much better :)
15:41pilnei will keep that in mind, because for java, intellij is my favorite option.
15:42pilnebut i've actually been a vim guy most of my life >.< lol
15:43kwladykaworld is subjective :)
15:44kwladykavim and emacs is so cool when you have to work in terminal, but if you don't have too... windows are very comfortable and have the same power if you use shortcuts - it is my personal opinion
15:44pilnetrue, i try to remain editor neutra/minimal but when I work with java i feel like a basic editor doesn't make it "as easy as it should be" lol.
15:45kwladykai feel much better using intellij as emacs instead of using emacs :)
15:45pilneyeah, i use a lot of shortcuts regardless of the environment i'm in, blows my coworker's minds that i barely touch the mouse sometimes lol (i don't work in a tech-y job)
15:46pilneand my only thoughts on windows, mac, linux, etc, is "i like the jvm because i can target them all (relatively) easily" lmao
15:47pilnei'm a linux (ok, ubuntu guy who likes arch, just not good enough for it lol) guy, gf is a windows 7 gal (who knows her days are numbered in terms of official support), her family is macs, my family is mostly apple... best part is, everyone is satisfied with where they are LMAO.
15:51kwladykai was fun in order: windows, linux, windows again, now mac - long story and a lot of experience to change my mind :)
15:52pilne(: same here
15:52engblomThis is super fast in repl (about 0.5 ms): (map write-value pins values) write-value got a side-effect. When wrapping it with (seq ...) for the time goes up to 1.5ms. How should I get the same fast result as without any wrapping, but still make sure it will run even if the returned value is never used?
15:53engblom(doseq ...) is taking 4-5 ms seconds for the same task
15:53justin_smithengblom: if you don't need a return value, use run!
15:53justin_smithit is like the two arg version of map but is not lazy and returns nil
15:54justin_smith,(doc "run!")
15:54clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.Symbol"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.Symbol"\n :at [clojure.core$ns_resolve invokeStatic "core.clj" 4239]}]\n :trace\n [[clojure.core$ns_resolve invokeStatic "core.clj" 4239]\n [clojure.core$ns_resolve invokeStatic "core.clj" 4229]\n [clojure.core$re...
15:54justin_smith,(doc run!)
15:54clojurebot"([proc coll]); Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil"
15:55engblomIn this case I have two collections and one function
15:56justin_smithengblom: so you are calling (map f c1 c2) ?
15:56engblomjustin_smith: Yes
15:57engblomAnd f got side-effect
15:57engblomI would prefer the function to return the result also, but most of the time the result will be discarded
15:57justin_smithright, and run! only takes a single collection arg, and doseq forces you to create collections and call apply
15:57engblomIs mapv also lazy as map?
15:58engblomAh, I tried mapv, it is really slow
15:58lumano, vectors aren't lazy
15:58engblom4.5ms
15:59spuzkwladyka, can i ask you some questions about cursive?
15:59kwladykaspuz just ask :)
15:59spuzare you using structural editing mode?
15:59kwladykaspuz yes
15:59justin_smithengblom: I would go with (doall (map f c1 c2))
15:59qsysspuz yes
16:00spuzhow do you wrap a selection with parens?
16:00qsysspuz vim mode
16:00engblomjustin_smith: doall takes 1.5ms compared with 0.5ms for REPL to do both side effect and returning the new vector.
16:00kwladykaon the beginning it was irritating, but if you learn shortcuts it is extremely powerful and you wouldn't use anything else :)
16:00engblomWhat is REPL using for forcing the evaluation of the sequence)
16:00justin_smithspuz: create parens to the left of the thing with "(", then slurp the righthand element (control-shift-rightarrow here)
16:01pilneis that on a fresh non-cached jvm?
16:01engblomjustin_smith: Sorry, 3ms doall takes..
16:01kwladykaspuz go to intellij shortcuts edition preferences -> keymap -> clojure keybinding
16:02justin_smithengblom: the repl only forces the result via the printing side effect, but that won't show in the output of "time" because it happens after the function returns
16:02kwladykaspuz you can choose the ready map there and apply to shortcuts and set your own
16:02justin_smithengblom: so your "time" is not really measuring how long map takes, because map is lazy
16:02spuzjustin_smith, ctrl-shift-rightarrow just changes the selection, it doesn't change the structure
16:02justin_smithengblom: doall is showing you how long map really takes
16:03justin_smithspuz: clearly you have different bindings
16:03kwladykaspuz *you can choose the ready map of shortcuts there and apply or set your own shorcuts
16:03spuzkwladyka, what do you mean by 'choose the ready map'?
16:03pilneyou need to find the "slurp" clojure/vim mode binding and see what that is on to add parens the way justin_smith suggested
16:03kwladykaspuz you have there "binding set" list, choose one and you will see
16:04justin_smith,(time (map #(Thread/sleep %) [1000 2000 3000]))
16:04justin_smithengblom: see the above
16:04clojurebot"Elapsed time: 0.109709 msecs"\n(nil nil nil)
16:04justin_smithengblom: it says "elapsed 0.10... ms"
16:04TEttingerdo you have access to Thread?
16:05justin_smithengblom: we both know that's bullshit :)
16:05engblomjustin_smith: Thanks! That explains
16:05kwladykaspuz i am using bindings for mac with my little changes, but it is your preference and it depend on your system
16:05engblomjustin_smith: Then the fastest option in my tests so far seem to be (seq ...)
16:05justin_smithTEttinger: it didn't complain about Thread/sleep...
16:05TEttingerI had some lag
16:05justin_smithengblom: doall and seq should be the same
16:05justin_smithTEttinger: ahh, OK :)
16:06engblomjustin_smith: (seq ...) seem to be faster than (doall ...) for me.
16:06justin_smiththat's weird!
16:06kwladykaspuz you definitely need set "slurp forwards" and "barf forwards"
16:07pilneahhh lisps, the only place it is ok to talk about slurping and barfing in mixed company >.<
16:07kwladykaspuz also look on cursive doc how to use cursive. They are great gifs explain everything.
16:07spuzthe docs are not great
16:07justin_smithengblom: seq and doall are really close in my repl, but the real way to know a microbenchmark like this is to use criterium
16:07staplerdo clojurians lean towards tabs or spaces?
16:08justin_smithspaces
16:08justin_smithspuz: https://cursive-ide.com/userguide/paredit.html
16:08kwladykastapler https://github.com/bbatsov/clojure-style-guide
16:09spuzmaybe it is because I'm using the intellij plugin and not the standalone ide but the menus are not the same as described by the docs
16:09kwladykaspuz yes docs are great :) just you have to connect description with intellij shortcuts. In shortcuts you have searcher so it is easy.
16:09spuzFor example, I can't find this setting: Settings→Editor→Smart Keys→Surround selection on typing quote or brace
16:11spuzalso the gifs don't show when a keyboard-shortcut is pressed
16:11kwladykaspuz open preferences, you have search textbox there
16:11kwladykajust write there smart keys
16:11spuzas far as I know the user just whispered a magic command and something magic happened
16:12kwladykaspuz don't worry, you will fast understand it. You can try emacs course and after that you will know how to use intellij
16:12spuzkwladyka, ah thanks
16:13spuzkwladyka, i've used intellij for a long time
16:13ridcully_spuz: ctrl-shift-a for search in the options/actions
16:13kwladykaspuz me too, but learn how to use emacs bring me to new level :)
16:13kwladykaof using intellij
16:13spuzare they not completely different?
16:14kwladykaspuz just if you start use intellij as emacs... it is very powerful.
16:14kwladykaYou wouldn't touch the mouse and you will edit everything easier and simpler
16:14spuzwhat features do they share?
16:15kwladykaspuz just try, you will see it very fast. But of course it is my own experience.
16:16pilnehttp://www.braveclojure.com/basic-emacs/
16:16pilnehas a good "quick and dirty" setup /runthrough for clojure and emacs
16:18kwladykapilne why "pilne" ? :) In my language it means something is very important and you have to do it fast :)
16:18pilnejust some random combinations of math stuff lol pi and ln_sub_e
16:19pilnei don't do much fast... other than type, i'm a cranky old man (:
16:40elvis4526Let's say I have a lazy list of 10000 hash structured like this {:id 1}, {:id 2}, {:id 3} ... until {:id 10000}
16:41elvis4526if I do (filter #(= (:id %) 10000) list-of-hashes)
16:42elvis4526it will still have to go through all the hashes right ?
16:42justin_smithelvis4526: right
16:43elvis4526k
16:44elvis4526how is the same thing possible with an infinite sequence returned by (range) then ?
16:45elvis4526If filter would have to go through all the hashes, it would never terminate
16:47elvis4526,(first (filter #(= % 10) (range 10 0 0)))
16:47clojurebot10
16:48ridcully_,(first (filter #{10000} (range)))
16:48clojurebot10000
16:49elvis4526ridcully_: is this a new syntax for filter ?
16:49elvis4526I thought #{} were reserved for sets
16:49lumathat is a set
16:49ridcully_sets are functions too
16:49ridcully_e.g. like keywords
16:49luma#{10000} is a set that has one element, 10000
16:50elvis4526sweet I didn't know about this - thanks
16:52justin_smithelvis4526: filter won't return if it never finds the item, but it can stop when it finds the item
16:52justin_smith,(filter #(= % Double/NaN) (range))
16:53clojureboteval service is offline
17:49domokatoIs anyone here using neko? I discovered a bug you might want to know about https://github.com/clojure-android/neko/issues/59
18:09engblomWhy Clojure almost double as slow as BASH in this example: http://pastebin.com/GQyrmSZq ?
18:09engblomBoth measure only the time taken to write to files
18:09justin_smithhow are you starting the clojure process?
18:10engblomjustin_smith: I made uberjar, and run it by java -jar ...
18:10engblomjustin_smith: I do not measure the time for starting it up, only the actual time it is doing something
18:11justin_smithinteresting, yeah
18:11justin_smithI wonder what extra thing clojure is doing there that bash doesn't
18:11justin_smithengblom: this is probably irrelevant, but bash is sending newlines and clojure is not
18:12justin_smithit would be equivalent if you used echo -n or if you added a newline to what you spit
18:12engblomjustin_smith: I could test with newline...
18:12justin_smithanother difference is that in bash, the thing after > is always a file
18:13justin_smithwith spit, it has to figure out what to do with the first arg (could be a file, could be an outputstream, etc.)
18:13justin_smithcould be a file object, or a name of a file to open
18:15engblomEven with newline, BASH is winning big. Bash does take 3.26s while Clojure takes 5.9s
18:16justin_smithengblom: try doing (let [pin (java.io.File. "/sys/class/gpio18/value")] (time (dotimes [_ 10000] (spit pin "1\n") (spit pin "0\n"))))
18:16justin_smithhmm... maybe spit closes the output though
18:18justin_smithno, it doesn't, so that should work
18:21engblomjustin_smith: It reduced the time to 4.6s, but still not as good as Bash
18:22engblomI wonder what I could do to get it faster. I would need to get it faster to get stepper motors to work well
18:22justin_smithhmm
18:23justin_smithI bet using .write on an OutputStream that comes from opening the file would be much faster than spit
18:26engblomjustin_smith: spit seem to already use .write
18:26engblom,(source spit)
18:27clojurebotSource not found\n
18:27justin_smithso it would be like (let [pin (clojure.java.io/output-stream (java.io.File. "..."))] (doseq ... (.write pin (.getBytes "0\n")) (.flush pin))))
18:27justin_smithengblom: but it's creating a new writer each time, the above can reuse an output stream
18:29engblomjustin_smith: But the bash equivalent does not keep an file open...
18:29engblomjustin_smith: I will try the code and see what happens.
18:29justin_smithengblom: OK, why does that matter? clojure probably can't do things as simply as bash.
18:36engblomjustin_smith: Thanks, the last thing really made it fast. Now it takes 0.2s
18:36justin_smithkickass!
18:36engblomIt beats bash by far
18:36justin_smithengblom: it makes sense, if you keep using the same file, why not just keep outputting and not re-opening over and over
18:37engblomBut it will also force me to make quite big changes to my library if I will need to have those output-streams open all the time...
18:37justin_smithengblom: you could use core.async and do channel sends
18:37justin_smithand (and then have that outputstream open in a go block where you get those etc.)
18:38engblomIs it possible to have both an output- and an input-stream at the same time to one single file=
18:38engblom?
18:38justin_smithor even just a future with a loop, reading o na queue
18:38justin_smithengblom: should be possible, yeah
18:39pilnei wonder if the BEAM VM would lend itself better or worse to clojure...
18:41staplerclojure is pretty dope
18:41justin_smithengblom: another option actually, if you are just doing an app and not a reusable lib, is to just have a top level def for the outputstream, then a function that writes to it
18:41staplerstarted working on stuff yesterday
18:42pilnewelcome to the powerful addiction that is a well-done lisp (:
18:55engblomjustin_smith: If you look at https://github.com/engblom/gpio/blob/master/src/gpio/core.clj , do you have any advice for how I should keep track of the output streams? Should I have a ref containing a map between pin number and the stream? I would like both the input and the ouput stream to be created upon running (open-pin ...)
18:57justin_smithengblom: how about a hash-map from number to input stream, and another from number to output-stream
18:57justin_smitheach can be either in a def, or an atom inside a def
18:59justin_smithengblom: also, seq will force some of a result, but not the whole thing
18:59justin_smithengblom: (do (seq (map println (range 100))) nil) - only prints 0-31 then stops
19:00justin_smithdoall is the correct function
19:02engblomjustin_smith: I had forgotten to push the latest changes. I actually have doall there. It should be updated at github now
19:02justin_smithalso (into [] (map ...)) is (mapv ...)
19:46engblomjustin_smith: Should an input- or an output-stream get closed in some special way, or is it enough that there is no reference anymore to it?
19:46justin_smithengblom: you can calle .close on it
19:46justin_smithbut if there are no references, the finalizer will... eventually close it
19:46justin_smithbut if you know you are done with it, you can totally use .close
19:47engblomjustin_smith: Ok, thanks!
19:52KamuelaWhat's a large diffeeeence between Clojure and its script counterpart?
19:53WickedShellKamuela, runtime enviorment really. Clojure is meant for the JVM (there are other ports but JVM is the main target) clojurescript generates JS to be run on a browser or other JS interpreter
19:53LuytKamuela: ClojureScript gets compiled into JavaScript; Clojure compiles into JVM bytecode.
19:56KamuelaIn terms of like the limitations of each, I mean. I'm guessing library support obviously changes but is the core identical?
20:04rhg135mostly, a few things differ.
20:04rhg135the format function not existing was rather surprising
20:17engblomjustin_smith: Are you still around?
20:18justin_smithyes, what's up?
20:20engblomjustin_smith: All worked well in my benchmark, but now when I got the streams stored in a map, I end up in trouble. Please have a look at this simple function: http://pastebin.com/Cn0mpusf
20:20pilnehrm, i think i've found a personal project for my downtime at work.... converting this object-oriented code for a simulator of the mechanical workings of the "enigma machine" (i.e. it has the wheels as objects, with all sorts of state and such...)
20:21justin_smithengblom: seems OK...
20:21engblomjustin_smith: Still, running that function does not change the value...
20:23engblomjustin_smith: Sorry that I distrurbed you with this... It was my own fault. I had not been setting the direction of the pin. I should probably go to sleep. It is 03:23 am here
20:24justin_smithwell, at least you figured it out
20:24engblomI would just want to do the same for the read function now. What is the "inverse" of (.getBytes) ?
20:25justin_smith,(String. (.getBytes "OK"))
20:25clojurebot"OK"
20:25engblomThanks!
20:26justin_smith,(apply str (.getBytes "OK")) ; gotcha!
20:26clojurebot"7975"
20:29engblomIllegalArgumentException No matching ctor found for class java.lang.String clojure.lang.Reflector.invokeConstructor (Reflector.java:183)
20:30pilnehmmmm, i think all i need to do, is represent the "state" of the enigma machine as the only "mutable", then pass that data structure, and the input key to a function, in order to both generate a new machine state, and the output!
20:30engblomI am trying (String. (.read (get @input-streams pin)))
20:31justin_smithengblom: and is .read returning a byte-array? I thought it returned the number of bytes read
20:31clojurebotOk.
20:31justin_smithengblom: .read with only the stream as arg just returns a byte
20:31justin_smithhttps://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html
20:32justin_smithyou probably want to use the version that takes a byte-array as argument
20:34pilneis there a way to check a vector for a given element and return its index?
20:34justin_smithpilne: .indexOf
20:34pilnebeautiful
20:34justin_smith,(.indexOf [:a :b :c] :b)
20:34clojurebot1
20:35pilnenice... that makes the fact there is a reflector on the enigma machine even easier to deal with (: (: (:
20:36pilneit's amazing how much doing this the functional way has already refactored the pseudocode.... >.<
20:39justin_smithpilne: I think the reasoning of needing to use indexOf and not providing a clojure function is that scanning linearly for a matching item is often a sign that you could reorganize your data for better performance
20:39justin_smithpilne: not to say you need to change anything, I don't know what you are doing well enough to say that
20:40pilneit's just a toy project, trying to use code to not only emulate the output of the enigma machine, but to also "resemble" how it functions mechanically with the code itself.
20:40pilnehttps://en.wikipedia.org/wiki/Enigma_machine
21:01kenrestivodomokato: try #clojure-android or file it on github?
21:08staplerits good to avoid "do," yes?
21:23justin_smithstapler: do is implicit inside let and defn
21:23justin_smitherr, fn, which is what defn wraps
21:23staplerjustin_smith: oh, huh
21:23staplerinteresting!
21:24justin_smith,(let [] (print 'a) (print 'b) (print 'c))
21:24clojurebotabc
21:24justin_smithinvisible do
21:24staplerlots of uh invisible things in clojure
21:25justin_smithehh, less than most languages
21:25justin_smithalso there is an implicit do inside dotimes and doseq, but not inside for
21:29engblomJava surely makes simple things difficult. I have been now spending a long time trying to used buffered-input for reading a file and failing. It only reads once, and even though I use (.reset) it does not want to read it a second time.
21:31engblomThis is the function I am trying to get to work: http://pastebin.com/B74yid0e
21:31engblomWith (.reset ...) it does not read even once correctly
21:32engblomWithout (.reset ...) it only once read the correct value
21:33justin_smithengblom: are you sure reading a device file works that way? maybe it needs you to reopen the device each time (eg. just use slurp?)
21:36engblom(.markSupported (get @gpio.core/input-streams 18)) gives True
21:41aduengblom: Java is wierd like that
23:40yuunghey everyone, clojure noob here: could someone tell me why they think line 2 from https://gist.github.com/johnmarinelli/a8f3be10a7f994bfb532 isn't getting run?
23:40yuungwhenever i take out the recur part of get-wikimedia-pages (line 20), it works fine
23:42tolstoyyuung: My guess is that on line 10, you're using "map" to iterate, but map is lazy and nothing's causing it to resolve.
23:43yuung@tolstoy that was one of my suspicions
23:43tolstoyyuung: Try wrapping that map in (doall (map .... pages)) and see if that fixes it.
23:43yuung@tolstoy any recommendatioins how to fix this?
23:43yuungwill try and report back, thanks!
23:43justin_smithyuung: you can use run! instead of map in clojure 1.8
23:44tolstoyIf you don't need the results from the mapping, try (run! #(insert-page-into-db %) pages) as an alternative.
23:44justin_smithit is designed for cases like yours where you are not generating a collection, but actually doing a series of calls
23:44yuungtolstoy looks like it worked! now my question is, why was it being lazy?
23:44yuungtolstoy, justin_smith, will do
23:44justin_smithyuung: map is always lazy
23:44yuungjustin_smith so if i had returned a value from it then operated on that value, map would have ran
23:44justin_smithyuung: map is for generating values, and it doesn't actually generate them (sometimes) until you access the value
23:45yuungjustin_smith i see i see
23:45justin_smithyuung: if you accessed the first value that map returned, the first function call would have run
23:45tolstoyYeah, that's a language-design choice.
23:45justin_smithif you read all of them, they all would have run
23:46justin_smithyuung: an easy way to think of it is that a map, filter, concat, for, etc. is a no-op unless something consumes the values they return
23:46justin_smiththere are other tricky things like chunking so they might realize more items than you access