#clojure log - Oct 12 2015

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

0:00 neoncontrails: Yeah cannot reproduce. Lesson learned, don't count on templates to remain static

0:00 justin_smith: I've always thought there should be a version option for templates, it would help tutorials stay useful (though maybe not relevant)

0:02 neoncontrails: I alsot authors should post a final version of the file being modified, if not a full git repo

0:04 There's always some ambiguity when following these tuts. (Bracket the :require statement? Bracket it how?!)

5:08 sm0ke: how do you APPEND to classpath in boot or lein?

5:08 some arbitrary paths

5:09 oahner: :source-paths is added to the classpath (in lein)

5:09 probably a few other keys too

5:10 sm0ke: but they are not appended

5:11 so the classes may resolve from :source-paths before deps

5:11 oahner: ohh

5:11 that's... correct

5:13 I don't think it's possible with lein

5:13 sm0ke: i cannot believe how difficult we have made java -cp "a:b:c" with build tooling

5:14 i was looking into boot for this, but cannot find anything obvious

5:14 muhuk: worst case it should be possible with a lein plugin

5:16 oahner: actually

5:17 sm0ke: i am all ears oahner

5:17 oahner: lein adds the :dependencies in order

5:17 sm0ke: but adding a simple path with dozen of jars would be a pain

5:18 i am looking to a path glob "a/b/*"

5:18 oahner: add those jars to a maven repo and put them in your :dependencies

5:18 sm0ke: to add*

5:18 oahner: I believe that would be the lein way of doing things

5:19 sm0ke: unacceptable for my situation

5:19 I have two three paths with 100's of jars

5:19 oahner: I have to ask; what are those jars?

5:19 sm0ke: just provided dependencies for libraries

5:20 i dont want to include them as dependency in the project

5:20 oahner: libraries that have never been added to a maven repository?

5:21 sm0ke: they are in mvn but they are many and makes the project profile complex

5:21 specially with different versions

5:21 so if i add the folder to :resource-paths for e.g. it is PREPENDED to classpath

5:22 if classpath has httpclient-4.1.3 clj-http doesnt like it

5:22 you get the thing? common java nonsense

5:22 oahner: seems like you have a higher level problem than trying to add a classpath to your clojure project... but at this point you could simply look into clojure.core/add-classpath

5:23 sm0ke: hurmm i forgot https://github.com/cemerick/pomegranate

5:24 oahner: that would work too

5:24 sm0ke: let me try

5:25 is there a lein post hook for repl?

5:26 oahner: :repl-options :init

5:27 https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L345

5:28 sm0ke: awesome

5:29 oahner: you'll have to manually massage your java -cp when you decide to lein jar your project tho

5:30 sm0ke: no as i said the deps are provided

5:30 so when i run i have full freedom of java -cp

5:30 yeah sorry thats what you said

5:30 :P

5:31 oahner: ^^

5:31 sm0ke: well add-classpath from core fails for "a:b/c/*" with invalid path error

5:32 pomegranade add-classpath seems to run quietly

5:32 but i cannot access classes added

5:34 oahner: maybe pomegranate simply did the wrong thing

5:34 try adding a single one of those directories, see if it works for one jar

5:35 if it does, you may simply have to iterate over all subdirectories and add-classpath all of them

5:37 sm0ke: "/ab/c" is malformed for core/add-classpath i added "file://ab/c" it runs

5:37 but still classpath is not modified

5:38 oahner: sorry, I still don't grok that whole classloader story

5:41 Leonidas: yogthos: the example page dies with an ungaught exception: https://yogthos.github.io/reagent-forms-example.html

5:41 *uncaught, even.

5:48 oddcully: Leonidas: due to cloudflare not sending react? error i had at first reload was "React not defined" and 404 for reacht.min.js. frantic reloading fixed it

5:51 Leonidas: oddcully: no, I am getting "uncaught exception: Invalid match arg: /\./"

6:10 instilled: hi. how can I check a record implements a protocol? I've tried with instance? and satisfies? but both fail. Anyone?

6:14 dstockton: inhortte: satisfies? should do it

6:14 instilled:

6:14 sorry inhortte

6:21 instilled: dstockton: Thanks. The issue was when I reloaded the namespace with the protocol definition but not the namespace with the implementation. I should have thought of that. Thanks anyway.

7:01 ashwink005: does clojure.tools.logging library breakdown large error logs into smaller parts?

7:08 sm0ke: ashwink005: what do you mean? the log file?

7:08 oddcully: ashwink005: do you mean a rollover when the file grows?

7:09 sm0ke: you can configure log files with log4j.properties

7:09 or what every logger you are using

7:10 ashwink005: sm0ke, I have configured the log4j.properties but the logs are broken

7:10 when I open var/log/syslog

7:11 large log messages (those having stacktraces) are logged in parts

7:11 sm0ke: hurmm var/log/syslog are linux system logs

7:11 ashwink005: yes my log4j is configured to log onto Syslog

7:11 sm0ke: you must have configured it to some other location

7:11 ah

7:11 wont you need sudo permission for it?

7:12 ashwink005: I don't think so.. I can see the logs in it.

7:13 sm0ke, here's my log4j http://txt.do/aymbd

7:15 oddcully: ashwink005: is your message longer than 1k?

7:16 ashwink005: oddcully, no no not at all

7:16 oddcully, here's the log http://txt.do/aymb4

7:18 sm0ke: hurmm seems to use log4j.appender.SYSLOG.layout.ConversionPattern=venus %d{ISO8601} %p %t %c{1}.%M - %m%n

7:18 is the log not in the format you have put?

7:19 oddcully: is this mentioning of "localhost" actually using syslog via upd?

7:19 sm0ke: not sure if you should even put that as org.apache.log4j.net.SyslogAppender should have sane default for it already?

7:19 oddcully: i have never used that "feature"

7:19 sm0ke: me too

7:19 never used syslogs

7:20 oddcully: but if it is, there are limits to syslog, there are limits to udp

7:20 syslog rfc says, min-len is 480 byte. your message there comes close to this barrier

7:21 ashwink005: oddcully, thats minimum length right?

7:22 oddcully: thats the minimum length an implementation must support

7:23 ashwink005: I have not much idea about rsyslog. Though I did read the conf file.

7:23 smaller messages are going sweet

7:24 should removing syslogAppender help?

7:26 oddcully: i'd have a look in the depth of the web, if syslog is a safe, sane and performant option for your amounts of logs

7:27 ashwink005: oddcully, they aren't that large. Just stacktrace of errors

7:27 I want my clojure errors to be sent to loggly. And rsyslog is one of the few options

7:34 oddcully: well, to me the output looks it got split in parts, that fit the limit. your two entries there, the second looks like the continuation of the first

7:36 neoncontrails: Say you just made a version-breaking change to your stack, your app is back up and running as before, but keyboard inputs don't work. What would you inspect?

7:39 oddcully: stack is what? swing, javafx, react, ...?

7:40 neoncontrails: Chestnut. I incorporated Chestnut to simplify the Figwheel HTTP serving

7:41 And there's my error: yes, a missing keydown handler could have something to do with it.

7:58 sm0ke: oahner: i ended up using https://github.com/nickgieschen/lein-extend-cp in case you are interested

7:58 simply appends to the classpath

7:59 oddcully: neoncontrails: then i assume your keyboard no longer works in some input field in your html in the browser?

7:59 oahner: I like the Usage section of the readme

8:00 oddcully: neoncontrails: and in case this is react (by om, reagent, rum, ...) my very first check would be, if you put a constant value in that input, which would prevent any changes by keyboard

8:00 neoncontrails: otherwise i'd track down what your existing handler there does

8:01 neoncontrails: oddcully: I figured it out already, thanks. Sadly just a missing event handler... I should go to bed, heh

9:19 noncom: what's the most idiomatic way to find all indexes of a string in a string?

9:19 a reduce + .indexOf ?

9:50 yottabyte: hi guys, are clojure classes .java? can I use them with regular java classes?

9:50 i.e. can a clojure class call a java class' methods?

9:50 xemdetia: yottabyte, did you read this page? http://clojure.org/java_interop

9:50 mavbozo: ,(java.util.UUID/randomUUID)

9:51 clojurebot: #uuid "851cd002-7902-4514-b199-f88a378e4930"

9:51 noncom: clojure does not have classes as such..

9:52 there are various conditions when it is possible to talk about clojure classes, like when during aot compilation, but not for clojure itself

9:57 yottabyte: I can't really see how I would call a java method from clojure

9:57 oh like (. foo bar 7 4) ; call the method bar of the instance/class foo with arguments 7 and 4?

10:02 dzhus: what is the difference between nth and get for vectors?

10:02 snowell: yottabyte: The function name comes first. So for an instance you would do (.bar foo 7 4)

10:02 yottabyte: If the function is static, you'd do (foo/bar 7 4)

10:04 yottabyte: ah, k

10:05 sobel: noncom: clojure can generate java classes aot

10:06 noncom: sobel: yep, that's what i said in the second sentence

10:06 but as a language construct, they are non-existant

10:06 sobel: noncom: but i thought it did not have classes, rather uses java classes under the hood, but offers protocols and records instead

10:06 ah ok

10:07 noncom: sobel: yes, many things in clojure are actually JVM classes.. each (fn) even

10:07 sobel: impl details

10:08 noncom: oh, correct, that's the word

10:16 mmitchell: I'm starting to play with clojurescript for the first time really, and have a question about whether or not something is possible. For the final result/build, I'd like to have a bunch of JS functions, based off of a JSON schema on the file system. I don't want the final build to have any knowledge of the JSON schema, just JS functions. Do I need to use Clojure to read the schema file, and generate ClojureScript? Is there an

10:16 obvious way to do this that I'm not aware of (probably)?

10:23 luxbock: mmitchell: you can use a macro (in Clojure) that generates code in CLJS

10:34 I keep having problems with using a protocol as a part of my schema definition, and then reloading code in the REPL making my schemas invalid

10:35 I know the protocol and REPL reloading is a known issue, and the reloaded REPL work flow is one solution to the problem, but it feels so awfully heavy handed

10:53 mmitchell: luxbock: yeah +1. Makes sense, thanks!

11:15 justin_smith: luxbock: it's either that or not use protocols

11:16 or not reload your protocol definition, of course

11:16 luxbock: one thing that I find helps a lot is to have a file that has only the protocol definition, that rarely needs reloading (since protocols shouldn't change often...)

11:48 luxbock: justin_smith: yeah that's how I have them right now but it's still not quite perfect

11:56 Kante: When starting up emacs I get two buffers. For example when opening a file in Nautilus I see that file 2x. It happens when I do `(require-package 'cider)`.

11:59 justin_smith: Kante: do you mean that the view is split and both parts show the contents of the same file?

12:01 because emacs starts up with at least two buffers (*scratch* and *messages*) even if you don't open any files.

13:44 noncom: i am trying to fetch this dep, but the jar that leiningen gets does not contain the library http://search.maven.org/#artifactdetails%7Cde.schlichtherle.truezip%7Ctruezip-archetype-path%7C7.7.9%7Cmaven-archetype

13:44 what is that?

13:44 how do i get this library?

13:44 it only has this: http://joxi.ru/J2be6W4sPenxm6

13:45 and not much more :/

13:47 oddcully: aren't maven arche types used to bootstrap maven projects. like lein templates?

13:49 noncom: probably...

13:49 but..

13:49 is there no way to get that library ?

13:49 oddcully: you could look into that pom.xml and see for the real dep then

13:49 noncom: ah

13:51 oh, it worked!

13:51 i did as you said

14:00 janus_: Hello! How do I convert lazy data structure to a normal one, so I can print it normally? My current code prints like that

14:00 "The City and the City, written by clojure.lang.LazySeq@1"

14:00 justin_smith: janus_: (apply str lazy)

14:00 janus_: justin_smith: it gives me an empty string then

14:00 justin_smith: ,(apply str (range 10))

14:00 clojurebot: "0123456789"

14:00 justin_smith: janus_: then it is empty

14:01 also, there's string/join

14:01 ,(clojure.string/join \space (range 10))

14:01 clojurebot: "0 1 2 3 4 5 6 7 8 9"

14:03 janus_: apply str gives me "The City and the City, written by ", the other function gives me an error

14:03 justin_smith: Can I paste the code to sth like lpaste?

14:03 justin_smith: sure

14:04 janus_: justin_smith: It's kinda tangled, so I'll add the comments, wait a minute

14:04 justin_smith: ,(str (map inc nil))

14:04 clojurebot: "clojure.lang.LazySeq@1"

14:04 justin_smith: notice that is @1

14:04 I think @1 is always the empty lazy seq

14:05 janus_: check the result of (empty? your-lazy)

14:05 I bet it returns true

14:05 janus_: I'll do that

14:06 justin_smith: aand you're right

14:06 justin_smith: don't know why tho

14:06 justin_smith: janus_: well, you're one step closer at least

14:11 janus_: justin_smith: what is this nightmare? that helper function worked correctly 5 mins ago

14:11 justin_smith: thanks anyway, will talk to you when I figure out what's wrong

14:19 yottabyte: how do you pronounce clojure? like closure?

14:20 ane: yes

14:20 yottabyte: ty

14:21 justin_smith: yottabyte: I pronounce it like rich hickey does in his videos, which is almost identical to closure, but not exactly, but I don't know enough linguistics to describe the difference

14:37 free_beard: hi guys, how do i get all the keys/values from a map?

14:37 sorry if select-keys select-values is not obvious enough for me to use

14:38 justin_smith: free_beard: what format do you want?

14:38 free_beard: say a vector of them

14:38 any sequence is fine

14:38 justin_smith: ,(vec {:a 0 :b 1 :c 2})

14:38 clojurebot: [[:a 0] [:b 1] [:c 2]]

14:38 free_beard: yeah, but i don't know the keys

14:38 justin_smith: ?

14:38 the keys are the first value in each pair

14:39 free_beard: i don't know that they are :a :b :c

14:39 i don't know what they are beforehand

14:39 justin_smith: free_beard: that part doesn't matter

14:39 snowell: ,(keys {:a 1 :b 2 :c 3})

14:39 justin_smith: (vec m)

14:39 clojurebot: (:a :b :c)

14:39 justin_smith: free_beard: once again, what is the result you actually want to get?

14:40 free_beard: something like the python dict's keys()

14:40 and values()

14:40 justin_smith: free_beard: keys, vals

14:40 ,(keys {:a 0 :b 1 :c 2})

14:40 clojurebot: (:a :b :c)

14:40 free_beard: justin_smith: ah, perfect

14:40 justin_smith: thank you! I didn't understand your example for some reason

14:40 justin_smith: free_beard: I didn't think you wanted keys, because you were literally naming it in your question, hah

14:41 ,(vals {:a 0 :b 1 :c 2})

14:41 clojurebot: (0 1 2)

14:43 tdammers: so I have a macro in foo.clj; that macro takes an argument that is a function which it runs at compile time. Now I need to call that macro from clojurescript, but I can't for the life of me figure out how to write a suitable function to pass int

14:43 in*

14:44 I understand that I need to write the function in clojure, not clojurescript, but how can I refer to a clojure function from within clojurescript?

14:44 sveri: äfd)P?

14:45 justin_smith: tdammers: isn't this what :require-macros is for?

14:45 tdammers: so I thought, but what I'm pulling isn't a macro, it's a function

14:46 justin_smith: tdammers: can't you just have the function in the same ns you pull in with require-macros? or does the macro need to be parameterized when called?

14:47 tdammers: the macro is defined in a library

14:47 justin_smith: but at worst, you could have another macro, that calls the original with the apropriate function arg...

14:47 and then use require-macros to pull that into cljs in the normal way

14:48 tdammers: hmm

14:58 so wrapping the macro somehow doesn't work either

14:58 "Can't eval locals" - what does that mean?

15:11 oh, hmm, next question - everything compiled without errors, but when I run things in the browser, I get "Type error: foo.bar is undefined"

15:11 how is this even possible?

15:17 pbx: tdammers, runtime bug?

15:18 tdammers: how can an undefined macro be a runtime bug?

15:20 pbx: tdammers, sorry, i thought it was a js error

15:20 tdammers: it is

15:20 that's the weird thing

15:21 it's a JS error that occurs as a result of a macro not being in scope

15:21 pbx: tdammers, i shouldn't pretend to know anything about clojurescript, but share source and full error output?

15:21 dnolen: tdammers: it sounds like your macro needs var resolution to work no?

15:22 tdammers: nah, I have it solved now

15:22 can't share actual code because copyright shenanigans

15:22 but anyway, what happens was I simply didn't pull the wrapper in with require-macros

15:22 but everything compiled fine anyway

15:22 instead crashing at runtime

15:23 I'd expect something like this to raise a compiler error

15:23 dnolen: if there was something unresolved you should have been given a compiler warning

15:23 if you didn't that's a bug and you should determine a minimal reproducer

15:25 tdammers: I'll see what I can do

18:07 bja: ddellacosta: any chance you'll be able to get to https://github.com/jkk/honeysql/pull/95 in the next couple days?

18:07 just wondering if I need to make a temporary release for myself

18:10 ddellacosta: bja you should assume I won't get to it and do what you need to do

18:10 ...as with all open source projects

18:52 mungojelly: justin_smith: fyi the difference is that closure is pronounced with a "voiced alveolar fricative" aka /z/ https://en.wikipedia.org/wiki/Voiced_alveolar_fricative#Voiced_alveolar_sibilant while clojure is pronounced with a "voiced palato-alveolar fricative" aka /Z/ or more prettily ʒ https://en.wikipedia.org/wiki/Voiced_palato-alveolar_sibilant

18:53 justin_smith: (inc mungojelly) ; if only

18:53 thanks!

18:59 TEttinger: mungojelly: I pronounce closure with the ezh ("ʒ" as in treasure, another *sure word), and clojure with the d-ezh digraph (normally, "j")

19:01 I've never heard closure, as in "seeking closure" or "a closure that contains the current state" pronounced without a zh sound a la ezh or treasure

19:14 mungojelly: TEttinger: yeah i guess you're right, "closure" is often pronounced with /ʒ/, i don't recall hearing clojure with /dʒ/ though that's interesting.

19:15 TEttinger: yeah that might just be my literal pronounciation of the "Java" in the root of the name that I think was "CLR, Java, functional programming play on words"

19:15 mungojelly: it'd be nice if there were some way to distinguish them. and trie from tree. :/

19:16 TEttinger: I just say trie as try, but that has its own problems!

19:16 mungojelly: i was thinking for a second that a pun for a name is odd for something so serious, but then i remembered that even "C" is sorta a pun or play of some sort on "B"

19:18 justin_smith: there's nothing serious in the world of programming

19:21 mungojelly: i thought of a distinctive way to pronounce "trie" /triaɪ/ tree-eye but that doesn't do any good because no one knows my pronunciation hm

19:21 justin_smith: mungojelly: I got a copy of the Codex Seraphinianus recently, it has some tree-eyes in it

19:25 TEttinger: mungojelly: the choices for trie are what, "tree eye", "tree A" (like spanish pronounciation), or "try E" (overheard at raves)

19:26 or, Try Uh, which sounds like you haven't finished your sentence

19:32 mungojelly: i think we should say it every time all elongated like we're emphasizing what a ridiculous word it is like: http://vocaroo.com/i/s0ztmjDBei3W

19:44 TEttinger: hash-array mapped tryyyyyyyyyyyyyy

21:41 neoncontrails: I know that there is a cute way to do this using map + juxt:

21:41 You have a collection of keywords and strings like so, ["283" "89" :div]

21:42 And you'd like to reduce over the collection to return false if any of the values are "null" in their respective types.

21:50 Seylerius: Is there an easy clojure interface to calling up print dialogs?

21:52 neoncontrails: I kludged my problem to death and ended up with this, but I'd be curious to see this written correctly

21:53 ,(not-any? true? (into [] (map empty? (map str (map show ['x 'y 'op])))))

21:53 clojurebot: #error {\n :cause "Unable to resolve symbol: show in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: show in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: show in this co...

21:54 neoncontrails: ,(def show {'x 1 'y 2 'op :div})

21:54 clojurebot: #'sandbox/show

21:54 neoncontrails: ,(not-any? true? (into [] (map empty? (map str (map show ['x 'y 'op])))))

21:54 clojurebot: true

22:00 xzilend: Hi there, is there a simple way to monitor how many items are in a core.async buffer? I'd like to monitor a channel to make sure that the consumer(s) are keeping up with the producer(s).

22:01 Seylerius: xzilend: Try count?

22:03 justin_smith: it's intentionally prevented, if it was allowed it could lead to race conditions, believe it or not

22:03 Seylerius: Interesting!

22:04 justin_smith: D'you know if there's a straightforward way to call print dialogs from Clojure?

22:06 xzilend: hmm interesting, thanks! I'll have to come up with some other solution

22:06 justin_smith: Seylerius: from the jvm?

22:07 Seylerius: justin_smith: Essentially, yeah. I'm trying to see if something like seesaw already has the capability.

22:07 justin_smith: https://docs.oracle.com/javase/7/docs/api/java/awt/print/PrinterJob.html

22:07 I don't have high hopes there are clojure bindings already, but interop is easy usually

22:09 Seylerius: Hmm... Maybe I'll fiddle around with that and submit a PR for seesaw

22:10 justin_smith: Since it's generic and mostly controlled by the host, it should be easy to use on its own

Logging service provided by n01se.net