Sensei

Member Since 04 Oct 2013
Offline Last Active Today, 04:40 PM

#972829Palindromes by multiplication

Posted by on 20 February 2017 - 03:44 AM

That of course is true Sensei - I had forgotten that it was I who had introduced the idea of the the leading zero.

I found that his Python code fails with f.e. num=30..

My .NET Framework version of it, is showing "30*1=44".
after using 64 bit integers I got:
30 * 143165578 = 4294967340

2^32 = 4294967296
4294967340 - 4294967296 = 44...
The most significant bit set, is truncated, because of overflow of 32 bit integer..

After using long long everywhere in code ends up in infinite loop (2^64 numbers to check).

Could you prove that for any integer n (not divisible by 10) there is a palindrome (in decimal representation) divisible by n?

Divisibility test for 11 is the answer you're searching for?

According to
https://en.wikipedia...lindromic_prime
"Except for 11, all palindromic primes have an odd number of digits, because the divisibility test for 11 tells us that every palindromic number with an even number of digits is a multiple of 11."

Modified version of project. Instead of incrementing k by 1, it increments by 11.

• 1

#971405New flat earther video that's going around.

Posted by on 10 February 2017 - 11:07 PM

New flat earther video that's going around. (...) I thought some people here might find it entertaining.

Only imbeciles, will find it entertaining..

• 0

#971263SYMMETRY !

Posted by on 9 February 2017 - 09:23 PM

For example two eyes are designed to adore our faces.

Lol. Nonsense.

Two eyes are needed to being able to see 3 dimensions. One eye system cannot measure distance.

Robots made by human also must have two cameras (if they use visual spectrum of light, not radio waves to detect distance, which simply rely on reflection of photons from environment (different delay t=2d/c) ).

Computer analyze point in 1st camera image, and try to find it on 2nd camera image, and use Pythagorean triangle to calculate depth (distance between eyes/cameras is known/constant parameter)

• 0

#970703What will happen if we heat wood to a very high temperature by radiation in a...

Posted by on 6 February 2017 - 08:56 PM

If we heat wood like substance, it starts to burn and not melt.

It will start burning only when there is ready access to air or pure Oxygen.

If there is no easy access to air/Oxygen, it'll be dry distillation process.
https://en.wikipedia...ry_distillation
"Dry distillation is the heating of solid materials to produce gaseous products (which may condense into liquids or solids)."
"The method has been used to obtain liquid fuels from coal and wood. "

"When wood is heated above 270°C it begins to carbonize. If air is absent the final product, since there is no oxygen present to react with the wood, is charcoal. If air, which contains oxygen, is present, the wood will catch fire and burn when it reaches a temperature of about 400500°C and the fuel product is wood ash. If wood is heated away from air, first the moisture is driven off and until this is complete, the wood temperature remains at about 100110°C. When the wood is dry its temperature rises and at about 270°C it begins to spontaneously decompose and, at the same time, heat is evolved. This is the well known exothermic reaction which takes place in charcoal burning. At this stage evolution of the by-products of wood carbonization starts. These substances are given off gradually as the temperature rises and at about 450°C the evolution is complete. The solid residue, charcoal, is mainly carbon (about 70%) and small amounts of tarry substances which can be driven off or decomposed completely only by raising the temperature to above about 600°C."

But, what will happen if we heat wood to a very high temperature by radiation in a vacuum? Would it melt or something else?

Wood contains 40-50% Cellulose
https://en.wikipedia.../wiki/Cellulose

"Breakdown (cellulolysis)
Cellulolysis is the process of breaking down cellulose into smaller polysaccharides called cellodextrins or completely into glucose units; this is a hydrolysis reaction. Because cellulose molecules bind strongly to each other, cellulolysis is relatively difficult compared to the breakdown of other polysaccharides."

"Breakdown (thermolysis)
At temperatures above 350 °C, cellulose undergoes thermolysis (also called pyrolysis), decomposing into solid char, vapors, aerosols, and gases such as carbon dioxide."

Thermal decomposition
https://en.wikipedia...l_decomposition

Pyrolysis
"Pyrolysis is a thermochemical decomposition of organic material at elevated temperatures in the absence of oxygen "
https://en.wikipedia.../wiki/Pyrolysis
• 1

#970632Urgent help with persistent Chinese computer virus

Posted by on 6 February 2017 - 03:28 PM

When something like this happens, unplug Ethernet cable, turn off wifi etc. prior starting cleaning.

Good old trick is to rename folder/file, if folder/file is inaccessible because of privileges and/or it's already in use.
Might be needed to do this in safe mode.

After rename, create folder with the same name, as used by virus.

Then create empty file(s) with the same name as executable that's started (in text editor, File > Save As.. empty file, then rename to .exe),
but change its/their privileges and switch off file Writeable flag.
Then restart computer.

Hard to remove virus typically has couple executables.
One executable is restarting other,
and other executable is starting the first one.
So if somebody try to shutdown 1st one, 2nd one is restarting it, and vice versa.
1st one is blocking write access to 2nd file,
2nd one is blocking write access to 1st file.
It's protection against being deleted.

Making fake folder with fake files, with blocked access, blocked overwrite, will disallow restart.
• 1

#970517madmac surprise (Hijack from Two Bolts Strike Train)

Posted by on 6 February 2017 - 02:23 AM

I might think of one while i am watching the Falcons beat the Patriots.

I had to google for, what are "Falcons and Patriots".. WTF?! We're on science forums...

Yes, of course, LIGO. A very accurate clever apparatus, but found something that doesn't exist.

How can you detect something that does not exist.. ?
They could detect something else that's misinterpreted as gravitational wave,
but couldn't detect something that does not exist,
as it wouldn't make any sense.

How about the standard metre. Supposedly very very accurate, but, in fact the length varies depending on time of day & day of year.

Then, the next day, length will be the same as 24h ago,
so it's just a matter of repeating experiment..

Then, the next year, length will be the same as year ago,
so it's just a matter of repeating experiment..
• 1

#969998Another question regarding evolution.

Posted by on 3 February 2017 - 12:25 AM

Organisms which have better adaptation to certain environment, easier survive in that environment. Therefore their genes are spreading in offspring.

And vice versa.

Therefore you don't see polar bears in Africa.

White fur is adaptation to snow, to easier hide, and being able to hunt.

Darker bears simply died unable to catch anything.

Mutation is random. If it's useful mutation, organism survives, spreading genes to further generations. If it's adverse, organism dies.

What is useful or adverse is typically environment dependent.

• -1

#969666Just because you don't witness god doesn't mean he isn't there.

Posted by on 31 January 2017 - 10:28 PM

Cancer, (I know have been introduced to it) is here with us & we can study it but creation/evolution/forming of all the elements in the 1st place? We were not there to observe what went down & so faith.

Police officers are not at crime scene when crime happened, but still they are being able to reproduce step by step what happened (if they truly want to do it, and are objective, smart and acute)..

Geologists, paleontologists and archeologists are "police officers"/"detectives" of biology, geology, paleontology and history..

But they have to be much more intelligent, as there is much less evidence to work with..

• 1

#969627What is a field?

Posted by on 31 January 2017 - 06:30 PM

Magnetic field lines can be visualized by cheap device called "compass array".
Anyone can build 2D compass array using f.e. 100 (10x10) compasses, attached on table with similar spacing between them.
There is also 3D version of this device.

Here are my photos. It has 117 compasses.

While moving magnet, they obviously spin.
While passing current through wire, or through electromagnet, we can see how they spin accordingly to direction of current.

Visualization of electric field we do using f.e. Electroscope.
https://en.wikipedia...ki/Electroscope

• 1

#969056Alternative Facts, Broken Promises & Wolves

Posted by on 28 January 2017 - 09:30 AM

How could President Businessman make the mistake of thinking an import tariff on Mexican goods made Mexico pay for the wall?

How could any educated person, not only businessman, not known that the weaker economy of Mexico, the more people trying to get out and migrate to USA.. ?

• 1

#968617C Https Socket programming

Posted by on 26 January 2017 - 09:03 AM

```char* ConvertToUpper(char* szSource)
{
if (szSource == NULL)
return NULL;
int i = 0;
char *str = strdup(szSource);
while (str[i])
{
if (str[i] >= 97 && str[i] <= 122)
str[i] -= 32;
i++;
}
return (str);
}
```

C/C++ have built-in linked libraries functions for checking whether char is letter, whether it's upper or lower letter, or to making upper or lower letter from other one..

http://www.cplusplus...cctype/islower/

http://www.cplusplus...cctype/isupper/

http://www.cplusplus...cctype/isalpha/

http://www.cplusplus...cctype/toupper/

http://www.cplusplus...cctype/tolower/

You didn't even need it. You could use case-insensitive string comparison function stricmp() instead.

```
//Set the current date
message = "Date : ";```

Here you made the same error as before. There is no space after Date and colon..

```const char MimeTypes[][2][128] =
{

(....)

{"M4V","Content-Type: video/x-m4v\r\n"},
{"FLV","Content-Type: video/x-flv\r\n"}
};```

I would use NULL- terminated array instead of above (or better C++ classes and objects instead)...

f.e.

struct MIMEEntry

{

char *m_Extension;

char *m_ContentType;

bool m_Binary; // binary or text

};

static MIMEEntry entries[] =

{

{ "m4v", "video/x-m4v", true },

{ "html", "text/html", false },

(.... )

{ NULL },

};

Then in loop you're just checking whether entry is NULL or not, to stop enumeration..

Why don't you make function for sending headers?

f.e.

int send_header( socket, const char *row )

{

// send row,

// send \r\n

}

Then sending HTTP response will look like:

send_header( s, "HTTP/1.1 OK" );

send_header( s, "Content-Type: text/html" );

send_header( s, "Content-Length: 123" );

send_header( s, "" ); // empty

You could easily add logging there, if needed, and see what data are send to client..

```        while (fgets(message, 80, fp) != NULL)
{
send(socket, message, strlen(message), 0);
}
```

?!?!

strlen()?

Image is not ASCII string...

fgets() is NOT for reading binary files. It's for text files only..

You don't read documentation of functions which you're using..

http://www.cplusplus...e/cstdio/fgets/

"Get string from stream"

I see that you're using this code for either text files (.html, .css) and for binary (.png),

so you will have to use fgets() only to text files (and fopen() in "r" mode!)

and fread() only to binary files (and fopen() in "rb" mode!)

Also 80 row length is way to small..

Soon you will forget you made such limit, and have longer row, and it'll fail, and again you won't know why it failed..

`    shutdown(socket, 1);`

And again the same...

```    errNum = asctime_s(buffer, 32, &newtime);
if (errNum)
{
printf("Error code: %d", (int)errNum);
return "false";
}

//open and get the file handle
if ((fp = fopen(filename, "rb")) == NULL) {
return "HTTP 404";
shutdown(socket, 1);
}

```

Here is also not appropriate error handling..

You have to send error to client! Through TCP/IP socket.. In HTTP response..

```
const char* Sendfile::sendfile(int socket, char* filename) {
char dest[MAXCHAR];
```

MAXCHAR is NOT size of string buffer (char array)...

It's equal to 127 (2^7-1 = 127)

The largest signed char value.

Similar like MAXSHORT is 32767 (2^15-1) and MAXINT is 2147483647 (2^31-1)...

Make your own f.e.

#define BUFFERSIZE 1024

char buffer[ BUFFERSIZE ];

sprintf( buffer, "Content-Length: %d", get_file_size( filename ) );

send_header( s, buffer );

sprintf( buffer, "Content-Type: %s", get_file_type( filename ) );

send_header( s, buffer );

• 1

#967710New Keyboard layout

Posted by on 21 January 2017 - 11:24 AM

michel123456, do you know that 3D FPP game players won't touch it? We use WSAD!

There is also couple other issues for game players.. left ctrl must be the most left-bottom key to be easily accessible (by the smallest finger)..

It's "crouch" functionality. While crouching player has to be able to press WSAD keys at the same time.

(on your "conventional keyboard" it's also in wrong place for gamers. It must be some laptop keyboard?)

Left-alt and right-alt keys are widely used to enter regional characters not existing in English charset.

They must be in such places so using just one hand can hold alt and be able to pick up other key at the same time.

E key + alt key in your layout is very hard to get (especially for women and children).

Also N key + alt might be problematic.

• 1

#967565C Https Socket programming

Posted by on 20 January 2017 - 10:37 AM

shutdown(socket,1) does the same thing.

Do you want to learn programming correctly, or not?
Any IT employer would tell you the same:
Don't use hard-coded integers, when they are defined as macros/enums.
And when they are not (your own code), make them, with meaningful names.

So I just need to add CRLF?? I dunno maybe there is a function on MSDN to generate it. The received header data doesn't have CRLF.

CRLF = Carrier Return, Line Feed,
https://en.wikipedia...Carriage_return
They are two characters to add to strings returned to client by server.
Basically you do it by

printf( "Text....\r\n" );

\r is CR
\n is LF
\r\n is CRLF

Example HTTP response from HTTP server such as Apache:

After each line there is CRLF f.e. code in C/C++:

send(s,"HTTP/1.1 200 OK\r\n" );

send(s,"Content-Type: text/html\r\n" );

send(s,"\r\n" ); // empty CRLF

send(s,html_body_string );

No I didn't I read them and https://msdn.microso...3(v=vs.85).aspx trying to figure stuff out and it isn't exactly the same as what I want anyway since it's C++

In MSDN examples, C and C++ are pretty much the same, as they are not using C++ classes nor any C++ specific features.
They could simply call it "Example in C/C++" or "Ëxample in C".

• 2

#967534C Https Socket programming

Posted by on 20 January 2017 - 04:59 AM

message = "Content-Type: Text/Css";
send_all(new_socket, message, strlen(message));
message = "body{background:blue;}";
send_all(new_socket, message, strlen(message));

1st send_all() disabled sending (shutdown()) then how can you send 2nd time again after that?

shutdown() should looks like:

shutdown( socket, SD_SEND);

You didn't closesocket( new_socket );

You don't have proper HTTP-Response message..

https://www.w3.org/P...c2616-sec6.html

https://www.w3.org/P...2616-sec14.html

They MUST have CRLF each line....

And being separated by empty CRLF from the main reply body..

It would be good for you to take some personal firewall with built-in sniffer (f.e. Sygate Personal Firewall),

or stand-alone TCP/IP packet sniffer, and try to connect from web browser to local installed Apache,

and look in TCP/IP packet viewer what is sent and what is received from proper HTTP server..

Look at MSDN

how nicely WinSock functions are described f.e.

https://msdn.microso...9(v=vs.85).aspx

On the bottom there are examples of how to use these functions, including error handling, which you ignored..

• 1

#967368Why quantum physics is a WASTE OF TIME

Posted by on 19 January 2017 - 04:37 AM

Why you know - I didn't know that Benjamin Franklin was a quantum physicist. I can't think of a single improvement in the art of electronic engineering due to any of the wild guesses of quantum physics beyond the existence of the electron.

1. Smoke detector is using radioactive isotope of Americium-241 produced in nuclear reactors..
https://en.wikipedia...i/Americium-241
(see applications section)

2. Laser
https://en.wikipedia.org/wiki/Laser
(and as a consequence CD/DVD/Blu-ray, Laser Distance Meters, etc. etc.)

3. LED (light emitting diode)
https://en.wikipedia...-emitting_diode
(and as a consequence LCD/LED/OLED screens etc. etc.)

4. photo elements.
photodiode https://en.wikipedia...wiki/Photodiode
phototransistor
photoresistor https://en.wikipedia...i/Photoresistor

5. Solar panels
https://en.wikipedia...iki/Solar_panel

6. Geiger counter
https://en.wikipedia.../Geiger_counter

7. Decay of Plutonium-238 is used in RTG (Radioisotope thermoelectric generator) to create electricity for satellites flying in cosmos too far from the Sun to be able to use its energy.
https://en.wikipedia...i/Plutonium-238
https://en.wikipedia...ctric_generator

Just a few examples, in random order of importance..

While the speeds of atoms or subatomic particles accelerating into a black hole may approach the speed of light that is theoretical since the only proof we have of the existence of black holes is conjecture due to hypothetical gravity fields.

If you look at center of our galaxy, you will see that stars are orbiting around nothing visible (in visible spectrum)..

• 2