Skip to content

Instantly share code, notes, and snippets.

@sugyan
Forked from 140bytes/LICENSE.txt
Created May 27, 2011 09:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sugyan/994907 to your computer and use it in GitHub Desktop.
Save sugyan/994907 to your computer and use it in GitHub Desktop.
Generates sparktweets from input arrays of data.
function (
a, // argument array
b, s, l, r // variables
) {
l = ( // l is length of a
s = a.slice().sort() // s is copied and sored array of a
).length,
r = s[l - 1] - s[0]; // r is max(a) - min(a)
b = ''; // b is return value
while (l--) // loop l times
b = String.fromCharCode( // charcode: 9601 - 9608
// (some browser could not render unicode 9604 and 9608 ...?)
9601 + ~~ 7 * (a[l] - s[0]) / r // use "~~" instead of Math.floor()
) + b; // concat forward
return b
}
function(a,b,s,l,r){l=(s=a.slice().sort()).length,r=s[l-1]-s[0];b='';while(l--)b=String.fromCharCode(9601+~~7*(a[l]-s[0])/r)+b;return b}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "sparktweet",
"description": "Generates sparktweets from input arrays of data.",
"keywords": [
"sparktweet",
"plotting"
]
}
@Pet3ris
Copy link

Pet3ris commented May 27, 2011

Nice work, a for loop helps.

function(a,b,s,l,r){for(l=(s=a.slice().sort()).length,r=s[l-1]-s[0],b='';l--;b=String.fromCharCode(9601+~~7*(a[l]-s[0])/r)+b);return b}

@sugyan
Copy link
Author

sugyan commented May 27, 2011

awesome!
Thanks much.

@jfhbrook
Copy link

Aww I got out-sparktweeted. :(

Nice work! :D ^5

@jed
Copy link

jed commented Jul 11, 2011

hey @sugyan, would you mind taking the comments out of your package.json?

@sugyan
Copy link
Author

sugyan commented Jul 11, 2011

hi @jed, I removed comments. is this ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment