Get AVG() of values from table with different names

Question: I have a table :
CREATE TABLE data
(
    value integer,
    name varchar(100)
)

In my table there can be duplicate values of name possible with different value of value. Now I want to get DISTINCT name and there avg() value from the Table data.
I am able to get DISTINCT value of name but unable to get avg() of there values.
Now with following Query I get avg() of all data :
select floor(avg(value)) from data

I know this is incorrect but I am new to SQL. I want this select floor(avg(value)) for distinct values of name.
Data :
insert into data values(10, 'mnciitbhu')
insert into data values(20, 'mnciitbhu')
insert into data values(40, 'mafiya69')
insert into data values(20, 'mafiya69')
insert into data values(0, 'mafiya69')

Output :
mnciitbhu 15
mafiya69 20

Comment: give some example data and required output sample..??????
Comment: No shame in being new, but no harm in undertaking basic research either.
Comment: give some example data and required output sample @mnciitbhu
Answer: Adding this because the other answers while accurate, are not detailed.
What you want to do here, are use the grouping and aggregation features of SQL.
grouping your results by particular fields, will divide your result set into discrete sections, which you can operate on with aggregate functions, to get averages, sums, counts etc, per group.
For a full list of aggregate functions, and other miscellaneous information about group by, you can read 12.16.1 GROUP BY (Aggregate) Functions.
In your instance, since you want the average per name, you will need to group by name. This would give the following query:
select name, avg(value)
  from `data`
  group by name;       -- this is the important line

And this query will calculate the average of value, for each group of names in your table, returning one row per group.
One very important consideration when using group by, is that all fields contained in the select, must either be contained in the group by clause, or used in aggregate functions. If you refer to a field that isn't covered by this, you may end up with undesired indeterminate results.
From the manual 12.16.3 MySQL Handling of GROUP BY

MySQL extends the use of GROUP BY so that the select list can refer to
  nonaggregated columns not named in the GROUP BY clause. This means
  that the preceding query is legal in MySQL. You can use this feature
  to get better performance by avoiding unnecessary column sorting and
  grouping. However, this is useful primarily when all values in each
  nonaggregated column not named in the GROUP BY are the same for each
  group. The server is free to choose any value from each group, so
  unless they are the same, the values chosen are indeterminate.

The importance of that paragraph cannot be overstated.  It is very easy to mis-understand how this works, arrive at a query that seems to give the desired result, but will occasionally give incorrect/undesired data.
Answer: Use this code:
select name,AVG(value) as Average from data
group by name
order by name desc

OUTPUT:
name       Average
mnciitbhu   15
mafiya69    20

Answer: Try this
select name,avg(value) from data group by name

Comment: In the future, be sure to provide an explanation with your answer.


What is serial upvoting reversed?

Question: I know this user have more than 1K rep, but today I checked his reputation, he got negative reputation and also it mentioned Serial upvoting reversed. What it means and for what reason he got negative rep?
Answer: It means the user got votes from the same person, or from a group of people, in a way that they were considered serial voting: votes given to posts not because their quality, but because the person who wrote them. To make an example, I could up-vote the questions asked from my girlfriend, but if I start voting almost of the questions she asks, and the number of votes is higher than a prefixed number of votes, then they would be reversed.
The reputation change is negative because the reputation obtained from serial up-voting is removed. If it were serial down-voting, the users would get back the reputation they lost, and in that case the reputation change would be positive.

What is serial upvoting reversed?


REST API for codeigniter 2.0.1

Question: codeigniter-restserver is available for codeigniter 2.1.0 or above
(https://github.com/chriskacerguis/codeigniter-restserver)
but unable to find REST API for codeigniter 2.0.1
How to create restserver in codeigniter 2.0.1
Answer: You can download from GitHub archives:
I found the last compatible version that CodeIgniter-RestServer v2.4. Version 2.5 is for CodeIgniter 2.0.3 and higher.
CodeIgniter Reactor 2.0 (for 1.7.x support download v2.2 from Downloads tab)
GitHub Page: https://github.com/chriskacerguis/codeigniter-restserver/tree/v2.4
Comment: In this version we don't give us the possibility to use  function for setting up http_user_session `_check_login`

REST API for codeigniter 2.0.1


How to use 2 model in same view

Question: I want to use 2 models, model_1 and model_2 (one model_1, many model_2) but in one view I can use only one.
This is my view:
@model IEnumerable<ProjectFashion.Models.model_1>
@model IEnumerable<ProjectFashion.Models.model_2>
@{
    ViewBag.Title = "VMenu";
}

    @foreach(var n in Model) {

@n.name

                      @*I WANT TO GET model_2 which belongs to model_1*@

    }

and my _Layout.cshtml:

@Html.Action("VMenu", "Layout")

and my LayoutController.cs:
ShopContent db = new ShopContent();
public ActionResult VMenu() {
    return PartialView("_VMenu", db.model_1s);
}

I also use model_3 to include model_1 and model_2 but some problems occur in @Html.Action("VMenu", "Layout").
(I am sorry about my imperfect English...)
Comment: This looks a *lot* like ASP.NET MVC code, but the random assortment of tags says otherwise.  Can you clarify?  What on Earth does this have to do with Python or multiple mobile platforms?
Comment: -1 for a lot of tags but none of them relevant (this looks like ASP.NET MVC/Razor?) for starters, and a very unclear question after this is ignored
Answer: Is there a navigation property on model_1 that gives you the related model_2's?  If so, then you only need to pass the model_1 with the navigation model_2 filled in.  You would reference it in your sample line as something like @n.model_2s.property.
Answer: You don't want this:
@model IEnumerable<ProjectFashion.Models.model_1>
@model IEnumerable<ProjectFashion.Models.model_2>

You want this:
@model ProjectFashion.Models.SomeCustomModel

Your custom model could be as simple as this:
public class SomeCustomModel
{
    public IEnumerable<model_1> FirstModel { get; set; }
    public IEnumerable<model_2> SecondModel { get; set; }
}

(I couldn't come up with better names, your model names didn't really leave any clues about what they are.)
Then in your controller action you'd create an instance of SomeCustomModel, populate its fields, and return that to the view.  In general terms, what you're creating is a "composite object" which simply consists of other objects.
This is assuming, of course, that your models don't have any other existing relationship to each other.  (Again, the names don't give any clues.)  If they do, perhaps there's a "parent" object which has "child" objects already?  Maybe model_1 contains a property of type model_2 or a collection of model_2 instances already?
Comment: i tried it, but another problem is that @foreach(var item in Model.FirstModel) and
the error is that Object reference not set to an instance of an object
Comment: @user2494355: What isn't instantiated?  How are you building the model before passing it to the view?  Chances are you're trying to enumerate on a null list.  If it's possible that the list of objects is never set then you'd want to instantiate it to an empty list by default.  In the view model's constructor simply set the property to an empty list.
Comment: you're right........ my english still limited so i couldn't understand well, but finally i did it, thanks so much :)

How to use 2 model in same view


is it possible to test Retina Display on simulator?

Question: How can you test Retina Display on a simulator if it is possible?
Answer: Yes, run the application from Xcode, when the simulator opens go to Hardware->Device->iPhone 4
That will now have a 2x screen resolution.
Comment: is there a reason why i don't see the files with the '@2x-iphone` in the name going down the wire? i've got my emulator open as well as the Safari dev tools. I open the network tab on the dev tools, reload my page in the emulator, and am *not* seeing the '@2x-iphone' images going over the network.


Should I remove existing subfloor sheathing before increasing height of the floor system?

Question: We're turning a 13x13 area of attic space into livable space. The new 13x13 area joins an existing room. The attic floor structure is: 2x8 floor joists and OSB board on top.
There is a ~5 inch step down from the current room into the attic space area.
Someone presented the idea of keeping the OSB board on top of the 2x8 joists and running 2x4 joists on top of the OSB board. The 2x4s would run opposite of the 2x8's and the OSB would be sandwiched in between the existing 2x8s and the new 2x4's. On top of the 2x4's, we would place two layers of plywood to bring it flush with the existing room.
Should the OSB be removed first?
Comment: Have you got an engineer's report on this? You are talking about adding a large static load on the 2x8 ceiling joists. Why is the top of the 2x8 joists 5 inches lower than the other room? Does the other room have trusses or much larger joists?
Comment: I can appreciate the desire to have the floors even but sometimes loosing 5" of floor to ceiling height can be a problem. This could be even more of an issue in an attic space. Does the existing room sit on a different joist structure than this added area and is it under a different roof structure?
Answer: You've asked one specific question here, and I'll start by answering that: No. Unless you have a particular reason to do so, do not bother removing the existing OSB.
From there I'd say your plan is reasonable. Running the 2x4s perpendicular should pose no problem, as they're supported every 2 feet. They'll span that with no detectable sag. Be sure to butt join them over joists.
Rather than two expensive layers of 3/4" OSB, though, I'd rip 2x6 lumber to the appropriate height so that you can use just one layer of t&g OSB as the new subfloor. This mitigates the overload risk, too.
Note: I assume that you've had the roof system inspected for use as a living space (or even for storage). With 2x8 bottom chords I assume that either 1) it's a very long span, or 2) it was designed for use as such. That's a critical point here.
Answer: "Should the OSB be removed first?"  Absolutely.
Imagine some situation that causes the OSB to deteriorate or otherwise give cause for removal/replacement (moisture, mold,...whatever).  What would then support the 2x4's?  Also, how would one remove the OSB?
As for the background of your question, "The 2x4s would run opposite of the 2x8's".  I think you mean, "The 2x4's would run perpendicular to the 2x8's".
There's a potential problem here.
There's going to be one to three 2x8's supporting the overlapped ends of two, 8'0" long 2x4's.  The 2x4's will flex downward in the middle of the 13'x13' room (even if one braces them together where they sister for 3'0").
I'd also be concerned how the load of this room is carried downward.  The ends of the 2x4's need to rest on a load bearing wall/beam which is, in turn, supported by load-bearing columns to grade.


Displaying a dynamic list of images with corresponding text/URLs with jQuery

Question: I have a web service which returns me a list of images, it's titles and URL's that the user needs to be redirected to when clicked on these images in XML format. I need to build a dynamic list of these clickable images aligned horizontally and I need to do this using jQuery or javascript. Are there any known components which do this? Do I need to write from scratch? If I do then how do I go about it?
Comment: use `$.ajax` to retrieve the xml and then you need to parse it to html. There are lots of tutorials on web how to do this , keywords `ajax xml tutorial`. WHat does xml look like, and what does output need to look like?
Answer: I'd recommend using jQuery.parseXML()  to get the XML into a jQuery object and then iterate through the object to populate a knockout observable array of observable objects.  See http://knockoutjs.com/ for examples of how to use knockout for dynamic binding.  I'd use an unordered list to render each of the images with titles and links.  You can style the list any way you want.
Browse to the knockout.js tutorial - http://learn.knockoutjs.com/#/?tutorial=collections Nd in your javascript, add:
function SiteItem(u, t, s) {
    var self = this;
    self.url = ko.observable(u);
    self.title = ko.observable(t);
    self.imgSrc = ko.observable(s);
}

// Overall viewmodel for this screen, along with initial state
function ViewModel() {
    var self = this;

    // Editable data
    self.items= ko.observableArray([
        new SiteItem('http://www.google.com/', 'Test', 'http://www.google.com/images/srpr/logo3w.png'),
        new SiteItem('http://www.google.com/', 'Test', 'http://www.google.com/images/srpr/logo3w.png')
    ]);
}

ko.applyBindings(new ViewModel());

then in the HTML, the knockout template for the UL:

Your images

Comment: Parsing the XML is not the problem, really. The problem is once I have an object with the list of images with their details, how do I generate a list of images dynamically.
Comment: use knockout to generate the list
Comment: viperguynaz - can you send me an example? I couldn't find any helpful links with the images ...
Comment: added a code example to the answer - there are plenty of tutorials and examples on http://knockoutjs.com/
Comment: Thanks viperguynaz. I'm really trying to do a basic example and this doesn't work http://jsfiddle.net/n3w4C/
Comment: updated the answer - http://jsfiddle.net/viperguynaz/GkP3s/2/ - in jsfiddle - don't use doc, head, body tags and in the js, don't use script tags - there is a great tutorial on knockout.js @ http://learn.knockoutjs.com/#/?tutorial=intro that implements jsfiddle like interface


How the primary server down will be handled automatically in mongodb replication

Question: I never have my hands on coding. I got a doubt regarding mongodb replica sets
below is the situation
I have an alert monitoring application.
It is using mongodb with replica set with 3 nodes.
Applications Java code base keep connecting to the primary and doing some transactions.
Now my question is that,
if the primary server is down, how will it effect the application server.
I mean, would the app server writes error saying connection failed like errors.
OR
the replica set will pick one of the slaves automatically as master and provides the application server to do its activity. How will it happen...?
Thanks & Regards,
UDAY
Comment: Documented on the first page of the replica set documentation on MongoDB.org...reading helps
Comment: Check out [the documentation](http://docs.mongodb.org/manual/core/replication-introduction/#automatic-failover).
Answer: The replica set will try to pick another server as the new primary. If you have three nodes, and one goes down, the other two will negotiate which one becomes the new master. If two go down, or somehow communication between the remaining breaks down, there will be no new master until the situation is recovered.
The official drivers support this automatic fail-over, as does the mongos routing server if you use it. So the application code does not need to do anything here.
I am not sure if there will be connection errors during the brief period of time this fail-over negotiation takes (you will probably get errors for a few seconds).


Proving a complex equality

Question: Let $a$ and $c$ be complex numbers. Show there exists complex numbers $z$ s.t. $|z-a|+|z+a| = 2|c|$ if and only if $|a| \leq |c|$.
I've shown the forward direction correctly, but I don't know how to get the backwards direction.
Answer: Let $z = \frac{a|c|}{|a|}$ for $|a| \neq 0$ and $|c|\geq|a|$ (The case $|a|=0$ is trivial). Then,
\begin{align}
|z-a|+|z+a| & = \left|\frac{a|c|}{|a|}-a\right| + \left|\frac{a|c|}{|a|}+a\right| \\
& = |a|\left(\left|\frac{|c|}{|a|}-1\right| + \left|\frac{|c|}{|a|}+1\right|\right) \\
& = |a|\left(\frac{|c|}{|a|}-1 + \frac{|c|}{|a|}+1\right) \\
& = 2|c|.
\end{align}
Comment: So for the trivial case, you can't use the quotient you've set $z$ equal to?
Comment: @AlanH $z=c$ works if $|a|=0$ (or equivalently if $a=0$).
Answer: $|z-a|+|z+a| = 2|c|$ represents an ellipse, if $|c| < |a|$ then what would happen?
Comment: I'm aware of that answer, but I'm looking for an algebraic answer simply because that wouldn't come to me immediately. How did you see that it was an ellipse? I ask because it's not in the familiar form that you see in conic sections of calculus.
Comment: @Alan: An ellipse is the set of points in the plane such that the sum of the distances to two specific points--called the ellipse's foci--is some given number. (A circle is a special case of an ellipse, where the foci coincide.) In this particular case, it is the ellipse with foci $\pm a$, such that the sum of the distances to the foci is $2|c|$.

Proving a complex equality


C++11 with gcc 4.6.1 on a mac

Question: I'm new to the mac and trying to get gcc 4.6 working.
I installed MacPorts and installed gcc 4.6.1 (by executing sudo port install gcc46). I'm trying to compile a simple test code that compiles fine on Linux (with gcc 4.6.1 and 4.6.2) and Windows, but I'm getting errors that make me thing there is something wrong with the installed libraries.
#include <iostream>
#include <type_traits>
#include <future>

struct test {
    void get() {}
};

/*template<typename Func>
test async(const Func &f) {
    f();
    return test();
}*/

using namespace std;

int main (int argc, const char * argv[])
{
    auto t1 = async([]() -> int{
        cout << "This is thread 1" << endl;
        return 1;
    });

    auto t2 = async([]() -> int {
        cout << "This is thread 2" << endl;
        return 2;
    });

    std::cout << "This is the main thread" << endl;

    t1.get();
    t2.get();

    return 0;
}

The error messages:
macbook01:Test fozi$ g++ main.cpp -o test -std=c++0x
main.cpp: In function 'int main(int, const char**)':
main.cpp:30:6: error: invalid use of incomplete type 'std::enable_if<true, std::future<int> >::type'
/opt/local/include/gcc46/c++/future:111:11: error: declaration of 'std::enable_if<true, std::future<int> >::type'
main.cpp:30:6: error: unable to deduce 'auto' from '<expression error>'
main.cpp:35:6: error: invalid use of incomplete type 'std::enable_if<true, std::future<int> >::type'
/opt/local/include/gcc46/c++/future:111:11: error: declaration of 'std::enable_if<true, std::future<int> >::type'
main.cpp:35:6: error: unable to deduce 'auto' from '<expression error>'
/opt/local/include/gcc46/c++/future: At global scope:
/opt/local/include/gcc46/c++/future:150:5: error: 'typename std::enable_if<(! std::is_same<typename std::decay<_Functor>::type, std::launch>::value), std::future<decltype (declval<_Fn>()((declval<_Args>)()...))> >::type std::async(_Fn&&, _Args&& ...) [with _Fn = main(int, const char**)::<lambda()>, _Args = {}, typename std::enable_if<(! std::is_same<typename std::decay<_Functor>::type, std::launch>::value), std::future<decltype (declval<_Fn>()((declval<_Args>)()...))> >::type = std::future<int>]', declared using local type 'main(int, const char**)::<lambda()>', is used but never defined [-fpermissive]
/opt/local/include/gcc46/c++/future:150:5: error: 'typename std::enable_if<(! std::is_same<typename std::decay<_Functor>::type, std::launch>::value), std::future<decltype (declval<_Fn>()((declval<_Args>)()...))> >::type std::async(_Fn&&, _Args&& ...) [with _Fn = main(int, const char**)::<lambda()>, _Args = {}, typename std::enable_if<(! std::is_same<typename std::decay<_Functor>::type, std::launch>::value), std::future<decltype (declval<_Fn>()((declval<_Args>)()...))> >::type = std::future<int>]', declared using local type 'main(int, const char**)::<lambda()>', is used but never defined [-fpermissive]

Note that if I use my dummy async function it compiles and runs fine.
I'm kind of stuck, do I have to install a specific library (version)? How do I do that?
Comment: Hmm... are you sure you're taking the headers from the correct path? You can run gcc with `-H` to see where the headers come from. I've previously built GCC 4.6.0 from source on MacOS, with no problems.
Comment: I actually tried to fix them and saw the changes, so yes, I'm pretty sure I'm using the right libraries.
Comment: You have a strange `future` include file. In mine, lines 111 and 150 don't seem  to be related to `std::enable_if` (I have 4.6.1 too). Perhaps it's corrupted.
Comment: Do you still use the g++ command? In such case it may not have been replaced. Try g++ --version to get the actual version you are using.
Also, if you get only the compiler nothing says that you have the libraries too... Or perhaps you have to include them separately (try -v flag to see include header pathes)
Comment: Mac has no future, j/k ... I thought MacPorts GCC had some issues with C++0x does Apple GCC still not support lambdas?
Comment: Apple gcc is 4.2 - so no lambda support
Comment: Also the macports gcc46 is effectively 4.6.0 not 4.6.1 (I think it is actually a release candidate from the release date 25/03/11)
Comment: @Mark that could explain the file differences. I tried to update the header files to 4.6.2 but it failed as well. I didn't succeed to build gcc 4.6.2 on the mac.
Comment: 4.6.2 is not released yet so I would stick to 4.6.1 unless you want to debug the compiler
Comment: A collegue managed to build 4.6.1 on a diffrent machine but it failed to compile my test as well. It doesn't look like this is a problem with my installation. Has anyone tried to compile the code I posted?
Comment: Compiles fine on 4.6.0 20110505 on OpenSUSE.
Answer: I've had similar issues with gcc-4.6.1 and OS X 10.6. The problem is C++0x's thread is not supported at the moment on OS X.
See this post: c++0x, std::thread error (thread not member of std)
If you look in "${prefix}/include/c++/4.6.1/future" header file, you'll see the line:
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
        && defined(_GLIBCXX_ATOMIC_BUILTINS_4)

Unfortunately, _GLIBCXX_HAS_GTHREADS evalute to 0 on OS X.
Answer: We're getting there
gcc 4.7 (port) compiles this code just fine.
Xcode 4.3 comes with clang 3.1 which is supposed to support this, but it crashes when I try to compile. However I built clang from SVN and replaced the compiler Xcode is using and now it compiles and runs fine as well.
And it only took half a year.
Answer: Try g++ -v to get the version of G++ you're using. I'm not using a pre-compiled compiler but perhaps it is the same for you.
The GCC 4.6.0 is installed in /usr/local/bin under the name x86_64-apple-darwin10.7.0-g++
If you still use the simple g++ command, it may still be /usr/bin/g++, which is Apple's llvm-gcc flavor.
Comment: wanted to post it as a comment, sorry :s
Comment: I'm starting g++ from a terminal, so yes, I'm sure the version is correct. Also, I renamed the originals to gcc-4.2 and so on and am using symbolic links to switch them around. That includes the ones in /Development.

C++11 with gcc 4.6.1 on a mac


This is showing an error "Local Variable 'win' referenced before assignment"

Question: win=0

def fun():
    win+=1
    print(win)

a = 0

while True:
    if a == 0:
        fun()

Comment: Possible duplicate of [referenced-before-assignment-error-in-python](https://stackoverflow.com/questions/855493/referenced-before-assignment-error-in-python)
Answer: You need to refer to the variable as global inside your function, or it will assume it's local:
def fun():
    global win
    win+=1


Prove $\sum\limits^{n-1}_{i=1} i\ln (i) \leq \frac{n^2}{2}\ln (n)-\frac{n^2}{4}+\frac{1}{4}$ for $n\geq 1$.

Question: I'm quite stuck, truly. I have tried proving it directly, using induction, showing that $$n\ln (n) \leq \Big(\frac{(n+1)^2}{2}\ln (n+1)-\frac{(n+1)^2}{4}+\frac{1}{4}\Big)-\Big( \frac{n^2}{2}\ln (n)-\frac{n^2}{4}+\frac{1}{4}\Big)$$
as well as using the fact that $$\sum ^n_{i=1}i\ln (i)\leq \sum ^n_{i=1}i\ln (n)=\frac{n(n-1)}{2}\ln (n
)$$
but haven't been able to achieve much. The inequality does hold though, I've checked using desmos.
Comment: @ms._VerkhovtsevaKatya What I've seen generally done is that the standard practice where the upper limit of a summation is less than the lower limit is that no terms are determined & added, with the result being treated as being $0$. This is similar to where you're dealing with a multiplication (e.g, $\pi_{i=1}^{0}f(i)$), but with the result being treated as $1$ in that case.
Comment: What was your base case? $i=n-1, n=1,\ln 0$ isn't defined.
Comment: @ms._VerkhovtsevaKatya If you are asking about the proof using induction, then I suppose the base case would be $\sum ^0_{i=1}i\ln (i)=0\leq 0$.
Comment: @JohnOmelian, thank you for the response!
Comment: You could apply Riemann sums, since $\int x \ln{x} dx = \frac{x^2}{4} (2 \ln{x} - 1) + C$
Answer: Look at the function $f(x)=x\ln{x}$ and recall Riemann sums (i.e. lower Riemann sum or lower Darboux sum). Given $f'(x)=\ln{x}+1$, $f(x)$ is monotone ascending for $x\geq1$. As a result
$$\sum^{n-1}_{i=1} i\ln{i}=
\sum^{n-1}_{i=1} i\ln{i} \left(i+1-i\right)=\\
\sum^{n-1}_{i=1} f(i) \left(i+1-i\right)\leq \int_{1}^{n}f(x)dx=\\
\frac{x^2}{4}(2\ln{x}-1)\Big|_{1}^n =
\frac{n^2}{4}(2\ln{n}-1)+\frac{1}{4}=\\
\frac{n^2\ln{n}}{2}-\frac{n^2}{4}+\frac{1}{4}$$
Answer: It's not clear to me what the sticking point is.  If you have proven that $$n\ln (n) \leq \Big(\frac{(n+1)^2}{2}\ln (n+1)-\frac{(n+1)^2}{4}+\frac{1}{4}\Big)-\Big( \frac{n^2}{2}\ln (n)-\frac{n^2}{4}+\frac{1}{4}\Big)$$ then you are basically done, as this shows that the change in the left side of your desired inequality is less than the change of the right side.
To be explicit, let $f(n):=\sum_{i=1}^{n-1} i \ln (i)$ and let $g(n):= \frac{n^2}{2}\ln (n)-\frac{n^2}{4}-\frac{1}{4}$.  Then $f(n+1)-f(n)$ is the left side of the above inequality, and $g(n+1)-g(n)$ is the right side.  By induction, if $f(n)\leq g(n)$, then $$f(n+1) = \left(f(n+1)-f(n)\right)+f(n) \leq \left(g(n+1)-g(n)\right) + g(n) = g(n+1)$$ and together with $f(2)=0\leq 2\ln(2)-\frac{5}{4} = g(2)$ you're done.  (The reason I chose $n=2$ as a base case rather than $n=1$ is because it makes the following argument work more smoothly.  The $n=1$ case is trivial.)
The hard part is showing that the top inequality holds.  Here's one way to do so:
$$
\begin{align}
& \Big(\frac{(n+1)^2}{2}\ln (n+1)-\frac{(n+1)^2}{4}+\frac{1}{4}\Big)-\Big( \frac{n^2}{2}\ln (n)-\frac{n^2}{4}+\frac{1}{4}\Big) \\
= & \frac{n^2}{2}\left(\ln (n+1)-\ln(n)\right) + n\ln(n+1) + \frac{1}{2}\ln(n+1) - \frac{n}{2} - \frac{1}{4} \\
= & \frac{n^2}{2}\ln (1+\frac{1}{n}) + n\ln(n+1) + \frac{1}{2}\ln(n+1) - \frac{n}{2} - \frac{1}{4}
\end{align}
$$
Using $\ln(1+\frac{1}{n}) \geq \frac{1}{n}-\frac{1}{2n^2}$ (from the Taylor series expansion of $\ln$) on the first term, $\ln(n+1)\geq\ln(n)$ on the second term, and $\ln(n+1)\geq 1$ (for $n\geq 2$) for the third term, we find that the above is
$$\geq\frac{n}{2}-\frac{1}{4} + n\ln(n)+\frac{1}{2}-\frac{n}{2}-\frac{1}{4} = n\ln(n)$$as desired.


Clarification on Dirac delta distribution

Question: I am studying the Dirac delta and I am struggling with the intuition of the following two points.

I understand the Dirac delta as a distribution with mass in one point. Perhaps, the limiting case of a standard normal distribution when the standard deviation approaches zero. As such, it integrates to one: $\int_{-\infty}^{\infty} \delta(x) dx = 1$. This seems a little counter-intuitive to me, since that the integral is doing something akin to computing the area under a point.

Intuitively, the expected value of a random variable with the Dirac delta distribution is zero. That is because the whole mass is centred at x=0. That being said, $\delta(x)=\infty$  at x=0. How come that it does not affect the "weighting" in the expected value calculation?
Comment: The issue is, fundamentally, that the Dirac delta is not quite a function in the usual sense (a mapping $\mathbb{R} \to \mathbb{R}$), and these ideas about the integral or it equaling infinity are only true in some vague sense but convenient for calculations. Some details [here](https://mathworld.wolfram.com/DeltaFunction.html).
Answer: Dirac's delta is not an ordinary function, indeed it is a distribution.
The "definition" you are talking about in the second part of your post i.e.
$$\delta(x):=\begin{cases} 0\quad\text{if}\quad x\neq0 \\
+\infty\quad\text{if}\quad x=0\end{cases}\tag{1}$$
is not a rigorous one and instead it is a sloppy way to say that the weight is non-zero only in the point where the $\delta$ function is centered ($x=0$ in the present case). Another way to formulate that is$^1$
$$\begin{cases} \delta(x)=0\quad\text{if}\quad x\neq0\\ \int\limits_{-\infty}^{+\infty}\delta(x)dx=1\end{cases}\tag{2}$$
This will remind you of the definition you proposed as the limit of a normalized gaussian distribution.
You can easily see that $(2)$ is not possible for any ordinary function. In fact, such function would be zero when $x\neq0$ as requested, thus it can only be non-zero when $x=0$, that is a zero-measure set as it consists of a single point. This is the reason why in "definition" $(1)$ delta is infinite at the point where it is centered.
Nonetheless, also $(2)$ is ill-defined, since as there is no ordinary function that satisfies such property, so even the integral of such an object is undefined.$^2$
So we understood this not just a regular real function of real variable, then what is this $\delta$ distribution? Let $V$ be the linear space of all real functions defined on the real line (with the usual operation). The (linear) functional
$$\delta:V\rightarrow\mathbb{R}$$
defined by
$$\delta(f)=f(0)\qquad\forall f\in V$$
is what we call Dirac's $\delta$.
As I defined $V$, the function can be any function $f:\mathbb{R}\rightarrow\mathbb{R}$ e.g.
$$f(x)=\cosh(x)(\implies f(0)=1)$$
Then
$$\delta(\cosh)=1$$
If we were to use the integral notation the RHS would be
$$\int_{-\infty}^{+\infty}\delta(x)\cosh(x)dx=1$$
I should also mention there are other definitions, this is the one used in distribution theory. The space where it is defined generally has some other regularity restrictions I didn't mention here.

$^1$This is the definition originally used by Paul Dirac.
$^2$ In fact, it is a matter of convenience to use the integral symbol for distributions and as described below, it is camouflaging what is actually going on.
Comment: The reason why I concluded it can be no ordinary function is that we're demanding that it has finite (non zero) integral even though it is "almost always" (except on a zero measure set) zero.
Comment: *This will remind you of the definition you proposed as the limit of a normalized gaussian distribution*. I had exactly this definition in mind. I still have a few questions, I will post them as separate reply messages.
Comment: Q1: What do you mean by ordinary function that is non-zero only on a zero-measure set? I have to admit that all these negatives have confused me a little. Can you maybe make an example? Also, can you formalise a bit more why $\delta(x)$ cannot be an ordinary function?
Comment: I edited my answer to make the phrasing much clearer.
Comment: Thanks, that's clear now. I have some doubts regarding the last bit though. I am a bit rusty with functionals. Could you please add some points of clarifications in that part of your post as well? Perhaps an example of function $f$?
Comment: When I say functional I really mean *linear* functional in this context (I added that together with a dummy example). Hope that helps.
Comment: Thanks, it helps. However, I have one - hopefully, final - doubt. How can you write $\delta(x)$ when defining Dirac's delta as a functional? In other words, if x is not a function, what's the meaning of $\delta(x)$ within that context?
Comment: The meaning is that of definition $(1)$ or $(2)$ if you prefer. As I stressed, that is nothing more than just symbolic notation.
Answer:
The dirac delta on $\mathbb{R}$ is a probability measure on the Borel subsets of $\mathbb{R}$ defined by $\delta(A) = I(0 \in A)$. It is true that $\delta$ is the weak limit of normal distributions $N(0, \varepsilon)$ with mean $0$ and variance $\varepsilon$ as $\varepsilon \to 0$. It is natural to say that $\delta = N(0, 0)$. What we mean by "$\delta$ integrates to 1" is that $\delta$ is a probability measure that assigns $0$ probability $1$. It is also called "the point mass at $0$".

If $X$ has the dirac delta distribution, then $P(X = 0) = 1$, so $E(X) = 0$. We can also see this by computing $$E(X) = \int_{\mathbb{R}} x \,\delta(dx) = x|_{x = 0} = 0.$$
The $\delta$ distribution does not have a density, because if it did, the density would be $0$ almost everywhere, which is absurd.
Answer: Preliminary for understanding anything about the Dirac delta
An absolutely integrable function $\eta:\,\Bbb R\mapsto\Bbb R$ with $\int_{\Bbb R}\eta(x)dx=1$ is a nascent delta function. You've favoured the example $\eta(x):=\frac{1}{\sqrt{2\pi}}\exp\frac{-x^2}{2}$. Regardless of the choice, for $\epsilon>0$ define $\eta_\epsilon(x):=\frac{1}{\epsilon}\eta(\frac{x}{\epsilon})$ so$$\lim_{\epsilon\to0^+}\eta_\epsilon(x)=\left\{ \begin{array}{rl}
\infty & x=0\\
0 & x\ne0
\end{array}\right.$$(proof is an exercise). On the other hand,$$\lim_{\epsilon\to0^+}\int_{\Bbb R}\eta_\epsilon(x)f(x)dx=\lim_{\epsilon\to0^+}\int_{\Bbb R}\eta(y)f(y\epsilon)dy\stackrel{!}{=}\int_{\Bbb R}\eta(y)\lim_{\epsilon\to0^+}f(y\epsilon)dy\stackrel{!}{=}\int_{\Bbb R}\eta(y)\lim_{\epsilon\to0^+}f(0)dy=f(0),$$provided the function $f$ is "sufficiently nice" for the $\stackrel{!}{=}$s to work (these are good enough). If we defined a function $\delta(x):=\lim_{\epsilon\to0^+}\eta_\epsilon(x)$, this would imply $\int_{\Bbb R}\delta(x)f(x)dx=0$, which in general doesn't match the above calculation; we mustn't conflate $\lim_{\epsilon\to0^+}\int_{\Bbb R}\eta_\epsilon(x)f(x)dx$ with $\int_{\Bbb R}(\lim_{\epsilon\to0^+}\eta_\epsilon(x))f(x)dx$. But an object satisfying $\int_{\Bbb R}\delta(x)f(x)dx=f(0)$ is of sufficient interest we define it anyway. It is a distribution, generalized function and measure, but not a function, and must not be conflated with the function $\lim_{\epsilon\to0^+}\eta_\epsilon(x)$, whose values you've seen quoted. Incidentally, $f$ is so nice its derivatives are too, so repeated integration by parts gives $\int_{\Bbb R}\delta^{(n)}(x)f(x)dx=(-1)^nf^{(n)}(0)$.
Your question about expectations
The above addresses your first question, so let's look at your second. Any PDF can be chosen for $\eta$. In that case, $\eta_\epsilon$ is then also a PDF, of expectation$$\int_{\Bbb R}x\eta_\epsilon(x)dx=\epsilon\int_{\Bbb R}y\eta(y)dy,$$which exists for all $\epsilon>0$ provided the original $\eta$ has a mean. Since $\int_{\Bbb R}x\delta(x)dx=0$, your question boils down to whether $\delta$ should be identified with any probability distribution. We might describe it as a probability density measure for the degenerate distribution whose only possible value is $0$. One way to make this masses-are-Dirac-deltas notion more rigorous is in terms of characteristic functions. If $X$ is degenerate with value $a$,$$\Bbb Ee^{itX}=e^{ita}=\int_{\Bbb R}\delta(x-a)e^{itx}dx,$$so $\delta(x-a)$ is the density. Generalizing the inversion formula by which characteristic functions specify a probability distribution, so as to support the case where densities are measures rather than "ordinary" functions, relies upon this insight.


How to find the initial and the future population based on today's data?

Question: I need help for the part B of the following questions. Here is the question and my work:
A certain species of bird was introduced in a certain county $25$ years ago. Biologists observe that the population doubles every $10$ years, and now the population is $27,000$.
$(A)$ - What was the initial size of the bird population? (Round your answer to the nearest whole number.)
$n\ \text{(initial)} = \dfrac{27,000}{2^{(25/10)}}\implies [n]\ \text{(initial)} = 4773$ ----- correct.
$(B)$ - Estimate the bird population $8$ years from now. (Round your answer to the nearest whole number.)
$n\ \text{(8 years later)} = 4773\times 2^{(8/10)}\implies [n]\ \text{(8 years later)} = 8310$ ----- wrong.
Comment: The population is now $27,000$. Therefore the population in eight years is $27,000\cdot 2^{\frac{8}{10} }$
Comment: Would it be 47010?
Comment: Yes. That is what I got.
Comment: If you use the initial value of the population, you would substitute $25 + 8 = 33$ for the time since $25$ years have already elapsed.  You would calculate $n(33) = 4773 \cdot 2^{\frac{33}{10}}$ to find the population eight years from now.
Answer: Population is now 27000.Before 10 yrs,it was 27000/2,before 20 yrs it was $27000/2^2$,before 25 yrs it was $27000/2^\frac{5}{2}=27000/4\sqrt2=4772$
Population after 8 yrs from now=$27000\times2^\frac{8}{10}=47009$


Activity does not start

Question: I use this code to start a new Game from my MainMenu, everything works fine but when a game is finished the users get a popup Window (just another Activity named GameFinished with Theme.Dialog). The users can chose if they want to play the game again or go back to the MainMenu. This also works fine, but when I start another game the Activity from my MainMenu nothing happens, the debugger shows that the line is executed.
Visual Guide:
A --> B --> C --finish--> B --finish--> A
After that I cannot this:
A --> B
public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

    if (id == 0) {
                        startActivity(new Intent(GameMenu.this, GuessFlag.class));
                    } else if (id == 1) {
                        startActivity(new Intent(GameMenu.this,
                                MovieQuestions.class));
                    } else if (id == 2) {
                        startActivity(new Intent(GameMenu.this, SimpleMath.class));
                    } else if (id == 3) {
                        startActivity(new Intent(GameMenu.this, TickTacToe.class));
                    }
                }

The only thing I added in a few weeks was this line so I Tapifier would work:
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
        .permitAll().build();

StrictMode.setThreadPolicy(policy);

This is my (very big) logcat:
01-16 17:17:28.845: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@42342078 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:28.845: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@42342078 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.MovieQuestions.onCreate(MovieQuestions.java:45)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:28.845: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:29.900: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@423555f8 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:29.900: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@423555f8 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.SimpleMath.onCreate(SimpleMath.java:46)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:29.900: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:30.520: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4294f240 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.520: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4294f240 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.MovieQuestions.onCreate(MovieQuestions.java:45)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:30.520: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:30.825: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4296a908 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.825: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4296a908 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.GuessFlag.onCreate(GuessFlag.java:46)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:30.825: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:31.225: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429858b0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.225: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429858b0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.SimpleMath.onCreate(SimpleMath.java:46)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:31.225: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:31.500: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429a0de0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.500: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429a0de0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.GuessFlag.onCreate(GuessFlag.java:46)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:31.500: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)

SimpleMath:
@Override
    protected void onCreate(Bundle savedInstanceState) {

            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_game_simpemath);

        }

protected void onResume() {
    super.onResume();
    if (AppData.questionsLoaded) {
        AppData.questionsLoaded  = false;
        runGame();
    }

    if (AppData.restartGame) {
        AppData.restartGame = false;
        finish();
        startActivity(new Intent(SimpleMath.this, TickTacToe.class));
    }

    if(AppData.finishMe){
        finish();
    }

}

PlayAgain (Get calls when the game finishs):
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_game_gamefinished);

    Window window = this.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

    android.view.WindowManager.LayoutParams params = getWindow()
            .getAttributes();
    params.width = android.view.WindowManager.LayoutParams.MATCH_PARENT;
    getWindow().setAttributes(
            (android.view.WindowManager.LayoutParams) params);

            setListeners();
}

public void setListeners() {

    button_restart.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AppData.restartGame = true;
            finish();
        }
    });

    button_mainmenu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AppData.finishMe = true;
            finish();
        }
    });
}

The only other things that are relavent are that I use an AsyncTask and a Handler.
Answer: ObAt, I have exactly same error in my application. You wrote you don't use IntentReceiver, but it's probably not true.
Seems you're using special feature of Samsung devices - MultiWindow, so if you have registered intent-filter in your manifest, like me:
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

        <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
    </intent-filter>

    <meta-data android:name="com.sec.minimode.icon.portrait.normal"
        android:resource="@drawable/ic_launcher" />
    <meta-data android:name="com.sec.minimode.icon.landscape.normal"
        android:resource="@drawable/ic_launcher" />

then probably Samsung device register IntentReceiver on it's own on background to correctly handle some tasks related to MultiWindow feature. I see this error in log for a few months and it never had any issues. So I just ignore this till Samsung fix this problem on their side. This is just how I see it
Comment: I am using a Samsung Galaxy S3 with JB (so it has MultiWindow), that will explain a lot! I will test it but thanks a lot :)
Answer: According to your error,  you are are leaking a IntentReceiver you registered previously.
you need to unregister the IntentReceiver,   the onPause method would be a good place to do this for your SimpleMath activity.
@Override
protected void onPause() {
    super.onPause();
    unregister(); //  here
}

Comment: I don't use onPause in SimpleMath, I only Override onResume. 'The method unregister() is undefined '
Comment: you should! the `onPause` is the perfect place to unregister the receiver you made so that you dont leak it when going to the next activity.
Comment: Thank you! But hwo do I call unregister? Eclipse cannot find this method.
Comment: I cannot help you any further without seeing your `SimpleMath` activity code. CAn you edit your question and add it there ?
Comment: The weird thing is that I'd never used an IntentReceiver

Activity does not start


Cannot import module mariadb

Question: I use python 3.9 on MacOS 11.2.2 and want to use mariadb, which is installed ("mariadb 10.5.9 is already installed and up-to-date").
However, python cannot import the module mariadb, and I get this error:
import mariadb  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/__init__.py", line 10, in <module>
    from ._mariadb import (
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/_mariadb.cpython-39-darwin.so, 2): Symbol not found: _mysql_ps_fetch_functions
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/_mariadb.cpython-39-darwin.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/_mariadb.cpython-39-darwin.so

Pls help correct this. Thank you.
Comment: Have you followed [those](https://mariadb-corporation.github.io/mariadb-connector-python/install.html#build-prerequisites) steps or just ran `pip install mariadb`?
Comment: @gribvirus74. The steps are not all that helpful. Yes, I have python installed, yes, mariaDB is installed and it should install the connector with it. Is this a PATH problem?
Comment: I doubt it. My guess is that it has something to do with these C libs. But I think even if you don't have them on your system, it should install a binary package or fail on installation.
Answer: Too long for a comment...
_mariadb.cpython-39-darwin.so should be linked against libmariadb.3.dylib and the latter one should provide the exported symbol mysql_ps_fetch_functions.
To determine the problem I would suggest the following:

Check that mariadb.cpython-39-darwin.so is linked against Connector/C:

ldd /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/_mariadb.cpython-39-darwin.so should list libmariadb.3.dylib

Determine the location of libmariadb.3.dylib and check the output of

nm libmariadb.3.dylib | grep mysql_ps_fetch_functions.
If output doesn't list the mysql_ps_fetch_functions api call, your installed C/C version is too old, or you have multiple instances of C/C installed.
Homebrew e.g. provides the latest version 3.1.12, to use this version make sure that setup.py will find mariadb_config of the latest installation.
As an alternative you could also build C/C and C/Python from source.
I know that the installation is not very comfortable, but providing generic binaries for non windows platforms doesn't work well due to too much dependencies (like TLS libraries).
Comment: the first command (the mac  equivalent for `ldd` is `otool -L`): otool -L /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/_mariadb.cpython-39-darwin.so
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mariadb/_mariadb.cpython-39-darwin.so:
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
Comment: /Library/Developer/CommandLineTools/usr/bin/nm: error: libmariadb.3.dylib: No such file or directory.
Comment: I am ready to give up. I wish there were an installer for the Mac -- after all the MacOS is not some obscure flavor nobody'd ever want to install MariaDB on.
Comment: If libmariadb.3.dylib was not found it means it is not installed. Did you try e.g. `brew install mariadb-connector-c` ?
Comment: Sorry this didn't work either. I do appreciate your trying to help.
Comment: "Didn't work" isn't very verbose. If C/C couldn't be found after pip install there should be an error message. If C/C was found, but can't be loaded it's likely that there is a unsupported/outdated version installed. Also make sure that you did a pip uninstall mariadb before trying again.
Comment: @KOwen-ReinstateMonica did you manage to resolve the issue? I'm facing it right now.

Cannot import module mariadb


How to show timezone with country and city name in list in android?

Question: I am developing an application where i have to show the timezone with country and city name in spinner. I have use TimeZone class for it. But in this case i am getting a timezoneId and timezoneName only. How i can show timezone with country and city name in spinner ?
Comment: @OleV.V. i want to show the timezone like Calcutta (India), Berlin (Germany) but in my case it show like "Europe/Berlin" . I didn't get the county name here. Is there any api or library which shows show timezone with country and city name in list ?
Comment: See this doc https://developer.android.com/reference/java/util/TimeZone.html#getDisplayName() and this https://developer.android.com/reference/java/util/TimeZone#getAvailableIDs(int)
Comment: Time zones are usually given with *region* (continent or ocean) and city (or island (group)), as for example America/Adak, Asia/Bangkok, Atlantic/Canary, Indian/Mahe. Would this be fine with you?
Comment: @crammeur i have checked the documentation. But it couldn't solve my issue.
Comment: I don't know of such an API, but one might exist. You basically need a database of towns and countries, I guess.
Answer: Have you considered using Joda-Time? it provides a DateTimeUtils.getDefaultTimeZoneNames() method which returns a map of Time zone names.
You can find more information here
Comment: If you're ready to accept an external library — which could have great benefits, I agree — why not go for the successor of Joda-Time? java.time has been backported and the backport adapted for Android in [ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP/blob/master/build.gradle). On a new Android (API level 26 or higher) java.time is even built in and no external library needed.
Comment: @OleV.V. I was just suggesting Joda Time because that's the one I know, but I will take a look to ThreeTenABP, thanks!
Answer: Solution:-
private String[] timezoneArray;
private Spinner spinner_timezone;

spinner_timezone = (Spinner) findViewById(R.id.spinner_timezone);

Then call this
 timezoneArray = TimeZone.getAvailableIDs();
        CustomAdapter customAdapter = new CustomAdapter(getApplicationContext(), timezoneArray);
        spinner_timezone.setAdapter(customAdapter);
        for (int i = 0; i < timezoneArray.length; i++) {
            if (timezoneArray[i].equals(TimeZone.getDefault().getID())) {
                spinner_timezone.setSelection(i);
                break;
            }
        }

then CustomAdapter class
 public class CustomAdapter extends BaseAdapter {
        Context context;
        String[] countryNames;
        LayoutInflater inflter;

        public CustomAdapter(Context applicationContext, String[] countryNames) {
            this.context = applicationContext;
            this.countryNames = countryNames;
            inflter = (LayoutInflater.from(applicationContext));
        }

        @Override
        public int getCount() {
            return countryNames.length;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            view = inflter.inflate(R.layout.custom_spinner_items, null);
            TextView names = (TextView) view.findViewById(R.id.textView);
            names.setText(displayTimeZone(TimeZone.getTimeZone(countryNames[i])));
            return view;
        }

        private String displayTimeZone(TimeZone tz) {

            long hours = TimeUnit.MILLISECONDS.toHours(tz.getRawOffset());
            long minutes = TimeUnit.MILLISECONDS.toMinutes(tz.getRawOffset())
                    - TimeUnit.HOURS.toMinutes(hours);
            // avoid -4:-30 issue
            minutes = Math.abs(minutes);

            String result = "";
            if (hours > 0) {
                result = String.format("(GMT +%d:%02d) %s", hours, minutes, tz.getID());
            } else {
                result = String.format("(GMT %d:%02d) %s", hours, minutes, tz.getID());
            }

            return result;

        }
    }

And custom_spinner_items here
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:padding="10dp"
        android:textSize="15sp"
        android:text="Wifi Airtel"
        android:textColor="#000" />
</RelativeLayout>

Comment: It hardly gives the time zones in the format Calcutta (India) or Berlin (Germany) as requested by the asker in [a comment](https://stackoverflow.com/questions/51667693/how-to-show-timezone-with-country-and-city-name-in-list-in-android#comment90362339_51667693). Also it uses the long outdated and poorly designed `TimeZone` class. Its modern replacement is the `ZoneId` class from java.time, the modern Java date and time API.
Comment: I appreciate your experience , you can update the answer or post new answer for it dear :) , i will check it too


Dedekind's theorem on a weakly Artinian integrally closed domain without Axiom of Choice

Question: Let $A$ be a commutative ring.
Let $f$ be any non-zero element of $A$.
Suppose that $A/fA$ has a composition series as an $A$-module.
Then we say $A$ is a weakly Artinian ring (this may not be a standard terminology).
Can we prove the following theorem without Axiom of Choice?
Theorem
Let $A$ be a weakly Artinian integrally closed domain.
Then the following assertions hold.
(1) Every ideal of $A$ is finitely generated.
(2) Every non-zero prime ideal is maximal.
(3) Every non-zero ideal of $A$ is invertible.
(4) Every non-zero ideal of $A$ has a unique factorization as a product of prime ideals.
EDIT
May I ask the reason for the downvotes?
Is this the reason?
EDIT
What's wrong with trying to prove it without using AC?
A proof without AC is constructive.
When you are looking for a computer algorithm for solving a mathematical problem, this type of a proof may provide a hint. At least, you can be sure that there is a constructive proof.
EDIT
why-worry-about-the-axiom-of-choice.
Comment: Are you going to ask a single question for each and every combination of algebraic properties, whether or not it holds without the axiom of choice?
Comment: @BenjaLim: I'm not sure that the good folks on MO will appreciate this behavior of posting a convergent sequence of partial answers. If anything I would expect mathematicians to appreciate the ability to hold back the answer *until* it was about done. I also don't know if people would appreciate a rain of questions verifying a majority of commutative algebra is constructive for "tame" objects.
Comment: @Asaf, do you have some kind of objection in principle to asking about the various uses of AC in algebra? To my way of thinking, this is a perfectly reasonable topic of study, particularly in those cases where it seems likely that AC is required.
Comment: @AsafKragila "Are you going to ask a single question for each and every combination of algebraic properties, whether or not it holds without the axiom of choice?" No. I ask it mostly when the answer is likely to be affirmative and mostly when I think it's interesting and it has important applications.
Comment: @Makoto Please do not bump questions or answers for the purpose of asking about downvotes. Such questions are only rarely fruitful. If you insist on posing such questions then please do so in comments, so that the thread is not bumped. Better, as always, discuss such *meta* issues on the meta site - where they belong.
Comment: You can prove without AC that every ideal of $A$ is contained in a maximal ideal (take a chain - it terminates, cause all chains do because of the composition series ---> no reason to appeal to Zorn's lemma) and so I think the answer to all four questions is affirmative.
Comment: @MakotoKato I see that many of your posts have drawn a lot of flak from users on math.stackexchange. I think that the people at MO would be more competent to handle your questions, why don't you post them there on MO? I can help you by posting them on your behalf on MO if you would like to. Regards,
Comment: @BillDubuque I'll try to put them as comments from now on. However, I can't promise I'll always do so. I may put them in my qestions or answers in rare cases. Is that okay?
Comment: @YACP, please do not bring back questions from the dead for the sole purpose of italicizing a phrase. I also prefer terms being defined to be emphasized in some way, but it is not *that* important...
Comment: @YACP, well, it may be important for you, but there is a scarce resource which is the list of Top Questions, which is *shared* between all users, those that have absolutely no interest in this sort of edits and you. It is not polite to proceed under the assumption that your interest in italics trumps other's people questions time share on the main list.
Comment: The point is, you are contributing mostly *noise* to the site by doing this. Surely you understand this... If you intend to keep this up, please be nice and start a meta thread to see what the community thinks about your quest for typographical correctness.
Comment: Well, I am trying to moderate your bumping old questions for the sole purpose of correctly typographical errors!(actually, to be precise: what *you* see as errors, as there is no International Treaty one should respect by italicizing defined terms, really... It may well be the case that MK purposefully did not italicize those terms because *he* has a different idea of what «perfect» is...) I suggest that you strive to perfect what you write, and leave minor would-be-issues like these on other people's post alone.
Comment: **Please** make any further comment on this topic in a meta thread: this is 200% off-topic here.
Answer: We assume tacitly the definitions in my answer to this question.
Definition 1
Let $A$ be a commutative ring.
Suppose $A$ has a composition series as an $A$-module.
Then we say $A$ is an Artinian ring.
Lemma 1
Let $A$ be an Artinian ring.
Let $I$ be an ideal of $A$.
Then $A/I$ is an Artinian ring.
Proof:
This follows from Lemma 2 of my answer to this question.
Lemma 2
An Artinian ring is weakly Artinian.
Proof:
This follows from Lemma 1.
Lemma 3
Let $A$ be a weakly Artinian ring.
Let $I$ be a non-zero ideal of A.
Then $A/I$ is Artinian.
Proof:
Since $I$ is non-zero, $I$ contains a non-zero element $f$.
Since $A/fA$ is Artinian, $A/I$ is Artinian by Lemma 1.
QED
Lemma 4
Let $A$ be a weakly Artinian ring.
Let $I$ be an ideal of $A$.
Then $A/I$ is a weakly Artinian ring.
Proof:
Clear.
Lemma 5
Let $A$ be a weakly Artinian ring.
Then every ideal of $A$ is finitely generated.
Proof:
Let $I$ be a non-zero ideal of $A$.
Let $f \in I$ be a non-zero element.
By Lemma 7 of my answer to this question, $I/fA$ is a finite $A$-module.
Since $fA$ is a finite $A$-module, $I$ is also a finite $A$-module.
QED
Lemma 6
Let $A$ be a (not necessarily commutative) ring.
Let $M$ be a left $A$-module.
Suppose that $M$ has a composition series.
Let $f:M \rightarrow M$ be an injective $A$-homomorphism.
Then $f$ is surjective.
Proof:
Since $f$ is injective, $leng$ $M = leng$ $f(M)$.
By Lemma 4 of my answer to this question, $f(M) = M$.
QED
Lemma 7
Let $A$ be an Artinian integral domain.
Then $A$ is a field.
Proof:
Let $a$ be a non-zero element of $A$.
Let $f: A \rightarrow A$ be the map defined by $f(x) = ax$.
Since $f$ is injective, it is surjective by Lemma 6.
Hence $a$ is invertible.
Hence $A$ is a field.
QED
Lemma 8
Let $A$ be an Artinian ring.
Let $P$ be a prime ideal of $A$.
Then $P$ is maximal.
Proof:
This follows immediately from Lemma 1 and Lemma 7.
Lemma 9
Let $A$ be a weakly Artinian ring.
Let $P$ be a non-zero prime ideal.
Then $P$ is maximal.
Proof:
By Lemma 3, $A/P$ is an Artinian ring.
Since $A/P$ is an integral domain, $A/P$ is a field by Lemma 7.
Hence $P$ is maximal.
QED
Lemma 10
Let $A$ be a (not necessarily commutative) ring.
Let $M$ be a left $A$-module.
Suppose that $M$ has a composition series.
Let $N$ be an $A$-submodule of $M$.
Then $leng$ $M = leng$ $N + leng$ $M/N$.
Proof:
By Lemma 2 of my answer to this question, $leng$ $M/N$ is finite.
By Lemma 3 of my answer to this question, $leng$ $N$ is finite.
Hence $leng$ $M = leng$ $N + leng$ $M/N$.
QED
Lemma 11
Let $A$ be a (not necessarily commutative) ring.
Let $M$ be a left $A$-module.
Let $N_0 \supset N_1 \supset ... \supset N_r$ be a descending sequence of $A$-submodules of $M$.
Suppose that $N_i \neq N_{i+1}$ for $i = 0, 1, ..., r - 1$.
Then $r \leq leng$ $M$.
Proof:
This follows from Lemma 10.
Lemma 12
Let $A$ be an Artinian ring.
Then Spec($A$) is finite.
Proof:
This follows from Lemma 2 of my answer to this question and Lemma 8 and  Lemma 11.
Lemma 13
Let $A$ be an Artinian ring.
By Lemma 12, Spec($A$) is finite.
Let Spec($A$) = {$P_1, ..., P_r$}.
Let $I = P_1 \cap ..., \cap P_r$.
Then $I$ is nilpotent.
Proof:
This follows from Lemma 8 and the proposition of my answer to this question.
Lemma 14
Let $A$ be a weakly Artinian ring.
Let $I$ be a non-zero proper ideal of $A$.
Then there exist maximal ideals $P_1, ..., P_r$ such that $P_1...P_r \subset I$.
Proof:
By Lemma 3, $A/I$ is Artinian.
By Lemma 13, Spec($A/I$) is finite.
Let Spec($A/I$) = {$Q_1, ..., Q_s$}.
Let $J = Q_1 \cap ... \cap Q_s$.
Since each $Q_i$ is maximal, $J = Q_1...Q_s$.
By Lemma 13, $J^k = 0$ for some integer $k \geq 1$.
Let $P_i$ be the inverse image of $Q_i$ by the canonical morphism $A \rightarrow A/I$.
Then $(P_1...P_s)^k \subset I$.
QED
Lemma 15
Let $A$ be a weakly Artinian integrally closed domain.
Then every non-zero prime ideal of $A$ is invertible.
Proof:
Let $P$ be a non-zero prime ideal of $A$.
We claim that $P^{-1} \neq A$.
Let $a \in P$ be non-zero.
By Lemma 14, there exist maximal ideals $P_1, ..., P_r$ such that $P_1...P_r \subset aA$.
Choose $r$ such that $r$ is minimal.
Since $P_1...P_r \subset P$, one of $P_i = P$.
Without loss of generality, we can assume $P_1 = P$.
By the minimality of r, $P_2...P_r$ is not contained in $aA$.
Hence there exits $b \in P_2...P_r$ such that $b$ is not contained in $aA$.
Since $bP \subset aA$, $ba^{-1}P \subset A$.
Hence $ba^{-1} \in P^{-1}$.
Since $ba^{-1}$ is not contained in $A$, $P^{-1} \neq A$.
Since $P$ is maximal and $P \subset PP^{-1} \subset A$, $P = PP^{-1}$ or $PP^{-1} = A$.
Suppose $P = PP^{-1}$.
Since $P$ is finitely generated by Lemma 5, every element of $P^{-1}$ is integral over $A$.
Since $A$ is integrally closed $P^{-1} \subset A$.
This is a contradiction.
QED
Lemma 16
Let $A$ be a weakly Artinian integrally closed domain.
Then every non-zero ideal is invertible.
Proof.
Let $\Lambda$ be the set of non-zero ideals which are not invertible.
Suppose $\Lambda$ is not empty.
By Lemma 5 of my answer to this question, there exists a maximal element $I$ in $\Lambda$.
Since $A \neq I$, by Lemma 5 of my answer to this question, there exists a maximal ideal $P$ such that $I \subset P$.
$I \subset IP^{-1} \subset II^{-1} \subset A$.
If $I = IP^{-1}$, since $P$ is finitely generated by Lemma 5, every element of $P^{-1}$ is integral over $A$.
Since $A$ is integrally closed, this cannot happen by the proof of Lemma 15.
Hence $I \neq IP^{-1}$.
Since $I$ is a maximal element in $\Lambda$, $IP^{-1}$ is invertible.
Hence $I$ is invertible.
This is a contradiction.
QED
Lemma 17
Let $A$ be a weakly Artinian integrally closed domain.
Then every non-zero ideal is a product of prime ideals.
Proof:
Let $\Lambda$ be the set of non-zero ideals which are not a product of prime ideals.
Suppose $\Lambda$ is not empty.
By Lemma 5 of my answer to this question, there exists a maximal element $I \in \Lambda$.
Since $I$ is not a maximal ideal, By Lemma 5 of my answer to this question, there exists a prime ideal $P$ such that $I \subset P$.
Then $IP^{-1} \subset A$ and $IP^{-1} \neq A$.
Suppose $I = IP^{-1}$. Since I is finitely generated by Lemma 5, every element of $P^{-1}$ is integral over $A$. Since $A$ is integrally closed, this cannot happen by the proof of Lemma 15. Hence $I \neq IP^{-1}$.
Since $I \subset IP^{-1}$, $IP^{-1}$ is a product of prime ideals.
Then $I$ is a product of prime ideals.
This is a contradiction.
QED
Proposition
Let $A$ be a weakly Artinian integrally closed domain.
Then every non-zero ideal has a unique factorization as a product of prime ideals.
Proof:
This follows immediately from Lemma 16 and Lemma 17.


How many Guardians are in Zelda: Breath of the Wild?

Question: I'm curious from a lore perspective - how many Guardians are there in Zelda: a Breath of the Wild, including both the destroyed Guardians, and the active ones that have been corrupted by Ganon (including the immobile ones)? It doesn't look like there's an answer on any of the wikis I've checked, nor on any of the walkthrough sites that turn up on a Google search. Does the number of Guardians in the game match the number of Guardians in the tapestry depicting the events 10000 years prior to the game?
I'm primarily interested in the main, full-sized hexapedal variety of Guardian, but if you also want to include tallies of the Guardian Scouts, fliers, and turrets, that would also be fine.
Comment: In addition to the many you can see, lore-wise there will be many that are buried, and possibly hundreds of thousands still in the vaults below the castle.
Comment: I'd say that the tapestry would be inaccurate, purely used for depiction of "a large force", for the reasons you've pointed out, such as the variety of guardians available in the game.
Comment: @OrangeDog My understanding is that the guardians that were being stored under the castle were released by Calamity Ganon when he took them over and raised the pillars containing them from the ground.
Comment: @nick012000 it was my understanding that there were still loads down there, which is how they respawn.
Comment: @OrangeDog Do you have a source for that? I had assumed that they respawned due to the Malice that powers them when they're under Calamity Ganon's control.
Answer: MrCheeze's BOTW Object Map lists the following items:

46 Guardian Stalkers
29 Guardian Skywatchers
20 Guardian Turrets
55 Decayed Guardians
18 Sentries (found only around Divine Beast Vah Rudania)

Additionally, there are 3 Guardian Skywatchers and 1 Guardian Turret that are part of The Champion's Ballad DLC pack, and hence are not under the influence of Ganon.
Also, there are 367 Dead Guardians, of which 294 can be looted for ancient parts, and 47 can be flipped (for example, with Cryonis).
In particular, in the fields west of Fort Hateno (Blatchery Plain, Ash Swamp) there are 68 Dead Guardians and 2 Decayed Guardians.
Comment: Does this include mostly destroyed guardians, such as those at Akkala Tech Lab, or those submerged in lava at Death Mountain?
Comment: Does the number of Guardians plus Dead Guardians match the number of Guardians depicted on the tapestry?
Comment: @MatthewWells yes, they appear as dead guardians in the Object Map (look for `ruinguardian`, ignore the arms).


SQL rows in place of columns?

Question: I have a form with many project questions and in some of those questions are about 20 CheckBoxes to be checked. I want to create a SQL structure for these projects.
The majority of data is located in a Project table.
But I don't want to have all these CheckBoxes as columns of the project table, instead I want to make a table where all these CheckBoxes would be represented as Rows. This table would have a group designating the question (parent of all those checkboxes) and I'd add 1 more table, between the project and the table with checkboxes to create a [1]-[N N]-[1] structure.
But I'm asking, if this is acceptable, because when the query comes, I won't have the columns to set the condition for, but a table with rows...
Any better idea?
Thank you
Comment: That is acceptable, you are using it now, look at stackoverflow.  Those upvotes/downvotes (they are checkboxes for all intents and purposes) by each user, it translates to rows in database.  637 thousand questions, with a million answers, how can that approach go wrong
Answer: This is absolutely acceptable.  We sell a couple products that deal with dynamic data in just that way.  Also it's very fast even with large data sets (1M+ records)
To be sure, you will want to be on SQL 2008.  Things like Table Value Parameters, MERGE, and CTE's make dealing with this type of data so much easier than older versions of sql server.
HINT: you might be tempted to create views of that data in order to select out of it..If the number of columns is less than 10, then you'll be fine.  Anything more than that and you are much better off doing the rows to columns transform (I'm thinking reports here) in code.
Comment: It's not only acceptable, it's *correct*.  Normalizing to rows instead of columns makes it possible to index and change the options.

SQL rows in place of columns?


php ziparchive leave unfinished zip files

Question: I'm trying to create three zip packages with php. I'm running a function that copies a directory and looking through the content to add each file with a loop into the zip.
Problem is that ZipArchive does not seem to close the files when finishing up.
What I want to end up with is three zip files like this:
Package1.zip
Package2.zip
Package3.zip

Instead I end up with something like this:
Package1.zip.a012341
Package1.zip.b012342
Package2.zip.a023451
Package2.zip.b023452
Package3.zip.a034561
Package3.zip.b034562

It's like the zip files don't close and finish up to remove the temporary extension and tries to create another one of each file and fails with those aswell. I get no error what so ever, atleast not what I've seen.
What I'm guessing is that there are some kind of setting I need to change in php.ini or on my webserver/IIS. The files I'm trying to create are pretty big, somewhere between 450 - 600 MB.
This is my best guess because I got two almost identical server setups I've tried the same code on. It works perfectly on one of them but not the other. That proves that my ZipArchive code can not the issue here (I did not set up the servers btw, so I'm not sure what differs).
I've tried to increase the memory_limit and execution time in my php.ini. The latter was an earlier issue and I got a message telling me it had timed out.
Thanks in advance!
Edit: Added the function.
function package_site($filepath, &$context) {
    $context['message'] = 'Creating package';

    // Mac app
    $mac_zipfile = 'public://site_export/mac_package.zip';
    copy_directory($mac_zipfile, $filepath . '/mac_package.zip', '/.*/');
    $files = file_scan_directory($filepath . '/files', '/.*/');

    $mac_zip = new ZipArchive();
    if($mac_zip->open(drupal_realpath($filepath . '/mac_package.zip')) === true) {
        foreach($files as $key => $value) {
            $mac_zip->addFile(drupal_realpath($value->uri), 'mac_package.app/Contents/Resources/' . substr(drupal_realpath($value->uri), strlen(drupal_realpath($filepath . '/files')) + 1));
        }
    } else {
        drupal_set_message("Could NOT open mac_package.zip");
    }
    $mac_zip->close();

    // PC app
    drupal_unlink($filepath . '/package.zip');
    $start_files_path_pc = 'public://site_export/pc_files';
    copy_directory($start_files_path_pc, $filepath . '/files', '/.*/');
    $pc_files = file_scan_directory($filepath . '/files', '/.*/');

    $zip = new ZipArchive();
    $res = $zip->open(drupal_realpath($filepath . '/package.zip'), ZipArchive::CREATE);
    if ($res === TRUE) {
        foreach ($pc_files as $key => $value) {
            $zip->addFile(drupal_realpath($value->uri), substr(drupal_realpath($value->uri), strlen(drupal_realpath($filepath . '/files')) + 1));
        }
        $zip->close();
    }

    // Create a html package
    create_pure_html_package($filepath);

    // HTML package
    drupal_unlink($filepath . '/html.zip');
    $html_files = file_scan_directory($filepath . '/files/site', '/.*/');

    $zip_html = new ZipArchive();
    $res = $zip_html->open(drupal_realpath($filepath . '/html.zip'), ZipArchive::CREATE);
    if ($res === TRUE) {
        foreach ($html_files as $key => $value) {
            $zip_html->addFile(drupal_realpath($value->uri), substr(drupal_realpath($value->uri), strlen(drupal_realpath($filepath . '/files')) + 1));
        }
        $zip_html->addFile(drupal_realpath($filepath . '/start.html'), 'start.html');
        $zip_html->close();
    }

    rrmdir(drupal_realpath($filepath . '/files'));
    unlink(drupal_realpath($filepath . '/start.html'));
}

Comment: Are you able to post some example code as i have used the ziparchive before to do something similar and didn't encounter this
Answer: I ran into the same issue just now. I solved the problem by changing the file directory permissions (to non-readonly). That's my answer and I hope it helps you!


HTML page reloading without updating text areas' data

Question: In my HTML page there are two Text Areas with default values and a SUBMIT button.
After SUBMIT has been pressed by the user, I want to update the two text areas with the new numbers, and at the same time use the values to call the function loadCountryDataFromCsv(countrySelected, indicatorSelected).
The problem is that the whole page is reloading, ignoring the values inserted by the user and using the ones inserted by default in the HTML body.

      <meta charset="utf-8">
      <title>Homicide count and rate</title>

           <d1 style="float: left;"><big>Intentional homicide, counts and rates per 100,000 population</big></d1>

           <d1 style="float: left;">Intentional homicide is defined as unlawful death inflicted upon a person with the intent to cause death or serious injury.</d1>

        <fieldset>
            <legend>Select a Country</legend>
            <d1>Region:   </d1>
            <select id="region-select">
                <option value="Africa">Africa</option>
                <option value="Americas" selected>Americas</option>
                <option value="Asia">Asia</option>
                <option value="Europe">Europe</option>
                <option value="Oceania">Oceania</option>
            </select>
            <d1>  Subregion:   </d1>
            <select id="subregion-select">

            </select>
            <d1>  Country:   </d1>
            <select id="country-select">
            </select>

            <d1>Indicator Select:   </d1>
            <select id="data-select">
                <option value="count" selected>count</option>
                <option value="rate">rate</option>
            </select>
            <d1>  Format Select:   </d1>
            <select id="format-select">
                <option value="">none</option>
                <option value="decimal" selected>decimal</option>
                <option value="scientific">scientific</option>

                <option value="short">short</option>
                <option value="long">long</option>
            </select>

            <form>

                <d1>Min Range:    </d1>
                 <input style="width: 55px;" id="minCnt" type="text" name="minCnt" value="0">
                <d1>Max Range:    </d1>
                 <input style="width: 55px;" id="maxCnt" type="text" name="maxCnt" value="10000">
                      <input onclick="return updateRange();" id="submit" type="submit" value="Submit" onsubmit="return false;">

            </form>
        </fieldset>

Pluckr code -> http://plnkr.co/edit/UxcMxzwVShuMjEAo2wug?p=preview
In order to stop reloading the page, I've already tried using
<input onclick="return false;" id="submit" type="submit" value="Submit" onsubmit="return false;">
but the problem is that while the page is not loading, at the same time I'm not able to call the loadCountryDataFromCsv(countrySelected, indicatorSelected) function with the new values.
Comment: Remove the `form` tag and the page won't reload.
Answer: add an id to your form (say "form1"). then remove the submit.onchange =function and do the following

$('formid').on('submit',function(e){
  e.preventDefault();
  var minCnt = document.getElementById('minCnt').value;
  var maxCnt = document.getElementById('maxCnt').value;
  range[0] = minCnt; range[1] = maxCnt;
  var countrySelected = document.getElementById('country-select').value;
  var indicatorSelected = document.getElementById('data-select').value;
  loadCountryDataFromCsv(countrySelected, indicatorSelected);
});
Comment: have you ever checked the console of your browser?
The function :
loadCountryDataFromCsv(countrySelected, indicatorSelected);
is causing your page to refresh

else place the loadCountryDataFromCsv(countrySelected, indicatorSelected) definition outside the function drawChart()

you cant get a function that is not globally defined from updateRange()
Comment: is this jquery? becauseI get "Uncaught ReferenceError: $ is not defined"
Comment: you will need jquery

If you dont want to use jquery, i ll edit the code