This file contains 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 () { | |
var a=1, | |
b=2, | |
c=3 | |
d=4, | |
e=5, | |
f=6; | |
}()); | |
console.log(d,e,f); // 4,5,6 |
This file contains 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 i = 27 // 27 | |
var j = 027 // 23 |
This file contains 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 foo (x) { | |
if (x=true) { | |
// no matter what value is | |
// passed in for x, this | |
// will always execute | |
} | |
} | |
foo(false); |
This file contains 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
Math.floor(.5 + ((Math.cos(val)*.5))) |
This file contains 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 (!val) { … } |
This file contains 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 foo = function (person) { | |
// stuff happens | |
// perhaps a breakpoint is added here | |
// or they attempt to log the object | |
console.log(person); | |
} | |
var person = {}; | |
person[‘\t’] = ‘Nicholas’; |
This file contains 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 |
This file contains 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 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 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; | |
NewerOlder