9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] toy: pseudo-sparklines
@ 2011-05-17  4:25 Anthony Sorace
  2011-05-17  7:37 ` erik quanstrom
  0 siblings, 1 reply; 2+ messages in thread
From: Anthony Sorace @ 2011-05-17  4:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]

Edward Tufte's sparklines[0] are a wonderful way of
representing a wide variety of data in word-like spaces. You
can't use them in text-only places, though, leading some
folks to come up (very rough) approximations using unicode
characters[1]. They're a poor shadow of the real thing, but
can still be useful for some types of data and some contexts.

Roughly inspired by a writeup of some guy's python
implementation[2] of a generator, I threw one together this
afternoon in rc and hoc: [3]

	:; sparkline 0 2 4 7 12 16 3 11 9 0 4 
	▁▂▃▄▇█▂▆▅▁▃:; 

The internet has noted that in some contexts the baseline gets
messed up, but they're still a fun toy.

Also, thanks to lmnop in #plan9 for this:

	fn moustache { sparkline `{seq 0 1 10} `{seq 9 -1 0} ; echo }

Maybe a tribute to our go friends[3].

a

[0]	http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR&topic_id=1
[1]	http://kottke.org/11/05/twitter-sparklines
[2]	http://www.leancrew.com/all-this/2011/05/textexpander-sparkline-snippet/
[3]	/n/sources/contrib/anothy/bin/rc/sparkline
[4]	http://moustach-io.appspot.com/


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 210 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] toy: pseudo-sparklines
  2011-05-17  4:25 [9fans] toy: pseudo-sparklines Anthony Sorace
@ 2011-05-17  7:37 ` erik quanstrom
  0 siblings, 0 replies; 2+ messages in thread
From: erik quanstrom @ 2011-05-17  7:37 UTC (permalink / raw)
  To: 9fans

> Roughly inspired by a writeup of some guy's python
> implementation[2] of a generator, I threw one together this
> afternoon in rc and hoc: [3]
> 
> 	:; sparkline 0 2 4 7 12 16 3 11 9 0 4 
> 	▁▂▃▄▇█▂▆▅▁▃:; 
> 
> The internet has noted that in some contexts the baseline gets
> messed up, but they're still a fun toy.
> 
> Also, thanks to lmnop in #plan9 for this:
> 
> 	fn moustache { sparkline `{seq 0 1 10} `{seq 9 -1 0} ; echo }

thanks for the toy!

in addition to being naturally fun, it was interesting to play with.
i initially ran your program directly from sources.  since my path
is the default, one could see each character print.  (1985 says hi!)

just for fun, i decided to modify sparkline to do a constant number
of execs by pipelining most of the work.  /n/sources/contrib/quanstro/sparkline.
(yes, this is pointless.)

since run time should be dominated by execs, the fewer the better.
here's the comparison.  n is the number of input numbers.
orig	5n + 0
mod	0 + 12	(or 11 if you don't add the trailing \n.)

and here's the actual run time for moustache (on an atom)
	local				from sources
orig	0.03u 0.12s 0.37r			0.03u 0.12s 5.26r
mod	0.02u 0.02s 0.06r			0.01u 0.03s 0.86r

exercize for bored reader: replace one sed with a hoc function.

- erik



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-17  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-17  4:25 [9fans] toy: pseudo-sparklines Anthony Sorace
2011-05-17  7:37 ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).