master branch and ‘origin/master’ have diverged, how to ‘undiverge’ branches’?

You can review the differences with a: before pulling it (fetch + merge) (see also “How do you get git to always pull from a specific branch?”) When you have a message like: “Your branch and ‘origin/master’ have diverged, # and have 1 and 1 different commit(s) each, respectively.” , check if you need to update origin. If origin is up-to-date, then some commits … Read more

What does getActivity() mean?

Two likely definitions: getActivity() in a Fragment returns the Activity the Fragment is currently associated with. (see http://developer.android.com/reference/android/app/Fragment.html#getActivity()). getActivity() is user-defined.

getline() does not work if used after some inputs

haracters are extracted until either (n – 1) characters have been extracted or the delimiting character is found (which is delimiter if this parameter is specified, or ‘\n’ otherwise). The extraction also stops if the end of the file is reached in the input sequence or if an error occurs during the input operation. When cin.getline() reads … Read more

Remove all child elements of a DOM node in JavaScript

Option 1 A: Clearing innerHTML. This approach is simple, but might not be suitable for high-performance applications because it invokes the browser’s HTML parser (though browsers may optimize for the case where the value is an empty string). Option 1 B: Clearing textContent As above, but use .textContent. According to MDN this will be faster than innerHTML as browsers won’t invoke their HTML parsers … Read more

Using “super” in C++

Bjarne Stroustrup mentions in Design and Evolution of C++ that super as a keyword was considered by the ISO C++ Standards committee the first time C++ was standardized. Dag Bruck proposed this extension, calling the base class “inherited.” The proposal mentioned the multiple inheritance issue, and would have flagged ambiguous uses. Even Stroustrup was convinced. After discussion, Dag Bruck … Read more

How to compare arrays in JavaScript?

To compare arrays, loop through them and compare every value: Comparing arrays: Usage: You may say “But it is much faster to compare strings – no loops…” well, then you should note there ARE loops. First recursive loop that converts Array to string and second, that compares two strings. So this method is faster than use … Read more