Skip to content

Instantly share code, notes, and snippets.

@towerofnix
Created May 20, 2016 20:18
Show Gist options
  • Save towerofnix/831ac7ceb763b82a2864809474f52c7e to your computer and use it in GitHub Desktop.
Save towerofnix/831ac7ceb763b82a2864809474f52c7e to your computer and use it in GitHub Desktop.
// str should be a great big binary string, e.g. '01101010'
// the string gets split into 8 bits of ascii codes, and then
// the characters are gotten from those
str = str.split('').filter(c => c === '0' || c === '1').join('')
new Array(str.length / 8)
.fill('')
.map((_,i) => str.slice(i*8,i*8+8))
.map((s) => String.fromCharCode(parseInt(s, 2)))
.join('')
@towerofnix
Copy link
Author

test case:

var str = '0100100100100000011101000110100001101001011011100110101100100000010100110110001101110010011000010111010001100011011010000010000001110011011010000110111101110101011011000110010000100000011000100110010100100000010010000101010001001101010011000011010100101100001000000110111101110010001000000110000101110100001000000110110001100101011000010111001101110100001000000111010001101000011001010111001001100101001000000111001101101000011011110111010101101100011001000010000001100010011001010010000001100001011011100010000001001000010101000100110101001100001101010010000001100101011001000110100101110100011010010110111101101110001011100010000001001000010101000100110101001100001101010010000001101001011100110010000001100001001000000110110101110101011000110110100000100000011001100110000101110011011101000110010101110010001000000111001101100011011100100110100101110000011101000110100101101110011001110010000001101100011000010110111001100111011101010110000101100111011001010010110000100000011000010110111001100100001000000100100100100000011101000110100001101001011011100110101100100000011010010111010000100000011101110110111101110101011011000110010000100000011000100110010100100000011000100110010101110011011101000010000001100110011011110111001000100000010100110110001101110010011000010111010001100011011010000010000001110100011011110010000001100010011001010010000001001000010101000100110101001100001101010010111000100000010010010111010000100000011101110110111101110101011011000110010000100000011000100110010100100000011101010111001101100101011001100111010101101100001000000110001001100101011000110110000101110101011100110110010100100000011101000110100001100101001000000110001001101001011001110010000001100001011011100110010000100000011100110110110001101111011101110010000001110000011100100110111101101010011001010110001101110100011100110010000001110111011011110111010101101100011001000010000001100010011001010010000001100110011000010111001101110100001000000110000101100111011000010110100101101110001000010010000001000001011011100110010000101100001000000111010001101111001000000111010001101000011001010010000000110011010001000010000001110000011100100110111101100111011100100110000101101101011011010110010101110010011100110010110000100000001100110100010000100000011100100110010101101110011001000110010101110010011010010110111001100111001000000111000001110010011011110110101001100101011000110111010001110011001000000111011101101111011101010110110001100100001000000110001001100101001000000110011001100001011100110111010000101110001000000100100100100000011101000110100001101001011011100110101100100000011101000110100001100101001000000101001101100011011100100110000101110100011000110110100000100000010101000110010101100001011011010010000001110011011010000110111101110101011011000110010000100000011011010110000101101011011001010010000001110100011010000110100101110011001000000110001101101000011000010110111001100111011001010010110000100000011100110110111101101111011011100010111000100000010000010110110001110011011011110010110000100000011100000110110001100101011000010111001101100101001000000111001101110000011100100110010101100001011001000010000001110100011010000110010100100000011101110110111101110010011001000010000100100000010010010010000001110111011000010110111001110100001000000111010001101000011010010111001100100000011000110110100001100001011011100110011101100101001000000111010001101111001000000110001101101111011011010110010100100000011101000111001001110101011001010010000100100000010000010111010000100000011011000110010101100001011100110111010000100000011000110110000101101110001000000111100101101111011101010010000001101101011000010110101101100101001000000110000101101110001000000100100001010100010011010100110000110101001000000110111101110000011101000110100101101111011011100010110000100000010100110110001101110010011000010111010001100011011010000010000001100011011011110111010101101100011001000010000001100010011001010010000001000110011011000110000101110011011010000010000001100001011011100110010000100000010010000101010001001101010011000011010100100001001000000100100100100000011101110110000101101110011101000010000001110100011011110010000001101101011000010110101101100101001000000110000100100000011001000110100101100110011001100110010101110010011001010110111001100011011001010010000100001101000010100000110100001010010101000110100001100101001000000111001001100101011000010111001101101111011011100010000001001001001000000111011101100001011011100111010000100000010010000101010001001101010011000011010100100000011001010110010001101001011101000110111101110010001000000110100101110011001000000110001001100101011000110110000101110101011100110110010100100000011010010111010000100000011101110110100101101100011011000010000001100110011010010111100000100000011101000110100001100101001000000111001101101100011011110110111101101111011011110111011101110111011101110111011101110111001000000110011001101100011000010111001101101000001000000111000001110010011011110110101001100101011000110111010000100000011100000110110001100001011110010110010101110010001011100000110100001010'


str = str.split('').filter(c => c === '0' || c === '1').join('')

new Array(str.length / 8)
.fill('')
.map((_,i) => str.slice(i*8,i*8+8))
.map((s) => String.fromCharCode(parseInt(s, 2)))
.join('')

I think Scratch should be HTML5, or at least there should be an HTML5 edition. HTML5 is a much faster scripting language, and I think it would be best for Scratch to be HTML5. It would be useful because the big and slow projects would be fast again! And, to the 3D programmers, 3D rendering projects would be fast. I think the Scratch Team should make this change, soon. Also, please spread the word! I want this change to come true! At least can you make an HTML5 option, Scratch could be Flash and HTML5! I want to make a difference!

The reason I want HTML5 editor is because it will fix the sloooowwwww flash project player.

source

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