Uncaught Invariant Violation: Rendered more hooks than during the previous render

The fix works because the first code sample (the erroring one) invokes a function inside onClick, while the second (the working one) passes a function to onClick. The difference is those all-important parentheses, which in JavaScript mean ‘invoke this code’. Think of it this way: in the first code sample, every time component is rendered, renderResults is invoked. Every time that … Read more

Commit history on remote repository

Will display the log of a given remote branch in that repository, but only the logs that you have “fetched” from their repository to your personal “copy” of the remote repository. Remember that your clone of the repository will update its state of any remote branches only by doing git fetch. You can’t connect directly to … Read more

How can I move a tag on a git branch to a different commit?

Use the -f option to git tag: You probably want to use -f in conjunction with -a to force-create an annotated tag instead of a non-annotated one. Example Delete the tag on any remote before you pushgit push origin :refs/tags/<tagname> Replace the tag to reference the most recent commitgit tag -fa <tagname> Push the tag to the remote origingit push origin master … Read more

Why write script type=”text/javascript” when the mime type is set by the server?

Douglas Crockford says: type=”text/javascript” This attribute is optional. Since Netscape 2, the default programming language in all browsers has been JavaScript. In XHTML, this attribute is required and unnecessary. In HTML, it is better to leave it out. The browser knows what to do. He also says: W3C did not adopt the language attribute, favoring instead a type attribute … Read more

WebException (Status: Protocol Error)

Your server is returning HTTP 1201 which is not a standard status code. WebClient will fail with an exception when facing a non-successful status code (or an unrecognized one, in your case). I encorauge you to use the new HttpClient class if you can: If you have to do it synchronously:

Java better way to delete file if exists

Starting from Java 7 you can use deleteIfExists that returns a boolean (or throw an Exception) depending on whether a file was deleted or not. This method may not be atomic with respect to other file system operations. Moreover if a file is in use by JVM/other program then on some operating system it will not be … Read more

Including .cpp files

What include does is copying all the contents from the file (which is the argument inside the <> or the “” ), so when the preproccesor finishes its work main.cpp will look like: So foo will be defined in main.cpp, but a definition also exists in foop.cpp, so the compiler “gets confused” because of the function duplication.

Converting from Radians to Degrees

You want to calculate radians=tan(y/x) first. Then you can convert it to degrees: See the reference here for atan: On a side note, you also have to take into account what quadrant you are in to get the correct answer (since -y/x is the same number as y/-x)