-
-
Save thegoleffect/2362718 to your computer and use it in GitHub Desktop.
Sparklines in CoffeeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env coffee | |
ticks = ['▁','▂','▃','▄','▅','▆','▇','█'] | |
exports.clark = (data) -> | |
m = Math.min data... | |
n = (Math.max(data...)-m)/(ticks.length - 1) | |
(ticks[(t-m)/n >> 0] for t in data).join('') | |
if require.main == module | |
data = process.argv | |
.map((a) -> parseInt(a, 10)) | |
.filter((v) -> v==v) | |
process.stdout.write("#{exports.clark(data)}\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment