Fork me on GitHub
#beginners
<
2017-05-23
>
leontalbot15:05:25

Do you have a good tutorial for simple buddy integration?

jumar15:05:39

@leontalbot perhaps https://lambdaisland.com/episodes/buddy-authentication ? - but it's not free. you can still look at the source code: https://github.com/lambdaisland/booklog/tree/ep28-start. However, if you're interested in more than one episode consider subscribing - it's really worth it.

leontalbot15:05:48

Saw it, thanks! It uses component. Was curious about a ring integration

noisesmith15:05:39

it’s not possible to use buddy without ring as far as I know

noisesmith15:05:56

component and ring do completely different things, and are often used together

deg16:05:21

(Testing in CLJS 1.9.542), I get an error "could not find tag parser for :user ..." trying (cljs.reader/read-string "#:user{:a 1 :b 2}"). What is the correct way to read a namespaced map?

alexmiller16:05:34

Seems like CLJS 1.9.542 should know how to read namespaced maps, shouldn’t it? I thought that was added a while ago.

deg16:05:20

#:user{:a 1 :b 2} does work just fine.

deg16:05:54

Do I need to wrap some binding, or use something other than cljs.reader/read-string?

alexmiller16:05:17

not sure. tools.reader, which the cljs reader uses supports namespaced maps. I’m not clued in enough to know the difference between that and cljs.reader/read-string.

fingertoe17:05:27

So I have a db query that returns me a keyword :[email protected]@prev When I filter with that, it gives me symbol prev unknown error. Is there an escape char or the like to make it work, or do I need to rename my result?

noisesmith17:05:44

@fingertoe I prefer to not keywordize, but you can just use (keyword "[email protected]@prev") also

noisesmith17:05:12

it’s not a valid keyword according to the reader rules, but you can make a keyword out of anything that can fit in a string (for better or worse)

noisesmith17:05:29

it might be that it’s cumbersome to turn off the keywordizing (depending on your db library) but I recommend just not turning random garbage into keywords in the first place

fingertoe17:05:14

I am using clojure.java.jdbc with “com.ibm.as400.access.AS400JDBCDriver” Not sure how to turn that keywordize switch on or off.. The (keyword “[email protected]@prev”) does make my filter work.

fingertoe17:05:32

I’d suppose the right answer is to Select as and give it a keyword that is legit.

noisesmith17:05:20

that would work too - I’m surprised there’s no easy way to just get the keys as strings

drewverlee19:05:56

Random question of the day. When does it make sense to not use a single hashmap as the argument to your function. It seems like the typical thing to do in most languages is to expect an ordered list of arguments.

def full-name(first , last): 
   ...
but do we really care about the order? When would using a list be better then a hashmap with validation checks?

ghadi19:05:38

great question. for me list vs hashmap is about extensibility. If you choose a list, and make a change where you need to require more arguments, now you have to change every single calling signature. Hashmaps are associative and represent an open information model... you can just add a key and choose to use it or not.

dpsutton20:05:03

and makes the default values super simple. in c# this is nice but requires a language feature. Method(arg3: val3, arg2: val2) vs (method {:arg3 val3 :arg2 val2})

dpsutton20:05:41

ah but a reason to not use a map is so that you can use apply easily with it

deg20:05:06

I can only think of two cases where an ordered list is better: 1) when efficiency really matters. (and these cases are increasingly rare; and I'd imagine that any half-decent compiler can optimize most real cases anyway). 2) when the function is so simple that the mental overhead of typing/reading the argument keywords is greater than the flexibility that they give.

donaldball20:05:36

If there is a set of required args, I will always want to see them as explicit args, in order from the most general to least general, or least variable to most variable

noisesmith20:05:41

but the clojure compiler doesn’t do those kinds of optimizations

dpsutton20:05:10

And then there are obvious cases: can't imagine map taking {fn: #(inc %) :coll [1 2 3]} or addition taking a map of things to add rather than just a list

dpsutton20:05:30

just to point out the simple case to "when does it make sense to not use a single hashmap as the argument to your function".

lilactown20:05:52

yeah, it breaks things like threading, apply, map, reduce, etc.

lilactown20:05:10

you lose a lot of the functional-y syntax tricks

drewverlee20:05:59

Thanks for all the feedback! :+1: