12 ms·
Spark
- yycom 15y agohttps://gist.github.com/1366875 https://gist.github.com/1366875 (python)
- rogerallen 15y agothanks. here's a couple bugfixes. fixed width calc & handles negative #s https://gist.github.com/1368454 https://gist.github.com/1368454
- jmah 15y agoAh, as inspired by Edward ttyfte.
- huhtenberg 15y agoThat ^ is why HN needs a LOL button :) http://img819.imageshack.us/img819/264/hnlol.png 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.
- zyfo 15y agoI was about to upvote compensate you before I read your edit.
- huhtenberg 15y agoWell. When I posted the above comment, its parent was lingering at the very bottom of the page. Then it quickly floated to the top, and after that mine got as quickly downvoted into oblivion. Interesting dynamic in itself. Right now the karma counter keeps oscillating around 4600... which makes me regret that I didn't say it was 4701 :)
- anacrolix 15y agoi upvoted you because HN is a dry humorless clone of /r/programming.
- pg 15y agoWould you please not do this?
- etanol 15y agoThe 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).
- willvarfar 15y agoFork and fix please!
- imrehg 15y ago... and send a pull-request, so everyone can share the happy.
- etanol 15y agoAlready done, and someone even did a better fix: https://github.com/holman/spark/pull/8 https://github.com/holman/spark/pull/8
- kelnos 15y agoNetBSD seriously doesn't put bash in /bin? That's just broken by design.
- ketralnis 15y agoI can't speak to NetBSD, but FreeBSD doesn't put any user-installed programs in /bin or /usr/bin, they all go into /usr/local. Since bash isn't distributed as part of the base system, it goes into /usr/local/bin/bash
- kelnos 15y agoSo then how do you write cross-platform scripts? You can't even do "#!/usr/bin/env bash" since I'm assuming what you're saying means 'env' is in /usr/local/ as well, but on Linux systems it'll be in /usr/. Broken! Can we please just pick one convention and stick with it? Oh, standards... so many to choose from.
- thechut 15y agoHolman never fails to impress
- jvoorhis 15y agoI hooked this up to my homebrew cohort-analysis script and saw a gratifying terminal hockeystick :D
- premchai21 15y agoI'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.
- tome 15y agoNo idea. Here they are for everyone's use: ticks = " ▁▂▃▄▅▆▇█" I've included SPACE as well. That's an obvious missing one.
- bodyfour 15y agoAt least in my OS/X terminal using the "Monaco" font (which I think is the default), the final one (U+2588) doesn't descend as far as the rest of the characters. It really produces some ugly output with that one included. 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.
- carterschonwald 15y agoYes, on the mac it seems only menlo renders it correctly, (vs all the other fixed with font families that bork the rendering in various ways)
- scottyallen 15y agoHmm, I get the following: [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.
- Chirono 15y agoTry changing line 120 to echo -e $"$(print_tick $number)\c" And it should work fine.
- rnadna 15y agoI found it necessary to escape the backslash echo -e $"$(print_tick $number)\\c"
- enduser 15y agoadd a '-e' after 'echo' on line 120
- woof 15y agohttps://github.com/Omnipresent/spark/commit/43e4de4bfc69093a26a22625407bf5cb41c94be6 https://github.com/Omnipresent/spark/commit/43e4de4bfc69093a...
- nitrogen 15y agoThe "\c" escape sequence makes the -n unnecessary (as I discovered while reading "help echo").
- nitrogen 15y agohttps://github.com/holman/spark/pull/4 https://github.com/holman/spark/pull/4 (in addition to line 120, there are some "\n"s in the help)
- kablamo 15y agoCool. I also like that he set up a wiki where people can contribute interesting spark one liners: https://github.com/holman/spark/wiki/Wicked-Cool-Usage https://github.com/holman/spark/wiki/Wicked-Cool-Usage
- kvermeer 15y agoAll involve awk or sed. That cuts out a large portion of the potential userbase... 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?
- Oompa 15y agoI feel like they're examples of really awesome use cases, so it shouldn't matter if people can't use them. Not to mention, I feel like this tool is targeted for terminal junkies who likely already have awk/sed.
- gwern 15y agoBasically. Are there very many people who would generate sparklines, using a sh program - somewhere that has sh but not awk or sed?
- mfukar 15y agoWhat would be really interesting is finding out which decent programming fonts can show block elements. I mean, beyond the DejaVu Sans Mono fiasco.
- gurraman 15y agohttp://www.levien.com/type/myfonts/inconsolata.html http://www.levien.com/type/myfonts/inconsolata.html
- icebraining 15y agoThis is what I've been using (after more than a year with DejaVu Sans Mono) and I sometimes still stop to admire my terminal ;) Using #e8e8e8 instead of pure white for the text color helps too.
- mfukar 15y agoDoesn't seem to be able to display the block characters neither on PuTTY, gvim on Windows or my Linux terminals/editors. Am I missing something obvious here?
- andrewcooke 15y agoschumacher clean works (i can cut + paste the title of this post to my shell) - it's a bitmap font that's been in X forever. and has anyone worked out how to get recent cpu load into their bash prompt yet?
- jablan 15y agoLiberation Mono and Terminus both work.
- seabee 15y agoYou'll have difficulty on Windows if you use PuTTY, since it doesn't do font substitution.
- davidjhall 15y agoAre there any Windows SSH programs that display? I get nothing but garbage or "." characters for any of the symbols.
- spektom 15y agoThis reminds me of another useful utility from the childhood: alias updick='/usr/bin/uptime | perl -ne "/(\d+) d/;print 8,q(=)x\$1,\"D\n\""'
- sktrdie 15y agoThis is sort of useless. Giving visual meaning to a bunch of numbers means nothing. It's just a bunch of numbers.
- skeletonjelly 15y agoBlogs on swearing are so last week. This week is Holman week. Just an observation.
- 0xdeadc0de 15y agohttps://github.com/bitly/data_hacks https://github.com/bitly/data_hacks
- philjackson 15y agoI would rather it took a number, one per line from stdin. Great idea though.
- deleted 15y ago[deleted]
- icebraining 15y agoTry this: alias spark='tr "\\n" "," | xargs spark'
- gwern 15y agoEveryone want a different delimiter... Hence, I filed https://github.com/holman/spark/issues/23 https://github.com/holman/spark/issues/23
- adaml_623 15y agoSparklines are cool. This is just a bar graph and not nearly as useful.
- knowtheory 15y agoSo, because you can't deviate below the x axis this is really that much less useful?
- abrowne 15y agoThis also doesn't meet the high resolution part of Tufte's definition ("a small intense, simple, word-sized graphic with typographic resolution"[1]). [1]: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR&topic_id=1 http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0...
- tel 15y agoThey're comparatively higher density...
- abrowne 15y agoThis gives you eight levels (plus blank)[1]. Most of the type I read is at least twice that many pixels high. [1]:https://github.com/holman/spark/blob/master/spark#L46 https://github.com/holman/spark/blob/master/spark#L46
- tel 15y agoTufte honestly thinks pixelated type is pretty terrible, too. 16 pixel density is embarrassing compared to printed or pressed text. 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.
- adaml_623 15y ago
- Mgccl 15y agoJust did a Haskell version of spark. It supports in 9 lines of code (exclude comment + empty line) Double instead of just Int. Negative numbers. https://github.com/Mgccl/mgccl-haskell/blob/master/random/spark.hs https://github.com/Mgccl/mgccl-haskell/blob/master/random/sp...
- tome 15y agoI really like your version. Very neat!
- jcromartie 15y agoSame features. 4 SLoC of Ruby :) https://gist.github.com/1367091 https://gist.github.com/1367091
- silvestrov 15y ago'floor' on last line should be changed to 'round'. ▁▁▁▁▁▁▂▂▂▂▂▂▃▃▃▃▃▃▅▅▅▅▅▅▆▆▆▆▆▆▇ = floor ▁▁▁▂▂▂▂▂▂▃▃▃▃▃▃▅▅▅▅▅▅▆▆▆▆▆▆▇▇▇▇ = round
- jcromartie 15y agoThanks! Much better.
- jodrellblank 15y agoAnd here's a PowerShell version. (Use PowerShell ISE as PowerShell normal prompt doesn't support unicode). http://pastie.org/2867807 http://pastie.org/2867807 [edit: updated, careless variable rename, thanks jcromartie]
- jcromartie 15y ago$stats should be $minmax
- Mgccl 15y agoUpdated. thx to gwern. Now I know the existence of hlint. Now, without the type declaration, white space, comments, it's only 6 lines, and looks even better. :)
- yycom 15y agoa bit more efficient, and without the comma requirement https://gist.github.com/1366926 https://gist.github.com/1366926
- jcfrei 15y agohad basically the same idea a while back - but would have used standard ascii characters and written it in c... still cool though!
- shubhendu 15y agoHello! Pls to review Kabutar - a web & iphone app kinda reddit for real world. kabutar.in | http://itunes.apple.com/us/app/kabutar!/id477970251?mt=8 http://itunes.apple.com/us/app/kabutar!/id477970251?mt=8 pretty pls :)
- hasantayyar 15y agothis should be utf-8 supported.
- DanielN 15y agoThis 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.
- antics 15y agoThis is a totally fair complaint. Sometimes it is a mystery to me why HN-ers downvote things.
- bitops 15y agoIn all seriousness: some folks on HN (not all) seem to be the guard in the center of the panopticon. 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.
- SquareWheel 15y agoI think having downvotes public is an intersting idea. It would certainly force people to justify their downvotes, anyway.
- gwern 15y agoIn my defense, I did try: https://github.com/holman/spark/pull/34/files https://github.com/holman/spark/pull/34/files
- craigkerstiens 15y agoHere's a port of it to Python already live: https://github.com/kennethreitz/spark.py https://github.com/kennethreitz/spark.py
- RyanMcGreal 15y agoHere's my effort: https://gist.github.com/1368953 https://gist.github.com/1368953
- raphman 15y agoNice: found a sparkline generator at http://sandbox.kidstrythisathome.com/louis/ http://sandbox.kidstrythisathome.com/louis/ : ⡠⠞⠉⠙⠦⣀⠴⠋⠉⠳⢄⡠⠞⠉⠙⠦⣀⠴⠋⠉⠳⢄
- Groxx 15y agoNeeds a lot more characters to handle height progressions and angles better, but that's awesome.
- bch 15y agoI've quickly looked at the link, read the reviews here, and there's actually no description of what spark _is_. I gather is an UTF-8 graph generator.
- IgorPartola 15y agoSparklines Wikipedia page: http://en.wikipedia.org/wiki/Sparkline http://en.wikipedia.org/wiki/Sparkline spark, the linked project, is just an implementation of a sparkline generator for the command line.
- bch 15y agoThanks! First time I've heard of "sparkline". Of course I've seen these items for as long as I can remember, but I just call them "graphs". :P
- teej 15y agoA sparkline is a specific type of graph used for certain types of data. The wiki page is pretty clear with the uses and limitations. 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.
- bch 15y agoI feel like I'm being reprimanded. Forgive me if I'm mistaken. > 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!
- jongraehl 15y agocool, but: $ spark 3,4,9 ▃▇▇ huh?
- gwern 15y agoA fixed bug https://github.com/holman/spark/issues/19 https://github.com/holman/spark/issues/19 With HEAD: $ spark 3 4 9 ▃▄▇
- ieure 15y agoBecause I want my shell prompt to be a giant graph. ▁▁▁▁▅▁▇▁▁▅▁▁▁▁▁▂▂▁▃▃▁▁▃▁▃▁▂▁▁▂▂▅▂▃▂▃▃▁▆▃▃▃▁▇▁▁▂▂▂▇▅▁▂▂▁▇▁▃▁▇▁▂▁▇▁▁▆▂▁▇▁▂▁▁▂▅▁▂▁▆▇▇▂▁▂▁▁▁▂▂▁▅▁▂▁▁▃▁▃▁▁▁▃▂▂▂▁▁▅▂▁▁▁▁▂▂▁▁▁▂▂$ Ship it.
- smackfu 15y agoDoes HN really not have any protection against comments that are very long single words that screw up the page width?
- deleted 15y ago[deleted]
- zx2c4 15y agoI 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: http://git.zx2c4.com/spark/tree/spark.c 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 ▂▃▄▃▃▃▄▃▇▃▄▄▄▅▃▄▄▄▅▅▅▄▄▄▃▃▃▃▃▄▃▄█▅▄▄▄▄▃▇▄▄▄█▄▃▄▄▄▄▃▃▄▅▄▅▃▃▃▃▇▄▅▄▇▃▅▃▄▃▄▃▇▃▃▄▇▃▄▃▄▃▃▃▄▃▃▃▃▃▃▅▃▄▃▃