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 buff = new Buffer(100); | |
fs.open(file, 'r', function(err, fd) { | |
fs.read(fd, buff, 0, 100, 0, function(err, bytesRead, buffer) { | |
var start = buffer.indexOf(new Buffer('mvhd')) + 17; | |
var timeScale = buffer.readUInt32BE(start, 4); | |
var duration = buffer.readUInt32BE(start + 4, 4); | |
var movieLength = Math.floor(duration/timeScale); | |
console.log('time scale: ' + timeScale); | |
console.log('duration: ' + duration); |
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 fs = require('fs'); | |
fs.readFile('test.png', function (err, data) { | |
var pngHeader = new Buffer([137, 80, 78, 71, 13, 10, 26, 10]); | |
var header = data.slice(0, 8); | |
if(header.compare(pngHeader) != 0) { | |
console.log('Invalid png file header!') | |
process.exit(); | |
} | |
var fileHeader = { |
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
Block b = .... | |
BlockFace[] sides = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; | |
for(BlockFace bf : sides) { | |
if(b.getRelative(bf, 1).getType() == b.getType()) { | |
Inventory left = ((DoubleChestInventory)((InventoryHolder)b.getState()).getInventory()).getLeftSide(); | |
Inventory right = ((DoubleChestInventory)((InventoryHolder)b.getState()).getInventory()).getRightSide(); |