C char array initialization: what happens if there are less characters in the string literal than the array size?

The first declaration: char buf[10] = “”; is equivalent to char buf[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; The second declaration: char buf[10] = ” “; is equivalent to char buf[10] = {‘ ‘, 0, 0, 0, 0, 0, 0, 0, 0, 0}; The third declaration: char buf[10] = “a”; … Read more

What are the differences between readable and data event of process.stdin stream?

They are two different APIs that allow you to access the same stream of data blocks. The ‘readable’ API was introduced in Node 0.10.0 as part of “Streams 2”, so if you search for that, it should help. The core of the issue is that the ‘readable’ interface allows for much simpler managing and buffering … Read more

How to know actual size of byte buffer`s content in nodejs?

You need byteLength: var buff = fs.readFileSync(__dirname + ‘/test.txt’); console.log(Buffer.byteLength(buff)); For node 0.10.21 you can try this: Update buffer.toSTring() is unsafe, since buffers are meant to store binary data and toString() will attempt to do character encoding translation which will corrupt the binary data. console.log(buff.toString().length);

Buffered files (for faster disk access)

Windows file caching is very effective, especially if you are using Vista or later. TFileStream is a loose wrapper around the Windows ReadFile() and WriteFile() API functions and for many use cases the only thing faster is a memory mapped file. However, there is one common scenario where TFileStream becomes a performance bottleneck. That is … Read more

Use of Vertex Array Objects and Vertex Buffer Objects

Fundamentally, you need to understand two things: Vertex Array Objects (VAOs) are conceptually nothing but thin state wrappers. Vertex Buffer Objects (VBOs) store actual data. Another way of thinking about this is that VAOs describe the data stored in one or more VBOs. Think of VBOs (and buffer objects in general) as unstructured arrays of … Read more

How can I save my mini-buffer history in Emacs?

As Trey Jackson said, you want to put this: (savehist-mode) in your Emacs start up file, then restart Emacs. (Calling it interactively will stomp on your current mini-buffer history, so you may not want to do that.) It’s also worth pointing out that you can persist other variables across sessions by adding them to savehist-additional-variables, … Read more