This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-21
Channels
- # beginners (38)
- # boot (88)
- # cljs-dev (142)
- # cljsrn (2)
- # clojars (1)
- # clojure (107)
- # clojure-berlin (2)
- # clojure-italy (8)
- # clojure-russia (76)
- # clojure-spec (325)
- # clojure-taiwan (3)
- # clojure-uk (28)
- # clojurescript (80)
- # clojurewest (2)
- # core-async (36)
- # core-logic (1)
- # cursive (21)
- # datomic (16)
- # dirac (18)
- # docs (2)
- # emacs (1)
- # euroclojure (3)
- # garden (3)
- # gsoc (2)
- # hoplon (3)
- # immutant (4)
- # jobs-discuss (16)
- # lein-figwheel (5)
- # liberator (17)
- # lumo (19)
- # off-topic (2)
- # om (20)
- # onyx (28)
- # pedestal (50)
- # planck (4)
- # re-frame (5)
- # reagent (3)
- # ring-swagger (13)
- # spacemacs (1)
- # specter (43)
- # testing (3)
- # timbre (3)
- # uncomplicate (1)
- # vim (2)
- # yada (4)
@seancorfield How do you understand which functions should be part of core and which ones not?
What would be cool is a public utility functions library. So people can easily copy functions put together by others. Not a library you pull down but a reference online.
@grounded_sage like clojure-cookbook (which I discovered yesterday)
@foamdino I was thinking that. But I think something even more like http://clojuredocs.org where the function is described anyone can put in examples etc. Then maybe people could vote, comment on them etc
one resource when I was learning to use pandas (the python dataframe library) was a paste that had a bunch of interesting snippets the creator had used frequently. Something like that might be useful but for anything else a google search for a stack overflow post is more useful.
That is works fine in repl, but just in the function changed the variable (binding). How can I modify the map (like global variable)?
that is work too.. but not update the original variable which contains the user data (it loaded once from the database, when started the website)
You may be looking for atom
and swap!
alter-var-root!
lets you change the value of a var, but many would advise only going down that path with very good reason
yes, that would be much more common, putting an atom value in a var
That would set the value of the user
var to the current value of the thing referenced by userdb
@sb the documentation for Friend is using users
as a substitute for a real database, so the example will be simple.
I tried with that too
(let [user {"ewq" {:username "ewq"
:password (creds/hash-bcrypt "pass")
:roles #{::user}}}]
(friend/merge-authentication (ring.util.response/redirect "/testdb2") user))
If you are just trying to learn Friend, it’s ok to use an atom instead of an immutable variable
I am looking at the Friend example here: https://github.com/cemerick/friend
If you would like to be able to make changes to that “toy” user database, you can define it like this:
Then you can update it with (swap users assoc username {:username “joe” :password “whatever” :roles #{::user}})
or (swap users assoc ”joe" {:username "joe" :password "whatever" :roles #{::user}})
oops, make that swap!
not swap
, I always do that derp
by the way @sb if you haven’t looked at Buddy you might want to take a look, as a possible alternative to Friend https://github.com/funcool/buddy