journal (Thu May 21 2020)

Today I learnt

  • #jsonapi
  • #stocks
  • #rails

Learnt about the structure of JSONAPI error format

Here's an example

{
  "errors": [
    {
      "status": "422",
      "source": { "pointer": "/data/attributes/firstName" },
      "title":  "Invalid Attribute",
      "detail": "First name must contain at least three characters."
    }
  ]
}

https://jsonapi.org/examples/#error-objects-basics

HTTP status codes Learnt that 4xx is for when the error is due to the client and 5xx is when the server is aware that the error is due to the server https://www.w3.org/Protocols/HTTP/HTRESP.html

Learnt about the shape of error objects in axios https://github.com/axios/axios/issues/960#issuecomment-554680380 Basically, you have error.response which has properties like status


Learnt about a youtube channel on growth investing by Joseph Carlson https://www.youtube.com/channel/UCbta0n8i6Rljh0obO7HzG9A

Payout ratio for a stock - The percentage of its earnings a compay pays out as dividends. The higher this number, the worse the stock. Because then the company is not investing its profits to grow and simply paying it out.


Learnt about the difference between various attribute accessors in rails cattr_accessor is not available on services, but it is on controllers.

https://medium.com/selleo/comparison-of-class-level-accessors-in-ruby-on-rails-40605d92a7a

If you dont pass a keyword argument to a ruby function, it uses a default. If you pass in null, it uses null and omits the default.

Other notes https://thoughtbot.com/upcase/videos/ruby-keyword-arguments https://thoughtbot.com/blog/ruby-2-keyword-arguments

Using hash.fetch is pretty much like lodash.get