var a = Date; Object.defineProperty(window, "Date", { get: function() { console.log(this); return a; } });  (new Date); Date();   How can I know, when Date is being called as a constructor(with "new"), and when it's being called as a function?  Update  answers don't work for this case. this is always equal to a window
Given a function:  function x(arg) { return 30; }   You can call it two ways:  result = x(4); result = new x(4);   The first returns 30, the second returns an object.  How can you detect which way the function was called inside the function itself?  Whatever your solution is, it must work with the following invocation as well:  var Z = new x();  Z.lolol = x;  Z.lolol();   All the solutions currently think the Z.lolol() is calling it as a constructor.
I'm wanting to use Xen Hypervisor to be able to run both Ubuntu 12.04 and Windows 7 at the same time using virtualization. I can find plenty of XCP tutorials but I'm not looking to install the cloud stack, I just want the server confined to my machine.  All I need is a link to a decent tutorial for this purpose. I've read a ton of articles that lead me to believe I'm on the right track, but not enough to feel comfortable getting it right if I just dive in. I'm getting caught up on whether I need to install Ubuntu and then install Xen into it, or do I need to install Xen on a small partition and then leave the rest of the hard drive open for the virtualization... I dunno.  Basically, I need the virtualization of Windows 7 for Adobe Premiere and After Effects (until Lightworks for Linux comes out and I can afford NUKEX). If I didn't need those, I'd be rocking out a straight up Ubuntu machine or just using VirtualBox for my virtualization. However, I need Windows to run as an HVM so it runs like I would expect rather than having the issues I may run into with VirtualBox (video drivers, etc).  So, any suggestions? How to determine day of week by passing specific date? Lightning Cancel Enqueued Server Side Action Why shouldn't I prefix my fields? I've never been a fan of Hungarian notation, I've always found it pretty useless unless you're doing some really low level programming, but in every C++ project I've worked on some kind of Hungarian notation policy was enforced, and with it the use of some 'not-really-Hungarian' prefixes as m_ for fields, s_ for statics, g_ for globals and so on.  Soon I realized how much useless it was in C# and gradually started to drop all of my old habits... but the 'm_' thing. I still use the m_ prefix on private fields because I really find it very useful to being able to distinguish between parameters, locals and fields.  The  says I shouldn't, but it does not say why (the way e.g. Google's conventions generally tend to rationalize their prescriptions).  Are there reasons why I shouldn't or is it only a matter of style. If it is the latter, are prefixes generally considered a bad style and can I expect negative reactions from other people working on the codebase? identity element of $(D_n ,\gcd)$ Let $x*y=\gcd(x,y)$ on $D_n=\{x\in \mathbb N:x |n\}$. I have to prove that $(D_n,*)$ is a commutative monoid and I have a problem when finding the identity element.  $x*e=x$  So $gcd(x,e)=x \to e=xk,k\in \mathbb N^*$ and $e \leq n$  A good $e$ is $0$ but it's not in $D_n$ Short story identification: society partitioned off by high wall Double dispatch in C#? I have heard/read the term but don't quite understand what it means.  When should I use this technique and how would I use it? Can anyone provide a good code sample? List or IList Can anyone explain to me why I would want to use IList over List in C#?  Related question: I'm wondering what the preferred method is for dealing with AJAX calls. Should one use the same plugin php file to process the POST or a separate one? Which is cleaner or safer? Finding the Dimension of a Matrix Polynomial: $W$ = { $p(B)$ : $p$ is a polynomial with real coefficients} Let $W = \{ p(B) : p \text{ is a polynomial with real coefficients}\}$, where $$B= \begin{pmatrix} 0 &amp; 1 &amp; 0\\  0 &amp; 0 &amp; 1\\  1 &amp; 0 &amp; 0 \end{pmatrix}$$  Which of the following possibilities presents the tightest bounds on the dimension $d$ of the vector space $W$?     $4 ≤ d ≤ 6$    $6 ≤ d ≤ 9$    $3 ≤ d ≤ 8$    $3 ≤ d ≤ 4$ Sort and count number of occurrence of lines I have Apache logfile, access.log, how to count number of line occurrence in that file? for example the result of cut -f 7 -d ' ' | cut -d '?' -f 1 | tr '[:upper:]' '[:lower:]' is  a.php b.php a.php c.php d.php b.php a.php   the result that I want is:  3 a.php 2 b.php 1 d.php # order doesn't matter 1 c.php I thought this would be really simple, but it's presenting some difficulties. If I have std::string name = &quot;John&quot;; int age = 21;  How do I combine them to get a single string &quot;John21&quot;? Is it possible to connect two monitors on a laptop, one through HDMI and the other through DisplayPort? For example the Alienware m17x offers 3 connections, HDMI, DisplayPort, and VGA. Is it possible to connect two independent external monitors, one through the DisplayPort and one through the HDMI port? What’s the rule to decide whether you add -er or whether you add -or when creating an agent noun from a verb?    Sometimes it’s -er:      read > reader hate > hater hit > hitter   But other times it’s -or:    meditate > meditator collect > collector "Everything is a file" in the UNIX World.  Above sentence is famous. When I run echo "hello programmer" &gt;&gt; /dev/tty1 , I can watch the given string on TeleType 1  , ....  What and where is file per each socket? Suppose my friend connects to my PC, and its IP is h.h.h.h , how can I access the respective file? Is it possible? Most efficient way to see if an ArrayList contains an object in Java I have an ArrayList of objects in Java.  The objects have four fields, two of which I'd use to consider the object equal to another.  I'm looking for the most efficient way, given those two fields, to see if the array contains that object.  The wrench is that these classes are generated based on XSD objects, so I can't modify the classes themselves to overwrite the .equals.    Is there any better way than just looping through and manually comparing the two fields for each object and then breaking when found?  That just seems so messy, looking for a better way.  Edit: the ArrayList comes from a SOAP response that is unmarshalled into objects. Is it possible to extend a tourist Schengen visa (12 more days)? Find a quadratic equation with root $x_1^2$ and $x_2^2$ I'm struggling to solve this problem:  "If the equation $ax^2 + bx +c$ $(a \neq 0)$ admits real and not null roots of $x_1$ and $x_2$, obtain the equation which evaluates to roots $(x_1)^2$ and $(x_2)^2$"  I know the answer is $a^2x^2 -(b^2 - 2ac)x + c^2$ but I am not able to get to this answer, I was trying to derive it from the sum and product equations $S=-b/a$ and $P=c/a$ but the answer I'm getting to is a monstruous different thing.  Could someone explain to me how to get to this answer?  Thanks Getting filesystem path of class being executed Detect if program is running with full administrator rights