This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-16
Channels
- # admin-announcements (44)
- # adventofcode (2)
- # avi (1)
- # beginners (22)
- # boot (328)
- # cider (1)
- # cljs-dev (6)
- # cljsrn (29)
- # clojure (164)
- # clojure-chicago (1)
- # clojure-dev (7)
- # clojure-nl (5)
- # clojure-russia (73)
- # clojure-seattle (1)
- # clojure-turkiye (2)
- # clojured (1)
- # clojurescript (98)
- # core-async (6)
- # cursive (26)
- # datomic (9)
- # editors (5)
- # emacs (41)
- # events (3)
- # garden (2)
- # hoplon (125)
- # ldnclj (18)
- # om (178)
- # omnext (8)
- # onyx (5)
- # parinfer (1)
- # proton (5)
- # re-frame (20)
@spei: sure, here it is https://www.refheap.com/112736
hmmm....I seem to be really bad at transducers as i'm not sure how to solve this problem with transducers...
Its not very good, but i tried to pull it apart a little https://gist.github.com/ship561/2e3f3664c2f0bf3676f9
on the bright side, each of those xf1 and xf2 functions are supposed to be the composable transducing functions, which I think is what they are supposed to look like
is there a good example of a 'close over environment variable by accident at compile time' bug?
i had a long discussion with someone at work today about it. the long and short of it is that they thought that if you had (def charnock (System/getenv "CHARNOCK"))
in an ns, that it would somehow freeze at that value at compile time.
to prove this wasn't the case i gave them an example that printed the value of the def
and ran it with multiple CHARNOCK=foo
s using java -jar
and indeed everything was fine.
they gave me a counterexample like this
(def charnock (if-not (System/getenv "CHARNOCK") (throw (Exception.)) (System/getenv "CHARNOCK"))
even though if you do set it you can still reset it at runtime in that process's environment
it came down to his mental model being that somehow the (def charnock (System/getenv …
call being frozen at the time of compilation whereas i knew that it would maintain its fluidity
but i still have it in the back of my head that it's possible to close over compile time scope in someway due to aot compilation. i just can't think of how
@timvisher: I know what you mean, though I can’t remember the exact circumstances, AOT sounds right though
Anyone here can help me with something in hiccup
?
Don’t ask to ask, just ask
The drop-down
is like this: (drop-down attr-map? name options selected)
, how can I format options
in order to allow a custom :value
with a different label such as: [:option {:value id} label]
?
If I use map
and do [:option {:value id} label]
without making use of drop-down
, I cannot specify selected
without writing an ugly hack
Anyone got any bright ideas?
hi, can someone help me with how I would get pull-person-attrs
to bring that vector into the quoted form returned by find-person
please?
(def pull-person-attrs [:entity/uuid
:person/name
:person/token])
(def find-person
'[:find (pull ?person pull-person-attrs) . :in $ ?person])
@davebryand: do you want generate the [:find ..] vector from [:entity/uuid …] ?
@trancehime: Do you just want to jam [:option {:value id} label]
into options
, so this question can be answered without knowing about hiccup?
I... guess? The way I'm doing it now I'm just setting options
as a vector containing the stuff I want to pass in a form, so just a vector of id
. Of course when it's rendered that's not helpful to the end-user since there's nothing to indicate what the ID is actually assigned to
Oh I see - so its a hiccup question. I hoped it might be answered just with clojure knowledge.
Sorry >_>
hiccup.form
its basically just a shorthand way of writing a <select></select>
in HTML
Each option
needs a value
attribute. And you are giving that attribute but still it does not display?
that is correct.
I do not know how to format the options
vector in drop-down
such that :value "volvo"
and "Volvo" can be different
since I am populating the selectable fields from a database
or rather, selectable choices
Hmm - with map
you can create anything out of anything, just has to be same number of them.
I've already been using map
to format the data
https://github.com/weavejester/hiccup/blob/1.0.5/src/hiccup/form.clj#L77 <-- Perhaps help me make sense of this
I can only use map
to have drop-down
give me [:option {:value "something"} "something"]
when I want [:option {:value "something"} "Actual Term"]
i'm not sure that helps given drop-down
's options
argument only accepts 1 collection
it passes that collection to something called select-options
which I have linked
I think I have to do a vector of vectors
[["something" "Actual Term"] ["something2" "Term 2"]]
I have no idea, but I need to go so I'll see if it works another time
thanks for hearing me out
(def input [["something" "Actual Term"] ["something2" "Term 2"]])
;; @trancehimeNew lib released this morning for those lucky people using DynamoDB: https://github.com/mixradio/faraday-atom just thought I'd plug it here before putting out on mailing list tonight
Hello , I try to register a user. Therefore I use a last-login which has to be a time. But the user have not logged in. How do I make a dummy time object for this ?
How do people usually handle accept mimetypes on api endpoints? Does bidi/ring have anything built-in?
I want to change the response based on the accept header
throws
CompilerException java.lang.RuntimeException: No such namespace: my-ns, compiling:...
this could do the job but doesn't seem popular for something i expect is very common: https://github.com/rufoa/ring-middleware-accept
@denik: The keys in a defrecord
become local variables within the body of methods the record implements. They also compile into Java instance fields.
@stuartsierra: thanks. I’m going from datomic/datascript hash-maps to records. Is that uncommon? Or do people remove all the namespace prefixes to do that?
@denik: If you have maps with namespaced keys to start with, it's probably easiest to leave them as maps.
@stuartsierra: ok makes sense. Thank you!
We should have another RC coming out soon.
Hard to predict time from there to release but hopefully not too long
That lets you create DateTime objects and coerce them into whatever format you want/need
hello fellow Clojurians. I wrote up a post mortem on a production bug in our Clojure service. Just thought I would share it: http://techblog.roomkey.com/posts/too-many-files.html
nice writeup!
I'm sure it will help some poor soul down the line :)
ha! yes, I did not find much on the googles when I initially began debugging this problem
prob out of file descriptors ;)
hmm, I don't see any problems at the moment, it's just static content on an s3 bucket, should be pretty resilient
@pbostrom: http://techblog.roomkey.com does not resolve
in the meantime, this works:http://techblog.roomkey.com.s3-website-us-east-1.amazonaws.com/
I could not find any good tutorial or book to learn how to make authentication work with buddy or friend
@roelof: maybe this is helpful enough? https://adambard.com/blog/clojure-auth-with-buddy/
sorry I mean a tutorial of how I can make a user registering and storing in a database and the autherisation
There is a get and a post route. I thought the first needed to point only to the page which holds the registration form
@snowell: the most critical of those -v fns were created, but did not want to create an entire alternate universe of vector fns
at this point, you can get the identical effect with transducers
@roberto: I have this so far in my routes.clj :
(ns clcommerce.routes.home
(:require [clcommerce.layout :as layout]
[compojure.core :refer [defroutes GET]]
[ring.util.http-response :refer [ok]]
[ :as io]))
(defn home-page [req]
(layout/render
"home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
(defn about-page []
(layout/render "about.html"))
(defn login-page [req]
(layout/render "login.html"))
(defn save-message![req]
)
(defroutes home-routes
(GET "/" [] (home-page))
(GET "/about" [] (about-page))
(GET "/login" request (login-page request))
(POST "/" request (save-message! request))
@alexmiller: Oh yeah, I understand it would be completely unneeded. Just a random thought I had
and I think the save message needs to be something like this : (store/add-user! ds (update-in user [:password] #(hs/encrypt %))))
the add-user is in another ns and looks like this :
(ns acme-auth.store
(:require [clojure.java.jdbc :as jdbc]
[buddy.hashers :as hs]))
(defn add-user! [ds user]
(jdbc/with-db-transaction [conn ds]
(let [res (jdbc/insert! conn
:user
{:name (:name user) :admin (:admin user) :last-login NULL :is_active true :password (:password user)})
user-id ((keyword "scope_identity()") (first res))])))
I’m sorry. I don’t think I follow. I don’t see where in your routes you are adding users or authenticating them.
but none of your routes is adding users, at least none of the routes you pasted. So I’m at a little loss.
would love help on a simple clojure question, please. I’m trying to get pull-board-attrs
to be used in the find
vectors in find-board
and find-boards-for-person
, but not sure how to do that in this quoted form. Should I just use a function instead?
(def pull-board-attrs [:entity/uuid :board/name])
(def find-board
'[:find (pull ?board pull-board-attrs) . :in $ ?board])
(def find-boards-for-person
'[:find [(pull ?board pull-board-attrs) ...] :in $ ?person
:where [?person :person/boards ?board]])
Ok, I think I got it. Does this look idiomatic or am I barking up wrong trees?
(def pull-board-attrs [:entity/uuid :board/name])
(def find-board
`[:find (pull ?board ~pull-board-attrs) . :in $ ?board])
nope, that’s not it
@danielstockton: i'm the guy who made rufoa/ring-middleware-accept - it should do what you're looking for! I can't account for its lack of github stars though 😉
@rufoa I went for parsing the accept header with a regex but your library looks good if I need languages and encoding too
usually?
i mean i rarely capitalize anything but if i'm in proper-grammar-mode then i do
@davebryand: you should be able to send in pull-board-attrs as an argument (assuming you'll eventually do a datomic/query call)
Hey everyone! I am trying to understand how compojure-api deals with middleware. In particular, I want to set a middleware for a group of routes. Until now, I have accomplished it for a single endpoint (repeating the same code for the others) doing this:
@rcanepa: You can use :middlewares
with context*
Reading the docs, wasn’t enough for me to understand how to set the middleware for all the endpoints of the context.
Somethings seems magical to me right now (I have been working with Clojure for less than a month)… so to understand the basis of how compojure-api works, should I dive into the ring and compojure code bases?
Yes, Compojure-api is quite magical
sorry, I hate to be down on something because there are people behind projects, but peek under the covers of compojure-api vs compojure itself
Back to context*, if you have path-parameter in the context path, you should be able to use :path-params
with context, but I'm not sure if documentation works correctly with that
Great… I want to learn how it works and I have time to read the other code bases. So if you say that I should peek on compojure’s code, I will.
@rcanepa: There's a test about using :path-params
with context*
, so it should work correctly: https://github.com/metosin/compojure-api/blob/master/test/compojure/api/integration_test.clj#L613-L622
Clojure 1.8.0-RC4 is now available https://groups.google.com/forum/#!msg/clojure/DctHC7ip0Tg/ikDd9hwxBQAJ
@juhoteperi: Thanks, I will read it too.
thanks @oli — i’ll give it a shot
okay, so hello world on installing a template for local use
getting
$ lein new my-template foo
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Failed to resolve version for my-template:lein-template:jar:RELEASE
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Could not find template my-template on the classpath.
$
not sure what I’m doing wrong—I did little other than lein new template my-template —to-dir my-template-dir
and then lein install
inside of my-template-dir
what dumb thing am I doing (or not doing)?
lein version is 2.5.1
@ddellacosta: You need to add the --snapshot
flag to the command: lein new my-template foo --snapshot
(I tend to just remove the -SNAPSHOT part of the project version, usually)
oh, I didn’t realize that was the issue there…gotcha, thanks