How can I allow only numbers, one comma, and two digits after the comma in my input field? I have an input field, that only allows numbers and one point.     $('.number').keypress(function(event) {     var $this = $(this);     if ((event.which != 46 || $this.val().indexOf('.') != -1) &amp;&amp;        ((event.which &lt; 48 || event.which &gt; 57) &amp;&amp;        (event.which != 0 &amp;&amp; event.which != 8))) {            event.preventDefault();     }      var text = $(this).val();     if ((event.which == 46) &amp;&amp; (text.indexOf('.') == -1)) {         setTimeout(function() {             if ($this.val().substring($this.val().indexOf('.')).length &gt; 3) {                 $this.val($this.val().substring(0, $this.val().indexOf('.') + 3));             }         }, 1);     }      if ((text.indexOf('.') != -1) &amp;&amp;         (text.substring(text.indexOf('.')).length &gt; 2) &amp;&amp;         (event.which != 0 &amp;&amp; event.which != 8) &amp;&amp;         ($(this)[0].selectionStart &gt;= text.length - 2)) {             event.preventDefault();     }       }); .number {     padding: 5px 10px;     font-size: 16px; } &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;input type="text" class="number" /&gt;     I want to use this for currency so instead of the point I need to have a comma. So I replaced every point into the function with a comma. But it is not working.    $('.number').keypress(function(event) {     var $this = $(this);     if ((event.which != 46 || $this.val().indexOf(',') != -1) &amp;&amp;        ((event.which &lt; 48 || event.which &gt; 57) &amp;&amp;        (event.which != 0 &amp;&amp; event.which != 8))) {            event.preventDefault();     }      var text = $(this).val();     if ((event.which == 46) &amp;&amp; (text.indexOf(',') == -1)) {         setTimeout(function() {             if ($this.val().substring($this.val().indexOf(',')).length &gt; 3) {                 $this.val($this.val().substring(0, $this.val().indexOf(',') + 3));             }         }, 1);     }      if ((text.indexOf(',') != -1) &amp;&amp;         (text.substring(text.indexOf(',')).length &gt; 2) &amp;&amp;         (event.which != 0 &amp;&amp; event.which != 8) &amp;&amp;         ($(this)[0].selectionStart &gt;= text.length - 2)) {             event.preventDefault();     }       }); .number {   padding: 5px 10px;   font-size: 16px; } &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;input type="text" class="number" /&gt;
Validate decimal numbers in JavaScript - IsNumeric() 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
According to this , if at least one of the nouns involved is plural then it should take the plural form of the verb. Otherwise, it should take the singular form of the verb. But in the last part it says not all grammars agree to those rules thus proximity rule applies. However, it doesn't explain when to apply the proximity rule and when not to use the former rules. How to "unpivot" or "reverse pivot" in Excel? I have data that looks like this:  Id | Loc1 | Loc2 | Loc3 | Loc4 ---+------+------+------+----- 1  | NY   | CA   | TX   | IL 2  | WA   | OR   | NH   | RI   And I want to convert it to this:  Id | LocNum | Loc ---+--------+---- 1  |   1    | NY 1  |   2    | CA 1  |   3    | TX 1  |   4    | IL 2  |   1    | WA 2  |   2    | OR 2  |   3    | NH 2  |   4    | RI   What's the easiest way to do this in Excel 2007? CAML query daterange not working How do you find a question's view counter? How do you see how many views a question has had when you're not in the newest category?  I've tried a word-for-word search for the question, but still can't see the view counter. I want to list a company name in the author field of a bibliographic entry:  @book{CUDA,   author    = {NVIDIA Corporation},   title     = {NVIDIA CUDA Compute Unified Device Architecture Programming Guide},   publisher = {NVIDIA Corporation},   year      = {2007} }   But the entry keeps showing up "N. Corporation".  Is there a way to get the full author name to show up?  I'm currently using the siam BibTEX style. How should one interpret the comparison of means from different sample sizes? Take the case of book ratings on a website. Book A is rated by 10,000 people with an average rating of 4.25 and the variance $\sigma = 0.5$. Similarly Book B is rated by 100 people and has a rating of 4.5 with $\sigma = 0.25$.   Now because of the large sample size of Book A the 'mean stabilized' to 4.25. Now for 100 people, it may be that if more people read Book B the mean rating may fall to 4 or 4.25.   how should one interpret the comparison of means from different samples and what are the best conclusions one can/should draw?    For example - can we really say Book B is better than Book A. I have a stubborn folder that someone must have created accidentally and that has persisted all this time. I can see it with:  # find /var/www/html -maxdepth 1 -type d   which gives me:  /var/www/html /var/www/html/files /var/www/html/.?   unfortunately the question mark there is not the actual character ?, it merely seems to denote that there is no proper glyph and/or translation for that character. So something like rmdir is out of the question. My system has UTF-8 as the default locale as so many modern Ubuntu systems, but admittedly the folder in question may have originated on a RHEL or CentOS box (tared up and unpacked).  # env|grep LANG LANG=en_US.UTF-8   When trying to cd .\? (as mentioned before it is not actually ?) I get auto-corrected to . by bash and actually end up in /var/www/html/. for some reason. Now if I can't "name" this folder usefully, I cannot access it in any way. How can I get rid of it without putting the whole system in jeopardy?  Now I installed detox already but that only seems to act on files, not folders, according to its documentation and besides it still requires that I be able to name the object somehow to do something with it. Mapping of zero vector under a linear transformation Let $T$ be a linear transformation from a vector space $V$ to $W$ that are defined over a field $\mathbb F$.   Now, $T(\mathbf0)=\mathbf0$.   Which implies the zero vector in $V$ can't move or be transformed to a new vector in $W$. Why is it so?   Does it also have a geometrical significance? I no longer use the service that I originally used to register, and would like to change the service I use to log in, or at least add a second account.  Is this possible? How do I change my login provider or associate a backup method to log in?     For more information, see "" in the . I learned recently that when an object moves with a velocity comparable to the velocity of light the (relativistic) mass changes. How does this alteration take place? "Die from cancer" vs. "die of cancer" Is there a difference between those expressions: "Die from cancer" or "Die of cancer"? Are they both correct? Why do I have so many .Xauthority.* files in my home directory? What causes the 'Connection Refused' message? This is a  about Connection Refused    We see a lot of questions to the effect      When I try to connect to a system I get a message      Connection refused      Why is this ? Cast Double to Integer in Java Finding conditional distribution Let $X$ and $Y$ be independent $Exp(1)$-distributed random variables. Find the conditional distribution of $X$ given that $X + Y = c$ ($c$ is a positive constant).  this is my idea:  $$f_{X \mid X+Y}(x\mid c) = \frac{f_{X,X+Y}(x,c)}{f_{X+Y}(c) } $$  if this is the right definition then i might calculate the righthand side to obtain the distribution but Iam unsure How to prove $n^5 - n$ is divisible by $30$ without reduction How can I prove that prove $n^5 - n$ is divisible by $30$? I took $n^5 - n$ and got $n(n-1)(n+1)(n^2+1)$ Now, $n(n-1)(n+1)$ is divisible by $6$. Next I need to show that $n(n-1)(n+1)(n^2+1)$ is divisible by $5$. My guess is using Fermat's little theorem but I don't know how. Let $\mathcal{C}$ be a finite binary code such that for any two sequences $\{a_n\},\{b_n\}\in \mathcal{C}$ if $a_j\not=b_j$ for some $j$ then the concatenation binary sequence $a_1a_2\cdots a_n\not=b_1b_2\cdots b_n$, the Kraft-Mcmillan Inequality says that $$\sum_{i}\frac{N_i}{2^{i}}\le 1,$$where $N_i$ is the number of codes in $\mathcal{C}$ with length of $i$.  If we assume the code is prefix free, we will have an elegant probabilistic proof at  (consider the infinite binary sequence generated by i.i.d. binomial random variable with probability $1/2$, define $E_x$ be the event that the sequence has prefix $x\in \mathcal{C}$, then $\sum_i\frac{N_i}{2^i}\le \sum_i P[E_x]=  P[\cup_i E_x]=1$). But for the general case one will not necessarily have the events $E_i$s disjoint, I'm curious if similar argument exists for the general case. (The problem is an excercise in the probabilistic method of alon, I guess some probabilistic argument should exist)  (My attempt is that consider the product topology $T=\prod_i\mathcal C$ whose open sets generated by $E_x$s where $x$ is the concatenation codes of $\mathcal{C}$, we define a natural product measure $\mu$ over $T$ by $\mu(E_x)=2^{-|x|}$. Clearly $\mu(T)\le 1$ (as $T$ is a sub-topology of $\prod_i\{0,1\}$), I want to show $\mu(E_x\cap E_y)=0$ for $x\not=y\in \mathcal{C}$, if not we can find $E_z$ such that $E_z\subset E_x\cap E_y$ by compactness, if we can show $z$ can be write as concatenation code start with both $x,y$ we will done, but I get stuck at here.) How to interpret decomposition plot and check for seasonality As I understand it, anything created with an alloc, new, or copy needs to be manually released. For example:  int main(void) {     NSString *string;     string = [[NSString alloc] init];     /* use the string */     [string release]; }   My question, though, is wouldn't this be just as valid?:  int main(void) {     NSAutoreleasePool *pool;     pool = [[NSAutoreleasePool alloc] init];     NSString *string;     string = [[[NSString alloc] init] autorelease];     /* use the string */     [pool drain]; } Debian : Verify disk encryption password for already mounted system I am working on our Debian server on which we have a Raid drive encrypted with 2 devices. I did this around 1.5 years back and have never rebooted since. Now, we want to reboot for some reasons, but I have to make sure that the password I have is the correct one, or we will be stuck.   How can we verify the password for an encrypted-raid? Thank you.  Raid details :    mdadm --detail /dev/md0    /dev/md0:         Version : 1.2   Creation Time : Thu Feb 11 14:43:40 2016      Raid Level : raid1      Array Size : 1953382336 (1862.89 GiB 2000.26 GB)   Used Dev Size : 1953382336 (1862.89 GiB 2000.26 GB)    Raid Devices : 2   Total Devices : 2     Persistence : Superblock is persistent      Update Time : Fri Mar 10 10:37:42 2017           State : clean   Active Devices : 2 Working Devices : 2  Failed Devices : 0   Spare Devices : 0             Name : HOSTNAME:0  (local to host HOSTNAME)            UUID : 5c450558:44a2b1e9:83cb4361:9c74df8e          Events : 49      Number   Major   Minor   RaidDevice State        0       8        1        0      active sync   /dev/sda1        1       8       17        1      active sync   /dev/sdb1   Thank you.   Update  dmsetup table --showkeys CryptVol: 0 Large_Number crypt aes-cbc-essiv:sha256 RANDOM_TEXT  0 253:0 4096 RaidVG-LVMVol: 0 Large_Number linear 9:0 2048