3 ms·
Creating a chart about charts.css with charts.css from the command line: ( echo "<table class='charts-css bar show-labels show-heading'>" echo
by lucb1e 6y ago
Creating a chart about charts.css with charts.css from the command line:
(
echo "<table class='charts-css bar show-labels show-heading'>"
echo "<caption>Size of Charts.css releases</caption>"
for version in $(curl -sS https://github.com/ChartsCSS/charts.css/releases | grep -o releases/tag/[0-9.]* | cut -d/ -f3 | tac); do
url=https://cdn.jsdelivr.net/npm/charts.css@$version/dist/charts.min.css
size=$(($(curl -sS "$url" | wc -c)/1024))
echo "<tr><th>v$version</th><td style='--size: calc($size/100)'>${size}KiB</td></tr>"
done
echo "</table><link rel=stylesheet href='$url'>"
) > size-chart.html
Result: https://jsfiddle.net/wcfez6oq/ https://jsfiddle.net/wcfez6oq/
Since I couldn't easily find how large it was and wanted to try it out at the same time.
- fastball 6y agoNeeds axis labels! Nice script tho.
- lucb1e 6y agoThe unit is shown on the right for me, maybe it's different in mobile view. For an SI-compliant unit, add iB behind the ${size}k :)
- fastball 6y agoI mean you need to tell me they're payload size (and version numbers). I actually thought it was number of downloads until I rechecked your script.
- lucb1e 6y agoOh! Now I understand the confusion, good point. Will try to edit something in quickly before the edit timer expires :) Obligatory: https://xkcd.com/833/ https://xkcd.com/833/
- mraza007 6y agoYou just taught me something cool as someone who loves commandline I’m definitely going to try this and save this as a gist for future reference
- lucb1e 6y agoWhat was it that you didn't know yet? As an aside, a friend of mine has already arranged (as a joke) the rights to compile and remix any bash snippets I post in chat groups in a blog or book. Maybe I should write more about this, but then, it's probably most helpful exactly because I just drop it in places rather than writing a comprehensive work that nobody sits down to read. Still, I'm curious what the syntax/feature/pattern is that you found useful :)
- TheSoftwareGuy 6y agoPersonally, I didn't know about the ( ... commands ... ) > some_file.txt syntax. Like, I knew about file redirection, but I didn't know you could group commands like that and redirect all their output with one operator. I would have had to do a bunch of appending with `>>`
- mraza007 6y agoHey if you create a book or blog I would love to check out your bash scripts You should definitely try mdbook if you want to keep it in a book format as it offers good fulltext search And I found the entire script interesting I would definitely try this once I get to my laptop as I’m currently surfing HN on my phone
- mraza007 6y agoIf you got more bash hacks or one liners or cool commands for automation I would love to check it out !!!
- lucb1e 6y agoThree tools that I think are less widely known compared to how useful they are: jq, progress, and pv. `pv` (pipe view) is rather simple but I use it for viewing a lot and sometimes rate-limiting transfers. Usage is simple: `curl huge-file | pv | some-operation` will show you the progress (okay, curl already does... but pv works for any pipe input, and pv can work in line mode with -l so you can see how many lines (records, presumably) it processed). `progress` is even simpler! Just type progress in a random terminal while, in another, you are running an operation like cp, gzip, etc. $ progress [10123] bzip2 /tmp/test 32.5% (127.0 MiB / 390.6 MiB) Use -m to monitor instead of doing a one-shot. This will also allow it to calculate the remaining time (for anything running at more than a few kilobytes per second). I also love progress just because it's such a hack. It hooks into the process and monitors file operations. Simple but effective. Somehow it works super well because it manages to ignore everything irrelevant and only shows you the file handle you care about (you can give it hints if necessary, I've used that maybe once in ten years). `jq` takes JSON data and either pretty-prints (default) or operates on it: $ echo '{"whoami": "root"}' | jq { "whoami": "root" } # imagine colored output above $ echo '{"whoami": "root"}' | jq .whoami "root" $ echo '{"users": [{"name": "abc", ...}, ...]}' | jq '.users[].name' # prints the name of all users in this array $ curl localhost/api/v1/users | jq '.users[] | "\(.name) \(.age)"' | sort -n -k 2 | tail -1 && echo "is our oldest user!"
- fouc 6y agoChart in Fiddle doesn't show in safari, but a standalone page with the same html loads just fine. Fiddle doesn't properly support safari I guess.
- jjcm 6y agoI'm seeing it fine in both Safari and Safari Tech Preview for what it's worth. Versions 14.0.3 and 14.2 respectively.