Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
Last active August 3, 2019 07:24
Show Gist options
  • Save lyoshenka/8472a31c60b6ba0c778c to your computer and use it in GitHub Desktop.
Save lyoshenka/8472a31c60b6ba0c778c to your computer and use it in GitHub Desktop.
Probability that it will rain near you in the next half-hour
# requires python, jq
# get your API key from https://developer.forecast.io/
API_KEY=
# enter the latitude and longitude for your location
LAT=
LNG=
CHANCE=$( curl -s https://api.forecast.io/forecast/API_KEY/LAT,LNG?exclude=hourly,daily,alerts,flags | jq .minutely.data[].precipProbability | head -n 30 | python -c 'import sys; print(max(float(x) for x in sys.stdin.readlines()))' )
if [[ $CHANCE > .6 ]]; then
# alert somehow
# save the fact that we alerted, then don't do it for the next X minutes
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment