Live data from Hacker News

Curl Wttr.in

github.com

61–70 of 128 posts

Re: Curl Wttr.in

#62
This is one of those services that I love when I find them, use extensively for the next 30 minutes and forget about. But I keep coming back to it!

I even spent a time to make a simple function in my shell to cut off the output after today and accept a location name

    w () {
        curl -s "wttr.in/$1?M1q" | head -17
    }
and then I can just do

    w london
to get the weather for London today.

But, like most of the functions/aliases I create, I can't remember the last time I used it (except couple of times when I see someone talking about it and I remember about it)

Re: Curl Wttr.in

#63
post #56
post #48

I will take this opportunity to offer some caution: From what I understand, “curl example.com” is almost exactly as risky as “curl example.com | bash”, since curl does not escape terminal command sequences, and those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ evil@example.com”.

> those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ evil@example.com”. oh my god. From http://www.termsys.demon.co.uk/vtansi.htm : > Set Key Definition [{key};"{string}"p > Associates a string of text to a keyboard key. {key} indicates the key by its ASCII value in decimal. But I can't reproduce it; in my terminal (gnome-terminal), `print('\x1b[97;"echo foo"p')` just sh…

No modern terminal implements any of the dangerous escape sequences.

Re: Curl Wttr.in

#64
post #48

I will take this opportunity to offer some caution: From what I understand, “curl example.com” is almost exactly as risky as “curl example.com | bash”, since curl does not escape terminal command sequences, and those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ evil@example.com”.

It was the case indeed (many many years ago), we discussed at the anuualy curl hackers conference in Nuremberg back in 2017, but the only terminals that we managed to find with the support of this were not younger than 2001.

Anyway, one can write a small filter, to cut any suspicious sequences from the output off, and add some wrapper like that to your bashrc:

curl() { [ -t 1 ] && curl "$@" | sanitize || curl "$@"; }

Re: Curl Wttr.in

#65

This is one of those services that I love when I find them, use extensively for the next 30 minutes and forget about. But I keep coming back to it! I even spent a time to make a simple function in my shell to cut off the output after today and accept a location name w () { curl -s "wttr.in/$1?M1q" | head -17 } and then I can just do w london to get the weather for London today. But, like most of the functions/aliases…

Just add `F` to the options, and you don't need `| head -17` then

Re: Curl Wttr.in

#66
post #60

Very cool, if i could suggest improvements it would be another view that shows some sort of line graph of temperature and rain and sunshine hours. Also thanks for the T option - useful if your terminal has a white background( like Apple's default).

curl v2.wttr.in

and for the white background:

curl wttr.in/?I

Re: Curl Wttr.in

#68
post #22

Welcome to my alias list. This provides better weather information than local news websites who have dedicated pages. That said, I'm in a developing country where it's just monsoon all the damm time :D

Been using it for years here in Ireland. I have the following: alias wett='curl wttr.in/limerick'. :-)

Try this:

curl ga.wttr.in/limerick

Re: Curl Wttr.in

#69

This is one of those services that I love when I find them, use extensively for the next 30 minutes and forget about. But I keep coming back to it! I even spent a time to make a simple function in my shell to cut off the output after today and accept a location name w () { curl -s "wttr.in/$1?M1q" | head -17 } and then I can just do w london to get the weather for London today. But, like most of the functions/aliases…

Just add `F` to the options, and you don't need `| head -17` then

I wasn't sure what F you were talking about, if other people are wondering, the new command would be:

  w () {
     curl -s "wttr.in/$1?M1qF"
  }
Post reply on HN