Skip to content

Instantly share code, notes, and snippets.

View sammillner's full-sized avatar

Sam Millner sammillner

  • Ghyston
  • Bristol, UK
View GitHub Profile
@sammillner
sammillner / Forecast
Created September 30, 2020 06:36
Fivethirtyeight general election forecast
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
const url = "https://projects.fivethirtyeight.com/2020-election-forecast/us_timeseries.json"
const req = new Request(url)
const res = await req.loadJSON()
const Biden = Math.round(res[0].candidates.find(x => x.candidate == "Biden").dates[0].winprob) + "%"
const Trump = Math.round(res[0].candidates.find(x => x.candidate == "Trump").dates[0].winprob) + "%"
@sammillner
sammillner / Senate
Created September 30, 2020 06:39
Fivethirtyeight senate forecast
//Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
const url = "https://projects.fivethirtyeight.com/2020-election-forecast/senate_us_latest.json"
const req = new Request(url)
const res = await req.loadJSON()
const classicWinProb = Math.round(res.find(f => f.type == "classic").candidates.find(p => p.candidate == "Democrats").winprob) + "%"
const classicWinSeats = res.find(f => f.type == "classic").candidates.find(p => p.candidate == "Democrats").seats.mean.toFixed(1)
const liteWinProb = Math.round(res.find(f => f.type == "lite").candidates.find(p => p.candidate == "Democrats").winprob) + "%"