2017-06-29
| 00:12 | random_numbers | https://github.com/enragedginger/tensorflow-clj Any opinion on this wrapper? |
| 00:23 | TEttinger | random_numbers: if it hasn't hit Hacker News yet, get ready |
| 00:24 | random_numbers | Oh? |
| 00:24 | TEttinger | just guessing baseed on machine learning, immutable functional programming, and hacker news |
| 00:27 | random_numbers | Fair point. |
| 01:19 | kenrestivo | i think it's been around a while |
| 01:20 | kenrestivo | says alpha api tho |
| 04:52 | Hanonim | Yop |
| 07:05 | dysfun | hi |
| 07:18 | Rovanion | Hello |
| 07: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? |
| 07:39 | dysfun | (.encode (Charset/forName "ISO-8859-1") my-string) |
| 07:44 | BigSafari | Thanks! |
| 07:45 | dysfun | that's java.nio.charset.Charset btw |
| 07:47 | BigSafari | Yes, found it :-) |
| 07: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? |
| 07:53 | dysfun | oh, then postal must handle the encoding |
| 07:53 | dysfun | java strings are strings of logical characters |
| 07:53 | BigSafari | yes, will look further into Postal for a solution. |
| 08:25 | Hanonim | here is a silly request : is there something akin to a plotting clj lib for the terminal ? |
| 08:30 | xemdetia | ascii art? |
| 08:30 | Hanonim | probably |
| 08:38 | osfabibisi | sadly looks like JavE never quite got open-sourced http://www.jave.de/developer/index.html |
| 08:40 | Hanonim | too bad, looks cool |
| 08:44 | dysfun | i expect if you email, you might get a copy |
| 08:45 | osfabibisi | yeah, very likely. Markus seemed like a nice guy when I used to hassle him about JavE bugs and features ;-) |
| 08:45 | dysfun | risk you might get asked to maintain it though ;) |
| 08:52 | osfabibisi | hehe yeah |
| 08:52 | osfabibisi | every now and then I think I might want to write an ascii art toolkit |
| 08:53 | osfabibisi | I've got a couple of Perl modules that do bits and bobs including https://metacpan.org/release/Text-JavE to read JavE output ;-) |
| 09:05 | fu86 | hi |
| 09:05 | dysfun | hello |
| 09: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"} |
| 09:06 | fu86 | Is there a clever way to do this besides map/keyword/interleave/ ... |
| 09:06 | dysfun | ,(into {} (map (juxt keyword identity)) {"a" "b" "c" "d"}) |
| 09:06 | clojurebot | {nil ["c" "d"]} |
| 09:07 | dysfun | hrm |
| 09:07 | justin_smith | ,(into {} (map (fn [[k v]] [(keyword k) v])) {"a" "b" "c" "d"}) |
| 09:07 | clojurebot | {:a "b", :c "d"} |
| 09:07 | dysfun | yes, that was my first version and then i rewrote it |
| 09:07 | dysfun | but it still hasn't clicked why it didn't work |
| 09:07 | fu86 | :) looks good |
| 09:08 | dysfun | what's my bug justin_smith ? |
| 09:08 | justin_smith | dysfun: juxt uses the same arg twice, you want to use the first and second elements in the arg separately |
| 09:08 | dysfun | oh yeah |
| 09:08 | dysfun | thanks |
| 09:09 | justin_smith | (partial map #(% %2) [keyword identity]) |
| 09:09 | dysfun | yeah, but then it's not convenient heh |
| 09:09 | justin_smith | ,(into {} (partial map #(% %2) [keyword identity]) {"a" "b" "c" "d"}) |
| 09: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... |
| 09:09 | justin_smith | err |
| 09:09 | ridcully_ | (transform [MAP-KEYS] keyword {"a" "b"}) ; specter |
| 09:09 | justin_smith | ,(into {} (map (partial map #(% %2) [keyword identity])) {"a" "b" "c" "d"}) |
| 09: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 ... |
| 09:10 | dysfun | yeah, just use specter |
| 09:10 | justin_smith | ,(into {} (map (partial mapv #(% %2) [keyword identity])) {"a" "b" "c" "d"}) ; sorry about the false starts |
| 09:10 | clojurebot | {:a "b", :c "d"} |
| 09:12 | fu86 | didn't know specter. Is this a thing everybody uses? (like jquery for webdev?) |
| 09:13 | ridcully_ | ,{(keyword "a :b") "c"} ; also be aware of the keyword-all-the-things pitfalls |
| 09:13 | clojurebot | {:a :b "c"} |
| 09:13 | ridcully_ | my impression from the lack of questions here is, that it's not widely used |
| 09:14 | ridcully_ | on the other hand it has some solid amount of GH stars for a clj lib |
| 09:14 | ridcully_ | so maybe all are just happy and dont have any questions about it |
| 09: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 | michaelrose | 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 | random_numbers | 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 | random_numbers | alright, now that works. |
| 15:17 | random_numbers | That rightly should be highlighted and isn't. |
| 15:17 | michaelrose | my mode is fundamenta |
| 15:18 | michaelrose | 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 | random_numbers | 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 | technomancy | 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 | TimMc | (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 | TimMc | ~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:27 | TimMc | Is Acme, by any chance, a collection of silly stuff? |
| 17:27 | dysfun | it is, how did you guess? |
| 17:28 | dysfun | other acme modules include Acme::Octarine (which does evil evil evil stuff to modify a colours module to add Octarine) |
| 17:29 | dysfun | 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 | osfameron | e.g. with a seed? |
| 20:45 | justin_smith | yes, via java.util.Random or gfredericks's library that wraps it |
| 20:45 | justin_smith | 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 |
| 22:46 | TEttinger | osfameron: in Java 8 and higher, SplittableRandom is good (much better than java.util.Random in many ways) |
| 22:47 | TEttinger | 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 | TEttinger | it's also in java.utl IIRC |
| 23:02 | TEttinger | 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 | TEttinger | 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 | TEttinger | this is of course not as convenient in clojure since it needs mutation |
| 23:03 | TEttinger | also a ton of bit twiddling |
| 23:04 | TEttinger | also those longs are both negative |
| 23:04 | TEttinger | ,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? |