#clojure logs

2017-06-29

00:12random_numbershttps://github.com/enragedginger/tensorflow-clj Any opinion on this wrapper?
00:23TEttingerrandom_numbers: if it hasn't hit Hacker News yet, get ready
00:24random_numbersOh?
00:24TEttingerjust guessing baseed on machine learning, immutable functional programming, and hacker news
00:27random_numbersFair point.
01:19kenrestivoi think it's been around a while
01:20kenrestivosays alpha api tho
04:52HanonimYop
07:05dysfunhi
07:18RovanionHello
07:37BigSafariTrying to convert a string to ISO-8859-1 and use it as body in an email im sending using Postal. Any hint to how to convert from standard Clj string to ISO-8859-1?
07:39dysfun(.encode (Charset/forName "ISO-8859-1") my-string)
07:44BigSafariThanks!
07:45dysfunthat's java.nio.charset.Charset btw
07:47BigSafariYes, found it :-)
07:51BigSafariencode seems to return a java.nio.HeapByteBuffer but i need it as a string to be able to send it with Postal. But is that even possible?
07:53dysfunoh, then postal must handle the encoding
07:53dysfunjava strings are strings of logical characters
07:53BigSafariyes, will look further into Postal for a solution.
08:25Hanonimhere is a silly request : is there something akin to a plotting clj lib for the terminal ?
08:30xemdetiaascii art?
08:30Hanonimprobably
08:38osfabibisisadly looks like JavE never quite got open-sourced http://www.jave.de/developer/index.html
08:40Hanonimtoo bad, looks cool
08:44dysfuni expect if you email, you might get a copy
08:45osfabibisiyeah, very likely. Markus seemed like a nice guy when I used to hassle him about JavE bugs and features ;-)
08:45dysfunrisk you might get asked to maintain it though ;)
08:52osfabibisihehe yeah
08:52osfabibisievery now and then I think I might want to write an ascii art toolkit
08:53osfabibisiI've got a couple of Perl modules that do bits and bobs including https://metacpan.org/release/Text-JavE to read JavE output ;-)
09:05fu86hi
09:05dysfunhello
09:05fu86I have a map with the structure {"a" "b" "c" "d"} and I want to make it like this: {:a "b" :c "d"}
09:06fu86Is there a clever way to do this besides map/keyword/interleave/ ...
09:06dysfun,(into {} (map (juxt keyword identity)) {"a" "b" "c" "d"})
09:06clojurebot{nil ["c" "d"]}
09:07dysfunhrm
09:07justin_smith,(into {} (map (fn [[k v]] [(keyword k) v])) {"a" "b" "c" "d"})
09:07clojurebot{:a "b", :c "d"}
09:07dysfunyes, that was my first version and then i rewrote it
09:07dysfunbut it still hasn't clicked why it didn't work
09:07fu86:) looks good
09:08dysfunwhat's my bug justin_smith ?
09:08justin_smithdysfun: juxt uses the same arg twice, you want to use the first and second elements in the arg separately
09:08dysfunoh yeah
09:08dysfunthanks
09:09justin_smith(partial map #(% %2) [keyword identity])
09:09dysfunyeah, but then it's not convenient heh
09:09justin_smith,(into {} (partial map #(% %2) [keyword identity]) {"a" "b" "c" "d"})
09:09clojurebot#error {\n :cause "clojure.lang.LazySeq cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.LazySeq cannot be cast to clojure.lang.IFn"\n :at [clojure.core.protocols$iter_reduce invokeStatic "protocols.clj" 49]}]\n :trace\n [[clojure.core.protocols$iter_reduce invokeStatic "protocols.clj" 49]\n [clojure.core.protocols$fn__9124 invokeStati...
09:09justin_smitherr
09:09ridcully_(transform [MAP-KEYS] keyword {"a" "b"}) ; specter
09:09justin_smith,(into {} (map (partial map #(% %2) [keyword identity])) {"a" "b" "c" "d"})
09:09clojurebot#error {\n :cause "clojure.lang.Keyword cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.Keyword cannot be cast to java.util.Map$Entry"\n :at [clojure.lang.ATransientMap conj "ATransientMap.java" 44]}]\n :trace\n [[clojure.lang.ATransientMap conj "ATransientMap.java" 44]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 17]\n ...
09:10dysfunyeah, just use specter
09:10justin_smith,(into {} (map (partial mapv #(% %2) [keyword identity])) {"a" "b" "c" "d"}) ; sorry about the false starts
09:10clojurebot{:a "b", :c "d"}
09:12fu86didn't know specter. Is this a thing everybody uses? (like jquery for webdev?)
09:13ridcully_,{(keyword "a :b") "c"} ; also be aware of the keyword-all-the-things pitfalls
09:13clojurebot{:a :b "c"}
09:13ridcully_my impression from the lack of questions here is, that it's not widely used
09:14ridcully_on the other hand it has some solid amount of GH stars for a clj lib
09:14ridcully_so maybe all are just happy and dont have any questions about it
09:14fu86:)
14:55michaelroseI'm wondering why by default the popup buffer that is generated by say cider grimiore isn't syntax highlighted. its not really hard to make it run clojure-mode on creation and bind q to quit but it seems rather obvious
14:58michaelroseoh actually maybe the sections labeled ```clojure are supposed to be highlighted
15:01random_numbersFound a bug?
15:07michaelroserandom_numbers, its not highlighted didn't think it was by default is it supposed to be?
15:09random_numbersI've yet to install/setup grimoire so I don't know.
15:09michaelroseits part of cider
15:10random_numbersPart of the core?
15:10random_numbersI really should read the manual...
15:11michaelrosewanna run cider-grimoire and see if its highlighted?
15:15random_numbersHm... I seem to not be able to resolve anything. Guess my config's borken.
15:16random_numbersalright, now that works.
15:17random_numbersThat rightly should be highlighted and isn't.
15:17michaelrosemy mode is fundamenta
15:18michaelrosefundamental
15:18random_numbersMe too.
15:18michaelrosebut the ```cider ``` sections are syntax highlighted?
15:19random_numbersNope.
15:19michaelroseah that is what I meant
15:20random_numbersMhm, it should be highlighting but doesn't. Thing is that'd depend on a markdown mode which would require highlight info for clojure.
15:20random_numbersI remember having issues compiling a couple manuals locally because debian-stable didn't distribute the version with those additions.
16:24xemdetiamake sure you check messages
17:17technomancythis codebase has a lot of uses of -> where they make sure that the first argument is just a straight variable
17:18technomancywhereas I almost always make my first function call in the first position of ->
17:20TimMcI've seen idiomatic cases of both.
17:20TimMc(def idiomatic? tim-approves?)
17:21technomancyI just need to keep resisting the urge to "clean it up" to my style
17:22TimMctechnomancy: Some people prefer to buy paint and then paint their bikeshed, whereas others prefer to paint their bikeshed with paint they've bought.
17:22technomancyI am also seeing a predicate function which instead of returning a boolean, throws an exception to indicate false-ness
17:23TimMcuh-oh
17:23TimMc~guards
17:23clojurebotSEIZE HIM!
17:23osfameron!
17:24random_numberstechnomancy: Now that's not idiomatic.
17:24dysfunit's arguably not a predicate
17:24technomancythe docstring even says that's how it's supposed to work
17:24jeayeIt only ever returns true. :)
17:24technomancybut I have to fix real bugs first
17:27TimMcIs Acme, by any chance, a collection of silly stuff?
17:27dysfunit is, how did you guess?
17:28dysfunother acme modules include Acme::Octarine (which does evil evil evil stuff to modify a colours module to add Octarine)
17:29dysfunhttps://metacpan.org/pod/Acme::EyeDrops and Acme::EyeDrops is perhaps infamous
17:30technomancyoh dear
17:34random_numbersheh
20:44osfameroncan you generate repeatable random numbers?
20:44osfamerone.g. with a seed?
20:45justin_smithyes, via java.util.Random or gfredericks's library that wraps it
20:45justin_smithhttps://github.com/gfredericks/four
20:47osfameronta
20:48justin_smithif you look at thecode using interop - it's probably easier to just use the java stuff instead of his lib, unless you want the stateless thing https://github.com/gfredericks/four/blob/master/src/four/stateful.clj
20:52osfameronyeah, that looks very much like Haskell's API for random
20:53justin_smiththat's no coincidence
22:46TEttingerosfameron: in Java 8 and higher, SplittableRandom is good (much better than java.util.Random in many ways)
22:47TEttingerhigher period, a large amount of different number streams can be produced from one seed (usually one per thread), better quality AND speed
22:47TEttingerit's also in java.utl IIRC
23:02TEttingerosfameron: the core of SplittableRandom is pretty shockingly simple. it's pretty much this function, if you call it with a parameter that is incremented by an odd number.
23:02TEttingerpublic static long splitMix64(long z) { z = (z ^ (z >>> 30)) * 0xBF58476D1CE4E5B9L; z = (z ^ (z >>> 27)) * 0x94D049BB133111EBL; return z ^ (z >>> 31); }
23:02kenrestivoSpitballRandom
23:03TEttingerso calling splitMix64(state += 1337) would work if you did that every time on one thread, and splitMix64(state += 421) on another thread
23:03TEttingerthis is of course not as convenient in clojure since it needs mutation
23:03TEttingeralso a ton of bit twiddling
23:04TEttingeralso those longs are both negative
23:04TEttinger,0xBF58476D1CE4E5B9
23:04clojurebot13787848793156543929N
23:04TEttinger,(unchecked-long 0xBF58476D1CE4E5B9)
23:04clojurebot-4658895280553007687
23:57random_numbersIt's not cryptographically secure anyway, is it?