News for hackers. Stuff that matters.
Re:Weather reports with curl by ternaryoperator on Sunday July 08, 2018 @11:13PM (#17487727)
> curl is a program that is included in your Mac OSX distribution used for transferring data from or to a server.

For newbies who might be misled, cURL is available on a ridiculous number of platforms[1]

[1] https://curl.haxx.se/download.html

Re:Weather reports with curl by theptrk on Monday July 09, 2018 @03:00AM (#17488435)
^ definitely right, I kind of write my blog as a peripheral extension of my brain so I forget there are other computers.
Re:Weather reports with curl by gkya on Sunday July 08, 2018 @07:52PM (#17486986)
Nice! The http://wttr.in website shows a nice report too.

If you use emacs, I've made this [1][2] which gets its data from DarkSky.net.

[1] https://github.com/cadadr/elisp/blob/master/forecast.el

[2] https://raw.githubusercontent.com/cadadr/elisp/master/foreca...

Re:Weather reports with curl by theptrk on Monday July 09, 2018 @03:05AM (#17488450)
yeah interestingly enough, `wttr.in` uses `wego` which (according to their github) uses `forecast.io` as the default weather service, but if you click on the link, it forwards you to `darksky.net`. So you've built your own wttr.in
Re:Weather reports with curl by igor_chubin on Monday July 09, 2018 @03:46AM (#17488600)
wttr.in uses its own version of "wego" with many additional features, forked from wego several years ago. Actually, it would be better to say, that wttr.in uses only artwork from "wego".
Re:Weather reports with curl by theptrk on Monday July 09, 2018 @11:16AM (#17490831)
thanks for making wttr igor! sorry about rate limiting this post might have caused, which api does wttr.in use? I think I'll write about setting up your own weather service api account next.
Re:Weather reports with curl by gkya on Monday July 09, 2018 @05:25AM (#17488973)
DarkSky was forecast.io when I wrote forecast.el, they renamed.
Re:Weather reports with curl by samcheng on Sunday July 08, 2018 @09:24PM (#17487335)
My favorite text-based weather report is definitely the "discussion" product from the National Weather Service. It gives some perspective, instead of just the numbers. Importantly, it commonly has a discussion of forecast confidence/uncertainty.

If you read it long enough, you'll start to pick up some of the 'why' in the weather.

Here's an example:

https://forecast.weather.gov/product.php?site=NWS&issuedby=M...

I suppose you could curl it...

Re:Weather reports with curl by craftyguy on Monday July 09, 2018 @01:12AM (#17488103)
How stable is the output here? I noticed sections are delimited by '&&', and start with '.<SECTION TITLE>...'.

If it's stable, then it might be fun to write a cli client to query/display this..

Re:Weather reports with curl by aftbit on Monday July 09, 2018 @02:50AM (#17488409)
Five minutes in python3 + requests:

  #!/usr/bin/python
  import requests
  import re
  
  SHOW_GROUPS = ['SYNOPSIS', 'DISCUSSION', 'MTR WATCHES/WARNINGS/ADVISORIES']
  CITY = 'MTR'
  
  txt = requests.get('https://forecast.weather.gov/product.php?site=NWS&issuedby='+CITY+'&product=AFD&format=txt&version=1&glossary=0', timeout=30).text
  
  m = re.search(r'(?mis)<pre class="glossaryProduct">(.*)</pre>', txt)
  groups = m.group(1).split('&&\n')
  for g in groups:
      m = re.search(r'\.(.*?)\.\.\.', g)
      if m and m.group(1) in SHOW_GROUPS:
          print(g.strip()+'\n')
Re:Weather reports with curl by craftyguy on Monday July 09, 2018 @01:44PM (#17492017)
Yep, not hard if the input is somewhat stable...
Re:Weather reports with curl by samcheng on Monday July 09, 2018 @01:34AM (#17488181)
Probably quite stable; this stuff dates back to the telegraph...
Re:Weather reports with curl by craftyguy on Monday July 09, 2018 @02:10AM (#17488299)
source?
Re:Weather reports with curl by samcheng on Monday July 09, 2018 @02:17AM (#17488315)
Re:Weather reports with curl by craftyguy on Monday July 09, 2018 @01:46PM (#17492030)
That does not mention that the format of 'discussions' has been stable since the telegraph.. which is what I was asking about. Not the history of the NWS.
Re:Weather reports with curl by moreentropy on Monday July 09, 2018 @04:49AM (#17488813)
Video of wttr.in author's short talk about console oriented services at CCC/entropia's GPN18 conference two months ago:

https://media.ccc.de/v/gpn18-164-using-and-creating-console-...

Re:Weather reports with curl by Bromskloss on Monday July 09, 2018 @09:29AM (#17489985)
What's going on with the terminal resizing there? Is someone else controlling it?
Re:Weather reports with curl by yakshaving_jgt on Monday July 09, 2018 @03:58AM (#17488643)
Nice. You can also get a little weather indicator based on your IP address in your tmux status bar. Sorry to push my own stuff, but many people have enjoyed this:

https://jezenthomas.com/showing-the-weather-in-tmux/

Re:Weather reports with curl by andreineculau on Monday July 09, 2018 @01:32AM (#17488168)
Alternative: finger and the Norwegian weather service YR - https://github.com/ways/pyyrascii
Re:Weather reports with curl by Symbiote on Monday July 09, 2018 @02:17AM (#17488316)
YR essentially request that only users from Norway/Scandinavia use the service.

https://om.yr.no/info/verdata/free-weather-data/

Re:Weather reports with curl by bionoid on Monday July 09, 2018 @07:43AM (#17489500)
If you are delivering software or hardware products that include weather forecast, do not rely on anyone else's API directly. Build a wrapper service and direct your clients there.

As a particularly disasterous example, the Yahoo Weather API was unchanged for the longest time. Integrators worldwide deployed thousands - no probably millions - of systems using an unofficial "Yahoo Weather Module". It was the canonical solution.

Then they made a breaking change to the API and everyone cried.

Re:Weather reports with curl by craftyguy on Monday July 09, 2018 @12:56AM (#17488053)
On zsh, I had to surround the url in quotes since it (zsh) kept trying to handle the '?'
Re:Weather reports with curl by Fnoord on Monday July 09, 2018 @05:41AM (#17489055)
I like it (the usage of ascii chars to draw the weather, the usage of arrow for wind direction, the articulation on temperate with color)

The geolocation is off (as usual) because it uses the same DB as ipleak.net and others which is wrong for my (semi static) cable IPv4. I don't mind though, I just add some city.

It doesn't show well in a standard 80x25 terminal either, and that I do mind. That's my main issue with it.

So I ended up with:

n=0 ; while (( $n <= 72 )) ; date ; do curl wttr.in/~Amsterdam?0 ; sleep 1200 ; n=$(( n+1 )) ; done

Which grabs the weather every 20 min for 24 hours straight after which it has to be restarted. Not sure how it deals with laptop's suspend though.

watch -cn 1200 didn't work for me because while it does parse the ascii colors, it doesn't show them.

Since that hammers the servers though I'd write an alias for wttr.in/~Amsterdam?0 such as 'gcw' ("get current weather") or something like that.

Anyway, instead of having a dedicated terminal for this open (e.g. in Tmux) its probably better to queue for this every X minutes in Tmux statusbar as someone else suggested.

For now though I just use the KNMI application on Android though which gives a notification in the morning and evening about the weather (the evening one also describing the forecast for next day). Its basically as if watching the weather forecast on TV. I get the notification on my smartwatch as well (Pebble 2).

Also, this doesn't beat Android's Buienalarm push notification service which alerts you right before it is going to rain on current location plus locations you specified (home, work, family, etc)

Re:Weather reports with curl by BurnGpuBurn on Monday July 09, 2018 @06:12AM (#17489167)
To create the last bit you could use the Buienradar radar service at https://gps.buienradar.nl/getrr.php?lat=xx.xx&lon=yy.yy which is updated every five minutes and returns a table with precipitation predictions for the next two hours. To calculate how much it'll rain precisely use the formula 10^((value-109)/32) on the first column to get to mm/h (eg a value of 77 is equal to 0.1mm/h.) I assume this is just a couple of radars or perhaps just one in The Netherlands.
Re:Weather reports with curl by danso on Sunday July 08, 2018 @09:16PM (#17487307)
Given that `curl` was initially created to make it easier to fetch currency rates for IRC, seems very apt for users to learn to use it for everyday things like checking the weather

https://youtu.be/Lq2ksox21Eg?t=6m11s

Re:Weather reports with curl by emwjacobson on Sunday July 08, 2018 @08:18PM (#17487093)
Calling it on its own always returns the weather for Ottawa. Id expect it to use the requesting IP's location at the least. Using wttr.in/~LosAngeles returns the weather for "Rua Professora Maria Losângeles Navarro", a street in Brazil.
Re:Weather reports with curl by moviuro on Monday July 09, 2018 @03:27AM (#17488534)
You're looking for `http://wttr.in/Los%20Angeles`
Re:Weather reports with curl by opk on Monday July 09, 2018 @05:28AM (#17488988)
It gives me the weather for "Italy, United States of America". So having got the country of Italy from the geolocation, it must then be doing a US-centric text search for the location.

The weather report is nice but doesn't work too well with rxvt-unicode or with a light-coloured background.

Re:Weather reports with curl by sudosushi on Sunday July 08, 2018 @09:17PM (#17487313)
Mine returned Oymyakon, Russia. Nearly 8,000km from my location, or IP address geoloc. I'm assuming it's possibly picking up some hop in between, maybe?
Re:Weather reports with curl by jedberg on Sunday July 08, 2018 @09:30PM (#17487356)
Mine too, but at the very bottom, it says "We were unable to find your location so we have brought you to Oymyakon, one of the coldest permanently inhabited locales on the planet."
Re:Weather reports with curl by 4O4 on Monday July 09, 2018 @01:18AM (#17488122)
There's an explanation below the weather table:

> We were unable to find your location so we have brought you to Oymyakon, one of the coldest permanently inhabited locales on the planet.

Re:Weather reports with curl by theptrk on Monday July 09, 2018 @03:02AM (#17488442)
I have no idea how it parses text. `curl wttr.in/~LosAngelesCA` gave me an address in Russia `curl wttr.in/~LosAngeles,CA` gave me LA in California
Re:Weather reports with curl by gkoberger on Sunday July 08, 2018 @08:58PM (#17487229)
For me, it used my IP and got the correct location.
Re:Weather reports with curl by bkanber on Sunday July 08, 2018 @09:06PM (#17487262)
It found my correct location automatically.
Re:Weather reports with curl by hyperpallium on Monday July 09, 2018 @12:06AM (#17487915)
Very nice. But can't you adjust column width for mobile terminals.

docs: https://github.com/chubin/wttr.in/blob/master/README.md

Re:Weather reports with curl by mongol on Monday July 09, 2018 @04:34AM (#17488757)
Nice. But wind speed when expressed in SI units are more often expressed as m/s rather than km/h.
Re:Weather reports with curl by Bromskloss on Monday July 09, 2018 @09:01AM (#17489854)
> Notice that wttr is returning ASCII characters.

The wind arrows are not ASCII. Not that I have any trouble with that.

Re:Weather reports with curl by theptrk on Monday July 09, 2018 @09:24PM (#17494753)
Update. Thanks!
Re:Weather reports with curl by theptrk on Monday July 09, 2018 @10:56AM (#17490610)
oh no I think we maxed out the API calls. "Sorry, we are running out of queries to the weather service at the moment. Here is the weather report for the default city (just to show you, how it looks like). We will get new queries as soon as possible."
Re:Weather reports with curl by swanlyk on Monday July 09, 2018 @03:02PM (#17492585)
Can anyone suggest any other good curl-able datasets for other domain areas?
Re:Weather reports with curl by theptrk on Monday July 09, 2018 @09:25PM (#17494763)
The author also created “rate.sx” for bitcoin prices
Re:Weather reports with curl by charleyma on Sunday July 08, 2018 @09:13PM (#17487289)
Love simple services that do exactly what you would expect
Re:Weather reports with curl by fastbmk on Monday July 09, 2018 @04:14AM (#17488703)
Re:Weather reports with curl by icebraining on Monday July 09, 2018 @05:30AM (#17488994)
You should say "free for now" or "free during beta". "Free, no ads and no data collection" just make me wary.
Re:Weather reports with curl by Jaruzel on Monday July 09, 2018 @06:24AM (#17489220)
I have curl installed on Windows 10... this is what I got:

https://imgur.com/xOAUhOU

Well done Windows, well done. ;)

(Yes, I know why it looks crap)

Re:Weather reports with curl by fergie on Monday July 09, 2018 @03:49AM (#17488617)
Wow- the thunder animation is pretty cool
Re:Weather reports with curl by Bromskloss on Monday July 09, 2018 @09:11AM (#17489904)
Where do you see that?
Re:Weather reports with curl by rmbeard on Monday July 09, 2018 @01:13AM (#17488108)
Worked beautifully for me. Love it.