Skip to content

Instantly share code, notes, and snippets.

@gokulkrishh
Forked from addyosmani/README.md
Last active June 16, 2020 16:32

Revisions

  1. @addyosmani addyosmani revised this gist Oct 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    CSS Layout Debbuger
    CSS Layout Debugger
    =====================

    A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
  2. @addyosmani addyosmani revised this gist Sep 29, 2014. 1 changed file with 0 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions LICENSE.txt
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    Version 2, September 2014

    Copyright (C) 2014 Addy Osmani @addyosmani

    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.
  3. @addyosmani addyosmani revised this gist Sep 29, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion LICENSE.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    Version 2, December 2014
    Version 2, September 2014

    Copyright (C) 2014 Addy Osmani @addyosmani

  4. @addyosmani addyosmani revised this gist Sep 28, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    CSS Layout Debbuger
    =====================

    A tweet-sized debugger for visualizing your CSS layouts. Gives every DOM element on your page a random (valid) CSS hex color.
    A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

    **One-line version to paste in your DevTools**

  5. @addyosmani addyosmani revised this gist Sep 27, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ Tested in IE:

    Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/515533526549024768) for verifying.

    # Improvement: Tag Specific Color Highlighting
    # Tag Specific Layout Debugging In 82 Bytes

    My original implementation outlined each DOM element on the page with a random (valid) hex color.

  6. @addyosmani addyosmani revised this gist Sep 27, 2014. 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
    @@ -45,7 +45,9 @@ Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/5155335265490

    # Improvement: Tag Specific Color Highlighting

    My original implementation outlined each DOM element on the page with a random (valid) hex color. Thanks to the work by @aemkei, @p01, @sindresorhus and other commenters, we now have an even shorter version (108 bytes golfed down to 82) that uses a specific hex color *per tag name*. This lets you visually group elements similar to how pesticide.io does.
    My original implementation outlined each DOM element on the page with a random (valid) hex color.

    Thanks to the work by @aemkei, @p01, @sindresorhus and other commenters, we now have an even shorter version (108 bytes golfed down to 82) that uses a specific hex color *per tag name*. This lets you visually group elements similar to how pesticide.io does.

    ```js
    for(i=0;A=$$("*")[i++];)A.style.outline="solid hsl("+(A+A).length*9+",99%,50%)1px"
  7. @addyosmani addyosmani revised this gist Sep 27, 2014. 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
    @@ -45,7 +45,7 @@ Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/5155335265490

    # Improvement: Tag Specific Color Highlighting

    There are several optimizations made in the comments that improve on the original source - check em' out. One that goes beyond code-golfing in this version by @aemkei that mimics pesticide.io, using a specific color for every tag name:
    My original implementation outlined each DOM element on the page with a random (valid) hex color. Thanks to the work by @aemkei, @p01, @sindresorhus and other commenters, we now have an even shorter version (108 bytes golfed down to 82) that uses a specific hex color *per tag name*. This lets you visually group elements similar to how pesticide.io does.

    ```js
    for(i=0;A=$$("*")[i++];)A.style.outline="solid hsl("+(A+A).length*9+",99%,50%)1px"
    @@ -54,3 +54,5 @@ for(i=0;A=$$("*")[i++];)A.style.outline="solid hsl("+(A+A).length*9+",99%,50%)1p
    Preview:

    ![](http://i.imgur.com/N5VkRC6.png)

    Thanks for the awesome help improving this folks <3
  8. @addyosmani addyosmani revised this gist Sep 27, 2014. 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
    @@ -43,7 +43,7 @@ Tested in IE:

    Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/515533526549024768) for verifying.

    # Improvements
    # Improvement: Tag Specific Color Highlighting

    There are several optimizations made in the comments that improve on the original source - check em' out. One that goes beyond code-golfing in this version by @aemkei that mimics pesticide.io, using a specific color for every tag name:

    @@ -53,4 +53,4 @@ for(i=0;A=$$("*")[i++];)A.style.outline="solid hsl("+(A+A).length*9+",99%,50%)1p

    Preview:

    ![](http://i.imgur.com/lrcDQJm.png)
    ![](http://i.imgur.com/N5VkRC6.png)
  9. @addyosmani addyosmani revised this gist Sep 27, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/5155335265490
    There are several optimizations made in the comments that improve on the original source - check em' out. One that goes beyond code-golfing in this version by @aemkei that mimics pesticide.io, using a specific color for every tag name:

    ```js
    for(i=0;A=$$("*")[i++];)A.style.outline="1px solid hsl("+(A+A).length*9+",99%,50%)"
    for(i=0;A=$$("*")[i++];)A.style.outline="solid hsl("+(A+A).length*9+",99%,50%)1px"
    ```

    Preview:
  10. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -42,3 +42,15 @@ Tested in IE:
    ![](http://i.imgur.com/j4A3eNq.png)

    Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/515533526549024768) for verifying.

    # Improvements

    There are several optimizations made in the comments that improve on the original source - check em' out. One that goes beyond code-golfing in this version by @aemkei that mimics pesticide.io, using a specific color for every tag name:

    ```js
    for(i=0;A=$$("*")[i++];)A.style.outline="1px solid hsl("+(A+A).length*9+",99%,50%)"
    ```

    Preview:

    ![](http://i.imgur.com/lrcDQJm.png)
  11. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -36,3 +36,9 @@ Tested from Firefox DevTools:
    Tested from WebKit Nightlies (Safari):

    ![](http://i.imgur.com/HeUZE2V.png)

    Tested in IE:

    ![](http://i.imgur.com/j4A3eNq.png)

    Thanks to [gregwhitworth](https://twitter.com/gregwhitworth/status/515533526549024768) for verifying.
  12. @addyosmani addyosmani revised this gist Sep 26, 2014. 4 changed files with 11 additions and 11 deletions.
    8 changes: 4 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -7,18 +7,18 @@ A tweet-sized debugger for visualizing your CSS layouts. Gives every DOM element

    Use `$$` if your browser aliases it:

    ~ 110 byte version
    ~ 108 byte version

    ```javascript
    [].forEach.call($$("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    [].forEach.call($$("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
    ```

    Using `document.querySelectorAll`:

    ~ 132 byte version
    ~ 131 byte version

    ```javascript
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
    ```

    If you're looking for a proper version that uses a set color per tag type, check out [pesticide.io](http://pesticide.io).
    6 changes: 3 additions & 3 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@ function(a){ // Supply a valid selector (e.g '*' for
    [].forEach.call( // Treat Nodelist as an Array (fewer bytes than Array.prototype.forEach.call(...);)
    // Gets the prototype of Array & uses call to execute the function on the NodeList.
    document.querySelectorAll(a), // Query DOM for elements matching the supplied selector
    // (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    // (For 108 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    (~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}) // Convert to a base 16 number. BOOM.
    }
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    function(a){return [].forEach.call(document.querySelectorAll(a),function(b){b.style.outline = "1px solid #" +(+~~(Math.random()*(1<<24))).toString(16)});}
    function(a){return [].forEach.call(document.querySelectorAll(a),function(b){b.style.outline = "1px solid #" +(~~(Math.random()*(1<<24))).toString(16)});}
    6 changes: 3 additions & 3 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -24,9 +24,9 @@
    // (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    (~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}) // Convert to a base 16 number. BOOM.
    }
    myFunction('*');
    </script>
    <!-- quick JSBin:http://jsbin.com/soseq/1/edit -->
    <!-- quick JSBin:http://jsbin.com/soseq/2/edit -->
  13. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    CSS Layout Debbuger
    =====================

    A tweet-sized debugger for visualizing your CSS layouts.
    A tweet-sized debugger for visualizing your CSS layouts. Gives every DOM element on your page a random (valid) CSS hex color.

    **One-line version to paste in your DevTools**

  14. @addyosmani addyosmani revised this gist Sep 26, 2014. 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
    @@ -29,3 +29,4 @@
    }
    myFunction('*');
    </script>
    <!-- quick JSBin:http://jsbin.com/soseq/1/edit -->
  15. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -17,13 +17,15 @@
    <div>I am element</div>
    <div>I am element</div>
    <script>
    var myFunction = function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (could be shortened to $() as Chrome & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    var myFunction = function(a){ // Supply a valid selector (e.g '*' for wildcard)
    [].forEach.call( // Treat Nodelist as an Array (fewer bytes than Array.prototype.forEach.call(...);)
    // Gets the prototype of Array & uses call to execute the function on the NodeList.
    document.querySelectorAll(a), // Query DOM for elements matching the supplied selector
    // (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    }
    }
    myFunction('*');
    </script>
  16. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    function(a){ // Supply a valid selector (e.g '*' for wildcard)
    [].forEach.call( // Convert Nodelist -> Array
    [].forEach.call( // Treat Nodelist as an Array (fewer bytes than Array.prototype.forEach.call(...);)
    // Gets the prototype of Array & uses call to execute the function on the NodeList.
    document.querySelectorAll(a), // Query DOM for elements matching the supplied selector
    // (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    function(b){
  17. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    function(a){ // Supply a valid selector (e.g '*' for all)
    function(a){ // Supply a valid selector (e.g '*' for wildcard)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    document.querySelectorAll(a), // Query DOM for elements matching the supplied selector
    // (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
  18. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ Tested from Chrome DevTools:

    Tested from Firefox DevTools:

    ![](http://i.imgur.com/3qgOAXJ.jpeg)
    ![](http://i.imgur.com/3qgOAXJ.png)

    Tested from WebKit Nightlies (Safari):

  19. @addyosmani addyosmani revised this gist Sep 26, 2014. 2 changed files with 19 additions and 5 deletions.
    22 changes: 18 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,12 @@ A tweet-sized debugger for visualizing your CSS layouts.

    **One-line version to paste in your DevTools**

    Use `$` or `$$` if your browser aliases it:
    Use `$$` if your browser aliases it:

    ~ 109 byte version
    ~ 110 byte version

    ```javascript
    [].forEach.call($("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    [].forEach.call($$("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```

    Using `document.querySelectorAll`:
    @@ -21,4 +21,18 @@ Using `document.querySelectorAll`:
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```

    If you're looking for a proper version that uses a set color per tag type, check out [pesticide.io](http://pesticide.io).
    If you're looking for a proper version that uses a set color per tag type, check out [pesticide.io](http://pesticide.io).

    ## Screenshots

    Tested from Chrome DevTools:

    ![](http://i.imgur.com/8w5y2q1.png)

    Tested from Firefox DevTools:

    ![](http://i.imgur.com/3qgOAXJ.jpeg)

    Tested from WebKit Nightlies (Safari):

    ![](http://i.imgur.com/HeUZE2V.png)
    2 changes: 1 addition & 1 deletion annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (For 109 bytes, use $() as Chrome & FF expose it in DevTools)
    document.querySelectorAll(a), // Query for the selector (For 110 bytes, use $$() as Chrome, Safari & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
  20. @addyosmani addyosmani revised this gist Sep 26, 2014. 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
    @@ -5,7 +5,7 @@ A tweet-sized debugger for visualizing your CSS layouts.

    **One-line version to paste in your DevTools**

    Using `$` if your browser aliases it:
    Use `$` or `$$` if your browser aliases it:

    ~ 109 byte version

    @@ -21,4 +21,4 @@ Using `document.querySelectorAll`:
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```

    If you're looking for a non-toy version of the script, check out pesticide.io.
    If you're looking for a proper version that uses a set color per tag type, check out [pesticide.io](http://pesticide.io).
  21. @addyosmani addyosmani revised this gist Sep 26, 2014. 2 changed files with 11 additions and 15 deletions.
    10 changes: 5 additions & 5 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (For 109 bytes, use $() as Chrome & FF expose it in DevTools)
    function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (For 109 bytes, use $() as Chrome & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    }
    16 changes: 6 additions & 10 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -17,17 +17,13 @@
    <div>I am element</div>
    <div>I am element</div>
    <script>
    // write a small example that shows off the API for your example
    // and tests it in one fell swoop.

    var myFunction = function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (could be shortened to $() as Chrome & FF expose it in DevTools)
    var myFunction = function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (could be shortened to $() as Chrome & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    }

    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    }
    myFunction('*');
    </script>
  22. @addyosmani addyosmani revised this gist Sep 26, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (could be shortened to $() as Chrome & FF expose it in DevTools)
    document.querySelectorAll(a), // Query for the selector (For 109 bytes, use $() as Chrome & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
  23. @addyosmani addyosmani revised this gist Sep 25, 2014. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    CSS Layout Debuger
    CSS Layout Debbuger
    =====================

    A tweet-sized debugger for visualizing your CSS layouts.
    @@ -19,4 +19,6 @@ Using `document.querySelectorAll`:

    ```javascript
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```
    ```

    If you're looking for a non-toy version of the script, check out pesticide.io.
  24. @addyosmani addyosmani revised this gist Sep 25, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -7,12 +7,16 @@ A tweet-sized debugger for visualizing your CSS layouts.

    Using `$` if your browser aliases it:

    ~ 109 byte version

    ```javascript
    [].forEach.call($("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```

    Using `document.querySelectorAll`:

    ~ 132 byte version

    ```javascript
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```
  25. @addyosmani addyosmani revised this gist Sep 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ CSS Layout Debuger

    A tweet-sized debugger for visualizing your CSS layouts.

    One-line version to paste in your DevTools
    **One-line version to paste in your DevTools**

    Using `$` if your browser aliases it:

  26. @addyosmani addyosmani revised this gist Sep 25, 2014. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,16 @@ CSS Layout Debuger

    A tweet-sized debugger for visualizing your CSS layouts.

    One-line version to paste in your DevTools:
    One-line version to paste in your DevTools

    Using `$` if your browser aliases it:

    ```javascript
    [].forEach.call($("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```

    Using `document.querySelectorAll`:

    ```javascript
    [].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```
  27. @addyosmani addyosmani revised this gist Sep 25, 2014. 6 changed files with 50 additions and 55 deletions.
    4 changes: 2 additions & 2 deletions LICENSE.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    Version 2, December 2004
    Version 2, December 2014

    Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
    Copyright (C) 2014 Addy Osmani @addyosmani

    Everyone is permitted to copy and distribute verbatim or modified
    copies of this license document, and changing it is allowed as long
    36 changes: 7 additions & 29 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,10 @@
    140byt.es
    =========
    CSS Layout Debuger
    =====================

    A tweet-sized, fork-to-play, community-curated collection of JavaScript.
    A tweet-sized debugger for visualizing your CSS layouts.

    How to play
    -----------
    One-line version to paste in your DevTools:

    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
    --------------------

    See the [140byt.es](http://140byt.es) site for a showcase of entries (built itself using 140-byte entries!), and 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), with help from Alex Kloss. It was inspired by work from [Thomas Fuchs](http://mir.aculo.us) and [Dustin Diaz](http://www.dustindiaz.com/).
    ```javascript
    [].forEach.call($("*"),function(a){a.style.outline="1px solid #"+(+~~(Math.random()*(1<<24))).toString(16)});
    ```
    16 changes: 7 additions & 9 deletions annotated.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,8 @@
    function(){
    // make sure
    // to annotate
    // your code
    // so everyone
    // can learn
    // from it!
    // see jed's entries
    // for examples.
    function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (could be shortened to $() as Chrome & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    }
    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){return [].forEach.call(document.querySelectorAll(a),function(b){b.style.outline = "1px solid #" +(+~~(Math.random()*(1<<24))).toString(16)});}
    12 changes: 5 additions & 7 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,11 @@
    {
    "name": "theNameOfYourLibWhichMustBeAValidCamelCasedJavaScriptIdentifier",
    "name": "CSSLayoutDebugger",

    "description": "This should be a short description of your entry.",
    "description": "A helper for debugging CSS layouts",

    "keywords": [
    "five",
    "descriptive",
    "keywords",
    "or",
    "fewer"
    "css",
    "layout",
    "debugger"
    ]
    }
    35 changes: 28 additions & 7 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,33 @@
    <!DOCTYPE html>
    <title>Foo</title>
    <div>Expected value: <b>undefined</b></div>
    <div>Actual value: <b id="ret"></b></div>
    <!DOCTYPE html>
    <title>CSS Layout Debugger</title>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</div>
    <div>I am element</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 myFunction = function(a){ // Supply a valid selector (e.g '*' for all)
    [].forEach.call( // Convert Nodelist -> Array
    document.querySelectorAll(a), // Query for the selector (could be shortened to $() as Chrome & FF expose it in DevTools)
    function(b){
    b.style.outline = "1px solid #" + // Set the selector outline
    (+~~(Math.random()*(1<<24))) // Pick a valid random CSS hex color
    .toString(16)}); // Convert to a base 16 number. BOOM.
    }

    document.getElementById( "ret" ).innerHTML = myFunction()
    </script>
    myFunction('*');
    </script>
  28. @140bytes 140bytes revised this gist Jul 28, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ All entries must also be licensed under the [WTFPL](http://sam.zoy.org/wtfpl/) o
    For more information
    --------------------

    See the [140byt.es](http://140byt.es) for a showcase of entries built itself using 140-byte entries, and follow [@140bytes](http://twitter.com/140bytes) on Twitter.
    See the [140byt.es](http://140byt.es) site for a showcase of entries (built itself using 140-byte entries!), and 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).

  29. @140bytes 140bytes revised this gist Jul 28, 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
    @@ -25,8 +25,8 @@ All entries must also be licensed under the [WTFPL](http://sam.zoy.org/wtfpl/) o
    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.
    See the [140byt.es](http://140byt.es) for a showcase of entries built itself using 140-byte entries, and 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/).
    140byt.es is brought to you by [Jed Schmidt](http://jed.is), with help from Alex Kloss. It was inspired by work from [Thomas Fuchs](http://mir.aculo.us) and [Dustin Diaz](http://www.dustindiaz.com/).
  30. @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>