Spark
github.com
github.com
https://github.com/Mgccl/mgccl-haskell/blob/master/random/sp...
▁▁▁▁▁▁▂▂▂▂▂▂▃▃▃▃▃▃▅▅▅▅▅▅▆▆▆▆▆▆▇ = floor
▁▁▁▂▂▂▂▂▂▃▃▃▃▃▃▅▅▅▅▅▅▆▆▆▆▆▆▇▇▇▇ = round[edit: updated, careless variable rename, thanks jcromartie]
Now, without the type declaration, white space, comments, it's only 6 lines, and looks even better. :)
https://gist.github.com/1367709
mapNormalize takes a function, and produces a function that runs that function with the normalized input. It runs in a single iteration, rather than 2 maps. Credit to `dylex` for much hand holding on a single iteration normalizer :)
benchmarking spark_mggcl
mean: 49.29483 us, lb 48.77776 us, ub 50.25594 us, ci 0.950
std dev: 3.495423 us, lb 2.140951 us, ub 6.373469 us, ci 0.950
benchmarking spark_ocharles
mean: 60.12347 us, lb 58.95586 us, ub 61.48084 us, ci 0.950
std dev: 6.434853 us, lb 5.529613 us, ub 7.824865 us, ci 0.950
The simpler version appears to be faster.(As an aside, is there something in particular you dislike about do syntax? I find that it often makes things more readable, though slightly more verbose.)
In terms of do syntax, I try and avoid that because I find it detracts from the overall flow of data. With: "putStrLn . spark . map read =<< getArgs" I find it easy to see that main doesn't do much other than transform the users input. maybe a personal preference thing though...
I'm all for being cute, but it shouldn't come at the cost of a basic understanding of what the program actually does and is useful for.
If you could see a list of who downvoted you, I'd bet that something interesting would happen.
I almost expect to come back and see my karma drop as a result of this comment.
For starters, it won't work in dash (Debian and Ubuntu /bin/sh implementation). So the shebang line should be changed to #!/bin/bash (not sure if it would work in Zsh either).
Broken! Can we please just pick one convention and stick with it? Oh, standards... so many to choose from.
alias updick='/usr/bin/uptime | perl -ne "/(\d+) d/;print 8,q(=)x\$1,\"D\n\""'
Edit: U+2588 seems like an obvious candidate as well.
ticks = " ▁▂▃▄▅▆▇█"
I've included SPACE as well. That's an obvious missing one.
Including the space character means that you lose a nice baseline if the input is fairly sparse, so it looks less like a bar graph and more like just some random blobs.
http://img819.imageshack.us/img819/264/hnlol.png
(edit) Ah, the downvoting frenzy! 4601 karma points to go. Bring it on, fellow HNers. Don't forget to quote the guidelines and to lecture me too as no bashing is complete without showing some smug superiority with a hint of righteousness.
Right now the karma counter keeps oscillating around 4600... which makes me regret that I didn't say it was 4701 :)
http://git.zx2c4.com/spark/tree/spark.c
$ git clone http://git.zx2c4.com/spark
$ cd spark
$ make
$ ./spark 1 4 2 8 14
▂▃▂▅█
$ curl -s http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M1.txt | cut -d, -f9 | ./spark
▂▃▄▃▃▃▄▃▇▃▄▄▄▅▃▄▄▄▅▅▅▄▄▄▃▃▃▃▃▄▃▄█▅▄▄▄▄▃▇▄▄▄█▄▃▄▄▄▄▃▃▄▅▄▅▃▃▃▃▇▄▅▄▇▃▅▃▄▃▄▃▇▃▃▄▇▃▄▃▄▃▃▃▄▃▃▃▃▃▃▅▃▄▃▃⡠⠞⠉⠙⠦⣀⠴⠋⠉⠳⢄⡠⠞⠉⠙⠦⣀⠴⠋⠉⠳⢄
[scotty@Scotty-Allens-MacBook-Air ~/bin]$ spark 1,2,3,4,5
▇\c
▇\c
▇\c
▇\c
▇\c
I suspect this has something to do with my terminal settings, but I'm not sure quite what...Nifty idea, regardless.
echo -e $"$(print_tick $number)\c"
And it should work fine. echo -e $"$(print_tick $number)\\c"(in addition to line 120, there are some "\n"s in the help)
spark, the linked project, is just an implementation of a sparkline generator for the command line.
Not all graphs are created equal, it's important to use the right tool for the job. This tool isnt just a graph generator, it's a spark bar chart generator that's compact enough to fit in the command line. Overall a cool idea.
> A sparkline is a specific type of graph
My point is this should be explained _somewhere_. Anybody else unfamiliar with sparklines will now have the benefit of this thread. Previously, to me anyway, it was a mystery.
> The wiki page is pretty clear with the uses and limitations.
It is. It was only presented upon my initial query, and am grateful to @IgorPartola for providing!
> Not all graphs are created equal, it's important to use the right > tool for the job. This tool isnt just a graph generator, > it's a > spark bar chart generator that's compact enough to fit in > the > command line. Overall a cool idea.
It is, indeed. My initial note wasn't about the coolness of the project, just "what _is_ the project"? Is clear now. Anybody else who is ignorant about sparklines as I was, enjoy this thread!
Perhaps common uses could be wrapped in options to the script? For instance, an option to graph numbers on separate lines, to graph all numbers in the input in order, to graph a specific column of information (like passing through cut first) or to graph commonly graphed sources?
[1]: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0...
But in either case, it's obvious that's a silly argument. Trends posterized to 8 levels are far easier to read in "sparkbar" form than as a list of numbers. It's suboptimal, but better than the plain list.
▁▁▁▁▅▁▇▁▁▅▁▁▁▁▁▂▂▁▃▃▁▁▃▁▃▁▂▁▁▂▂▅▂▃▂▃▃▁▆▃▃▃▁▇▁▁▂▂▂▇▅▁▂▂▁▇▁▃▁▇▁▂▁▇▁▁▆▂▁▇▁▂▁▁▂▅▁▂▁▆▇▇▂▁▂▁▁▁▂▂▁▅▁▂▁▁▃▁▃▁▁▁▃▂▂▂▁▁▅▂▁▁▁▁▂▂▁▁▁▂▂$
Ship it.
Using #e8e8e8 instead of pure white for the text color helps too.
and has anyone worked out how to get recent cpu load into their bash prompt yet?
alias spark='tr "\\n" "," | xargs spark'$ spark 3,4,9 ▃▇▇
huh?
$ spark 3 4 9
▃▄▇Just an observation.