8 ms·
From time to time, I want a quick tool to help me compare EC2 instances price. https://ec2instances.info/ https://ec2instances.info/ works great but it's somewh
by kureikain 6y ago
From time to time, I want a quick tool to help me compare EC2 instances price. https://ec2instances.info/ https://ec2instances.info/ works great but it's somewhat slow and didn't have a way to just `curl` from terminal.
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,m4
- tinhspace 6y agoThank you so much. Going to try this one, very useful tool.
- simedw 6y agoUseful tool! Do 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.
- bdcravens 6y agoYes, but many terminals will escape it for you if you paste in.
- JimDabell 6y agoAre you manually detecting Curl specifically? If I use anything other than Curl, e.g. HTTPie or wget, I get the HTML page, even if I provide an `Accept: text/plain` request header. If I use one of those tools and spoof the Curl user agent string, I get the text/plain response. You should probably just look at the Accept request header, it’s there specifically so clients can tell you what kind of response they want.
- jasonjayr 6y agoThere should be a new mime type for this: text/x-ansi
- gruez 6y agobut why "ansi"? ANSI is only an encoding. You can have html that's in ansi, and you can have something like OP's that's not in ansi (eg. if you add emojis).
- geofft 6y agoThis is "ANSI" as in ANSI X3.64 escape sequences, not "ANSI" as in a character encoding. You can output color to curl on an ANSI-compatible terminal but not to something expecting actual plain text like a browser.
- skissane 6y agoI think text/ecma48 would be a better name. There are lots of ANSI standards. (I guess text/ansi-x3.64 might also work, but text/ecma48 seems simpler.)
- jasonjayr 6y agoYes, I should have been more specific. text/x-term-${TERM} probably would be better, since it could be any number of terminal types...
- nitrogen 6y agoYou might be thinking of ASCII?
- gruez 6y agohttps://en.wikipedia.org/wiki/ANSI_character_set https://en.wikipedia.org/wiki/ANSI_character_set
- nitrogen 6y agoFrom the wiki: "The phrase ANSI character set has no well-defined meaning and has been used to refer to the following, among other things" 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?
- kureikain 6y agoGreat idea. I just implement it: https://github.com/yeo/ec2.shop/commit/ab258aef3ac2ad3d45b26d76304476424379a77c 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.
- karmakaze 6y agoThere should be no reason to check user agent if already checking `Accept`. That's usually more for browser quirks or allow/blocking.
- brodouevencode 6y agoAnd it has to be infinitely better than using the pricing API.