This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-06
Channels
- # aleph (13)
- # announcements (1)
- # babashka (89)
- # beginners (23)
- # calva (14)
- # circleci (7)
- # clj-kondo (39)
- # clj-on-windows (1)
- # cljdoc (5)
- # cljsrn (29)
- # clojure (98)
- # clojure-art (3)
- # clojure-conj (5)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojurescript (18)
- # clr (39)
- # code-art (3)
- # community-development (3)
- # cursive (3)
- # emacs (11)
- # events (1)
- # fulcro (12)
- # graalvm-mobile (16)
- # graphql (3)
- # gratitude (1)
- # honeysql (19)
- # java (7)
- # joyride (23)
- # lsp (22)
- # malli (2)
- # missionary (25)
- # off-topic (15)
- # polylith (15)
- # rdf (5)
- # reagent (9)
- # reitit (3)
- # scittle (3)
- # shadow-cljs (37)
- # slack-help (2)
- # sql (10)
Is it possible to guard against evaluating an expression that may include an unresolvable symbol?
I'd intended the following (automatically generated) code to return true
, because *honk
has no value (in the let
) but can't get past the syntax error from the fact that (unquoted) *honk
is unresolvable (can't even wrap it in try
.)
(let [*quack "like a duck"
bindings (quote {*quack "like a duck"})]
(if (get bindings (quote *honk))
(not (= *honk *quack))
true))
I'm generating the code before I know whether I'll have bindings (for optional *vars).
Does Clojure have a way around this, or do I need to re-architect?You can wrap the call to eval in a try/catch because that is where the exception is, not at runtime when the code is running
I want a very simple API, that will always only run on my local machine. I really only need a couple of endoints, a GET and a POST and I'm happy for it to just read / write a static json file on my HD. I'd like it to be pretty small and simple. What's a good clojure package to do this that doesn't need a lot of setup and boilerplate. I don't care about auth or CORS or anything like that at all. ?
Would something like this work for you? https://www.npmjs.com/package/json-mock-api
I would have liked it to be clojure, but I'm happy with JS / Python if its really simple and quick to fire up
I've written a little SPA in clojurescript for personal use to help me track a thing, but I've decided I want it to persist stuff now rather than trust cookies. SO I figure I'll just throw some json at an endpoint and write it to disk / read it from disk
It doesn't really care what you throw at it, could be json, txt, binary, whatever...
you could write a babashka script to do this pretty easily, with the (built in?) http kit webserver.
If you're okay with JS instead of CLJ(S), and only intend to serve JSON: It doesn't get any easier than https://github.com/typicode/json-server. • Been around almost as long as Node.js. • Battle-tested by serving up https://jsonplaceholder.typicode.com/ to the public for years. • Pretty extensive API options for free: pagination, sorting, mutation HTTP verbs like PUT and DELETE, etc. • Extensible with Express middleware + any arbitrary JS, if you outgrow the built-in features.
is there a function that will return an item from a seq or nil if it isn't found? It looks like core/find
only works with maps? failing at searching rn
looking for effectively this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Either some, or use filter and check the filter result to check if there are elements in the resulting seq.