In JavaScript, nested promises will automatically be flattened by .then
and await
: await Promise.resolve(Promise.resolve(5)) === 5
. This will cause issues with asynchronous methods taking generic values; as they will behave different if they take a Promise than with any other object.
Java Scanners (and other classes) use buffering behind the scenes. Therefore, when experiencing unexpected blocking when using custom Java Input-/OutputStreams, additionally override the read(byte[], int, int)
and write(byte[], int, int)
methods along with their no-argument variants. Counter-intuitively, these may return less bytes than requested (but at least one), without blocking. However, the default implementation does not make use of that. Therefore, buffers use them to do non-blocking buffer reads.
Additionally, you might want to consider overriding flush()
and available()
, but these seem to be of lesser significance.
When creating a draggable map, it might act weird when you move your mouse too quickly or outside the window, for example:
However, if we listen to mouseup
and mousemove
on window
or document
, it works:
If you’re running a process that listens on localhost in a Docker container/VM/…, and you want to access it from the outside world but it doesn’t work (even if forwarding works correctly), try explicitly setting the process host to 0.0.0.0 instead of 127.0.0.1. That may or may not fix it.
Here’s a simple tool to perform letter frequency analysis for characters and n-grams.
Read more...The SCP protocol is largely undocumentated, which is why you’re left in the dark if you’re trying to write your own implementation. However, by experimenting, I found some of the inner workings, and also how to write your own client and server.
First of all you might want to think about whether you really want to make your own implementation, or whether the -S
argument to change the transport layer is maybe sufficient already. The transport program must use stdin and stdout to communicate with scp. For detailed information, run scp -v -S echo 0.0.0.0:file.in file.out
and scp -v -S echo file.in 0.0.0.0:file.out
. Please make sure that you don’t accidentally print log messages or similar to stdout, as this will cause the process to fail.
If you decide you want to dig deeper, there are two undocumented scp
flags. The first is -f
, which reads from disk into stdout, and the other is -t
, which writes to disk from stdin.
Esc
-> :
-> q
-> !
-> Enter
git config --global core.editor="nano"
might help you, too :)