Skip to content

Instantly share code, notes, and snippets.

View renenw's full-sized avatar

renen watermeyer renenw

  • Cape Town, South Africa
View GitHub Profile
@renenw
renenw / sasa_analyzer.rb
Last active May 6, 2020 13:59
An ActiveStorage analyzer that pulls out GPS and other details
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
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
@renenw
renenw / four.png
Last active March 11, 2018 19:02
How to serve static HTTP content using Windows 10
four.png