Things I Learned This Week: May 16-20, 2016

May 20, 2016

This app is already indispensable to my workflow. Just check it out.

Monotonic functions
A function is called monotonic if and only if it is either entirely increasing or decreasing.

Stateless Components in ReactJS
Stateless components are pure functions of their props. They (obviously) don't have internal state, and do not call any component lifecycle methods.

Learned various ways this function can be used. The Ecto version of Rails' order("created_at desc") would be order_by(desc: :created_at).

Ecto provides the ability to capture foreign key constraint violations as errors on a changeset. The big difference to me between this function and assoc_constraint is that you can pass any key as the first argument, and Ecto will put the error on that key if the constraint fails. This is in contrast to assoc_constraint, which inflects on the key you pass in to determine what association constraint it's checking:

# Assume a post belongs to an author, lets ensure the author exists. If this fails,
# the error will be put on the "author" key in the changeset

# We can also capture some other foreign key violation,
# and put it on another key within the changeset
foreign_key_constraint(:some_custom_changeset_key, name: :some_database_fkey, message: "bad data!")

Singlecut Beersmiths
A brewery from my native Queens, NY. I had the Billy Half-Stack IPA, and I'd drink it again!