Here's a Haskell version that uses a single loop to do the normalizing, and has a main that doesn't use do syntax. This was mostly a nice little brainteaser:
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 :)
This is pretty cool. Unfortunately it's coupled with some of the more obnoxious documentation I have seen recently. While the docs aren't very long, I had to read through a third of it to figure out simply what Spark is.
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.
The script is not a proper POSIX bourne shell script, as it uses arrays.
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).
I'm curious: is there a reason U+2584 LOWER HALF BLOCK is missing from the character set, which otherwise contains the progression from U+2581 to U+2587?
Edit: U+2588 seems like an obvious candidate as well.
(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.
I rewrote it in C, so it's faster and can work more efficiently on different data sets. It also uses a prettier algorithm for determining heights. Have fun:
[+] [-] Mgccl|14 years ago|reply
https://github.com/Mgccl/mgccl-haskell/blob/master/random/sp...
[+] [-] jcromartie|14 years ago|reply
https://gist.github.com/1367091
[+] [-] jodrellblank|14 years ago|reply
http://pastie.org/2867807
[edit: updated, careless variable rename, thanks jcromartie]
[+] [-] tanoku|14 years ago|reply
https://gist.github.com/1368661
[+] [-] ranza|14 years ago|reply
[+] [-] tome|14 years ago|reply
[+] [-] ocharles|14 years ago|reply
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 :)
[+] [-] Mgccl|14 years ago|reply
Now, without the type declaration, white space, comments, it's only 6 lines, and looks even better. :)
[+] [-] DanielN|14 years ago|reply
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.
[+] [-] gwern|14 years ago|reply
[+] [-] antics|14 years ago|reply
[+] [-] etanol|14 years ago|reply
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).
[+] [-] VMG|14 years ago|reply
[+] [-] willvarfar|14 years ago|reply
[+] [-] spektom|14 years ago|reply
alias updick='/usr/bin/uptime | perl -ne "/(\d+) d/;print 8,q(=)x\$1,\"D\n\""'
[+] [-] derwiki|14 years ago|reply
[+] [-] reledi|14 years ago|reply
[+] [-] premchai21|14 years ago|reply
Edit: U+2588 seems like an obvious candidate as well.
[+] [-] tome|14 years ago|reply
ticks = " ▁▂▃▄▅▆▇█"
I've included SPACE as well. That's an obvious missing one.
[+] [-] jmah|14 years ago|reply
[+] [-] huhtenberg|14 years ago|reply
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.
[+] [-] zx2c4|14 years ago|reply
http://git.zx2c4.com/spark/tree/spark.c
[+] [-] raphman|14 years ago|reply
⡠⠞⠉⠙⠦⣀⠴⠋⠉⠳⢄⡠⠞⠉⠙⠦⣀⠴⠋⠉⠳⢄
[+] [-] Groxx|14 years ago|reply
[+] [-] scottyallen|14 years ago|reply
Nifty idea, regardless.
[+] [-] enduser|14 years ago|reply
[+] [-] Chirono|14 years ago|reply
[+] [-] woof|14 years ago|reply
[+] [-] nitrogen|14 years ago|reply
(in addition to line 120, there are some "\n"s in the help)
[+] [-] bch|14 years ago|reply
[+] [-] IgorPartola|14 years ago|reply
spark, the linked project, is just an implementation of a sparkline generator for the command line.
[+] [-] kablamo|14 years ago|reply
https://github.com/holman/spark/wiki/Wicked-Cool-Usage
[+] [-] 0xdeadc0de|14 years ago|reply
[+] [-] adaml_623|14 years ago|reply
[+] [-] knowtheory|14 years ago|reply
[+] [-] jvoorhis|14 years ago|reply
[+] [-] yycom|14 years ago|reply
https://gist.github.com/1366926
[+] [-] ieure|14 years ago|reply
▁▁▁▁▅▁▇▁▁▅▁▁▁▁▁▂▂▁▃▃▁▁▃▁▃▁▂▁▁▂▂▅▂▃▂▃▃▁▆▃▃▃▁▇▁▁▂▂▂▇▅▁▂▂▁▇▁▃▁▇▁▂▁▇▁▁▆▂▁▇▁▂▁▁▂▅▁▂▁▆▇▇▂▁▂▁▁▁▂▂▁▅▁▂▁▁▃▁▃▁▁▁▃▂▂▂▁▁▅▂▁▁▁▁▂▂▁▁▁▂▂$
Ship it.
[+] [-] smackfu|14 years ago|reply
[+] [-] mfukar|14 years ago|reply
[+] [-] gurraman|14 years ago|reply
[+] [-] seabee|14 years ago|reply
[+] [-] andrewcooke|14 years ago|reply
and has anyone worked out how to get recent cpu load into their bash prompt yet?
[+] [-] jablan|14 years ago|reply
[+] [-] yycom|14 years ago|reply
[+] [-] rogerallen|14 years ago|reply
https://gist.github.com/1368454
[+] [-] craigkerstiens|14 years ago|reply
https://github.com/kennethreitz/spark.py
[+] [-] philjackson|14 years ago|reply