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
| var x = 0; | |
| // this will toggle between 0 and 1 everytime is reset | |
| x ^= 1; | |
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
| var x = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'], | |
| y = []; | |
| for (var i = 0; i < x.length; i++) { | |
| y[y.length] = x[i]; | |
| } |
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
| (function($){ | |
| $.fn.yourPluginName = function(){ | |
| // Your code goes here | |
| return this; | |
| }; | |
| })(jQuery); |
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
| var nodes = document.getElementsByTagName('*'); | |
| for (var i = nodes.length - 1; i >= 0; i--) { | |
| nodes[i].addEventListener('click', function() { | |
| console.log('You clicked element #' + i); | |
| }); | |
| } | |
| var nodes = document.getElementsByTagName('*'); | |
| for (var i = nodes.length - 1; i >= 0; i--) { | |
| nodes[i].addEventListener('click', (function(i) { |
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
| var obj = { | |
| foo: 'foo', | |
| toJSON: function () { | |
| return 'bar'; | |
| } | |
| }; | |
| JSON.stringify(obj); // '"bar"' | |
| JSON.stringify({x: obj}); // '{"x":"bar"}' |
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
| // abuse | |
| var orig = [...]; | |
| var stuff = []; | |
| _.each(orig, function (item) { | |
| var t = // do something to item | |
| // Mutate somebody else's thing | |
| stuff.push(t); | |
| }; | |
| // reduce |
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
| 1 - BOX SIZING | |
| @mixin box-sizing($type) | |
| { | |
| -webkit-box-sizing:$type; | |
| -moz-box-sizing:$type; | |
| box-sizing:$type; | |
| } | |
| div { | |
| @include box-sizing(border-box); |
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
| $base-color: orange; | |
| @mixin headline($size, $color: $base-color) { | |
| color: $color; | |
| font-size: $size; | |
| } | |
| h1 { | |
| @include headline(12px); | |
| } |
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
| @mixin pad ($pads...) { | |
| padding: $pads; | |
| } | |
| .one { | |
| @include pad(20px); | |
| } | |
| .two { | |
| @include pad(10px 20px); | |
| } |
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
| @mixin cont { | |
| background-color: black; | |
| color: white; | |
| @content; | |
| } | |
| div { | |
| @include cont { | |
| font-size: 12px; | |
| font-style: italic; |