How to redirect ex command output into current buffer or file?

:redir >name_of_registers_file :registers :redir END :r name_of_registers_file :help redir The last command is very useful, since there are lots of options for redirection: to variables, to registers, how to append, further cornucopia. I still find it weird and annoying that it uses END that way, but since everything else that can follow redir has to … Read more

Is there a way to programmably flush the buffer in log4net

Assuming you’re using log4net out of the box, you can dig your way down & flush the appender like this: public void FlushBuffers() { ILog log = LogManager.GetLogger(“whatever”); var logger = log.Logger as Logger; if (logger != null) { foreach (IAppender appender in logger.Appenders) { var buffered = appender as BufferingAppenderSkeleton; if (buffered != null) … Read more

Buffer entire file in memory with Node.js

Basically, you need to use the readFile or readFileSync function from the fs module. They return the complete content of the given file, but differ in their behavior (asynchronous versus synchronous). If blocking Node.js (e.g. on startup of your application) is not an issue, you can go with the synchronized version, which is as easy … Read more

When to use .NET BufferedStream class?

According to Brad Abrams, almost never: link No, there is zero benefit from wrapping a BufferedStream around a FileStream. We copied BufferedStream’s buffering logic into FileStream about 4 years ago to encourage better default performance… In fact, I don’t think there are any Streams in the .NET Framework that require it, but it might be … Read more

Binary buffer in Python

You are probably looking for io.BytesIO class. It works exactly like StringIO except that it supports binary data: from io import BytesIO bio = BytesIO(b”some initial binary data: \x00\x01″) StringIO will throw TypeError: from io import StringIO sio = StringIO(b”some initial binary data: \x00\x01″)