Fork me on GitHub
#clojure
<
2018-11-26
>
isaac09:11:04

clojure data reader return nil will causes error

mping09:11:41

I have two protocols with the same fn name, how can I ensure I call the correct one?

mpenet09:11:17

use 2 diff namespaces

mpenet09:11:44

or different names. protocol functions are "per namespace"

tvalerio13:11:27

I’m trying to convert some strings to a number with different number of precisions I have to convert a string to a number with 2 decimals, so I did this:

(/ (double (read-string "199504")) 100)
1995.04

athos01:11:33

Does either (/ (Double/parseDouble "00000869") 1000) or (/ (Long/parseLong "00000869") 1000.0) work?

tvalerio13:11:14

How can I convert a tring like "00000869" to a number with three decimals? The result must be 0.869

clarice14:11:05

Hi, I am really struggling with logging and I am not sure if this is the right place to ask for help. I am still new to Clojure and am trying to put the pieces together. I'm trying to write to Graylog using gelf in taoensso.timbre.appenders.3rd-party.gelf for taoensso.timbre and org.graylog2.log.GelfAppender for clojure.tools.logging (`[org.graylog2/gelfclient "1.4.1"]`). timbre sends to Graylog but the messages are not readable. https://stackoverflow.com/questions/53481404/why-are-my-graylog-messages-using-the-taoensso-timbre-appenders-3rd-party-gelf-a The GelfAppender just doesn't send anything. I can verify this using sudo tshark | grep 1514

<appender name="graylog2" class="org.graylog2.log.GelfAppender">
        <param name="graylogHost" value=""/>
        <param name="graylogPort" value="1514"/>
        <param name="graylogProtocol" value="udp"/>
        <param name="extractStacktrace" value="true"/>
        <param name="addExtendedInformation" value="true"/>
        <param name="facility" value="app"/>
        <param name="Threshold" value="INFO"/>
        <param name="Layout" value="org.apache.log4j.PatternLayout"/>
    </appender>
    ... 
    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
        <appender-ref ref="graylog2" />
    </root>
Any ideas what I could be missing?

miikka14:11:55

@UCM1FJA4E With UDP transport, the messages are by default gzipped. I think it should just work with Graylog, but maybe there's something wrong. I'd try disabling the compression. Timbre's included appender does not allow you to disable the compression, but you could just copy-paste the code to a new namespace and edit it. In make-gelf-transport, you'd need to call (.compression Compression/NONE) on the GelfConfiguration.

miikka14:11:38

In a previous project I had so much trouble with the GELF appender that I ended up making my own, but I never published it. 😐

danieroux14:11:00

http://docs.graylog.org/en/2.4/pages/gelf.html "Graylog nodes detect the compression type in the GELF magic byte header automatically." That does not seem to happen then 😐

clarice14:11:00

@U1NDXLDUG Thanks so much. I'll give that a go tomorrow and let you know. Do you have a sample of your gelf appender by any chance? Sounds like something worth publishing ;)

miikka15:11:49

Unfortunately can't easily share it 😐

clarice06:11:34

No problem. Thanks 🙂

clarice09:11:21

Thanks for the help. I needed a GELF UDP input on Graylog on port 12201. That did the trick.

clarice09:11:12

Now I need to get org.graylog2.log.GelfAppender to send UDP data. For some reason it just doesn't want to send anything 😞

todo14:11:40

Is there any support for doing "The Little Typer" / Friedman + christiansen ... in Clojure ?

👏 1
Yehonathan Sharvit14:11:38

There is this Type therory project in Clojure LaTTe https://github.com/latte-central/LaTTe by @fredokun

kari17:11:18

Clojure is really wonderful. I needed to make a change to one Clojure app - to support different data sources. I thought this is a great place to study Clojure protocols. I created a protocol for my domain functions, then created a record per each environment and implemented that protocol for each environment and created a service factory to get the right service entity (based on profile the system is running). The changes were minimal to web layer (calling protocol functions with the service entity returned by the service factory). And using IntelliJ IDEA + Cursive REPL development is really fast.

❤️ 3
kardan18:11:32

I guess there is no way to from a tools.deps project use a git dependency that uses Leiningen (with it’s own deps), or am I wrong?

dpsutton18:11:29

if you control the lein dep you can have lein generate a pom file and then tools.deps can target it (i think)

kardan18:11:46

Ok, I’ll dig some more. I guess it’s time to learn more about all this Maven & pom stuff.

dpsutton18:11:47

it should be as simple as lein pom and then commit it

dpsutton18:11:05

the only danger is if your deps and pom file start to diverge over time.

runswithd6s18:11:39

Maybe add a git hook to run lein pom whenever project.clj is updated...

kardan18:11:43

Cool, after some LEIN_SNAPSHOTS_IN_RELEASE trickery and printing colouring drawings for my kids it worked like a charm. Thanks - much appreciated

kardan18:11:20

Or maybe not, will have to investigate some more.

dpsutton18:11:04

i have no idea what you mean but good luck 🙂

kardan19:11:59

I was trying to run latest aleph from master. Created pom.xml and ran a repl to make sure project worked. Then referenced it with local/root. But when I try to use the library I get Exception in thread “main” java.lang.ExceptionInInitializerError Caused by: java.io.FileNotFoundException: Could not locate aleph/http__init.class, aleph/http.clj or aleph/http.cljc on classpath.

kardan19:11:44

I’ll just install it in my local m2. But once seen, it’s difficult to ignore the git & sha story

manutter5118:11:48

I just stumbled on a new way to do multiline comments without semicolons or (comment...)

manutter5118:11:53

#_"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus maximus
   sem vitae libero dictum, vel posuere lectus imperdiet. Quisque vitae nisl nibh. 
   Donec iaculis tempor blandit. Suspendisse potenti. Sed at ipsum fermentum 
   justo maximus porta. Nullam posuere fermentum efficitur. In ut neque sed nisl."

manutter5118:11:55

I kinda like that--clean.

todo18:11:40

@viebel: I just bought "The Little Typer", so I'm really looking for a library to go along precisely with that book. 🙂

holyjak19:11:10

Hello, is there a way to pass java system property to the clj CLI tool? -Doption=value does not work... Thank you!

andy.fingerhut19:11:55

@manutter51 Yep, that is great when the string or other immediately following object is syntactically correct Clojure code/data, but otherwise will cause an error, similar to (comment ...). Most editors intended for programming have the capability in a few key/mouse strokes to select a region of lines and comment or uncomment them using ';;' or whatever that programming language uses for comments.

holyjak20:11:55

thanks a lot!!! I did read the help but obviously not well enough

alexmiller19:11:50

also see clj -h for help

manutter5119:11:12

Yeah, I’ve been using the keyboard shortcut, and it works great, but I think the string comment is visually appealing for multiline comments intended as documentation.

kenny23:11:30

Has anyone encountered Caused by: java.io.IOException: Too many open files when using clj-http?