Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Millner sammillner

  • Ghyston
  • Bristol, UK
View GitHub Profile
@sammillner
sammillner / Senate
Created Sep 30, 2020
Fivethirtyeight senate forecast
View Senate
//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) + "%"
@sammillner
sammillner / Forecast
Created Sep 30, 2020
Fivethirtyeight general election forecast
View 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) + "%"