So I've been trying to figure out prototypal inheritance in Javascript and I'm still confused on one point. Let's say I want to make a constructor function for a person with a few functions of it's own.  function Person(name) {   this.name = name;   this.sayName = function() {     console.log("My name is " + name);   } }  var john = new Person("John");  john.sayName();   So in this case I've created an object and called a function, however this doesn't seem to be the efficient way to do it. Another example I've seen this is this:  function Person(name) {   this.name = name; } Person.prototype.sayName = function() {   console.log("My name is " + name); }  var john = new Person("John");  john.sayName();   Now I've read that the second object is more efficient because it's not storing the sayName function within itself, instead it's going up the prototype chain until it finds it within Persons prototype object.  What I'm unsure about is which I should use for complicated constructor functions. The first snippet, in my opinion, is much much easier to read than the second because there is a clear hierarchical structure to it, but the second snippet is supposedly more efficient.   In a real world scenario, which style of constructor function would I be more likely to use?  Edit: I have a follow up question. Is there any way to make the second snippet more readable?
What's the difference between  var A = function () {     this.x = function () {         //do something     }; };   and  var A = function () { }; A.prototype.x = function () {     //do something };
Can you give a simple intuitive explanation of IRLS method to find the MLE of a GLM? Background:   I'm trying to follow .  I understand the basics of MLE estimation: likelihood, score, observed and expected Fisher information and the Fisher scoring technique. And I know how to justify .    The question:   I can't understand even the first line of this method :(   What's the intuition behind the $z_i$ working variables defined as:  $$ z_i = \hat\eta_i + (y_i -\hat\mu_i)\frac{d\eta_i}{d\mu_i}$$  Why are they used instead of $y_i$ to estimate $\beta$?   And what's their relation with the response/link function which is the connection between $\eta$ and $\mu$  If anyone has a simple explanation or can direct me to a more basic-level text about this I would be grateful. As of now, my desktop has begun showing the contents of my home folder (~) instead of the contents of ~/desktop. I must have changed something, but I have no idea what, or what I was doing exactly when it happened.  How do I re-point gnome to the right folder?  I'm running Ubuntu 11.04. android - out of memory exception when creating bitmap When is the limit of a sum equal to the sum of limits? I was trying to solve a problem and got stuck at the following step:  Suppose ${n \to \infty}$ .  $$\lim \limits_{n \to \infty} \frac{n^3}{n^3} = 1$$  Let us rewrite $n^3=n \cdot n^2$ as $n^2 + n^2 + n^2 + n^2 \dots +n^2$,$\space$ n times.  Now we have  $$\lim \limits_{n \to \infty} \frac{n^3}{n^3} = \frac {n^2 + n^2 + n^2 + n^2 + n^2 \dots +n^2}{n^3} $$  As far as I understand, we can always rewrite the limit of a sum as the sum of limits ...  $$\dots = \lim \limits_{n \to \infty} \left(\frac{n^2}{n^3} + \frac{n^2}{n^3} + \dots + \frac{n^2}{n^3}\right)$$  ...but we can only let ${n \to \infty}$ and calculate the limit if all of the individual limits are of defined form (is this correct?). That would be the case here, so we have:  $= \dots \lim \limits_{n \to \infty} \left(\frac{1}{n} + \frac{1}{n} + \dots + \frac{1}{n}\right) =$[ letting ${n \to \infty}]$ $= 0 + 0 + \dots + 0 = 0$  and the results we get are not the same.  Where did I go wrong? How do I create a script file for terminal commands? View a man page in a specific section I wanted to access man pages for command chmod.  Command whatis chmod gave this output:  chmod (2)            - change permissions of a file  chmod (1)            - change file mode bits  But I was actually looking for chmod(2).  When I type man chmod, man pages for chmod(1) appears.   Both man chmod(2) and man 'chmod(2)' commands show error.   I tried running info coreutils 'chmod invocation', but output is some kind of documentation which doesn't look like a typical man page. How to stop HTTPS requests for non-ssl-enabled virtual hosts from going to the first ssl-enabled virtualhost (Apache-SNI) I hope that title is clear.  How do I prevent HTTPS requests for non-ssl-enabled virtual hosts from going to the first ssl-enabled virtualhost (setup is Apache-SNI).  For example, using my abbreviated config below, requests for https://example.com (a non-ssl vhost) are being served by Apache at the ssl-enabled vhost https://example.org. I'd like to disable that behavior and possibly reply with the appropriate HTTP response code (unsure of what that is).  It may not even be possible, but I thought I'd ask.  # I actually have a SNI setup, but it's not demonstrated here. # I don't think it's relevant in this situation.  NameVirtualHost *:80 NameVirtualHost *:443  &lt;VirtualHost *:80&gt;     ServerName example.org &lt;/VirtualHost&gt;  &lt;VirtualHost *:443&gt;     ServerName example.org &lt;/VirtualHost&gt;  &lt;VirtualHost *:80&gt;     ServerName example.com &lt;/VirtualHost&gt;   EDIT: Maybe a mod_rewrite rule in the first ssl-vhost? Real Analysis: Continuity of a Composition Function Suppose $f$ and $g$ are functions such that $g$ is continuous at $a$, and $f$ is continuous at $g(a)$. Show the composition $f(g(x))$ is continuous at $a$.  My idea: Can I go straight from definition and take $\delta=\min\{\delta_1,\delta_2\}$, where $\delta_1$ is used for the continuity of $g$ at $a$ and $\delta_2$ is used for f being continuous at $g(a)$. In my proof I just treat $g(a)$ as a point when referring to the composition. So it goes like this:  Proof: Given $\epsilon&gt;0$, take $\delta=\min\{\delta_1,\delta_2\}$. Then $0&lt;|x-g(a)|&lt;\delta$ which implies $|f(g(x))-f(g(a))|&lt;\epsilon$. I have two hard drives. One is used for Windows and one is empty. I want to install Ubuntu on the empty hard drive. The Windows hard drive is disk0 in Windows and the empty hard drive is disk1. When I install Ubuntu and it asks where I want to install it, I choose "Something Else" but I am stuck there. What do I choose for "boot loader installation"? Is there any way to tinker with the iPhone SDK on a Windows machine? Are there plans for an iPhone SDK version for Windows?  The only other way I can think of doing this is to run a Mac VM image on a VMWare server running on Windows, although I'm not too sure how legal this is. How long are the life phases of a dragon? I'm trying to prove that for $p,q&gt;0$, we have $$\int_0^1t^{p-1}(1-t)^{q-1}\,dt=\frac{\Gamma(p)\Gamma(q)}{\Gamma(p+q)}.$$    The hint given suggests that we express $\Gamma(p)\Gamma(q)$ as a double integral, then do a change of variables, but I've been unable thus far to express it as a double integral.  Can anyone get me started or suggest an alternate approach?  Note: This wasn't actually given to me as the $\Gamma$ function, just as a function $f$ satisfying $$f(p)=\int_0^\infty e^{-t}t^{p-1}\,dt$$ for all $p&gt;0$, but I recognized that. This is in the context of an advanced calculus practice exam. Compare using Thread.Sleep and Timer for delayed execution I have a method which should be delayed running for a specified amount of time.  Should I use  Thread thread = new Thread(() =&gt; {     Thread.Sleep(millisecond);     action(); }); thread.IsBackground = true; thread.Start();   Or  Timer timer = new Timer(o =&gt; action(), null, millisecond, -1);   I had read some  about using Thread.Sleep is bad design. But I don't really understand why.  But for using Timer, Timer has dispose method. Since the execution is delayed, I don't know how to dispose Timer. Do you have any suggestions?  Or if you have alternative codes for delayed execution are also appreciate. Independent Edit/Object mode in splitscreen How do I add a notification for process completions How can I add a notification of some sort (like playing a .wav file or creating a pop-up on the status bar) when a process finishes. For example, I am compiling a program that takes a couple of hours to finish. I would like to hear/see some sort of message when it completes compiling. Is there a tool for doing this (like tying an alarm program to the pid of a process) or something like that? What does `:-` mean in a shell script I saw this in the end of an awesome shell script but I can't understand the login here because I think it's being short-handed for a longer command.  spark ${@:-`cat`}   This apears at the end of . Any ideas?  + Marks for some one who extends it into a full segment of code, even if its slower (Better for explanation) How to nest code within a list using Markdown Oftentimes, I want to include code samples in a list, for example:   Item One Item Two, for example: private bool ItemTwo() {     return this.IFeelLucky; } Item Three   The problem is that there isn't a good and intuitive way to do this using . It's doable, but you have to do some formatting black-magic to get it that way, which is just not "nice" to deal with.  Source that produces this:  1. Item One 2. Item Two, for example: &lt;br/>&lt;br/>&lt;pre>&lt;code>private bool ItemTwo()     {         return this.IFeelLucky;     }&lt;/code>&lt;/pre> 3. Item Three    I would love to just be able to do it this way:  1. Item One 2. Item Two, for example:      private bool Test()     {         return this.IFeelLucky;     }  3. Item Three  Which results in, well, this:   Item One Item Two, for example:  private bool Test() {     return this.IFeelLucky; } Item Three Coauthoring with a reviewer possible? I recently submitted an article to a math journal and got a response from a reviewer, with an attachment. In it, I have found some good  advice that could improve my article tremendously.  I am a bit suspicious of its accuracy since it could resolve what I have been working with for some months in a few  sentences.   But anyway, it was enough for me to ask the reviewer for coauthoring with me.   My question would be, does it often happen that an author asks a referee for coauthoring during the review process? Or could it even be possible?  I was given a month to revise my article, but the chance that I could revise successfully by myself seems to be fat.  I would be looking forward to any advice.  Thanks in advance. Why can't we downvote our own posts? Once in a blue moon, I've wanted the ability to downvote my own answer to some question.  ()  Obviously upvoting one's own posts is out of the question.  But down is different.  Voting my own answer down can help me improve the site by pushing my answer lower in the ranking than another answer with a better or more situation-appropriate alternative.  It's not something I'd do often, but I would use this feature if it were available.  If implemented, I'd expect this feature to operate just like downvotes on other user's posts.  That is:   I get a few seconds to undo the downvote;  I get to remove the downvote after an edit to the post;  I lose a point for placing the downvote (CW excepted); I lose two points for receiving the downvote (CW excepted).   If you're noticing that I'd lose 3 points for downvoting my own non-CW post, congratulations! You can add!  I can think of a couple of potential downsides to this change.  The first one may be a dealbreaker; the second is probably not that big a deal.   Strategic downvoting of oneself: since you can undo the vote after an edit, and you can always edit your own posts, someone could downvote themselves soon after posting (especially on a FGITW answer) to garner extra sympathy upvotes. Badge collecting: the Peer Pressure badge just got easier, because if you have a -2 score on an answer, just downvote and delete for an instant badge. Can one executable be both a console and GUI application? I want to make a  program that can be run as a CLI or GUI application depending on what flags are passed into it. Can this be done?  I have found these related questions, but they don't exactly cover my situation: