layout | title | header_img | description |
---|---|---|---|
post |
Things I Learned This Week: May 16-20, 2016 |
nyc-skyline.jpg |
What I learned this week. |
Dash
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.
Ecto.Query.order_by/3
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.Changeset.foreign_key_constraint/3
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:
{% highlight elixir %} # 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 assoc_constraint(:author)
foreign_key_constraint(:some_custom_changeset_key, name: :some_database_fkey, message: "bad data!") {% endhighlight %}
Singlecut Beersmiths
A brewery from my native Queens, NY. I had the Billy Half-Stack IPA, and I'd drink it again!