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
| <div><!-- 1 --> | |
| <span class="red"><!-- 6 --></span> | |
| </div> | |
| <div><!-- 2 --> | |
| <span class="green"><!-- 4 --><span> | |
| </div> | |
| <div><!-- 3 --> | |
| <span class="blue"><!-- 5 --></span> | |
| </div> |
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
| <div><!-- 1 --> | |
| <span class="red"><!-- 1.1 --></span> | |
| </div> | |
| <div><!-- 2 --> | |
| <span class="green"><!-- 4 --><span> | |
| </div> | |
| <div><!-- 3 --> | |
| <span class="blue"><!-- 5 --></span> | |
| </div> |
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
| myname = "global"; // global variable | |
| function func() { | |
| alert(myname); // "undefined" | |
| var myname = "local"; | |
| alert(myname); // "local" | |
| } | |
| func(); |
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 Waffle() { | |
| if (!(this instanceof Waffle)) { | |
| return new Waffle(); | |
| } | |
| this.tastes = "yummy"; | |
| } | |
| Waffle.prototype.wantAnother = true; | |
| // testing invocations | |
| var first = new Waffle(), | |
| second = Waffle(); |
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
| // Immediate function style 1 | |
| (function () { // JSLint prefers this one | |
| alert('watch out!'); | |
| }()); | |
| // Immediate function style 2 | |
| (function () { | |
| alert('watch out!'); | |
| })(); |
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 () { | |
| alert('watch out!'); | |
| }(); |
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
| /* | |
| * BMP FileHeader | |
| */ | |
| private class FileHeader { // 14 bytes | |
| public String signature; | |
| public int fileSize; | |
| public short reserved1; | |
| public short reserved2; | |
| public int fileOffsetToPixelArray; | |
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
| // Serialize the pixels | |
| int width = _bmp.getWidth(); | |
| int [] pixels = new int[width]; | |
| for (int h = _bmp.getHeight() - 1; h >= 0; h--) { // reverse scan line | |
| _bmp.getPixels(pixels, 0, width, 0, h, width, 1); | |
| for (int i = 0; i < width; ++i) | |
| pixels[i] = ByteOrder.reverse(pixels[i]); // reverse ARGB as BGRA | |
| dosl.write(pixels); | |
| } | |
| dosl.close(); |
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
| private int downSample(float factor, byte [] in, byte [] out) { | |
| int bytes = 4; // one audio sample is 32bits | |
| factor = 1.0f / factor; | |
| int downSampleCount = (int) (((in.length / bytes)) * factor); | |
| int ouputSampleCount = 0; | |
| for (int i = 0; i < downSampleCount; ++i) { | |
| float scaledIndex = i * factor; | |
| int floorIndex = (int)(scaledIndex); |
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
| if (x && y) { … } // bad | |
| if (!(!x || !y)) { … } // good |