From 26ccdacf6605492a9232721e39e616506e9f5d25 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Sun, 29 Sep 2019 21:50:20 -0400 Subject: [PATCH] Convert fish script to Bash --- .gitignore | 2 +- dark-sky.fish | 15 --------------- dark-sky.js | 3 ++- dark-sky.sh | 16 ++++++++++++++++ todo.md | 11 ++++++----- 5 files changed, 25 insertions(+), 22 deletions(-) delete mode 100755 dark-sky.fish create mode 100755 dark-sky.sh diff --git a/.gitignore b/.gitignore index 7909ae4..5f1e7d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.txt -api-keys-fish.sh +api-keys*.sh *.json # node {{{ - diff --git a/dark-sky.fish b/dark-sky.fish deleted file mode 100755 index 3d36150..0000000 --- a/dark-sky.fish +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/fish - -source api-keys-fish.sh - -# takes (coords, location_name) as parameters -function update-weather-json - set curl_url "https://api.darksky.net/forecast/$DARK_SKY_KEY/$argv[1]?exclude=minutely%2Cdaily%2Calerts%2Cflags&units=auto" - curl --request GET --url $curl_url > $argv[2].json - # echo "curl --request GET --url $curl_url > $argv[2].json" -end - -update-weather-json "43.8180904,-79.3350555" "markham" -update-weather-json "43.6596426,-79.3976676" "toronto" - -node dark-sky.js > dark-sky.txt diff --git a/dark-sky.js b/dark-sky.js index 6666661..2913f23 100644 --- a/dark-sky.js +++ b/dark-sky.js @@ -70,5 +70,6 @@ logTablePromises = [ logWeatherJson('./markham.json', 'Markham'), logWeatherJson('./toronto.json', 'Toronto')] Promise.all(logTablePromises).then(results => { - log(`${CREDIT_MSG}\n\nLast updated: ${new Date().toLocaleTimeString()}`) + const now = new Date() + log(`${CREDIT_MSG}\n\nLast updated: ${now.getHours()}:${now.getMinutes()}`) }) diff --git a/dark-sky.sh b/dark-sky.sh new file mode 100755 index 0000000..c27ec62 --- /dev/null +++ b/dark-sky.sh @@ -0,0 +1,16 @@ +#!/usr/bin/bash + +source api-keys.sh + +# takes (coords, location_name) as parameters +update-weather-json() { + curl_url="https://api.darksky.net/forecast/$DARK_SKY_KEY/$1?exclude=minutely%2Cdaily%2Calerts%2Cflags&units=auto" + curl --request GET --url $curl_url > $2.json + # echo "curl --request GET --url $curl_url > $2.json" +} + +update-weather-json "43.8180904,-79.3350555" "markham" +update-weather-json "43.6596426,-79.3976676" "toronto" + +node dark-sky.js > dark-sky.txt +# node dark-sky.js diff --git a/todo.md b/todo.md index 272d197..cdae39c 100644 --- a/todo.md +++ b/todo.md @@ -1,5 +1,4 @@ # Todo -- add to my site - deliver text/HTML depending on User-Agent in header - https://nginx.org/en/docs/http/ngx_http_browser_module.html - https://www.nginx.com/resources/wiki/modules/user_agent/ @@ -7,10 +6,6 @@ - colors - ANSI escape codes - https://github.com/gabx/archlinux/blob/master/etc/scripts/colortest -- fetch on load - - Lua os.execute in Nginx - - fetch JSON in JS - - generate table dynamically - icons # Done @@ -21,3 +16,9 @@ - "Powered by Dark Sky: https://darksky.net/poweredby/" - Dark Sky image - https://darksky.net/dev/docs/terms + +# Archived +- fetch on load + - Lua os.execute in Nginx + - fetch JSON in JS + - generate table dynamically