Skip to content

Instantly share code, notes, and snippets.

@bytespider
Forked from 140bytes/LICENSE.txt
Created June 4, 2011 11:46
Show Gist options
  • Select an option

  • Save bytespider/1007834 to your computer and use it in GitHub Desktop.

Select an option

Save bytespider/1007834 to your computer and use it in GitHub Desktop.

Revisions

  1. Rob Griffiths revised this gist Jul 11, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,6 @@

    "keywords": [
    "cryptography",
    "utf8",
    "utf8"
    ]
    }
  2. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 4 additions and 4 deletions.
    4 changes: 2 additions & 2 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    function stringToByteArray(a,b,c,d,e,f,g,h,i){
    for(
    b = [
    e = 0
    //d = 0
    e =
    d = 0
    ] // initialise variables
    ;
    c = a.charCodeAt(d++) // get the character code from the string
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f,g,h,i){for(b=[e=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;b[h]=g+(2<<6-i)+(c>>i*6))b[e++]=g+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;b[h]=g+(2<<6-i)+(c>>i*6))b[e++]=g+(c>>f*6&63)}return b}
    2 changes: 1 addition & 1 deletion test.html
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@
    return bytes;
    }

    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;b[h]=g+(2<<6-i)+(c>>i*6))b[e++]=g+(c>>f*6&63)}return b};
    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;b[h]=g+(2<<6-i)+(c>>i*6))b[e++]=g+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArrayOld("hello☺䭢 it works")
    document.getElementById( "ret2" ).innerHTML = stringToByteArray("hello☺䭢 it works")
  3. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 5 additions and 5 deletions.
    6 changes: 3 additions & 3 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    function stringToByteArray(a,b,c,d,e,f,g,h,i){
    for(
    b = [
    e =
    d = 0
    e = 0
    //d = 0
    ] // initialise variables
    ;
    c = a.charCodeAt(d++) // get the character code from the string
    @@ -35,8 +35,8 @@ function stringToByteArray(a,b,c,d,e,f,g,h,i){
    ;
    f-- > 0 // -1 and check if greater than 0 still
    ;
    b[h] = g + (2<<(6-i)) + (c >> i*6) // move onto the next slot in the byte array
    )
    b[h] = g + (2<<(6-i)) + (c >> i*6), // move onto the next slot in the byte array
    b[e++] = g + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    }
    return b // return the byte array
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;b[h]=g+(2<<6-i)+(c>>i*6))b[e++]=g+(c>>f*6&63)}return b}
    2 changes: 1 addition & 1 deletion test.html
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@
    return bytes;
    }

    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<g*512?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b};
    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;b[h]=g+(2<<6-i)+(c>>i*6))b[e++]=g+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArrayOld("hello☺䭢 it works")
    document.getElementById( "ret2" ).innerHTML = stringToByteArray("hello☺䭢 it works")
  4. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 6 additions and 4 deletions.
    6 changes: 4 additions & 2 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -23,9 +23,11 @@ function stringToByteArray(a,b,c,d,e,f,g,h,i){
    ?
    f = 2 // number of bytes left to process
    :
    c < 2<<20 && ( // finally, under 2097152 is 4bytes
    c < 2<<20 ? // finally, under 2097152 is 4bytes
    f = 3 // 3bytes left to process
    );
    :
    0
    ;

    for( // process the remaining bytes indicated by `f`
    h = e++,
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b}
    2 changes: 1 addition & 1 deletion test.html
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@
    return bytes;
    }

    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b};
    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<g*512?f=2:c<2<<20?f=3:0;for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArrayOld("hello☺䭢 it works")
    document.getElementById( "ret2" ).innerHTML = stringToByteArray("hello☺䭢 it works")
  5. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 8 additions and 9 deletions.
    11 changes: 5 additions & 6 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,6 @@ function stringToByteArray(a,b,c,d,e,f,g,h,i){
    for(
    b = [
    e =
    f =
    d = 0
    ] // initialise variables
    ;
    @@ -16,26 +15,26 @@ function stringToByteArray(a,b,c,d,e,f,g,h,i){
    ?
    b[e] = c // add to byte array
    :
    c < g*4 // under 2048 2bytes
    c < 2048 // under 2048 2bytes
    ?
    f = 1 // number of bytes left to process
    f = 1 // number of bytes left to process
    :
    c < 65536 // under 65536 is 3bytes
    ?
    f = 2 // number of bytes left to process
    f = 2 // number of bytes left to process
    :
    c < 2<<20 && ( // finally, under 2097152 is 4bytes
    f = 3 // 3bytes left to process
    );

    for( // process the remaining bytes indicated by `f`
    h = e++, // move onto the next slot in the byte array
    h = e++,
    i = f
    ;
    f-- > 0 // -1 and check if greater than 0 still
    ;
    b[h] = (2<<(5-f)) + (c >> 6*i) // add the first byte
    )
    b[h] = g + (2<<(6-i)) + (c >> i*6), // move onto the next slot in the byte array
    b[e++] = g + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    }
    return b // return the byte array
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;b[h]=(2<<5-f)+(c>>6*i))b[e++]=g+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b}
    4 changes: 2 additions & 2 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -26,8 +26,8 @@
    return bytes;
    }

    var stringToByteArray = function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;b[h]=(2<<5-f)+(c>>6*i))b[e++]=g+(c>>f*6&63)}return b};
    function stringToByteArray(a,b,c,d,e,f,g,h,i){for(b=[e=d=0];c=a.charCodeAt(d++);){g=128;c<g?b[e]=c:c<2048?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-- >0;)b[h]=g+(2<<6-i)+(c>>i*6),b[e++]=g+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArray("hello☺䭢 it works")
    document.getElementById( "ret" ).innerHTML = stringToByteArrayOld("hello☺䭢 it works")
    document.getElementById( "ret2" ).innerHTML = stringToByteArray("hello☺䭢 it works")
    </script>
  6. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 17 additions and 20 deletions.
    31 changes: 14 additions & 17 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -6,40 +6,37 @@ function stringToByteArray(a,b,c,d,e,f,g,h,i){
    e =
    f =
    d = 0
    ] // initialise variables
    ] // initialise variables
    ;
    c = a.charCodeAt(d++) // get the character code from the string
    c = a.charCodeAt(d++) // get the character code from the string
    ;
    ){
    g = 128;
    c < g // under 128 is UTF-8 (ASCII range), 1 byte
    c < g // under 128 is UTF-8 (ASCII range), 1 byte
    ?
    b[e] = c // add to byte array
    b[e] = c // add to byte array
    :
    c < g*4 // under 2048 2bytes
    c < g*4 // under 2048 2bytes
    ?
    (
    //b[e] = 192 + (c >> 6), // shift down 6bits, add 192 to put it in the right range
    f = 1 // number of bytes left to process
    )
    f = 1 // number of bytes left to process
    :
    c < 65536 // under 65536 is 3bytes
    ?
    f = 2 // number of bytes left to process
    f = 2 // number of bytes left to process
    :
    c < 2<<20 && ( // finally, under 2097152 is 4bytes
    f = 3 // 3bytes left to process
    f = 3 // 3bytes left to process
    );

    for( // process the remaining bytes indicated by `f`
    h = e++, // move onto the next slot in the byte array
    for( // process the remaining bytes indicated by `f`
    h = e++, // move onto the next slot in the byte array
    i = f
    ;
    f-- > 0 // -1 and check if greater than 0 still
    f-- > 0 // -1 and check if greater than 0 still
    ;
    b[h] = (2<<(5-f)) + (c >> 6*i) // add the first byte
    )
    b[e++] = g + (c >> f*6 & 63), // shift f * 6 bits, mask 1byte and add 128
    b[h] = (2<<(5-f)) + (c >> 6*i)
    b[e++] = g + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    }
    return b // return the byte array
    return b // return the byte array
    }
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;)b[e++]=g+(c>>f*6&63),b[h]=(2<<5-f)+(c>>6*i)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;b[h]=(2<<5-f)+(c>>6*i))b[e++]=g+(c>>f*6&63)}return b}
    4 changes: 2 additions & 2 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <!DOCTYPE html>
    <title>stringToByteArray</title>
    <div>Expected value: <b id="ret"></b></div>
    <div>Actual value: <b id="ret2"></b></div>
    <div>Actual value: &nbsp;&nbsp;&nbsp;&nbsp;<b id="ret2"></b></div>
    <script>
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.
    @@ -26,7 +26,7 @@
    return bytes;
    }

    var stringToByteArray = function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;)b[e++]=g+(c>>f*6&63),b[h]=(2<<5-f)+(c>>6*i)}return b};
    var stringToByteArray = function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;b[h]=(2<<5-f)+(c>>6*i))b[e++]=g+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArray("hello☺䭢 it works")
    document.getElementById( "ret2" ).innerHTML = stringToByteArray("hello☺䭢 it works")
  7. Rob Griffiths revised this gist Jun 4, 2011. 2 changed files with 3 additions and 7 deletions.
    8 changes: 2 additions & 6 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -25,21 +25,17 @@ function stringToByteArray(a,b,c,d,e,f,g,h,i){
    :
    c < 65536 // under 65536 is 3bytes
    ?
    (
    //b[e] = 224 + (c >> 12), // shift down 12bits and put it into the correct range
    f = 2 // number of bytes left to process
    )
    :
    c <2<<20 && ( // finally, under 2097152 is 4bytes
    //b[e] = 240 + (c >> 18), // shift down 18bits and 240 so its in the right range
    c < 2<<20 && ( // finally, under 2097152 is 4bytes
    f = 3 // 3bytes left to process
    );

    for( // process the remaining bytes indicated by `f`
    h = e++, // move onto the next slot in the byte array
    i = f
    ;
    f-- > 0 // -1 and check if greater than 0 still
    f-- > 0 // -1 and check if greater than 0 still
    ;
    )
    b[e++] = g + (c >> f*6 & 63), // shift f * 6 bits, mask 1byte and add 128
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;)b[e++]=g+(c>>f*6&63),b[h]=(2<<5-f)+(c>>6*i)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;)b[e++]=g+(c>>f*6&63),b[h]=(2<<5-f)+(c>>6*i)}return b}
  8. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 40 additions and 16 deletions.
    25 changes: 14 additions & 11 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // http://en.wikipedia.org/wiki/UTF-8

    function stringToByteArray(a,b,c,d,e,f){
    function stringToByteArray(a,b,c,d,e,f,g,h,i){
    for(
    b = [
    e =
    @@ -11,36 +11,39 @@ function stringToByteArray(a,b,c,d,e,f){
    c = a.charCodeAt(d++) // get the character code from the string
    ;
    ){
    c < 128 // under 128 is UTF-8 (ASCII range), 1 byte
    g = 128;
    c < g // under 128 is UTF-8 (ASCII range), 1 byte
    ?
    b[e] = c // add to byte array
    :
    c < 2048 // under 2048 2bytes
    c < g*4 // under 2048 2bytes
    ?
    (
    b[e] = 192 + (c >> 6), // shift down 6bits, add 192 to put it in the right range
    //b[e] = 192 + (c >> 6), // shift down 6bits, add 192 to put it in the right range
    f = 1 // number of bytes left to process
    )
    :
    c < 2^16 // under 65536 is 3bytes
    c < 65536 // under 65536 is 3bytes
    ?
    (
    b[e] = 224 + (c >> 12), // shift down 12bits and put it into the correct range
    //b[e] = 224 + (c >> 12), // shift down 12bits and put it into the correct range
    f = 2 // number of bytes left to process
    )
    :
    c < 2^21 && ( // finally, under 2097152 is 4bytes
    b[e] = 240 + (c >> 18), // shift down 18bits and 240 so its in the right range
    c <2<<20 && ( // finally, under 2097152 is 4bytes
    //b[e] = 240 + (c >> 18), // shift down 18bits and 240 so its in the right range
    f = 3 // 3bytes left to process
    );

    for( // process the remaining bytes indicated by `f`
    e++ // move onto the next slot in the byte array
    h = e++, // move onto the next slot in the byte array
    i = f
    ;
    f-- // -1 and check if greater than 0 still
    f-- > 0 // -1 and check if greater than 0 still
    ;
    )
    b[e++] = 128 + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    b[e++] = g + (c >> f*6 & 63), // shift f * 6 bits, mask 1byte and add 128
    b[h] = (2<<(5-f)) + (c >> 6*i)
    }
    return b // return the byte array
    }
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f--;)b[e++]=128+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;)b[e++]=g+(c>>f*6&63),b[h]=(2<<5-f)+(c>>6*i)}return b}
    29 changes: 25 additions & 4 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,33 @@
    <!DOCTYPE html>
    <title>stringToByteArray</title>
    <div>Expected value: <b>104, 101, 108, 108, 111, 226, 152, 186, 228, 173, 162, 105, 116, 32, 119, 111, 114, 107, 115, 237, 160, 189, 237, 177, 141</b></div>
    <div>Actual value: <b id="ret"></b></div>
    <div>Expected value: <b id="ret"></b></div>
    <div>Actual value: <b id="ret2"></b></div>
    <script>
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.

    var stringToByteArray = function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b};
    function stringToByteArrayOld(str) {
    var bytes = [], code, i;

    for(i = 0; i < str.length; i++) {
    code = str.charCodeAt(i);

    if (code < 128) {
    bytes.push(code);
    } else if (code < 2048) {
    bytes.push(192+(code>>6), 128+(code&63));
    } else if (code < 65536) {
    bytes.push(224+(code>>12), 128+((code>>6)&63), 128+(code&63));
    } else if (code < 2097152) {
    bytes.push(240+(code>>18), 128+((code>>12)&63), 128+((code>>6)&63), 128+(code&63));
    }
    }

    return bytes;
    }

    document.getElementById( "ret" ).innerHTML = stringToByteArray("hello☺䭢it works👍")
    var stringToByteArray = function(a,b,c,d,e,f,g,h,i){for(b=[e=f=d=0];c=a.charCodeAt(d++);){g=128,c<g?b[e]=c:c<g*4?f=1:c<65536?f=2:c<2<<20&&(f=3);for(h=e++,i=f;f-->0;)b[e++]=g+(c>>f*6&63),b[h]=(2<<5-f)+(c>>6*i)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArray("hello☺䭢 it works")
    document.getElementById( "ret2" ).innerHTML = stringToByteArray("hello☺䭢 it works")
    </script>
  9. Rob Griffiths revised this gist Jun 4, 2011. 3 changed files with 5 additions and 5 deletions.
    6 changes: 3 additions & 3 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -22,22 +22,22 @@ function stringToByteArray(a,b,c,d,e,f){
    f = 1 // number of bytes left to process
    )
    :
    c < 2^16 // under 65536 is 3bytes
    c < 65536 // under 65536 is 3bytes
    ?
    (
    b[e] = 224 + (c >> 12), // shift down 12bits and put it into the correct range
    f = 2 // number of bytes left to process
    )
    :
    c < 2^21 && ( // finally, under 2097152 is 4bytes
    c < 2<<20 && ( // finally, under 2097152 is 4bytes
    b[e] = 240 + (c >> 18), // shift down 18bits and 240 so its in the right range
    f = 3 // 3bytes left to process
    );

    for( // process the remaining bytes indicated by `f`
    e++ // move onto the next slot in the byte array
    ;
    f-- // -1 and check if greater than 0 still
    f-- > 0 // -1 and check if greater than 0 still
    ;
    )
    b[e++] = 128 + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f--;)b[e++]=128+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<65536?(b[e]=224+(c>>12),f=2):c<2<<20&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b}
    2 changes: 1 addition & 1 deletion test.html
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.

    var stringToByteArray = function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b};
    var stringToByteArray = function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<65536?(b[e]=224+(c>>12),f=2):c<2<<20&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = stringToByteArray("hello☺䭢it works👍")
    </script>
  10. Rob Griffiths revised this gist Jun 4, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <!DOCTYPE html>
    <title>Foo</title>
    <div>Expected value: <b>undefined</b></div>
    <title>stringToByteArray</title>
    <div>Expected value: <b>104, 101, 108, 108, 111, 226, 152, 186, 228, 173, 162, 105, 116, 32, 119, 111, 114, 107, 115, 237, 160, 189, 237, 177, 141</b></div>
    <div>Actual value: <b id="ret"></b></div>
    <script>
    // write a small example that shows off the API for your example
  11. Rob Griffiths revised this gist Jun 4, 2011. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions stringToByteArray.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    function stringToByteArray(str) {
    var bytes = [], code, i;

    for(i = 0; i < str.length; i++) {
    code = str.charCodeAt(i);

    if (code < 128) {
    bytes.push(code);
    } else if (code < 2048) {
    bytes.push(192+(code>>6), 128+(code&63));
    } else if (code < 65536) {
    bytes.push(224+(code>>12), 128+((code>>6)&63), 128+(code&63));
    } else if (code < 2097152) {
    bytes.push(240+(code>>18), 128+((code>>12)&63), 128+((code>>6)&63), 128+(code&63));
    }
    }

    return bytes;
    }
  12. Rob Griffiths revised this gist Jun 4, 2011. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -32,12 +32,12 @@ function stringToByteArray(a,b,c,d,e,f){
    c < 2^21 && ( // finally, under 2097152 is 4bytes
    b[e] = 240 + (c >> 18), // shift down 18bits and 240 so its in the right range
    f = 3 // 3bytes left to process
    )
    );

    for( // process the remaining bytes indicated by `f`
    e++ // move onto the next slot in the byte array
    ;
    f-- > 0 // -1 and check if greater than 0 still
    f-- // -1 and check if greater than 0 still
    ;
    )
    b[e++] = 128 + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b}
    function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f--;)b[e++]=128+(c>>f*6&63)}return b}
  13. Rob Griffiths revised this gist Jun 4, 2011. 5 changed files with 52 additions and 51 deletions.
    32 changes: 0 additions & 32 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,32 +0,0 @@
    140byt.es
    =========

    A tweet-sized, fork-to-play, community-curated collection of JavaScript.

    How to play
    -----------

    1. Click the ![Fork](https://d3nwyuy0nl342s.cloudfront.net/images/gist/buttons/fork_button.png) button above to fork this gist.
    2. Modify all the files to according to the rules below.
    3. Save your entry and tweet it up!

    Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.

    Rules
    -----
    All entries must exist in an `index.js` file, whose contents are

    1. an assignable, valid Javascript expression that
    2. contains no more than 140 bytes, and
    3. does not leak to the global scope.

    All entries must also be licensed under the [WTFPL](http://sam.zoy.org/wtfpl/) or equally permissive license.

    For more information
    --------------------

    The [140byt.es](http://140byt.es) site hasn't launched yet, but for now follow [@140bytes](http://twitter.com/140bytes) on Twitter.

    To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to [the wiki](https://github.com/jed/140bytes/wiki/Byte-saving-techniques).

    140byt.es is brought to you by [Jed Schmidt](http://jed.is). It was inspired by work from [Thomas Fuchs](http://mir.aculo.us) and [Dustin Diaz](http://www.dustindiaz.com/).
    54 changes: 45 additions & 9 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,46 @@
    function(){
    // make sure
    // to annotate
    // your code
    // so everyone
    // can learn
    // from it!
    // see jed's entries
    // for examples.
    // http://en.wikipedia.org/wiki/UTF-8

    function stringToByteArray(a,b,c,d,e,f){
    for(
    b = [
    e =
    f =
    d = 0
    ] // initialise variables
    ;
    c = a.charCodeAt(d++) // get the character code from the string
    ;
    ){
    c < 128 // under 128 is UTF-8 (ASCII range), 1 byte
    ?
    b[e] = c // add to byte array
    :
    c < 2048 // under 2048 2bytes
    ?
    (
    b[e] = 192 + (c >> 6), // shift down 6bits, add 192 to put it in the right range
    f = 1 // number of bytes left to process
    )
    :
    c < 2^16 // under 65536 is 3bytes
    ?
    (
    b[e] = 224 + (c >> 12), // shift down 12bits and put it into the correct range
    f = 2 // number of bytes left to process
    )
    :
    c < 2^21 && ( // finally, under 2097152 is 4bytes
    b[e] = 240 + (c >> 18), // shift down 18bits and 240 so its in the right range
    f = 3 // 3bytes left to process
    )

    for( // process the remaining bytes indicated by `f`
    e++ // move onto the next slot in the byte array
    ;
    f-- > 0 // -1 and check if greater than 0 still
    ;
    )
    b[e++] = 128 + (c >> f*6 & 63) // shift f * 6 bits, mask 1byte and add 128
    }
    return b // return the byte array
    }
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(){/* Your entry, a useful, unique, and valid JavaScript expression that packs as much functionality into 140 bytes as possible. */}
    function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b}
    11 changes: 4 additions & 7 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,10 @@
    {
    "name": "theNameOfYourLibWhichMustBeAValidCamelCasedJavaScriptIdentifier",
    "name": "stringToByteArray",

    "description": "This should be a short description of your entry.",
    "description": "Convert a string of characters to an array of UTF-8 bytes",

    "keywords": [
    "five",
    "descriptive",
    "keywords",
    "or",
    "fewer"
    "cryptography",
    "utf8",
    ]
    }
    4 changes: 2 additions & 2 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.

    var myFunction = function(){ /* the code here should be identical to the entry. */ }
    var stringToByteArray = function(a,b,c,d,e,f){for(b=[e=f=d=0];c=a.charCodeAt(d++);){c<128?b[e]=c:c<2048?(b[e]=192+(c>>6),f=1):c<2^16?(b[e]=224+(c>>12),f=2):c<2^21&&(b[e]=240+(c>>18),f=3);for(e++;f-->0;)b[e++]=128+(c>>f*6&63)}return b};

    document.getElementById( "ret" ).innerHTML = myFunction()
    document.getElementById( "ret" ).innerHTML = stringToByteArray("hello☺䭢it works👍")
    </script>
  14. @140bytes 140bytes revised this gist Jun 1, 2011. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,12 @@
    <!DOCTYPE html>
    <body>
    <div>Expected value: <b>undefined</b></div>
    <div>Actual value: <b id="ret"></b></div>
    </body>
    <!DOCTYPE html>
    <title>Foo</title>
    <div>Expected value: <b>undefined</b></div>
    <div>Actual value: <b id="ret"></b></div>
    <script>
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.

    var myFunction = function(){ /* the code here should be identical to the entry. */ }
    var ret = myFunction()

    document.getElementById( "ret" ).innerHTML = ret
    document.getElementById( "ret" ).innerHTML = myFunction()
    </script>
  15. @140bytes 140bytes revised this gist Jun 1, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <!DOCTYPE html>
    <body>
    <div>Expected value: <b>undefined</b></div>
    <div>Actual value: <b id="ret"></b></div>
  16. @140bytes 140bytes revised this gist May 31, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test.html
    Original file line number Diff line number Diff line change
    @@ -9,5 +9,5 @@
    var myFunction = function(){ /* the code here should be identical to the entry. */ }
    var ret = myFunction()

    document.getElementById( "ret" ) = ret
    document.getElementById( "ret" ).innerHTML = ret
    </script>
  17. @140bytes 140bytes revised this gist May 31, 2011. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <body>
    <div>Expected value: <b>undefined</b></div>
    <div>Actual value: <b id="ret"></b></div>
    </body>
    <script>
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.

    var myFunction = function(){ /* the code here should be identical to the entry. */ }
    var ret = myFunction()

    document.getElementById( "ret" ) = ret
    </script>
  18. @140bytes 140bytes revised this gist May 31, 2011. 3 changed files with 17 additions and 19 deletions.
    17 changes: 9 additions & 8 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,10 @@
    function(){
    /* Rules:
    (1) anonymous function or IIFE // make sure
    (2) may execute immediately // to annotate
    (3) <=140 bytes // your code
    (4) no globals // so everyone
    (5) permissive license // can learn
    (6) have a good time! // from it!
    */}
    // make sure
    // to annotate
    // your code
    // so everyone
    // can learn
    // from it!
    // see jed's entries
    // for examples.
    }
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(){/******************************************************************************************************************************/}
    function(){/* Your entry, a useful, unique, and valid JavaScript expression that packs as much functionality into 140 bytes as possible. */}
    17 changes: 7 additions & 10 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,13 @@
    {
    // [REQUIRED] A name for your library.
    // This must match /^[a-z_]\w*$/i
    "name": "140bytes",
    "name": "theNameOfYourLibWhichMustBeAValidCamelCasedJavaScriptIdentifier",

    // [OPTIONAL] A description of your library, phrased as a verb predicate.
    // The gist description is used by default.
    "description": "Explain the 140byt.es rules.",
    "description": "This should be a short description of your entry.",

    // [OPTIONAL] Up to 5 keywords used for indexing.
    "keywords": [
    "140bytes",
    "master",
    "rules"
    "five",
    "descriptive",
    "keywords",
    "or",
    "fewer"
    ]
    }
  19. @140bytes 140bytes revised this gist May 26, 2011. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    function(){
    /* Rules:
    (1) anonymous function // make sure
    (2) may execute immediately // to annotate
    (3) <=140 bytes // your code
    (4) no globals // so everyone
    (5) permissive license // can learn
    (6) have a good time! // from it!
    (1) anonymous function or IIFE // make sure
    (2) may execute immediately // to annotate
    (3) <=140 bytes // your code
    (4) no globals // so everyone
    (5) permissive license // can learn
    (6) have a good time! // from it!
    */}
  20. @140bytes 140bytes revised this gist May 25, 2011. 3 changed files with 8 additions and 8 deletions.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ Rules
    -----
    All entries must exist in an `index.js` file, whose contents are

    1. an assignable, valid Javascript expression, that
    1. an assignable, valid Javascript expression that
    2. contains no more than 140 bytes, and
    3. does not leak to the global scope.

    12 changes: 6 additions & 6 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    function(){
    /* Rules:
    (1) anonymous function // make sure
    (2) may be self-executing // to annotate
    (3) <=140 bytes // your code
    (4) no globals // so everyone
    (5) MIT license // can learn
    (6) have a good time! // from it!
    (1) anonymous function // make sure
    (2) may execute immediately // to annotate
    (3) <=140 bytes // your code
    (4) no globals // so everyone
    (5) permissive license // can learn
    (6) have a good time! // from it!
    */}
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(){/*Rules: (1) anonymous function (2) may be self-executing (3) <=140 bytes (4) no globals (5) MIT license (6) have a good time!*/}
    function(){/******************************************************************************************************************************/}
  21. @140bytes 140bytes revised this gist May 23, 2011. 2 changed files with 14 additions and 21 deletions.
    33 changes: 13 additions & 20 deletions LICENSE.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,13 @@
    Copyright (c) 2011 YOUR_NAME_HERE, YOUR_URL_HERE

    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:

    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    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.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ All entries must exist in an `index.js` file, whose contents are
    2. contains no more than 140 bytes, and
    3. does not leak to the global scope.

    All entries must also be licensed under a license as or more permitting than the MIT license.
    All entries must also be licensed under the [WTFPL](http://sam.zoy.org/wtfpl/) or equally permissive license.

    For more information
    --------------------
  22. @140bytes 140bytes revised this gist May 23, 2011. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -16,12 +16,11 @@ Rules
    -----
    All entries must exist in an `index.js` file, whose contents are

    1. a valid Javascript function expression, that
    2. optionally self-executes,
    1. an assignable, valid Javascript expression, that
    2. contains no more than 140 bytes, and
    3. does not pollute global scope.
    3. does not leak to the global scope.

    All entries must also be licensed under the MIT license.
    All entries must also be licensed under a license as or more permitting than the MIT license.

    For more information
    --------------------
  23. @140bytes 140bytes revised this gist May 22, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@ How to play
    2. Modify all the files to according to the rules below.
    3. Save your entry and tweet it up!

    Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.

    Rules
    -----
    All entries must exist in an `index.js` file, whose contents are
  24. @140bytes 140bytes revised this gist May 21, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -26,4 +26,6 @@ For more information

    The [140byt.es](http://140byt.es) site hasn't launched yet, but for now follow [@140bytes](http://twitter.com/140bytes) on Twitter.

    To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to [the wiki](https://github.com/jed/140bytes/wiki/Byte-saving-techniques).

    140byt.es is brought to you by [Jed Schmidt](http://jed.is). It was inspired by work from [Thomas Fuchs](http://mir.aculo.us) and [Dustin Diaz](http://www.dustindiaz.com/).
  25. @140bytes 140bytes revised this gist May 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@

    // [OPTIONAL] A description of your library, phrased as a verb predicate.
    // The gist description is used by default.
    "description": "Explain the 140byt.es rules."
    "description": "Explain the 140byt.es rules.",

    // [OPTIONAL] Up to 5 keywords used for indexing.
    "keywords": [
  26. @140bytes 140bytes revised this gist May 18, 2011. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,16 @@
    {
    // [REQUIRED] A name for your library.
    // This must match /^[a-z_]\w*$/i
    "name": "140bytes",
    "keywords": [ "140bytes", "master", "rules" ]

    // [OPTIONAL] A description of your library, phrased as a verb predicate.
    // The gist description is used by default.
    "description": "Explain the 140byt.es rules."

    // [OPTIONAL] Up to 5 keywords used for indexing.
    "keywords": [
    "140bytes",
    "master",
    "rules"
    ]
    }
  27. @140bytes 140bytes revised this gist May 18, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,6 @@ All entries must also be licensed under the MIT license.
    For more information
    --------------------

    The [140byt.es](http://140byt.es) site hasn't launched yet, but for now follow [@140bytes](http://twitter.com/140bytes) on Twitter.
    The [140byt.es](http://140byt.es) site hasn't launched yet, but for now follow [@140bytes](http://twitter.com/140bytes) on Twitter.

    140byt.es is brought to you by [Jed Schmidt](http://jed.is). It was inspired by work from [Thomas Fuchs](http://mir.aculo.us) and [Dustin Diaz](http://www.dustindiaz.com/).
  28. @140bytes 140bytes revised this gist May 18, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,8 @@ Rules
    -----
    All entries must exist in an `index.js` file, whose contents are

    1. a valid Javascript function expression, that is
    2. is optionally self-executing,
    1. a valid Javascript function expression, that
    2. optionally self-executes,
    2. contains no more than 140 bytes, and
    3. does not pollute global scope.

  29. @140bytes 140bytes revised this gist May 18, 2011. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,20 @@ How to play
    -----------

    1. Click the ![Fork](https://d3nwyuy0nl342s.cloudfront.net/images/gist/buttons/fork_button.png) button above to fork this gist.
    2. Modify all the files to according to the rules and style guide below.
    2. Modify all the files to according to the rules below.
    3. Save your entry and tweet it up!

    Rules
    -----
    All entries must exist in an `index.js` file, whose contents are

    1. a valid Javascript function expression, that is
    2. is optionally self-executing,
    2. contains no more than 140 bytes, and
    3. does not pollute global scope.

    All entries must also be licensed under the MIT license.

    For more information
    --------------------

  30. @140bytes 140bytes revised this gist May 18, 2011. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    140byt.es
    =========

    All the Codes that Fits in Tweet
    A tweet-sized, fork-to-play, community-curated collection of JavaScript.

    How to play
    -----------
    @@ -12,4 +12,5 @@ How to play

    For more information
    --------------------
    The 140byt.es site launched yet, but for now follow [@140bytes](http://twitter.com/140bytes) on Twitter, and keep you eye on http://140byt.es.

    The [140byt.es](http://140byt.es) site hasn't launched yet, but for now follow [@140bytes](http://twitter.com/140bytes) on Twitter.