Browse Source

Convert fish script to Bash

fix-precip
Kevin Mok 5 years ago
parent
commit
26ccdacf66
Signed by: Kevin-Mok GPG Key ID: AEA75288DC135CF5
  1. 2
      .gitignore
  2. 15
      dark-sky.fish
  3. 3
      dark-sky.js
  4. 16
      dark-sky.sh
  5. 11
      todo.md

2
.gitignore

@ -1,6 +1,6 @@
*.txt *.txt
api-keys-fish.sh
api-keys*.sh
*.json *.json
# node {{{ - # node {{{ -

15
dark-sky.fish

@ -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

3
dark-sky.js

@ -70,5 +70,6 @@ logTablePromises = [
logWeatherJson('./markham.json', 'Markham'), logWeatherJson('./markham.json', 'Markham'),
logWeatherJson('./toronto.json', 'Toronto')] logWeatherJson('./toronto.json', 'Toronto')]
Promise.all(logTablePromises).then(results => { 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()}`)
}) })

16
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

11
todo.md

@ -1,5 +1,4 @@
# Todo # Todo
- add to my site
- deliver text/HTML depending on User-Agent in header - deliver text/HTML depending on User-Agent in header
- https://nginx.org/en/docs/http/ngx_http_browser_module.html - https://nginx.org/en/docs/http/ngx_http_browser_module.html
- https://www.nginx.com/resources/wiki/modules/user_agent/ - https://www.nginx.com/resources/wiki/modules/user_agent/
@ -7,10 +6,6 @@
- colors - colors
- ANSI escape codes - ANSI escape codes
- https://github.com/gabx/archlinux/blob/master/etc/scripts/colortest - 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 - icons
# Done # Done
@ -21,3 +16,9 @@
- "Powered by Dark Sky: https://darksky.net/poweredby/" - "Powered by Dark Sky: https://darksky.net/poweredby/"
- Dark Sky image - Dark Sky image
- https://darksky.net/dev/docs/terms - https://darksky.net/dev/docs/terms
# Archived
- fetch on load
- Lua os.execute in Nginx
- fetch JSON in JS
- generate table dynamically
Loading…
Cancel
Save