Show HN: Curl https://ec2.shop
ec2.shop
ec2.shop
So I develop this small tool which you can do thing like
curl https://ec2.shop
curl https://ec2.shop?region=us-west-2&filter=t2,m4Do you not need to escape the ampersand in the second example? otherwise bash will run it in the background and skip the `filters=t2,m4` part.
So if you are thinking of CP-437 or Windows-1252 I suppose that's fair, but generally in the context of terminal apps "ANSI" without qualification refers to the escape sequences.
Now I am curious though, did ANSI the standards body have any official character encoding standards?
I just implement it: https://github.com/yeo/ec2.shop/commit/ab258aef3ac2ad3d45b26...
Now by default it's text mode, so request by http client library or tool like curl, wget, httppie all get text bersion.
Only when detecting `Accept` contains `html` and user agent is safari/chrome/firefox etc it send html version.
diff -u <(curl -sS "https://ec2.shop?region=eu-central-1" | grep "t3.large" ) <(curl -sS "https://ec2.shop?region=us-east-1" | grep "t3.large")We're hoping to have a different sort of discussion than internet default here.
You don't get any such opportunity if the developers hard code the colour values in (and it's worse with a tool like this because you can't even set an environmental variable to change the tools behaviour)
¹ sixteen colours plus bright and dark variants
You said you can't even set an env variable to change them so I assume that there is an even better way?
I've got some Go code that you can reuse if you want to the escape codes in Go: https://github.com/lmorg/murex/blob/master/utils/ansi/codes....
Just bare in mind that any numbers you see in documentation are sent as ASCII values rather than integers. eg `ESC[31m` (red text) should be sent to the terminal as
[]byte{ // http://www.asciitable.com/
27, // ESC character code
91, // '['
51, // '3'
49, // '1'
109, // 'm'
}
Though, as you know, most languages will have some syntactic sugar to translate characters to their ASCII values, eg 'm' == 109
Asc("m") == 109
...etc...
so at least you don't have to write all those values by hand.You can obviously
curl ec2.shop | grep -v ─
but I'm not sure I want to do that every time and I'm not exactly sure why, but when I do that, I can't select the entire row, only a column at a time (zsh on iTerm 2).I don't find the colors useful. They aren't contextual at all, it's just certain columns have certain colors, for no apparent reason.
I personally try looking into implementing a curl "interface" to one of my projects, realised that it actually need to check the user-agent (of curl and a plethora of curl alternatives) which I find kind of weird...
Like someone suggested for the featured page as well, I recommend you make use of the accept header.
For example, assuming your interface is outputting freeform text (since the goal was to have something readable in terminal), you could use something like this:
Accept: text/vnd.myproject.tui+plain; version=1.0
(Substitute “myproject” with the actual name of your project.)https://github.com/yeo/ec2.shop
The reason it check `curl` agent is because it share the same endpoint (root url) for both of `curl` page and browser version(the one with dropdown, grid etc)
It would be very helpful if you would support the `Accept: application/json` header. This way, we could use it in combination with jq to do arbitrary filtering:
curl -L -H "Accept: application/json" ec2.shop | jq .I truly do not care if someone goes through the effort to MITM my curl of ec2.shop to inject fake prices or something like that.
There's nothing here that's going to be executed, it'll just be printed or grepped.
In theory you could exploit a 0 day in curl or my terminal or something like that, but I think if you truly think about the risks and tradeoffs here it's really not worth worrying about.
If curl had an hsts list to make this irrelevant that'd also be cool.
... yet.
Imagine someone using it to find "the biggest size available under $1" and then taking that value to execute some other script.
alias curl='curl --proto-default https'Since I cannot edit original comment, yes, the site is open source: https://github.com/yeo/ec2.shop
It's definitely possible and not very challenging, but the API Documentation for prices was pretty weak when I built it (a year or two ago, written in Go if it makes a difference). The google cloud prices API was similarly gross. It was kinda fun, but I wouldn't enjoy maintaining that code. In reality, it turns out that $/hour isn't a super straightforward metric (there are many dimensions that go into it), so it's not super straightforward to query.
I'm going to add spot instance. Will just need to figure out what URL AWS is fetching
curl -s https://ec2.shop | grep 't2'
would work, but curl -s https://ec2.shop | grep 'm4'
does not? Both commands work if I write the curl result to a file, but when I pipe from curl, the pattern `m4` matches all instances of the number 4.The color code for blue is `"\033[34m` so it always match m4 for anything :(.
Just push a fix by disabling color as suggestion in here as well
Illustration: http://dmitry.cheryasov.info/random/missing-quote-mark.jpg
$Hourly * 750
750 being the number of hours in 1 month.
curl https://ec2.shop -H 'Accept: application/json'
curl https://ec2.shop -H 'Accept: application/json'
curl 'https://ec2.shop?json'
curl 'https://ec2.shop?txt'