NullPointerException when using Scanner.nextInt()
What is a NullPointerException, and how do I fix it?
What's the cleanest, most effective way to validate decimal numbers in JavaScript?  Bonus points for:   Clarity. Solution should be clean and simple. Cross-platform.   Test cases:  01. IsNumeric('-1')      =&gt; true 02. IsNumeric('-1.5')    =&gt; true 03. IsNumeric('0')       =&gt; true 04. IsNumeric('0.42')    =&gt; true 05. IsNumeric('.42')     =&gt; true 06. IsNumeric('99,999')  =&gt; false 07. IsNumeric('0x89f')   =&gt; false 08. IsNumeric('#abcdef') =&gt; false 09. IsNumeric('1.2.3')   =&gt; false 10. IsNumeric('')        =&gt; false 11. IsNumeric('blah')    =&gt; false Password Protect QGIS project On a shared computer, I have a QGIS project which links up to a PostGIS database that contains my data. If a user wants to access layers from the db, they have to enter the db credentials, so that's OK.   However, I have previously logged on and imported layers from my db into QGIS, and manipulated them in QGIS (styling options based on meta-data, etc.)... Anybody who opens my QGIS project can view these layers in QGIS, and can therefore see the data I wish to be protected in my db.  Is there a way to password protect my QGIS project? Adding a Method to an Existing Object Instance I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python.   I understand that it's not always good to do so. But how might one do this? how do I get my code to use the value of the $HOME variable? I'm trying to put together a generic script that will check the existence of several key directories for various users on different servers. Additionally, I want to leverage each user's $HOME variable.  For eg, let's say this were true:   on server 1: jdoe's home is /home/jdoe  on server 2: jdoe's home is /opt/jdoe2 server 3 hasn't been built yet; we won't know where they build his $HOME until the server is built. on server 4: mysql's home is /opt/home/mysql   This is what I have for my important directories (ordered from most to least impt):  $ cat mylist.txt $HOME/most_impt_dir1 $HOME/most_impt_dir2 $HOME/most_impt_dir3 $HOME/misc $HOME/junk   ...I want to find the most impt dir owned by this user.   Here's what I'm trying:  for i in `cat mylist.txt` do    if [[ -O $i ]] &amp;&amp; [[ -d $i ]]; then     echo "found it: $i"     break   else     echo "$i is not it."   fi  done   The above code does not work for anything in my list because it is literally checking for dirs beginning with $HOME. How do I get my code to use the value of the user's $HOME variable? How to "add existing frameworks" in Xcode 4? Should we use wheatstone bridges nowadays? For measuring strain gauges, the Wheatstone bridge is the historical choice.  In a quarter Wheatstone brigde (\$350 \Omega \$ typically (?)), with a high input impedance amplifier, and some bridge power voltage \$V\$, the ratio between the bridge output voltage w.r.t. any resistor is 1/4, which is the same ratio in a voltage divider between the output voltage w.r.t. any resistor, compared with a stable voltage reference of \$V/2\$.    A voltage divider with a voltage reference would have a voltage noise of about 35.16 nV/rtHz (from a voltage reference of 35 nV/rtHz plus two resistors), and the Wheatstone bridge a voltage noise of 4.86 nV/rtHz (from four resistors), which should be enough (?) for most ADC systems (i.e. for 24 bit, 0-5V range: 300nV resolution).  And a voltage reference (\$0.02\%\$ initial error, \$2 \ ppm/C^\circ\$, ), would be more stable and precise (?) about \$4\ ppm/C^\circ\$, than a precision resistor (\$0.005\%\$ error, \$2 \ ppm/C^\circ \$, ), about \$8 \ ppm/C^\circ\$.  Hence, why bother using Wheatstone bridges? I have two atoms, both of which are either bosons or fermions, with four allowed energy states: $E_1 = 0$, $E_2 = E$, $E_3 = 2E$, with degeneracies 1, 1, 2 respectively.  What's the difference between the partition functions of a pair of two bosons and that of a pair of two fermions? How to evaluate $ \lim \limits_{n\to \infty} \sum \limits_ {k=1}^n \frac{k^n}{n^n}$? I can show that the following limit exists but I am having difficulties to find it. It is $$\lim_{n\to \infty} \sum_{k=1}^n \frac{k^n}{n^n}$$ Can someone please help me? What is the best approach for solving the equations of the form      $p^x = x^q$ ; where $p$ and $q$ are some constants.   Basically, I wanted to solve $2^x = x^2$ to analyze algorithms with respective growth functions. Uncountable $\sigma$-algebra I'm stuck on the following problem (Source: Real Analysis for Graduate Students; Exercise 2.6; ):     Suppose $\mathcal A$ is a $\sigma$-algebra with the property that whenever $A \in \mathcal A$, there exists $B, C \in \mathcal A$ with $B \cap C = \emptyset$, $B \cup C = A$, and neither $B$ nor $C$ is empty. Prove that $\mathcal A$ is uncountable.   I think there is the added assumption that this is only true for $A \in \mathcal A$ having at least two elements, so it doesn't hold for singletons and the emptyset?  I tried to show this by way of contradiction and say that $\mathcal A = \{A_k\}$ is countable, but I didn't see how this could get me to a contradiction.  The other approach I tried was to look at $X = B_1 \cup C_1$ where $B_1 \cap C_1 = \emptyset$, then look at $B_1 = B_2 \cup C_2$ where $B_2 \cap C_2 = \emptyset$ and so on. If I look at the $C_k$'s they are pairwise disjoint and I either have a finite number of them or an infinite number of them in which case I've created a countable sequence of pairwise disjoint nonempty elements of $\mathcal A$. This path looked promising, but I couldn't see what to do next. Any ideas?  As a secondary question: I think this result is supposed to be used to show that if $\mathcal A$ is a $\sigma$-algebra with infinitely many elements, then it's uncountable, but I wasn't able to show that the property mentioned above (the one I'm trying to show) was satisfied in this case. I was reading the following article by Mathew Might.  I saw the following the paragraph  What doesn't matter GPA? I don't care if it's 2.0 or 4.0. I won't even look at it. The school you went to? I'll judge you the same whether you went to Nowhere State U or a top-ten school. Transcripts? Never seen one. GREs? Irrelevant. Where you work/worked? Unless it's a research lab, it's not important. I don't think these items have much predictive capacity as to whether or not someone can complete a Ph.D.  Is Mathew Might telling the truth? For me it's very hard believe that GPA, GRE scores and undergraduate school don't matter. I used to think that they play an extremely important role in grad school admission. Gummy residue from baking spray/oil I'm sure everyone's seen this - that brownish stuff left behind when you grease an area of a baking dish that gets left exposed to the heat. Soap doesn't bother it too much, and it likes to gum up my scrubber. What's going on there, and are there any easy ways to get it off? Hahn-Banach Theorem for separable spaces without Zorn's Lemma What's the equivalent of the "cls" command from Windows/DOS? Are the foods in the Star Wars Universe the same as ours'? Do they have strawberries or potatoes or something? I know that they might have some food other than the food that we also have, but I'm wondering if they have any food like ours'. Compare two objects in Java with possible null values Input 0  echo foo | xargs -L 1 -I '{}' echo '{}'   Output 0  foo   Input 1  echo foo | xargs -I '{}' -L 1 echo '{}'   Output 1  {} foo   Why changing the order of options of xargs changes the output?  Version: xargs (GNU findutils) 4.6.0 Now this might be a very stupid question for many readers, but I am getting really confused.   I was reading about electricity and current, and I read this:  Suppose we connect a wire to the ends of a battery, and a bulb in the circuit, current flows and lights up the bulb. The battery is responsible for doing work on the positive charges to move them from negative terminal to positive terminal, that is moving against the field. Now, these energised positive charges move through the external circuit, and within the circuit they give some of their energy to light the bulb. I understood this very well.  Now, reading further, it was written that "Electrons are actually responsible for current flow". It was written that there is concentration of energised negative charges on the negative terminal, and these electrons then move through the external circuit from negative to positive terminal. This is really confusing.     So my question: What actually flows? The negative charge or the   positive charge?   Further reading, I also read that in semi-conductors, fluorescent light bulbs etc., both charges move through the circuit.     Now, one more doubt: If both charges move through the circuit in this   case, shouldn't the charges stop in the middle of the wire, because   opposite charges will attract each other, hence stopping their   movement? Calculating $\lim_{x\to0} \left\lfloor\frac{x^2}{\sin x \tan x}\right\rfloor$ "Home page" or "homepage"? Is there a convention for the spelling of the name of the main page of a website? Should it be home page, with a space between the two words; or homepage, all one word?