#clojure log - Jun 29 2017

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:12 random_numbers: https://github.com/enragedginger/tensorflow-clj Any opinion on this wrapper?

0:23 TEttinger: random_numbers: if it hasn't hit Hacker News yet, get ready

0:24 random_numbers: Oh?

0:24 TEttinger: just guessing baseed on machine learning, immutable functional programming, and hacker news

0:27 random_numbers: Fair point.

1:19 kenrestivo: i think it's been around a while

1:20 says alpha api tho

4:52 Hanonim: Yop

7:05 dysfun: hi

7:18 Rovanion: Hello

7:37 BigSafari: Trying 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?

7:39 dysfun: (.encode (Charset/forName "ISO-8859-1") my-string)

7:44 BigSafari: Thanks!

7:45 dysfun: that's java.nio.charset.Charset btw

7:47 BigSafari: Yes, found it :-)

7:47 * dysfun tends to search 'java charset' or such to find the names heh

7:51 BigSafari: encode 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?

7:53 dysfun: oh, then postal must handle the encoding

7:53 java strings are strings of logical characters

7:53 BigSafari: yes, will look further into Postal for a solution.

8:25 Hanonim: here is a silly request : is there something akin to a plotting clj lib for the terminal ?

8:30 xemdetia: ascii art?

8:30 Hanonim: probably

8:38 osfabibisi: sadly looks like JavE never quite got open-sourced http://www.jave.de/developer/index.html

8:40 Hanonim: too bad, looks cool

8:44 dysfun: i expect if you email, you might get a copy

8:45 osfabibisi: yeah, very likely. Markus seemed like a nice guy when I used to hassle him about JavE bugs and features ;-)

8:45 dysfun: risk you might get asked to maintain it though ;)

8:52 osfabibisi: hehe yeah

8:52 every now and then I think I might want to write an ascii art toolkit

8:53 I've got a couple of Perl modules that do bits and bobs including https://metacpan.org/release/Text-JavE to read JavE output ;-)

9:05 fu86: hi

9:05 dysfun: hello

9:05 fu86: I have a map with the structure {"a" "b" "c" "d"} and I want to make it like this: {:a "b" :c "d"}

9:06 Is there a clever way to do this besides map/keyword/interleave/ ...

9:06 dysfun: ,(into {} (map (juxt keyword identity)) {"a" "b" "c" "d"})

9:06 clojurebot: {nil ["c" "d"]}

9:07 dysfun: hrm

9:07 justin_smith: ,(into {} (map (fn [[k v]] [(keyword k) v])) {"a" "b" "c" "d"})

9:07 clojurebot: {:a "b", :c "d"}

9:07 dysfun: yes, that was my first version and then i rewrote it

9:07 but it still hasn't clicked why it didn't work

9:07 fu86: :) looks good

9:08 dysfun: what's my bug justin_smith ?

9:08 justin_smith: dysfun: juxt uses the same arg twice, you want to use the first and second elements in the arg separately

9:08 dysfun: oh yeah

9:08 thanks

9:09 justin_smith: (partial map #(% %2) [keyword identity])

9:09 dysfun: yeah, but then it's not convenient heh

9:09 justin_smith: ,(into {} (partial map #(% %2) [keyword identity]) {"a" "b" "c" "d"})

9:09 clojurebot: #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...

9:09 justin_smith: err

9:09 ridcully_: (transform [MAP-KEYS] keyword {"a" "b"}) ; specter

9:09 justin_smith: ,(into {} (map (partial map #(% %2) [keyword identity])) {"a" "b" "c" "d"})

9:09 clojurebot: #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 ...

9:10 dysfun: yeah, just use specter

9:10 justin_smith: ,(into {} (map (partial mapv #(% %2) [keyword identity])) {"a" "b" "c" "d"}) ; sorry about the false starts

9:10 clojurebot: {:a "b", :c "d"}

9:12 fu86: didn't know specter. Is this a thing everybody uses? (like jquery for webdev?)

9:13 ridcully_: ,{(keyword "a :b") "c"} ; also be aware of the keyword-all-the-things pitfalls

9:13 clojurebot: {:a :b "c"}

9:13 ridcully_: my impression from the lack of questions here is, that it's not widely used

9:14 on the other hand it has some solid amount of GH stars for a clj lib

9:14 so maybe all are just happy and dont have any questions about it

9:14 fu86: :)

14:55 michaelrose: I'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:58 oh actually maybe the sections labeled ```clojure are supposed to be highlighted

15:01 random_numbers: Found a bug?

15:07 michaelrose: random_numbers, its not highlighted didn't think it was by default is it supposed to be?

15:09 random_numbers: I've yet to install/setup grimoire so I don't know.

15:09 michaelrose: its part of cider

15:10 random_numbers: Part of the core?

15:10 I really should read the manual...

15:11 michaelrose: wanna run cider-grimoire and see if its highlighted?

15:15 random_numbers: Hm... I seem to not be able to resolve anything. Guess my config's borken.

15:16 alright, now that works.

15:17 That rightly should be highlighted and isn't.

15:17 michaelrose: my mode is fundamenta

15:18 fundamental

15:18 random_numbers: Me too.

15:18 michaelrose: but the ```cider ``` sections are syntax highlighted?

15:19 random_numbers: Nope.

15:19 michaelrose: ah that is what I meant

15:20 random_numbers: Mhm, it should be highlighting but doesn't. Thing is that'd depend on a markdown mode which would require highlight info for clojure.

15:20 I remember having issues compiling a couple manuals locally because debian-stable didn't distribute the version with those additions.

16:24 xemdetia: make sure you check messages

17:17 technomancy: this codebase has a lot of uses of -> where they make sure that the first argument is just a straight variable

17:18 whereas I almost always make my first function call in the first position of ->

17:20 TimMc: I've seen idiomatic cases of both.

17:20 (def idiomatic? tim-approves?)

17:21 technomancy: I just need to keep resisting the urge to "clean it up" to my style

17:22 TimMc: technomancy: Some people prefer to buy paint and then paint their bikeshed, whereas others prefer to paint their bikeshed with paint they've bought.

17:22 technomancy: I am also seeing a predicate function which instead of returning a boolean, throws an exception to indicate false-ness

17:23 TimMc: uh-oh

17:23 ~guards

17:23 clojurebot: SEIZE HIM!

17:23 osfameron: !

17:24 random_numbers: technomancy: Now that's not idiomatic.

17:24 dysfun: it's arguably not a predicate

17:24 technomancy: the docstring even says that's how it's supposed to work

17:24 jeaye: It only ever returns true. :)

17:24 technomancy: but I have to fix real bugs first

17:25 * dysfun is reminded of Acme::HaltingProblem. it returns true if the given function completes.

17:27 TimMc: Is Acme, by any chance, a collection of silly stuff?

17:27 dysfun: it is, how did you guess?

17:28 other acme modules include Acme::Octarine (which does evil evil evil stuff to modify a colours module to add Octarine)

17:29 https://metacpan.org/pod/Acme::EyeDrops and Acme::EyeDrops is perhaps infamous

17:30 technomancy: oh dear

17:34 random_numbers: heh

20:44 osfameron: can you generate repeatable random numbers?

20:44 e.g. with a seed?

20:45 justin_smith: yes, via java.util.Random or gfredericks's library that wraps it

20:45 https://github.com/gfredericks/four

20:47 osfameron: ta

20:48 justin_smith: if 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:52 osfameron: yeah, that looks very much like Haskell's API for random

20:53 justin_smith: that's no coincidence

21:08 * random_numbers adds library to stack of things to read up.

22:46 TEttinger: osfameron: in Java 8 and higher, SplittableRandom is good (much better than java.util.Random in many ways)

22:47 higher period, a large amount of different number streams can be produced from one seed (usually one per thread), better quality AND speed

22:47 it's also in java.utl IIRC

23:02 osfameron: 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:02 public static long splitMix64(long z) { z = (z ^ (z >>> 30)) * 0xBF58476D1CE4E5B9L; z = (z ^ (z >>> 27)) * 0x94D049BB133111EBL; return z ^ (z >>> 31); }

23:02 kenrestivo: SpitballRandom

23:03 TEttinger: so calling splitMix64(state += 1337) would work if you did that every time on one thread, and splitMix64(state += 421) on another thread

23:03 this is of course not as convenient in clojure since it needs mutation

23:03 also a ton of bit twiddling

23:04 also those longs are both negative

23:04 ,0xBF58476D1CE4E5B9

23:04 clojurebot: 13787848793156543929N

23:04 TEttinger: ,(unchecked-long 0xBF58476D1CE4E5B9)

23:04 clojurebot: -4658895280553007687

23:57 random_numbers: It's not cryptographically secure anyway, is it?

Logging service provided by n01se.net