Rethinkdb recently published a cat challenge. Well, it’s not really a challenging challenge if you can solve it by looking up Vigenère encryption from Wikipedia and following instructions.
I don’t want to debate the pro and cons of the remainder operator in ANSI C and CPython: the two standards adopt one the divisor, the other the dividend’s sign for the result of the remainder operator. While the original K&R C left it to be platform dependent, if I remember correctly. I am not much of a systems hacker and I am on the wrong side of the Atlantic to submit my candidature, unless they’d consider sponsoring people from Europe — which I doubt.
I find however interesting their additional challenge, the dog command: it’s really a sort of glorified, asynchronous version of tee.
I am preparing for an interview in Berlin tomorrow, so I don’t have the time to write a full blown dog command today, but I did some preliminary research.
Writing non-blocking, Asynchronous I/O is still somewhat platform dependant:
- On Windows, your best bet is overlapped I/O with FILE_FLAG_OVERLAPPED.
- On POSIX, you can use aio.h.
- If you are specifically on Linux, you can go even faster avoiding copying in and out of user space by using tee(2), splice(2) and vmsplice(2).
Given that they wrote a man page for dog, I’d go with the POSIX or Linux solution.