Wednesday, April 24, 2019

Add json config to Heroku config variables

If you have a multiline JSON credentials file such the one you get from Google Firestore, you can simply do that if you already have Heroku cli installed in your machine as follows:

`heroku config:set FIRESTORE_CREDENTIALS="$(< /path/credentials.json)"`

You may also have to append the app name with `-a app-name-here`

Tuesday, April 16, 2019

Rails Benchmark Execution Time

Sometimes we need to benchmark the execution time of a code segment to check the performance.
For this we can use the `Benchmark` library available in Rails like below.

puts '====== Start benchmark ========'
time = Benchmark.realtime {
  ... Code being tested goes here ... 
}
puts time
puts '====== End benchmark =========='