This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'exifr/jpeg' | |
# Add to your Gemfile: gem 'exifr', '~> 1.3', '>= 1.3.6' | |
# I created the file in /lib/active_storage/sasa_analyzer.rb | |
# You will also need to update your application.rb: config.autoload_paths << "#{Rails.root}/lib/active_storage" | |
# Draws on https://ledermann.dev/blog/2018/05/15/exif-analyzer-for-active-storage/ | |
class SasaAnalyzer < ActiveStorage::Analyzer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.liquid_voltage_lookup(beer_voltage, battery_voltage) | |
# solve for rt in kilos: vo = vbat * (Rt/(Rt+R1)) | |
# vbat = battery_voltage | |
# vo = beer_voltage | |
# r1 = 100 | |
temperature = nil | |
rt = BigDecimal(beer_voltage,6) * BigDecimal(100,6) / ( BigDecimal(battery_voltage,6) - BigDecimal(beer_voltage,6) ) if battery_voltage!=beer_voltage | |
if rt |
