Немного о веселом. Думаю, лучше без перевода:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DEVELOPERS' WORKSHOP: The Refrigerator Question
By Eric Shepherd -- <sheppy@be.com>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Of all the functions the BeOS provides to programmers, one of the least understood and
most widely debated is is_computer_on(). Documentation has been sketchy, and developers
have debated the best use for this function. This week, we'll investigate is_computer_on()
in depth.
Some developers claim that this function always returns 1, and say that it's a sham. They say their tests have produced significant empirical evidence to this effect. Others offer circumstantial evidence, such as "programs can't run when the computer's off," which doesn't really explain anything.
This is a lot like trying to figure out if the light stays on in the refrigerator when you close the door. How can you be sure that is_computer_on() isn't returning some other value when the computer's off? Let's look at a test program:
#include <OS.h>
#include <stdio.h>
int main(void) {
int i;
printf("# Result\n");
printf("----- ------\n");
for (i=1;i<=25;i++) {
printf("%-5d %ld\n", i, is_computer_on());
}
return 0;
}
If you run this program, you get the following output:
# Result
----- ------
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
(and so on)
Now try running the program and shutting off your computer while it's running. Unfortunately, printf() doesn't work reliably in this case; you don't see your output, because the computer's video hardware becomes unreliable when turned off. You might try customizing this code to write the output to disk, but unfortunately, hard drives also become unreliable when power isn't applied to them throughout their operation. Networking and serial ports likewise have a high failure rate when power is turned off.
In other words, the empirical evidence is a little flimsy. Due to failures beyond Be's control, test programs such as the one above can't present their full results. I'm not saying that is_computer_on() returns some other value when the computer isn't running, but this is a prime example of the difficulty encountered when testing a theory through code.
However, Be guarantees that is_computer_on() will always return 1 if the computer is running.
С какого-то момента, примерно год или два назад, веб студии стали массово клепать сайты исходя из предположения, что заходящий на них точно согласился в браузере определять своё местоположение. Если же это вдруг не так (что с десктопа, в принципе, нередкость) приходится проходить квест, чтобы получить желаемое. Вариантов там ...далее
"Finally, we come to the instruction we've all been waiting for – SEX!" / из статьи про микропроцессор CDP1802 / В начале 1970-х в США были весьма популярны простые электронные игры типа Pong (в СССР их аналоги появились в продаже через 5-10 лет). Как правило, такие игры не имели микропроцессора и памяти в современном понимании этих слов, а строились на жёсткой ...далее