Fork me on GitHub

clojure data reader return nil will causes error


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


use 2 diff namespaces


or different names. protocol functions are "per namespace"


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)


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


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


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 (`[org.graylog2/gelfclient "1.4.1"]`). timbre sends to Graylog but the messages are not readable. 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"/>
    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
        <appender-ref ref="graylog2" />
Any ideas what I could be missing?


@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.


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 "Graylog nodes detect the compression type in the GELF magic byte header automatically." That does not seem to happen then 😐


@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 ;)


Unfortunately can't easily share it 😐


No problem. Thanks 🙂


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


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


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

👏 4
Yehonathan Sharvit14:11:38

There is this Type therory project in Clojure LaTTe by @fredokun

Kari Marttila17: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.

❤️ 12

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?


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


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


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


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


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


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


Or maybe not, will have to investigate some more.


i have no idea what you mean but good luck 🙂


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: Could not locate aleph/http__init.class, aleph/http.clj or aleph/http.cljc on classpath.


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


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


#_"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."


I kinda like that--clean.


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

Jakub Holý (HolyJak)19:11:10

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


@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.

Jakub Holý (HolyJak)20:11:55

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

Alex Miller (Clojure team)19:11:50

also see clj -h for help


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.


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