This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-08
Channels
- # aws (3)
- # beginners (126)
- # boot (19)
- # cider (31)
- # cljs-dev (324)
- # clojure (96)
- # clojure-boston (2)
- # clojure-denver (9)
- # clojure-dusseldorf (2)
- # clojure-greece (4)
- # clojure-italy (5)
- # clojure-losangeles (1)
- # clojure-spec (18)
- # clojure-uk (59)
- # clojurebridge (1)
- # clojurescript (184)
- # community-development (29)
- # cursive (2)
- # datascript (2)
- # datomic (5)
- # emacs (1)
- # figwheel (6)
- # fulcro (270)
- # hoplon (2)
- # jobs (1)
- # jobs-discuss (1)
- # keyboards (2)
- # leiningen (2)
- # london-clojurians (2)
- # luminus (10)
- # mount (1)
- # off-topic (26)
- # onyx (8)
- # other-languages (1)
- # parinfer (1)
- # protorepl (6)
- # re-frame (23)
- # reagent (61)
- # reitit (5)
- # shadow-cljs (100)
- # spacemacs (3)
- # sql (19)
- # unrepl (90)
- # vim (25)
pretty sure httpkit can do it
user=> (.(Random.)nextInt(100)) ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn user/eval150 (NO_SOURCE_FILE:4)
Hope this is a legit question on this channel, I wonder what would be the state-of-the-art web server library to use in clojure, for a not-very-complicated small web application? in simple, I mean not too many pages or views belonging in the web application, and no huge traffic. Quite a devops oriented web application...
@matan A lot of people start with luminus — it’s a quick way to pull in a lot of standard libraries and get a server up and running with minimal fuss. http://www.luminusweb.net/
If it's fairly basic, I might skip Luminus and do more of a bare-bones ring handler function with some ring middleware, with hiccup to create html from data.
I’m doing something similar, but more of an API server. Looking at yada, compojure-api, and others. Thoughts?
I’m interpreting that as you @alexmiller didn’t like it! 🙂
@alexmiller I probably didn't get it ....
I think it’s highly unlikely that Rich would like it :)
@teng - Do you know about fnil
?
on the simple server topic, did any of the revolutionary ones (that like should have been what datomic is to data) end up very usable and stable? I think there was a project om.next going, which was somewhere between odd and experimental at the time
@jeff.terrell Thanks for the tip. The alternative was to introduce a let-statement, because the incoming parameter was used in several places in the code and I didn’t want to introduce code duplication by using the ‘or’ or ‘fnil’ function. Clojure supports destructuring in the parameter list for maps that also supports :or, my idea was to support the :or part even for other types than maps.
Is there some better (as in more idiomatic and/or faster) way in clojure to get the file line/col of the calling function (when in a function) than traversing (.getStackTrace (Thread/currentThread))
or (.getStackTrace (Throwable. ))
?
Is there something, which can be dereffed to get the current value. Where the current value is updated by a periodic call. I kind of want a (sliding-buffer 1)
that's dereffable.
@ghadi For my case, the contention would potentially be prohibitive. There could be a lot of updates in bursts.
agents handle contention by queueing instead of retrying, which might be worth it if your retries are expensive
@leonoel that's a good point. I was thinking about that wrong. swap!
is sync isn't it?
how would atom / swap! apply any backpressure btw?
if backpressure is a problem you probably want a proper queue or channel setup
@noisesmith it doesn't, other than that the thing consuming the queue to perform the swap!
has backpressure.
OK but I don't see how any of this leads to an agent being a problem
TDEPS: Is there an easy way to add a dir to the classpath? Without deps.edn but on the command line.
@rauh not in tdeps, you could port the add-classpath! function from pomegranate, or use dynapath
@noisesmith Because if I am consuming from a queue, and immediately sending it to an agent faster than the agent can consume that queue, that will fill memory.
and atom/swap! doesn't have this problem? I'm not picturing this
@noisesmith swap!
is sync
, so the thing consuming the queue in the first place is blocked until the swap!
is complete. send-off
is async.
oh, right, so it's about keeping the backpressure on the queue you consume from, I get it
@ghadi I'm using manifold. The queue is handed to me. (But in practice I'm only using manifold.stream/stream
for now).
@dominicm Turns out {:paths ["foo/bar"]}
works fine for adding to the CP on the command line
Hey Clojurians! I've posted this on the #clojure channel on Freenode, but posting here as well in case someone has some ideas about my question. I've started playing out with Compojure and built a simple API, and was wondering how would I go if I wanted to create new clojure.spec's dynamically by simply POST'ing for example some payload to my API endpoint? How would I serialize the spec, so that the API knows how to build a spec out of it? Is this something feasible to do? The idea is to allow users to create new clojure.spec's on demand.
@dominicm that would be ideal I guess, but the end goal would be to allow non-dev users create specs. Having an API that can create specs and a nice frontend is what I'm thinking about. The users should not really know and care that behind all this is a clojure.spec
.
@dnaeon so you're looking for a front-end which makes it easy for non-developers to build specs?
It would be great if the users were able to write the specs, but they are not really developers, thus the need for a frontend which makes this simple for them.
The hardest part I guess would be to provide a frontend which covers all that clojure.spec
provides in a nice and intuitive way to use.
Then have a general-purpose predicate which takes 2 inputs, the DSL & the input to validate against.
Has someone worked with AWS Lambda? I'm trying to read a file from the resources folder and it's not finding, I'm using serverless for packaging
@pfeodrippe the most common error here is that you use io/file or java.util.File to open it - if it's in your resources, it will be inside your jar at runtime, which means you should use http://clojure.java.io/resource to access the contents
or you can extract the jar to disk, but you probably don't want to do that in lambda, even if you could
@noisesmith Thank you, noisesmith, gonna try it, and yes, I'm using clj-pdf and it must use io/file
, gonna try your way o/
It's working, thank you 😃
What's a good shorthand for (when (pred? (expensive-call)) (expensive-call))
basically a single element filter
but I don't want to calculate things twice
when-let and if-let don't cut it because they bind the result of predicate
which is true
but not the value being tested
a couple of these functions don't play nice with predicates that return booleans
like some
isn't that useful for "find an element that satisfies predicate x" when predicate returns a boolean
yeah, well I was looking for something shorter
Hello guys, any idea how to setup working Sentry appender for Timbre logging (from 3rd party appenders)? I have a configuration like
{:level :info
:ns-blacklist ["com.mchange.*"] ;disable Korma DB pool logging
:appenders {:spit (rotor-appender {:path "mylog.log"
:backlog 10})
:sentry (sentry-appender {:dns "url"})}}
Spit appender is correctly logging to a file (and rotating it), however Sentry logger is not doing anything and I am not sure how test it 🙂 It internally calls raven-clj,core/capture
which works well in the REPL by itself so maybe I am not getting the integration correctly or I have some silly mistake there 🙂 Thanks for any hints if you have experience with that 🙂When I get an error like this at the repl, is there any way to find out what line number in the source file caused it? ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:158)
@ajs clojure.repl/pst will show the last stack trace nicely if you call it
there's also the value *e which always holds the most recent uncaught exception, including its stack