How do I generate n random numbers with an extra condition
Random real numbers that sum up to specific value
Convert DOS line endings to Linux line endings in Vim If I open files I created in Windows, the lines all end with ^M. How do I delete these characters all at once? how to avoid number repeation by using random class in c#? Why is Leia okay with being tracked to Yavin? In A New Hope, after Han and Luke fight off the TIE Fighters while escaping from the Death Star, these exchanges happen:             INT. DEATH STAR - CONTROL ROOM             Darth Vader strides into the control room, where Tarkin is             watching the huge view screen. A sea of stars is before him.                                   TARKIN                      Are they away?                                   VADER                      They have just made the jump into                       hyperspace.                                   TARKIN                      You're sure the homing beacon is                       secure aboard their ship? I'm taking                       an awful risk, Vader. This had better                       work.             INT. MILLENNIUM FALCON - COCKPIT             Han, removes his gloves and smiling, is at the controls of             the ship. Chewie moves into the aft section to check the             damage. Leia is seated near Han.                                   HAN                      Not a bad bit of rescuing, huh? You                       know, sometimes I even amaze myself.                                   LEIA                      That doesn't sound too hard. Besides,                       they let us go. It's the only                       explanation for the ease of our                       escape.                                   HAN                      Easy... you call that easy?                                   LEIA                      They're tracking us!                                   HAN                      Not this ship, sister.             Frustrated, Leia shakes her head.                                   LEIA                      At least the information in Artoo is                       still intact.                                   HAN                      What's so important? What's he                       carrying?                                   LEIA                      The technical readouts of that battle                       station. I only hope that when the                       data is analyzed, a weakness can be                       found. It's not over yet!   Leia doesn't even know if there is a weakness, let alone whether they'll find one. If she (correctly) realizes that they're being tracked, why doesn't she suggest that the Millennium Falcon go somewhere besides Yavin 4 instead of just frustratedly shaking her head? I know the plans , but it seems unlikely that continuing to fly to the secret Rebel base in the ship she's certain is being tracked is the only option. They are already in hyperspace when this conversation happens, but they apparently have time to talk for a little while after, so presumably they'd have time to stop and reroute. Does a photon exert a gravitational pull? I know a photon has zero rest mass, but it does have plenty of energy. Since energy and mass are equivalent does this mean that a photon (or more practically, a light beam) exerts a gravitational pull on other objects? If so, does it depend on the frequency of the photon? Uncertainty principle and multiple observers My understanding is that an observer can measure the precise location of a particle so long as the corresponding uncertainty in momentum measurement is not an issue and vice-versa.    Say there is such an observer, interested in the precise position of a particular particle.  Now, consider a second, independent observer, unbeknownst to the first, who is trying to measure the exact momentum of the same particle without caring about the position.  As a thought experiment, we assume that the two observers are somehow able to access the same particle at the same time in some way without being aware of each other.  Can both observers get their desired results? Why does the following hold:  \begin{equation*} \displaystyle \sum\limits_{n=0}^{\infty} 0.7^n=\frac{1}{1-0.7} = 10/3\quad ? \end{equation*}  Can we generalize the above to      $\displaystyle \sum_{n=0}^{\infty} x^n = \frac{1}{1-x}$ ?   Are there some values of $x$ for which the above formula is invalid?  What about if we take only a finite number of terms? Is there a simpler formula?     $\displaystyle \sum_{n=0}^{N} x^n$   Is there a name for such a sequence?    This is being repurposed in an effort to cut down on duplicates, see here: Coping with  duplicate questions.  and here: . Replace arbitrary characters in the middle of an IP address string with sed I need to find and replace either one or two numerical characters in strings in a file.  The strings are IP addresses of the form:   10.xx.y.z    Where xx can be one or two characters.    I want to replace the xx with the single character 0, so I have  10.0.y.z    preserving the values of y and z.   The string may appear multiple times in the file.  What is the sed invocation to do this? ConTeXt: Flush right formula numbers in cases environment I would like to have the formula numbers of the cases environment flush right like regular formulas (not at a fixed distant from the cases like it is by default with the default setting numberdistance=2.5\emwidth). How can I do that?  \starttext  \startplaceformula     \startformula         \startcases             \NC x = 1 \NR[+]             \NC y = 1 \NR[+]         \stopcases     \stopformula \stopplaceformula  \stoptext     What I want (but with the left bracket):  \starttext  \startplaceformula     \startformula         \startalignment[n=1]             \NC x = 1 \NR[+]             \NC y = 1 \NR[+]         \stopalignment     \stopformula \stopplaceformula  \stoptext What are Salesforce ID's composed of? I remember seeing somewhere that IDs are composed of a few pieces. I always have a hard time trying to find that information when I'm looking for it. What I mean by the above is that the various places in the ID represent different things - for example the first few characters represent what type of sObject it is. trying to install libgraph In this case what is correct?        Keep Tom and I updated.      or         Keep Tom and me updated.      I understand that me is an object pronoun. And therefore I feel the second option is correct.  Especially, because I would say "Keep him updated" and also "Keep me updated". Instead of "Keep he updated" or "Keep I updated". But something about saying "Keep him and me updated" feels wrong.  However I am not sure, because several people have told me that in this case I is the correct option because it is being used in conjunction with a name (Tom) and not a pronoun. Is that correct? Is there a C pre-processor which eliminates #ifdef blocks based on values defined/undefined? How can super massive black holes have a lower density than water? I heard on a podcast recently that the  at the centre of some galaxies could have densities less than water, so in theory, they could float on the substance they were gobbling up... can someone explain how something with such mass could float?  Please see the below link for the podcast in question: Direct observations of a black hole? Given the following class  public class Foo {     public int FooId { get; set; }     public string FooName { get; set; }      public override bool Equals(object obj)     {         Foo fooItem = obj as Foo;          if (fooItem == null)          {            return false;         }          return fooItem.FooId == this.FooId;     }      public override int GetHashCode()     {         // Which is preferred?          return base.GetHashCode();          //return this.FooId.GetHashCode();     } }   I have overridden the Equals method because Foo represent a row for the Foos table.  Which is the preferred method for overriding the GetHashCode?  Why is it important to override GetHashCode? How to get string with pattern from std::regex in VC++ 2010 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? When writing large numbers, should a comma be inserted? I know that it is common to write the number 'ten thousand' as a numeral with a comma delimiting the 10 and the 000 like so: 10, 000  However, I have never seen a comma used for numbers less than 10,000, such as 8000 where, I assume using a comma would look like: 8,000.  Are there any rules relating to when a comma should be inserted into a numeral?  N.b. I live in the UK, so answers pertaining to UK English are preferred. How to view the output of a running process in another bash session? I have left a script running on a remote machine from when I was locally working at it. I can connect over SSH to the machine as the same user and see the script running in ps.   $ ps aux | grep ipcheck myuser  18386  0.0  0.0  18460  3476 pts/0    S+   Dec14   1:11 /bin/bash ./ipchecker.sh   It is simply outputting to stdout on a local session (I ran ./ipchecker.sh form a local terminal window, no redirection, no use of screen etc).  Is there anyway from an SSH session I can view the output of this running command (without stopping it)?  So far the best I have found is to use strace -p 18386 but I get hordes of text flying up the screen, its far too detailed. I can stop strace and then sift through the output and find the text bring printed to stdout but its very long and confusing, and obviously whilst it's stopped I might miss something. I would like to find a way to see the script output live as if I was working locally.  Can anyone improve on this? The obvious answer is to restart the script with redirection or in a screen session etc, this isn't a mission critical script so I could do that. Rather though, I see this as a fun learning exercise. How to use Mathematica functions in Python programs?