Live data from Hacker News

Curl Wttr.in

github.com

121–128 of 128 posts

Re: Curl Wttr.in

#121
post #10

A good opportunity to remind everyone that we finally inboxed curl into Windows 10, so this works (with color output) from a stock Windows command prompt. Better late than never, I hope.

No need for that. You can do this: (Invoke-WebRequest -Uri wttr.in).content from Powershell. Why not use the happy path?

Even easier with Invoke-RestMethod wtte.in

Re: Curl Wttr.in

#122
post #110

Earlier quoted context omitted.

Because it's the native Windows answer. There's no need to make Windows look like Unix. It's great (really!) the way it was designed.

Do you feel like you are typing a lot more for simple things like this?

Powershell comes installed with a lot of aliases.

Invoke-WebRequest is just iwr

Re: Curl Wttr.in

#123
post #44

Earlier quoted context omitted.

It's case insensitive and there are short aliases for commands. I live in Linux, but used it way back when. It's an object oriented shell that is kind of awesome and intuitive. Bash is great and you can get shit done, but i don't think it's as user friendly as powershell.

Honestly PS feels like yet another cryptic language with irregular/nih naming of functions and arguments (like AHK which is great, but invented its own megacryptic irrational language instead of taking something generic, and now you have to google every damn thing). If I programmed for PS, then okay, but seriously, Invoke-Rest-?Method, -Uri/Url, .content — how much semantics do you learn until you give up? I’d better…

> my console rather than this Invoke-WhatEver thing, because at least it seems programming language-y and names are consistent with all other web software.

Because curl is consistent?

> urn:isbn:0451450523

Curl can't do whatever this is either?

Re: Curl Wttr.in

#124
post #123
post #44

Earlier quoted context omitted.

Honestly PS feels like yet another cryptic language with irregular/nih naming of functions and arguments (like AHK which is great, but invented its own megacryptic irrational language instead of taking something generic, and now you have to google every damn thing). If I programmed for PS, then okay, but seriously, Invoke-Rest-?Method, -Uri/Url, .content — how much semantics do you learn until you give up? I’d better…

> my console rather than this Invoke-WhatEver thing, because at least it seems programming language-y and names are consistent with all other web software. Because curl is consistent? > urn:isbn:0451450523 Curl can't do whatever this is either?

Because that seems programming language-y and names are consistent with all other web software.

>Curl can't do whatever this is either?

Right. This is a valid URI, which Invoke-RestMethod uses as a parameter name (-Uri) and which is a unique id for a resource and not its location (it could be, but not in this particular case). They should not have call that argument “URI”, if what they actually do is fetching from a URL.

Re: Curl Wttr.in

#125
post #100

Earlier quoted context omitted.

Also very useful: curl ifconfig.co (shows your public ip)

I just use an alias myip is aliased to `dig +short myip.opendns.com @resolver1.opendns.com'

Nice. I like the curl thing because I can hop any any server and not have to worry if I setup an alias or not....I got a lot of servers I am constantly on.

Re: Curl Wttr.in

#127

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

Oh, awesome! I don't know if they added this after I created the function or if I just didn't notice it.

EDIT: I just realised that "they" is actually you!

Re: Curl Wttr.in

#128

Earlier quoted context omitted.

You could do something like this w () { curl -s "wttr.in/${*// /+}" } to make it work with places that have spaces in their name. E.g. w new york

Just use IFS for this w() { ( IFS=+; curl wttr.in/"$*";); }

I love when you can post something simple like a function/alias and learn so many new things. Never seen IFS before. Updated locally and works perfectly!
Post reply on HN