I know that if I add a function to an constructors prototype that it will then be available to every object that uses the constructor. And I know that if you add a function as an (object literal I think it's called?) that you would have to access it as a property of the constructor itself. ().  But what if you declare the new function as 'this.xxx()' within the constructor. How is that any different from declaring a property on the prototype?  My guess is that declaring the function object on the prototype would result in delegation (and only one copy of that function would exist). Vs with 'this', every constructed object would have its own copy of the function.   Is that correct?  function A () { }  A.prototype.printNum = function () {     console.log('hi'); }  x = new A (); x.printNum(); // hi  function B () {     this.printNum = function () {         console.log('hi');     } }  y = new B (); y.printNum(); // hi
What's the difference between  var A = function () {     this.x = function () {         //do something     }; };   and  var A = function () { }; A.prototype.x = function () {     //do something };
PHP Change Array Keys Is there a way to change all the numeric keys to &quot;Name&quot; without looping through the array (so a php function)? [     0 =&gt; 'blabla',     1 =&gt; 'blabla',     2 =&gt; 'blblll',     // etc ... ] Cleveref with counters with same name I am trying to use the  package.  I have the following counters defined (hopefully this is the right way to do it!)  \newtheorem{thm}{Theorem}[section] \newtheorem{lemma}[thm]{Lemma} \newtheorem{cor}[thm]{Corollary}   This works as I would like (i.e. Theorem 1.1, Corollary 1.2, Lemma 1.3, etc.)  My problem is \cref always returns Theorem 1.2, Theorem 1.3. I   Perhaps this is not right? (In my preamble)  \crefname{thm}{theorem}{theorem's} \crefname{lemma}{lemma}{lemma's} Show *realtime* mouse cursor coordinates? (Cursor mod / overlay) Also, copy to clipboard? I'm looking for a solution that would display the current mouse cursor coordinates in realtime (i.e. NOT xdotool and NOT xev).  I need to move the mouse to a certain position, then press Alt-Tab to flip to another window and record the coordinates there. (This would not move the mouse, so the coordinate display would stay the same).  There's a Windows program that works BEAUTIFULLY for this purpose -   ...but it doesn't even start up in Wine.  Alternately, instead of displaying the coordinates, if this solution could copy the coordinates (in XXX,YYY format) to the clipboard, upon pressing a hotkey, that would be even better.  Any suggestions would be much appreciated!  P.S. I'm running Ubuntu 12.04 LTS. I am having a problem running the CDC change capture job against some of my test databases.  The error message I'm getting is the following:     Executed as user: NT AUTHORITY\NETWORK SERVICE. Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission. [SQLSTATE 42000] (Error 15517).   How can I fix this? I've tried almost any method to root my ASUS ZenFone Live, but no one seems to work. Also I only need root, no unlocked bootloader (don't want to wipe data) or custom recovery (not essential ATM). Schengen area 90 days limit: Can I leave on the 91st day? Add a duplicate:0|1 search operator I often search for closed questions and sift through the ones that are not duplicates to see if any of them need to be killed. Technically, closure is the first step towards deletion and the only closed posts that are actually useful are duplicates (unless it's a crappy one).  For the rest, if the community hasn't bothered to reopen it after a while or if the OP has made no effort to edit their question, I delete it if it has no redeeming content. For example, the only closed posts seen on  are exact dupes.  But this does become tedious when there are several results for various close reasons with duplicates interspersed between them. I'd like to be able to search as:  closed:1 duplicate:0   so that it gives a list of questions closed as OT/NaRQ/NC/TL. This will be similar in behaviour to migrated:0|1.   This will also be useful for 10k+ users on all sites (2k+ in beta) in the network, especially SO, so that they can search for questions to spend their delete votes on— especially closed, non-dupe questions in the tag they specialize in. More often than not, I hesitate to vote on questions that are outside my area of interest (unless it is crappy). Is there a way to make Runnable's run() throw an exception? Where can I find the location of folders for installed programs? A fair coin is tossed $10$ times. What is the probability that no two   consecutive tosses are heads?   Possibilities are (dont mind the number of terms):  $H TTTTTTH$, $HTHTHTHTHTHTHT$.  But except for those,  let $y(n)$ be the number of sequences that start with $T$  $T _$, there are two options, $T$ and $H$ so,  $y(n) = y(n - 1) + x(n-1) = y(n - 1) + y(n - 2)$  Let $x(n)$ be the number of sequences that start with $H$,   $H _$ the next option is only $T$ hence,  $x(n) = y(n - 1)$   The total number of sequences $F(n)$ is:  $$F(n) = y(n) + x(n) = 2y(n - 1) + y(n - 2)$$  We are after $F(10)$,  $$F(10) = 2y(9) + y(8)$$  $$F(3) = 2y(2) + y(1) = 1 + 4 = 5$$  $$F(4) = 2y(3) + y(2) = 6 + 2 = 8$$  But I'm not quite sure where this will take me though. How can i change formatting of the table of contents to avoid section numbering and section title to overlap?  Document:  \documentclass[10pt,oneside,notitlepage]{book}  % Use Heuristica Font \usepackage{heuristica} \usepackage[heuristica,vvarbb,bigdelims]{newtxmath} \renewcommand*\oldstylenums[1]{\textosf{#1}}   \begin{document}  \tableofcontents  \part{Part one}  \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh} \chapter{Chapter Oh}   \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi} \section{Chapter Hi}  \end{document}   Example output: I have notice some sites have the same form for login, register and forgotten password.  Below the form you have 3 buttons    i forgot my password register log me in   What are the pros and cons on using this approach and which version would you go for. Proving any number of the form $2^n$ can't be written as the sum of k consecutive numbers. My code follows:  \documentclass{book} \usepackage{color,colortbl} \begin{document}  \begin{tabular}{ll&gt;{\color{red}}p{20pc}} a &amp;1 &amp;Test \end{tabular}  \end{document}   The output was:    Some unnecessary vertical space came before the last column. If I remove the tag \color{red} then everything works fine, how can I fix this?  Above said issue was fixed based on the suggestion given by David Carlisle and CarLaTeX, but the same problem was there if I use the supertabular environment, I used supertabular package for auto breaking table and the code follows:  \documentclass{book} \usepackage{color,colortbl,supertabular} \begin{document}  \begin{supertabular}{ll&gt;{\leavevmode\color{red}}p{4pc}&gt;{\leavevmode\color{black}}l&gt;{\leavevmode\color{black}}l&gt;{\leavevmode\color{red}}p{4pc}} a &amp;1 &amp;Test &amp;a &amp;1 &amp;Test\\ a &amp;1 &amp;Test &amp;a &amp;1 &amp;Test\\ \end{supertabular}  \end{document} How can I represent an 'Enum' in Python? I'm mainly a C# developer, but I'm currently working on a project in Python.  How can I represent the equivalent of an Enum in Python? How do you style an input type="file" button? Prove $\int_0^{\infty}\! \frac{\mathbb{d}x}{1+x^n}=\frac{\pi}{n \sin\frac{\pi}{n}}$ using real analysis techniques only I am trying to follow the best practice design patterns for triggers but get the error Constructor not defined: [CaseTriggerHandler].(). What am I missing?  Trigger  trigger CaseTrigger on Case (before insert, before update, before delete, after insert, after update, after delete, after undelete) {      CaseTriggerHandler handler = new CaseTriggerHandler();      //Before Insert     if(Trigger.isInsert &amp;&amp; Trigger.isBefore){         handler.OnBeforeInsert(Trigger.new);     }     //After Insert     else if(Trigger.isInsert &amp;&amp; Trigger.isAfter){         handler.OnAfterInsert(Trigger.new);     }     //Before Update     else if(Trigger.isUpdate &amp;&amp; Trigger.isBefore){         handler.OnBeforeUpdate(Trigger.old, Trigger.new, Trigger.newMap);     }     //After Update     else if(Trigger.isUpdate &amp;&amp; Trigger.isAfter){         handler.OnAfterUpdate(Trigger.old, Trigger.new, Trigger.newMap);     }     //Before Delete     else if(Trigger.isDelete &amp;&amp; Trigger.isBefore){         handler.OnBeforeDelete(Trigger.old, Trigger.oldMap);     }     //After Delete     else if(Trigger.isDelete &amp;&amp; Trigger.isAfter){         handler.OnAfterDelete(Trigger.old, Trigger.oldMap);     }     //After Undelete     else if(Trigger.isUnDelete){         handler.OnUndelete(Trigger.new);     } }   Handler      public with sharing class CaseTriggerHandler {      private boolean isExecuting = false;      public CaseTriggerHandler(boolean isExecuting){         this.isExecuting = isExecuting;     }      public void OnBeforeInsert(List&lt;Case&gt; newCases){         //EXECUTE BEFORE INSERT LOGIC     }      public void OnAfterInsert(List&lt;Case&gt; newCases){         //EXECUTE AFTER INSERT LOGIC     }      public void OnBeforeUpdate(List&lt;Case&gt; oldCases, List&lt;Case&gt; updatedCases, Map&lt;Id, Case&gt; CaseMap){         //BEFORE UPDATE LOGIC     }      public void OnAfterUpdate(List&lt;Case&gt; oldCases, List&lt;Case&gt; updatedCases, Map&lt;Id, Case&gt; CaseMap){         //AFTER UPDATE LOGIC     }      public void OnBeforeDelete(List&lt;Case&gt; CasesToDelete, Map&lt;Id, Case&gt; CaseMap){         //BEFORE DELETE LOGIC     }      public void OnAfterDelete(List&lt;Case&gt; deletedCases, Map&lt;Id, Case&gt; CaseMap){         //AFTER DELETE LOGIC     }      public void OnUndelete(List&lt;Case&gt; restoredCases){         //AFTER UNDELETE LOGIC     }      public boolean IsTriggerContext{         get{ return isExecuting;}     } } I have a command that I want to have run again automatically each time it terminates, so I ran something like this:  while [ 1 ]; do COMMAND; done;   but if I can't stop the loop with Ctrl-c as that just kills COMMAND and not the entire loop.  How would I achieve something similar but which I can stop without having to close the terminal? pgfplots data time format I have this type of data set:  Time          State 22:54:14.716    5 22:54:14.716    5 22:54:14.716    5 22:54:14.716    5 22:54:14.729    4 22:54:14.919    1 22:54:14.919    1 22:54:15.128    5   I would like to plot a graph with pgfplots but the package can not read properly the time format.