I am copying a Map from another Map. After the copying is done, I am changing the values in the new Map. However the new changes done in the new Map are also reflecting in the original Map. Is there any way to prevent this from happening? Map&lt;String,List&lt;String&gt;&gt; map1 = new Map&lt;String,List&lt;String&gt;&gt;(); Map&lt;String,List&lt;String&gt;&gt; map2 = new Map&lt;String,List&lt;String&gt;&gt;();  map1.put('abc',new List&lt;String&gt; {'123'}); map1.put('xyz',new List&lt;String&gt; {'0987'});  map2 = map1; // Even tried putall method here  for(String str1  :map2.keyset() ){     map2.get(str1).add('extra value'); } system.debug('map2===&gt;&gt;'+ map2); //{abc=(123, extra value), xyz=(0987, extra value)} system.debug('map1===&gt;&gt;'+ map1); //{abc=(123, extra value), xyz=(0987, extra value)} -- extra value should not relect here
Context Around this Code: I am making a schedulable class run each Sunday to track a couple of metrics important to the team.   Question: I am looking to consolidate DML operations and a big part of this is understanding pass by reference vs pass by value.  I want to pass the salesOps user object to the method SDREfficiencyLastWeek. I made the return type void, because I figured that I will be passing this by reference and I can make all the updates in the method without having to anything.   Why I am confused:    I read the above article and am thrown off by the following statement:  "Non-primitive data type arguments, such as sObjects, are also passed into methods by value. "   If the object is indeed passed by reference, then the query for the salesOps user in my code should be sufficient enough to edit all fields on that object without actually having to state each field in the query.  global class SDREfficientMetricsSchedulable implements Schedulable  {     global void execute(SchedulableContext sc)      {         User salesOps = [SELECT ID FROM USER WHERE id = '0056A000002Z3p9QAC'];         List&lt;String&gt; queries = new List&lt;String&gt;();          String contactsWorked_lastWeek  = 'select count(id) results from contact where LastActivityDate = last_week';         queries.add(contactsWorked_lastWeek);          String demosSet_lastWeek            = 'select count(id) results from form__c where CreatedDate = last_week';         queries.add(demosSet_lastWeek);          String demosCompleted_lastWeek  = 'select count(id) results from opportunity where (stagename = \'Unqualified Demo Completed\'  OR stagename = \'Qualified Demo Completed\' )  and RecordTypeId = \'0126A000000yudDQAQ\' and CloseDate = last_week';         queries.add(demosCompleted_lastWeek);          String qualifiedDemos_lastWeek  = 'select count(id) results  from opportunity where RecordTypeId = \'0126A0000004Ao6QAE\' and isclosed = false and  SDR_Owner__c != null and CreatedDate = last_week';         queries.add(qualifiedDemos_lastWeek);          String closedWon_lastWeek       = 'select count(id) results  from opportunity where RecordTypeId = \'0126A0000004Ao6QAE\' and iswon = true and  SDR_Owner__c != null and CloseDate = last_week';         queries.add(qualifiedDemos_lastWeek);            SDREfficiencyLastWeek(queries, salesOps);          update salesOps;     }       public void SDREfficiencyLastWeek(List&lt;String&gt; queries, User salesOps )     {        }  }
I was trying to find a font which has obsolete jamo and the right combining behaviour. Yesterday I found out about , which seems to have both of these. However, when I use it in XeTeX, I get some seemingly-arbitrary hanja (or blank spaces) instead of the expected characters.  (I’m guessing the composing behaviour will fix itself when the right characters are selected. And yes, I know that Code2000 is working perfectly in this example, but unfortunately it is the ugliest font in the world. :p)  MWE:  \documentclass{article} \usepackage{fontspec}  % 1. precomposed: U+BB47 % 2. separate jamo: U+1106, U+116E, U+11BA % 3. obsolete [separate jamo]: U+113B, U+119F, U+11EB \newcommand\test[1]{#1 &amp; {\fontspec{#1}{뭇; 뭇; ᄻᆟᇫ}} \\}  \begin{document}  \begin{tabular}{rl} \test{Arial Unicode MS} \test{Batang} \test{Code2000} \test{Gulim} \test{GungSeo} \test{HeadLineA} \test{Nanum Brush Script} \test{Nanum Myeongjo} \test{Nanum Pen Script} \test{Noto Sans Korean} \test{PCMyungjo} \test{PilGi} \test{Adobe Gothic Std} \test{Adobe Myungjo Std} \test{Apple SD Gothic Neo} \test{AppleGothic} \test{AppleMyungjo} \end{tabular}  \end{document} How to open a particular port in ubuntu? My SoulSeek client Nicotine+ checks my open ports during initial configuration and promts that the one port number it needs is closed, cutting me off frmo about 50% of the users. Is there anyway I can open that particular port for the application to use?  RUnning ubuntu desktop 13.04. I have not manually installed any firewalls, but not sure if its included in the default installation. How to replace plain URLs with links? I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match.  How I can replace all the URL? I guess I should be using the exec command, but I did not really figure how to do it.  function replaceURLWithHTMLLinks(text) {     var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/i;     return text.replace(exp,"&lt;a href='$1'&gt;$1&lt;/a&gt;");  } If $f(xy)=f(x)f(y)$ then show that $f(x) = x^t$ for some t Let  $f(xy) =f(x)f(y)$ for all $x,y\geq 0$. Show that $f(x) = x^p$ for some $p$.    I am not very experienced with proof. If we let $g(x)=\log (f(x))$ then this is the same as  $g(xy) = g(x) + g(y)$   I looked up the hint and it says let $g(x) = \log f(a^x) $   The wikipedia page for functional equations only states the form of the solutions without proof.  Attempt  Using the hint (which was like pulling a rabbit out of the hat)  Restricting the codomain $f:(0,+\infty)\rightarrow (0,+\infty)$ so that we can define the real function $g(x) =  \log f(a^x)$ and we have $$g(x+y) = g(x)+ g(y)$$   i.e $g(x) = xg(1)$ as $g(x)$ is continuous (assuming $f$ is).  Letting $\log_a f(a) = p$ we get $f(a^x) =a^p $. I do not have a rigorous argument but I think I can conclude that $f(x) = x^p$ (please fill any holes or unspecified assumptions) Different solutions are invited I have a header file  x.h which is included by more than one *.c source files. This header file has some structure variables defined.  I have put multiple inclusion prevention guard at the beginning of the header file as:  #ifndef X_H #define X_H ... .. //header file declarations and definitons.   #endif//X_H   On building I get linker errors related to multiple definitions. I understand the problem.   Won't a multiple inclusion prevention guard at the top of header file as I have, prevent multiple inclusions of the header file x.h and thereby avoid multiple definitions of the variables that are there in x.h? #pragma once does not work on this particular compiler, so what is the solution?  Someone had posted  answer to a similar question. It doesn't seem to work for me. How does this solution work? Mathematical physics text with plenty of applications I'm looking for texts on mathematical physics. I've seen various other threads, but the texts recommended in those threads were mathematical methods of theoretical physics texts, that is to say those texts focused on the math methods useful for physicists and assumed the applications of those methods would be covered in some other text. What I'm looking for is a book which introduces some math and then looks at its applications (back and forth) rather than a text which just goes over some math. (Example of books which are NOT what I'm looking for: Mathematics for physicists by Dennery, Math methods for physicists by Weber and Arfken etc)  I've taken courses in multi-variable calc, linear algebra, real analysis, and I'm currently taking a course in abstract algebra. But so far I've only seen applications of multi-variable to physics. I'm looking for books which look at the applications of the other subjects mentioned above to physics, of course books which cover subjects beyond those mentioned are also welcome.   So far I'm liking the flavor of the text "A Course in Modern Mathematical Physics" by Szekeres, but I'd prefer a text which got to the physics side of things more quickly (in the Szekeres text the first eight chapters are strictly on pure math).   After some amazon searching it looks like Theoretical Physics by Joos, Mathematical Physics by Henzel, and Physical Mathematics by Cahill may be good bets? Can't we compute $\lim_{n \to \infty}\frac{1+ \cdots +n}{n^2}=\lim_{n\to\infty}\frac{1}{n^2}+\cdots +\lim_{n\to\infty}\frac{n}{n^2}=0$? I just learned the definition of limits, and I learned that if $\{a_n\}, \{b_n\} $ converges, then $$\lim_{n\to \infty} (a_n+b_n)=\lim_{n \to \infty} a_n+\lim_{n \to \infty}b_n$$ holds.  And my teacher said that $\lim_{n \to \infty}\frac{1+2+3+ \cdots +n}{n^2}=\lim_{n\to \infty}\frac{\frac{n(n+1)}{2}}{n^2}=\frac{1}{2}$.  But can't we compute like  $$\lim_{n \to \infty}\frac{1+2+3+ \cdots +n}{n^2}=\lim_{n\to\infty}\frac{1}{n^2}+\lim_{n\to\infty}\frac{2}{n^2}+\lim_{n\to\infty}\frac{3}{n^2}+\cdots +\lim_{n\to\infty}\frac{n}{n^2}=0+0+\cdots+0=0$$? Windows 8 removes Grub as default boot manager I have a Sony VAIO S series with Windows 8 preinstalled, and I installed Ubuntu 12.10 on a new partition. When the PC boots Grub is display, and I can choose between Windows 8 (didn't worked at the beginning, had to change Grub settings) and Ubuntu 12.10. When I select Ubuntu 12.10 everything is OK, but when I use Windows 8, and I restart Grub isn't displayed anymore (Windows 8 boots immediately).  I booted a Ubuntu 12.10 LiveUSB, used efibootmgr, and found out that Windows 8 (each time it boots) changes EFI default bootloader from Grub to Windows Boot Manager.  How do I change this in Windows 8? I read something about bcdedit, but it does not work or I don't know how to use it... Is it correct to say user accounts or users account when referring to the accounts any user has on a site like this one?  In general, in the case of a noun that is used as adjective for the noun that follows, is it better to use &lt;plural-noun&gt; &lt;singular-noun&gt; or &lt;singular-noun&gt; &lt;plural-noun&gt;? Every closed subset $E\subseteq \mathbb{R}^n$ is the zero point set of a smooth function What is $\mathbb{E}[W(s)\mathrm{e}^{W(S)}]$ where W(S) is a standard Brownian Motion? I know that since it is a Brownian motion that $W(s)\sim{N(0,s)}$. One approach I tried, was to see that $W(s)-W(0)\sim N(0,1)$ and to let $X = W(s)$ and then solve $\mathbb{E}[X\mathrm{e}^X]$ but I end up with some awful integral. I was wondering whether there was an easier way? Or perhaps a simple way to solve this integral: $\int_{-\infty}^{\infty} \frac{1}{\sqrt{2{\pi}s}}x\mathbb{e}^{x}\mathbb{e}^{-\frac{x^2}{2s}}$ Let $\gamma:[0,1] \to \mathbb R^n$ be a smooth closed curve, such that $\gamma(0)=\gamma(1), \gamma'(0)=\gamma'(1), |\gamma'(a)|=1$ and let $B_r=\{x| \exists t, |\gamma(t)-x|&lt;r\}$. How can i show that the volume of $B_r$ is equal to $br^{(n-1)}$ for $r &lt;\varepsilon$ for some $\varepsilon&gt;0$. And how can I find $b$? It is intuitively obvious. But how can one prove it? I have no idea. Perhaps this is trivial: how does one prove that the work done by a homogeneous gravitational field on a system of particles is equal to the work done on a point mass with the total mass of the system, located at the center of mass of the system. It looks like we'll be adding  support to Stack Overflow. This is necessary to prevent bots, spammers, and other malicious scripted activity. We only want human beings to post or edit things here!  We'll be using a JavaScript (jQuery) CAPTCHA as a first line of defense:    The advantage of this approach is that, for most people, the CAPTCHA won't ever be visible!  However, for people with JavaScript disabled, we still need a fallback and this is where it gets tricky.  I have written a  which we can re-use.    However, I'd prefer to go with something textual to avoid the overhead of creating all these images on the server with each request.  I've seen things like..   ASCII text captcha: \/\/(_)\/\/ math puzzles: what is 7 minus 3 times 2? trivia questions: what tastes better, a toad or a popsicle?   Maybe I'm just tilting at windmills here, but I'd like to have a less resource intensive, non-image based &lt;noscript&gt; compatible CAPTCHA if possible.  Ideas? Are if else statement equivalent to logical and && or || and where should I prefer one over the other? I'm learning about decision making structures and I came across these codes:  if [ -f ./myfile ] then      cat ./myfile else      cat /home/user/myfile fi   [ -f ./myfile ] &amp;&amp; cat ./myfile || cat /home/user/myfile   Both of them behave the same. Are there any advantages to using one way from the other? How to calculate the confidence interval of the mean of means? Imagine that you repeat an experiment three times. In each experiment, you collect triplicate measurements. The triplicates tend to be fairly close together, compared to the differences among the three experimental means. Computing the grand mean is pretty easy. But how can one compute a confidence interval for the grand mean?  Sample data:  Experiment 1:   34, 41, 39  Experiment 2:   45, 51, 52  Experiment 3:   29, 31, 35  Assume that the replicate values within an experiment follow a Gaussian distribution, as does the mean values of each experiment. The SD of variation within an experiment is smaller than the SD among experimental means. Assume also that there is no ordering of the three values in each experiment. The left-to-right order of the three values in each row is entirely arbitrary.  The simple approach is to first compute the mean of each experiment: 38.0, 49.3, and 31.7, and then compute the mean, and its 95% confidence interval, of those three values. Using this method, the grand mean is 39.7 with the 95% confidence interval ranging from 17.4 to 61.9.   The problem with that approach is that it totally ignores the variation among triplicates. I wonder if there isn't a good way to account for that variation. Could new users be prompted to edit instead of commenting? It's very common to ask for additional information on a question.  This is perhaps most common with new users who are a little unfamiliar with the need to put all relevant information in their question to start with.  To be blunt, I'm a little tired of explaining to new users that an edit is better than a comment, particularly where we ask "please add the output of..." I note that some users have taken to explicitly asking OPs to edit their question and adding an edit link in their comment.  But still this is missed.  More recently, adding a comment to a new user's question displays a little note saying:     ... is a new contributor. Be nice, and check out our Code of Conduct.   Could there be a similarly formatted note to new contributors commenting on their own question or answer:     If you need to add more information please  your [question][answer] instead of adding a comment. Getting a stack overflow exception when declaring a large array The following code is generating a stack overflow error for me  int main(int argc, char* argv[]) {     int sieve[2000000];     return 0; }   How do I get around this? I am using Turbo C++ but would like to keep my code in C  EDIT:  Thanks for the advice.  The code above was only for example, I actually declare the array in a function and not in sub main.  Also, I needed the array to be initialized to zeros, so when I googled malloc, I discovered that calloc was perfect for my purposes.  Malloc/calloc also has the advantage over allocating on the stack of allowing me to declare the size using a variable. Questions on "All Horse are the Same Color" Proof by Complete Induction I'm bugged by the following that's summarized on p. 109 of .     False theorem: All horses are the same color.      Proof by induction:      $\fbox{$P(n)$ is the statement: In every set of horses of size $n$, all $n$ horses are the same color.}$   $\fbox{Base Case or $P(1)$:}$ One horse is the same color as itself. This is true by inspection.   $\fbox{Induction Step:}$ Assume $P(k)$ for some $k \geq 1$.   $\fbox{Proof of $P(k + 1) :$}$   Since $\{H_1, H_2, ... , H_n\}$ is a set of $n$ horses, the induction hypothesis applies to this set. Thus, all the horses in this set are the same color.   Since $\{H_2, H_3, ... , H_{n+1}\}$ is also a set of $n$ horses, the induction step likewise holds for this set. Thus, all the horses in this set are the same color too.         Therefore, all $n +1$ horses in $\{H_1, H_2, H_3, ... , H_n , H_{n+1}\}$ are the same color. QED.   The issue the instructor was trying to point out is clearly valid. For the case $n = 1$, there is only ${H_1}$. So this case says nothing about possible overlapping elements of each set of $(n + 1)$, for instance $H_2$ in the above proof.    But it was proposed in the class discussion that this was the only problem. Had you been able to prove $P(2)$ true, then a proof of the above format would have been fine.    My interpretation is that yes, you could prove all horses are the same color, if you can prove that any set of two horses will be the same color. But this format would not work.  Why not? The problem I see is that the above proof is for the existence of at least one particular pair of sets of horses of sizes $n$ and $n + 1$, such that in each set, all horses are the same color.  Particularly when the set of size $n$ is a subset of the set of size $n + 1$.  In order to prove the induction step, don't you need to prove that sets of sizes $n$ and $n + 1$, do not necessarily contain the same, overlapping elements?  You could prove that any horse can be added to a set of 2 horses.  Take the last two, and they must be the same color, and so on.  Wwhatever color the first two happen to be, all other horses must thus be the same color.    Am I misinterpreting the example, or am I making a logical error? Thanks in advance. Cards entering the battlefield simultaneously and "Enter the Battlefield" effects I was playing modern with the owner of a shop.  He played a  which he used to bring in 7 lands: 5 basic mountains and 2  cards.  He then claimed that each  triggered 5 times (killing me).  I am doubting this now.    Here is my reason: The two  cards entered at the same time as the other 5 basic lands.  That means when they were on the battlefield and their ability was in effect, the other 5 basic lands were already there too.  That seems too late to trigger a "Enters the Battlefield" effect.  So here is my question.  Am I right or wrong?  If I am wrong, please show me how the enter the battlefield effect can trigger for something that enters the battlefield at the same time as itself.  If I am right, please show me the rules that prove it.  I now have two shop owners that are convinced that this is a legal play.  If it is not legal, I am going to need clear rules citations to convince them.    Side note:  If I am wrong and it is a legal play, then I have a follow up scenario.  Say I have 2  cards and 5 other human cards in my graveyard.  If I play a spell that lets me return all of them to the battlefield at the same time (say ), would the  cards get 6 +1/+1 counters on them?    To me, if the trick that was played on me with  is legal then my  cards should also get the +1/+1 counters.