I'm working on a React app where you have a have a form where you can add a new employee and X number of dependents.  In the form, I set a default state like this:  class NewEmployee extends Component {   state = {     employees: [],     costEstimates: { ...emptyCosts },     relationshipOptions: [],     newEmployee: { ...emptyEmployee }   };   That emptyEmployee is coming from a const in a separate file, and it looks like this:  export const emptyEmployee = { firstName: '', lastName: '', dependents: [] };   I do this purely to just try and keep the initial state looking tidy in the code.  My problem is that the dependents array in emptyEmployee is getting modified, and I don't understand how. This is the function getting called when the user clicks to add a new dependent:    handleNewDependent = () =&gt; {     const newEmployee = { ...this.state.newEmployee };     // blank dependent for now     const dependent = {       firstName: '',       lastName: ''     };      newEmployee.dependents.push(dependent);      this.setState({ newEmployee });   };   I've pinpointed that this is when the dependents array of my emptyEmployee object gets modified. I don't understand how, since I use the spread operator to make a copy.
What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but . I've done things like obj = JSON.parse(JSON.stringify(o)); but question the efficiency.  I've also seen recursive copying functions with various flaws.  I'm surprised no canonical solution exists.
does anyone know the following result? If it holds in this form and any source which presents it? Thanks a lot.  Consider metric space $(X,d_{X})$.  Let $f:A \subset (X,d_{X}) \rightarrow \mathbb{R}$ be a Lipschitz continuous function i.e. $\exists K &gt; 0$ such that  \begin{align*} |f(x)-f(y)| \leq Kd_{X}(x,y) ~~~~\forall x,y \in A \end{align*}  then define functions  $$\bar{f_{1}}(x) := \sup\lbrace f(y) - Kd_{X}(x,y): y\in A \rbrace ~~ \forall x  \in X$$ and $$\bar{f_{2}}(x) := \inf\lbrace f(y) + Kd_{X}(x,y): y\in A \rbrace ~~ \forall x  \in X$$ it follows that  \begin{align*} \bar{f_{1}}, \bar{f_{2}}: X \rightarrow \mathbb{R}  \end{align*} are Lipschitz continuous with  \begin{align*} |\bar{f_{i}}(x)-\bar{f_{i}}(z)| \leq Kd_{X}(x,z) ~~~\forall x,z \in X \text{ and } \forall  i = 1,2 \end{align*} and  \begin{align*} \bar{f_{i}}(x) = f(x) ~~~ \forall x \in A \text{ and } \forall i =1,2 \end{align*} I have the following shortcut which opens an SSH instance. How can I modify it so that when SSH closes, the terminal stays open?  [Desktop Entry] Terminal=true Type=Application Name[en_US]=ssh Icon=/logo_sprite.png Exec=gnome-terminal --geometry=... --window-with-profile=... --title=... -e 'bash -c "ssh -t -i ~/dsa.key cle@12.210.9.17 sudo -s"' Postgis, get the points that are x meters near another point, in meters Let's assume there's this random company (XYZ)--that few are aware of--is selling stocks and they're doing really well. If their stock price is at $50 and no one is buying, will it still go up?  Do stock prices only go up when people are buying? My /boot partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.  After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?  Here is a list of files that are on my /boot partition:  :~$ ls /boot/ abi-2.6.31-21-generic         lost+found abi-2.6.32-25-generic         memtest86+.bin abi-2.6.38-10-generic         memtest86+_multiboot.bin abi-2.6.38-11-generic         System.map-2.6.31-21-generic abi-2.6.38-12-generic         System.map-2.6.32-25-generic abi-2.6.38-8-generic          System.map-2.6.38-10-generic abi-3.0.0-12-generic          System.map-2.6.38-11-generic abi-3.0.0-13-generic          System.map-2.6.38-12-generic abi-3.0.0-14-generic          System.map-2.6.38-8-generic boot                          System.map-3.0.0-12-generic config-2.6.31-21-generic      System.map-3.0.0-13-generic config-2.6.32-25-generic      System.map-3.0.0-14-generic config-2.6.38-10-generic      vmcoreinfo-2.6.31-21-generic config-2.6.38-11-generic      vmcoreinfo-2.6.32-25-generic config-2.6.38-12-generic      vmcoreinfo-2.6.38-10-generic config-2.6.38-8-generic       vmcoreinfo-2.6.38-11-generic config-3.0.0-12-generic       vmcoreinfo-2.6.38-12-generic config-3.0.0-13-generic       vmcoreinfo-2.6.38-8-generic config-3.0.0-14-generic       vmcoreinfo-3.0.0-12-generic extlinux                      vmcoreinfo-3.0.0-13-generic grub                          vmcoreinfo-3.0.0-14-generic initrd.img-2.6.31-21-generic  vmlinuz-2.6.31-21-generic initrd.img-2.6.32-25-generic  vmlinuz-2.6.32-25-generic initrd.img-2.6.38-10-generic  vmlinuz-2.6.38-10-generic initrd.img-2.6.38-11-generic  vmlinuz-2.6.38-11-generic initrd.img-2.6.38-12-generic  vmlinuz-2.6.38-12-generic initrd.img-2.6.38-8-generic   vmlinuz-2.6.38-8-generic initrd.img-3.0.0-12-generic   vmlinuz-3.0.0-12-generic initrd.img-3.0.0-13-generic   vmlinuz-3.0.0-13-generic initrd.img-3.0.0-14-generic   vmlinuz-3.0.0-14-generic   Currently, I'm using the 3.0.0-14-generic kernel. Default implementation for Object.GetHashCode() Suppose that you are given a polynomial $p(x)$ as a black box (i.e. some oracle, to which you feed $x$ and it returns $p(x)$). It is known that the coefficients of $p(x)$ are all positive integers. How do you determine what $p(x)$ is in the quickest way possible?  (There are 2 metrics for quickness: the number of calls to the oracle and total number of operations. The relationship between the two is not given so we try to minimize both.) how to properly save an architecture in a fpga ic forever Determine whether the series $\sum_{n=1}^{\infty}(\frac{n}{n+1})^{n^2}$ is convergent or divergent.  I've tried applying all the basic tests to no avail. I need to find out what the "trick" for this particular series is. It seems I put a   Bounty assigned by outside party, two lengthy, reference-citing answers, one "-1" (awarded the bounty), one "-2", two others scored "0" and "-2" respectively, the answers suggesting one or the other is correct, 73 comments and no consensus so far - and me, as the asker, lost without a clue what to think of the answers anymore -  this is no longer "Learners' Level" question, so I thought I'd bring it here and hear what the experts have to say.    Original question:  Plurality of verb depending on plurality of list elements  An edit was suggested to my sentence.     There was were an orange, some grapes, two apples and a small pile of cherries on the plate.   In my native language plurality of the verb always follows plurality of the first element on the list. There were an orange,... sounds awkward to me, no matter what follows up. My simple solution was reordering:     There were some grapes, an orange, two apples and a small pile of cherries on the plate.   But that's not the first time I faced this situation and I'd like to know what the rules of grammar say about that - was my editor overzealous or am I trying to copy rules of my language that don't apply in English?    Someone linked a  for negatives, where the situation is more clear-cut ("There is no..."). Same applies to connection with "or" apparently, per accepted answer there. Still, nothing for "and".  It seems there is a consensus that in that if the verb goes after the list, it will be plural.     an orange, some grapes, two apples and a small pile of cherries were on the plate.   There doesn't seem to be clear consensus for:     On the plate { was | were } an orange, some grapes, two apples and a small pile of cherries   Adding more to the confusion is the abbreviated form: "There's"     One last note. In North America, at least, there is a widespread use of using a singular form like "there is" and "there was", without regard for the subject item or items, and this "there is" is often shortened to "there's":           There's three apples on the table!      Could you please clarify this mess? Removing duplicate rows from table in Oracle I'm testing something in Oracle and populated a table with some sample data, but in the process I accidentally loaded duplicate records, so now I can't create a primary key using some of the columns.  How can I delete all duplicate rows and leave only one of them? I set /usr/bin, /usr/lib, and /usr/share to be owned by my regular user and now I am getting interesting errors After running this command - sudo chown -R $(whoami) usr/{lib/node_modules,bin,share} I am not able to run sudo anymore: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set. How do I fixed that?  I read  but I am not sure what advice to follow and if it's applicable to my case. Is it acceptable to take photos of slides at a conferences for private use? Is it accepted/appropriate to take pictures of presentation slides at conferences for private use?   I am not talking about putting those pictures out in the public afterwards, I know this is illegal without consent of the presenter.    Should it matter, I am talking about math conferences.  And I am asking because I don't see anyone taking pictures. I am using a tikzpicture for plotting. the values I want to plot are typical (X,Y) pairs. The x-value is an uninteresting id-value. I want to order the bins ascending/descending according to the y-value, but how do I do that? The figure seems to automatically take the x-values for ordering, how can I override that? (I am not particularly fixed to tikzpicture - its just the first thing that actually worked and displayed the plot....) Following minimal-working example, how could I achieve a reordering according to the y-value?  \documentclass{article} \usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{relsize} \usepackage{times} \usepackage{url} \usepackage{latexsym} \usepackage{graphicx} \usepackage{colortbl} \usepackage{color} \usepackage{caption} \usepackage{pgfplots, pgfplotstable} \usetikzlibrary{arrows} \usepackage{amsmath} \usepackage{multirow} \usepackage{booktabs}  \usepackage{filecontents} \definecolor{OgAns}{rgb}{0, 0.8, 0.4}  \begin{filecontents}{testdata.dat} 1   30 2   44 4   26 3   39 \end{filecontents}  \begin{document} \begin{figure} \begin{tikzpicture}         \begin{axis}[                ybar stacked,             ymin=0,             ymax=100,             bar width=5pt,             legend style={at={(0.35, -0.4)},anchor=south west},             legend columns=-1                       ]           \addplot[ybar,fill=OgAns]  file {testdata.dat};          \end{axis}     \end{tikzpicture} \end{figure}   \end{document} Moving an already-running process to Screen I'm trying to prove that the following set ($B$) defined by an ellipse is convex, but I am getting stuck.  $$B = \left\{(x_1,x_2):3(x_1-3)^2+2(x_2-3)^2 \leq 1 \right\} $$  My sad attempt:  $$ \textrm{Let }x,y \: \in \: B \:, \: \lambda \: \in \: [0,1]$$  $$ \lambda x+(1-\lambda)y=(\lambda x_1+(1-\lambda)y_1,\: \lambda x_2 +(1-\lambda)y_2  )$$ $$3(\lambda x_1 + (1-\lambda)y_1 -3)^2+2(\lambda x_2+(1-\lambda)y_2-3)^2=3(\lambda ^2x_1^2 +(1-\lambda)^2y_1^2+9+2\lambda x_1(1-\lambda)y_1-6\lambda x_1 -6(1-\lambda)y_1)+2(\lambda ^2x_2^2 +(1-\lambda)^2y_2^2+9+2\lambda x_2(1-\lambda)y_2-6\lambda x_2 -6(1-\lambda)y_2)$$  and this is where I have lost all confidence in proving it. I was able to factor some of the terms into the form $(\lambda x_1 -3)^2$, $((1-\lambda) y_1 -3)^2$, $(\lambda x_2 -3)^2$, and $((1-\lambda) x_2 -3)^2$, but I don't think that helps the situation any. Difference between shutdown and shutdownNow of Executor Service Post-hoc tests after Kruskal-Wallis: Dunn's test or Bonferroni corrected Mann-Whitney tests? I have some non-Gaussian distributed variable and I need to check if there are significant differences between the values of this variable in 5 different groups.  I have performed Kruskal-Wallis one-way analysis of variance (which came up significant) and after that I had to check which groups were significantly different. Since the groups are kind of sorted (the values of the variable in the first group are supposed to be lower than the values of the variable in the second group which are supposed to be lower than the values of the variable in the third group and so on) I only performed 4 tests:  Group 1 vs Group 2 Group 2 vs Group 3 Group 3 vs Group 4 Group 4 vs Group 5   I have performed this analysis with two different methods. I started by using Dunn's Multiple Comparison Test but nothing came up significant. On the other hand if I use Mann-Whitney test and correct for the number of tests (4) using Bonferroni, 3 tests come up significant.  What does it mean? Which results should I trust? Radius of Convergence of a given Power series Boot error > no such device: grub rescue After an installation of Ubuntu 12.04, erasing an old partition with Ubuntu 10.10, I can't get grub to load. I can't access my Windows 7 partition either  I get the message:  &gt; error: no such device: 58ABF29C...   grub rescue&gt;   I suppose my master boot record got erased/corrupted. How can I check and fix this?