I have code to merge two objects  Here is code    var obj1 = [{ food: 'pizza', car: 'ford'}, {food:'apple',car:'volvo'}]; var obj2 = { animal: 'dog' }   var allRules = Object.assign({}, obj1, obj2);  console.log(allRules);     It works, but in new object I have two elements and dog as 3 element. You can see it from snippet.  But I need two elements with dog as property. So it will be food, car and animal as key in every element of object.  How I can do this?  UPDATE  For merging array with object property I understood, but if I have two arrays like this      var arr1 = [{     food: 'pizza',     car: 'ford'   },   {     food: 'apple',     car: 'volvo'   } ];  var arr2 = [{   animal: 'dog' }, {animal:'cat'} ];   And want to merge it to one array with 1 element of 1 array, get's 1 element of 2 array , etc.  How I can do this?
I need to be able to merge two (very simple) JavaScript objects at runtime.  For example I'd like to:  var obj1 = { food: 'pizza', car: 'ford' } var obj2 = { animal: 'dog' }  obj1.merge(obj2);  //obj1 now has three properties: food, car, and animal   Does anyone have a script for this or know of a built in way to do this?  I do not need recursion, and I do not need to merge functions, just methods on flat objects.
Power set of a finite set is finite proof, no cardinality of power set Prove that $\mathcal{P}(A)$ of a finite set $A$ is finite.      I need to prove this without using the cardinality of $\mathcal{P}(A)$.  This is my attempt, which is by induction: $\newcommand{\lbrac}[1]{\left(#1\right)}$ $\newcommand{\sett}[1]{\left\{#1\right\}}$ $\newcommand{\pset}[1]{\mathcal{P}\lbrac{#1}}$ Proof by induction over cardinality.  If $A = \varnothing$, then $\pset{A} = \sett{\varnothing}$, which is finite.  Suppose that for a set $A$ of cardinality $n$, $\pset{A}$ is finite.  Let $A$ be a set of cardinality $n+1$. $A$ is not empty, since it is of cardinality $n+1 &gt; 0$, and therefore pick some $x\in A$. It follows that $A = \lbrac{A-\sett{x}}\cup\sett{x}$. We claim that $$ \pset{A} = \pset{\lbrac{A - \sett{x}}\cup\sett{x}} = \pset{A - \sett{x}}\cup\sett{C | C\in\pset{A}\wedge x\in C} $$ Suppose $B\in\pset{A} = \pset{\lbrac{A-\sett{x}}\cup{x}}$. Then either $x\in B$ or $x\not\in B$. If $x\in B$, then $x\in B \wedge B\in\pset{A}\Rightarrow B\in C$. If $x\not\in B$ then $B\subseteq A - \sett{x}$.  \newline Either way, $B\in \pset{A - \sett{x}}\cup\sett{C | C\in\pset{A}\wedge x\in C}\Rightarrow \pset{A}\subseteq\pset{A - \sett{x}}\cup\sett{C | C\in\pset{A}\wedge x\in C}$.  Suppose $B\in\pset{A - \sett{x}}\cup\sett{C | C\in\pset{A}\wedge x\in C}$. Then either $B\in\pset{A-\sett{x}}$ or $B\in\sett{C | C\in\pset{A}\wedge x\in C}$ (or both).  If $B\in\pset{A-\sett{x}}$, then $B\subseteq(A-\sett{x})\cup\sett{x} = A$, and if $B\in\sett{C | C\in\pset{A}\wedge x\in C}$, then by definition, $B\subseteq A$. Either way, we get that $B\in\pset{A} \Rightarrow \pset{A - \sett{x}}\cup\sett{C | C\in\pset{A}\wedge x\in C} \subseteq \pset{A}$.  Since we have shown both sets are contained in each other, they are equal.  My goal is to now prove that $\sett{C|C\in\pset{A} \wedge x\in C}$ is finite. I didn't manage to do so without non rigorous claims that could also "prove" the main question.  If this set is finite, and by induction hypothesis $\pset{A - \sett{x}}$ is finite, I'll be done.  Any ideas on how to prove $\sett{C|C\in\pset{A} \wedge x\in C}$ is finite? Bionic - Group addition using usermod -aG doesn't take effect until the next reboot How do I pipe colored diff output to less? Is there a fixed point in the MD5 transformation, i.e. does there exist x such that md5(x) == x? Change default XML comment snippet in Visual Studio When I hit /// in Visual Studio, is it possible to change the resulting snippet from this:  /// &lt;summary&gt; ///  /// &lt;/summary&gt;   to this?:  /// &lt;summary&gt;&lt;/summary&gt; Rough Smart objects problem in Photoshop I am using Adobe CC(2015) latest version and the behaviour of the smart objects isn't normal. When I paste a vector from Illustrator to Photoshop, the vector looks low quality or rough.   ORIGINAL  IN PHOTOSHOP   However, if I click over the smart object layer(in Photoshop)and this is opened in Illustrator, the vectors looks as the original one.   VECTOR OPENED IN ILLUSTRATOR FROM PHOTOSHOP SMART OBJECT   How can I solve this? Why do we say that the Earth moves around the Sun? In history we are taught that the Catholic Church was wrong, because the Sun does not move around the Earth, instead the Earth moves around the Sun.  But then in physics we learn that movement is relative, and it depends on the reference point that we choose.  Wouldn't the Sun (and the whole universe) move around the Earth if I place my reference point on Earth?  Was movement considered absolute in physics back then? Number reference headline I try to number the header of my references. I succeeded to add the number to the table of contents, but I can't get it to work for the header.  To add the number to the toc I used:  \addcontentsline{toc}{section} \protect\numberline{\thesection}References}   If I try the same for \refname, I get 5References without space.   \renewcommand{\refname}{\protect\numberline{\thesection References}}   When I put the references title outside the curly brackets, it's shown in a new line. What am I missing here? The full bibliography call looks like this:  \renewcommand{\refname}{\protect\numberline{\thesection References}} \addtocounter{section}{1} \cleardoublepage \phantomsection \addcontentsline{toc}{section}{\protect\numberline{\thesection}References} \bibliographystyle{apacite} \bibliography{bachelor}   EDIT 1:  As @TeXnician stated, a tilde would solve the problem. It is not very elegant, though, as I have to use approximatly three of them to get the same space as in the other headlines.   \renewcommand{\refname}{\protect\numberline{\thesection~~~References}}   EDIT 2: @Werner suggested a shorter solution, but it throws multiple errors, when I try to integrate it into my .tex file. Here's a short reproducable example which replicates the errors.  \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage[margin=1.1in]{geometry} \usepackage{listings} \usepackage{apacite} \usepackage{natbib}  \begin{filecontents}{mybib.bib}  @Article{draxler2010sample,     author    = {Draxler, Clemens},     title     = {Sample size determination for Rasch model tests},     journal   = {Psychometrika},     year      = {2010},     volume    = {75},     number    = {4},     pages     = {708--724},     publisher = {Springer}, }  \end{filecontents}   \begin{document}  \tableofcontents      \section{First Chapter}  \citep{draxler2010sample}  \let\oldsection\section% Store \section in \oldsection \renewcommand{\section}[2]{\oldsection{#2}}% Update \section to gobble * \bibliography{mybib} \bibliographystyle{apacite}  \appendix  \section{R Code}  \subsection{Greedings Function}  \begin{lstlisting}     print("Hello World") \end{lstlisting}  \end{document} Mysterious! Beamer itemize has no bullets after adding a few packages this is my first time using beamer.  I copied a template from the sharelatex page on Beamer  Which works, and \begin{itemize} shows bullets     But after adding a few more packages that I need, all the bullets are gone!    What is going on and how can I fix this?  \documentclass{beamer}  \usepackage[utf8]{inputenc}    \usepackage{amsmath}  \usepackage{amsthm}     %Theorem Environment  \usepackage{amssymb}  \usepackage{multirow}  \usepackage{cancel}  \usepackage{amsfonts}  \usepackage{graphicx}  \usepackage{subfigure}  \usepackage{upgreek}     \usepackage{mathtools}  \usepackage{thmtools}  \usepackage{enumitem}       %Information to be included in the title page: \title{Sample title} \author{Anonymous} \institute{ShareLaTeX} \date{2014}  \begin{document}    \frame{\titlepage}    \begin{frame}  \frametitle{Sample frame title}  \begin{itemize} \item  This is a text in first frame.  \item This is a text in first frame. \item This is a text in first frame.  \end{itemize}  \end{frame}  \end{document} How precisely do I need to post close to 7:00 (somewhere) to get hero of time? Prove that a positive polynomial function can be written as the squares of two polynomial functions As the question says, I need to edit my /proc/acpi/wakeup file, but when I open it with any text editor, it shows blank file. cat command, on the other hand, displays correct file contents in terminal. When I navigate to that file in file manager, it says it's size is 0 bytes. I'm using Xubuntu 15.04. I'm thoroughly confused. "Above"/"below" before/after a noun I have seen sentences similar to the following:  (1) See the reference above. (2) See the reference below.  And,  (3) See the above reference.  But not,  (4) See the below reference.  Are all these forms acceptable? Which is/are preferred in formal writing? Does the potential energy of a single object exist? I know that potential energy exists for a system of objects. But why? Is there no potential energy for a single object system? I assume that there is.  Consider the earth-object system. Suppose an external force lifts the object above the earth. Then the work done by it gets stored in the earth-object system as potential energy.Right?  Now, my question is that is the potential energy always zero for a single object system.   MY REASONING  If we consider the object only as the system and lift it above the Earth, we are doing positive work on it and filling it with energy and the gravitational field of the Earth is doing negative work on it and draining it of energy. Thus whenever the object is moving it has kinetic energy which is fine. But when it is not moving,i.e. when its weight is equal to the force applied by us, the net work done is zero and so the object should not have any kinetic energy. Does it have potential energy? There is (there's) vs.There are What are the roots of the creeping usage of "there's" for both singular and plural predicates? (This seems to be more common in spoken English.) I have 2 theories.  Perhaps it is because spoken communication our society is becoming less formal by the day. Or perhaps it is a reflection of speakers of other languages having increasing contact with native English speakers.  I am aware of German  "es gibt" and Spanish  "hay" constructions. Please comment.  3/06/14 I ran a couple of Google Ngrams and was surprised to find a greater rise in the use of "there's" in English fiction than in general English language books, since the turn of the century.  This would seem to support my contention that informality is behind the shift. Set HDMI sound output automatically on connect/disconnect I have a dual screen setup on my laptop (using 12.04 LTS) using a HDMI connected display. Everything works fine, but everytime I connect/disconnect the cable I have to go to Sound preferences and change the sound output device manually.  Is there any way to change the sound output device on connect/disconnection of cable, so when I connect my display the sound output is set to HDMI and when I disconnect it the sound goes back to laptop speakers? Tikz: shading region bounded by several curves I know that my effort below can be improved upon considerably.  In particular, there must be a way of shading the region in a single scope, as opposed to subdividing as I have done (thus necessitating a hidden gray boundary).  Neither am I fond of sample points, but this is where my research has led me.  Your constructive criticism is appreciated.    \documentclass{article} \usepackage{tikz} \begin{document}  \begin{tikzpicture} %graph \draw[draw=gray!50!white,fill=gray!50!white]      plot[smooth,samples=100,domain=0:1] (\x,{0}) --      plot[smooth,samples=100,domain=1:0] (\x,{1}); \draw[fill=gray!50!white] plot[smooth,samples=100,domain=1:2.71828] (\x,{ln(\x)}) --      plot[smooth,samples=100,domain=2.71828:1] (\x,{1}); \draw[domain=0:4] plot (\x,{1}); \draw[samples=100,domain=.25:4] plot (\x,{ln(\x)}) node[above left]{$y=\ln x$}; %coordinate grid \draw (-.5,0)--(4.5,0) node[right]{$x$}; \draw (0,-1.5)--(0,2.5) node[above]{$y$}; \foreach \x in {1,2,3,4}     \draw (\x,2pt)--(\x,-2pt) node[below] {$\x$}; \foreach \y/\ytext in {1,2}     \draw (2pt,\y)--(-2pt,\y) node[left] {$\y$};     %labels  \node at (.75,.5) {$\mathcal{D}$}; \end{tikzpicture}  \end{document} The product of a normal and Rademacher variables, independent from each other Let $X\sim N(0,1)$ and let $Z$ be a random variable independent of $X$ such that:  \begin{equation} \Pr(Z=z) = \begin{cases} \frac{1}{2} &amp; \mbox{if $z = -1$ or $z=1$}, \\ \\ 0 &amp; \mbox{otherwise}. \end{cases} \end{equation}   Define $Y = ZX$. Show that $Y \sim N(0,1)$. Determine $\operatorname{Cor}(X,Y)$. Are $X$ and $Y$ independent?   Progress:  I'm basically stuck at the beginning. I got as far as $P(ZX &lt; y) = P(Z &lt; y/X)$, which I'm not even sure is correct. I'm also not clear on what it means by defining $Y = ZX$ - does it mean I need to state the probability density function or something? And how do I show that $Y \sim N(0,1)$? My problem is that I want to have different .tex files for the preamble, the presentation aroundings (my target is a beamer PDF file) and the content of the presentation.  Mostly I'll be working on the content file. I even think about partitioning this content .tex file into several chapter files for a better overview. My problem with this solution is that I have to open the presentation.tex file to typeset the whole beamer PDF for looking at the results of my previous changes on the content files. (My presentation.tex file includes the preamble and the content.)  Is there any way to get TeXShop to always typeset one particular file (my presentation.tex) although I'm currently working on a different one (e.g. the content.tex)?  A shortcut? A command in the .tex file? An option in TeXShop? Anything? Executing a certain action for all elements in an Enumerable