Skip to content

Instantly share code, notes, and snippets.

@russellmcc
Created January 7, 2014 03:55
Show Gist options
  • Save russellmcc/8294421 to your computer and use it in GitHub Desktop.
Save russellmcc/8294421 to your computer and use it in GitHub Desktop.
Russell Temperature scale
http = require 'http'
kelvinToRussell = (kelvin) ->
kelvin = +kelvin
temps = [0, 273.15, 310.15, 373.15]
for i in [0...temps.length - 1]
if kelvin < temps[i + 1]
return i + (kelvin - temps[i]) / (temps[i + 1] - temps[i])
return 3 + (1 - 373.15 / kelvin)
http.get 'http://api.openweathermap.org/data/2.5/weather?q=Boston,ma', (res) ->
data = ""
res.on 'data', (d) ->
data += d
res.on 'end', ->
data = JSON.parse data
kelvin = data.main.temp
console.log kelvinToRussell kelvin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment