This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-19
Channels
- # aws-lambda (4)
- # beginners (62)
- # cider (20)
- # cljs-dev (9)
- # cljsrn (13)
- # clojars (3)
- # clojure (105)
- # clojure-brasil (1)
- # clojure-denver (1)
- # clojure-finland (4)
- # clojure-italy (23)
- # clojure-norway (1)
- # clojure-spec (6)
- # clojure-uk (56)
- # clojurescript (41)
- # cursive (10)
- # datomic (25)
- # emacs (23)
- # figwheel (2)
- # fulcro (133)
- # graphql (12)
- # hoplon (32)
- # instaparse (13)
- # keechma (1)
- # lein-figwheel (1)
- # luminus (1)
- # lumo (1)
- # nyc (2)
- # off-topic (34)
- # om (2)
- # onyx (10)
- # pedestal (8)
- # portkey (1)
- # re-frame (10)
- # reagent (26)
- # ring (8)
- # shadow-cljs (77)
- # spacemacs (4)
- # sql (8)
- # tools-deps (15)
- # vim (9)
I'm reading Web Development with Clojure by yogthos and I've noticed that the book is using metosin/ring-http-response
. Has that been superseded by ring.util.response
since the writing of the book?
If not, why would one use metosin/ring-http-response
instead of ring.util.response
? The github page of the former says that it's a "a drop-in-place replacement for ring.util.response", but I'm not sure what that means.
@nikoszp the metosin-version maps all http-status code and with their own names like ok
(200), found
(302) and see-other
(303). Ring has only few most used and have custom names for response
(200), redirect
(302) and redirect-after-post
(303).
@nikoszp Clojure is not very opinionated about libraries but instead takes a mix'n'match approach. Both metosin/ring-http-response
and ring.util.response
were last updated in the tail end of 2017 so they're both stable and (reasonably) well-maintained. So pick whichever you prefer.
A lot of Clojure libraries are very small and focused and therefore often "complete" and rarely in need of maintenance. This is very different to a lot of other technologies, so folks often ask "Is this library dead?"
In the end, both just generate Ring maps: (ok "kikka") => {:status 200, :body "kikka", :headers {}}
It's all data, all the way down 🙂
(sometimes it's better to learn to use the data than to learn the DSLs in these libraries)
I think that Web Development book pushes Luminus, doesn't it? I'd recommend starting with Ring basics and learning how it works at a lower level -- Luminus has a fair bit of "magic" in it...
Where I work, everything is built with Ring + either Compojure or Bidi + Selmer (sometimes). No frameworks.
Thanks, that's great advice! I'm reading the Ring documentation too in parallel. Btw, the first chapter of the book starts off with a luminus app but then the next chapter goes on to explore the elements of the Luminus stack, including Ring.
The story I like to tell about this... I wrote one of the most popular MVC frameworks in Language X. I decided to port it to Clojure. We started to convert our Language X Framework Y apps over to Clojure Framework Y. We fairly quickly discovered that Framework Y didn't really add anything in Clojure so we decided to sunset it and just use the raw libraries instead.
When you come from Language X, the lack of Framework Y can be a little unsettling... But it's normally because Clojure does not need an equivalent of Framework Y 🙂
Anyone here using re-natal? Would anyone recommend it to someone who has not used react-native before?
I checked some example in the hope of quickly transforming a re-frame project to react native. Had it running fast, but the templating is a lot different, and has no real use, so gave up.
ahhhhhhhhh how do people remember how contains?
works? I have to look up the docs every time I want to know if 2
is in [0 1 2]
(some #{2} (range 0 10)) ;;=> 2
--- this is the same line i find every time i look up contains?
, remember some
, reread the "set as a function" trick
(#{} x)
is equivalent to (get #{} x)
, like ({} x)
is equivalent to (get {} x)
.
contains?
checks for the presence of a key (index) in an associative collection - in the case of sets, this is set membership
some
runs the function passed on every element of a collection, and if the return value is truthy, returns that return value, else nil
riiiiight, and a set is 'really' the map {:x :x, 1 1, "item" "item"}
so running it as a function gets the value associated with the key which happens to be the key. Thank you, I think this helps
I almost never use contains?
-- and when I do, it's only ever on a hash map where I specifically need to support nil
values. Even there I mostly prefer either (the-key the-map ::not-found)
or (get the-map the-key ::not-found)
Hmm, interesting, I have just twelve occurrences of contains?
in my code but my colleague uses it a lot -- about 80 occurrences in their code. And that's in a total of about 80,000 lines of Clojure.
Start with plain old clojure.java.jdbc, and specialize if necessary.
this seemed superinteresting https://github.com/walkable-server/walkable
@U3G3MBL9H Korma has gone unmaintained for a while (although I believe it is being updated now) but it is a bit too ORM-like for most Clojurians tastes I think.
I think I’m going to stick with jdbc then transition to HuqSQL and Walkable when I need to. Thanks for the advice guys.
HugSQL is great if you like keeping your SQL outside your code. HoneySQL is a great Clojure DSL for composable queries in code -- we use it very heavily.
And we use org.clojure/java.jdbc very, very heavily (at World Singles). Also, I maintain that.
(we run a hundred dating sites on top of java.jdbc and Percona!)
Stupid question, how do I unit test SQL queries? I’m using HugSQL and would like to test my query is correct given different database states.
You could use a test DB, and then use clojure.test fixtures to set up the DB state in a transaction that rolls-back after each test? Then you can just use the query functions.
Clojurist newb help in need! Interop troubles me. So I have this beauty piece of Java
AccessToken token = new AccessToken.Builder(twilioAccountSid, twilioApiKey, twilioApiSecret)
.identity(identity).grant(grant).build();
System.out.println(token.toJwt());
So I tried this beautier Cloj:
(doto (AccessToken$Builder. "twilioAccountSid" "twilioApiKey" "twilioApiSecret")
(.identity "indentity")
(.grant
(doto (ChatGrant.)
(.setServiceSid "ServiceId")))
(.build))
BUT! How do I solve the .toJwt()
part? I still keep getting CompilerException java.lang.IllegalArgumentException: No matching field found: toJwt for class java.lang.String, compiling
reading the error I understand I cant call .toJwt
to a string.
And here I stop don’t knowing where to go 😞@overde how are you trying to call .toJwt
? also note that doto
returns the first argument, so it'll be the AccessToken$Builder
instance, not the return value of .build
.
the syntax for a method call is (.method obj)
; (.-toJwt token)
would be a field access
doto
is intended to be used when you want to do something to an object, but return that same object, like with setters