This works as intended:  for rcount in {0..10}; do     echo "${rcount}" done   But I have a variable that I want to use as a loop range:  var1=10  These don't work:  Trial 1:  for rcount in {0..var1}; do     echo "${rcount}" done   Trial 2:  for rcount in {0..${var1}}; do     echo "${rcount}" done   How can I do this?
How do I iterate over a range of numbers in Bash when the range is given by a variable?  I know I can do this (called "sequence expression" in the Bash ):   for i in {1..5}; do echo $i; done   Which gives:     1    2    3    4    5   Yet, how can I replace either of the range endpoints with a variable? This doesn't work:  END=5 for i in {1..$END}; do echo $i; done   Which prints:     {1..5}
Let $X \sim Bin(n,p)$ show that $X/n \nsim Bin()$ Let $X \sim Bin(n,p)$   Part A.  Show that the argument      "Then $X/n \sim Bin()$ with $E[X/n]=p$and $Var[X/n]=pq/n$"    is false.   My book says we can prove this result using a moment generating function. But to me it makes no intuitive sense: We have Bin-distributed RV $X$ and if we rescale it with $1/n$ of course it will be Bin-distributed.  And we know from standard formulas that $E[aX]=aE[X]$ and $Var[aX] = a^2Var[X]$ so I think the argument is correct.   (For full disclosure, the argument we should falsify according to the book is "Let X be a binomial random variable with mean np and variance np(1−p). Show that the ratio X/n also has a binomial distribution with mean p and variance p(1−p)/n." But I think the argument is correct. )    Ok, now I get part A. Here is Part B. Prove it using the moment generating function of $X/n$.   Attempt: I get $$m_X(t)=E[\exp(tX/n)]=(m_X(t))^{1/n}$$ I would like to protect myself from unreasonable demands during my work day.  One of those is telling people that I will not respond to any emails before 3pm.  I'd like to set up a rule in outlook that replies to all emails before 3pm with a specific message. I'd like this to be done every day, no matter the date.  How do I set this up?  I've scoured Google best I can so far, and I think, based on a Exchange forum, that a script might be needed for this.  But what I found so far was only server side scripts. I need something on my own machine.  references: Creating a textarea with auto-resize There was , which I've tried. But there is one problem: the textarea doesn't shrink if you delete the content. I can't find any way to shrink it to the correct size - the clientHeight value comes back as the full size of the textarea, not its contents.  The code from that page is below:  function FitToContent(id, maxHeight) {    var text = id &amp;&amp; id.style ? id : document.getElementById(id);    if ( !text )       return;     var adjustedHeight = text.clientHeight;    if ( !maxHeight || maxHeight &gt; adjustedHeight )    {       adjustedHeight = Math.max(text.scrollHeight, adjustedHeight);       if ( maxHeight )          adjustedHeight = Math.min(maxHeight, adjustedHeight);       if ( adjustedHeight &gt; text.clientHeight )          text.style.height = adjustedHeight + "px";    } }  window.onload = function() {     document.getElementById("ta").onkeyup = function() {       FitToContent( this, 500 )     }; } Reverse String order "I want you succeeding" vs. "I want your succeeding" Doom-style 2.5D Movement Animations I've started working on a demo for my 2.5D game. For a basic scene I figured I would just use the good old fashioned doom sprites textured to a double sided plane. Simple enough. But I've been scratching my head as to how to display the proper sprite animation relative to the player viewing the sprite...if that makes since.  For example suppose I have three players in the scene Players A, B, and C as such:    Player C should see player A as: Here's an example of what I think player A should look like from C's perspective:    While player B would see player A as follows:    My current idea is that for any given player, I will need to know the current direction of each other player, and where they are located/moving to relativly. From this, I could calculate which sprite image is required.  Is this correct? What improvements/optimizations could be made?  ** EDIT ** Total number of directions will be 8 as depicted below:    For each direction there are two sprites (to show walking movement, sprites for the right hand directions are mirrors of the left):    ** EDIT 2 ** Got this working and have a simple javascript/threejs example for anyone interested: How can I open a text file with TextWrangler from the Terminal (command line)? Where can I travel for prolonged periods of time while legally working remotely for a company in my home country? I found several questions about inbound travelers to the US in this scenario, but little about other countries: I work for a company in my home country (USA) who are open to me working remotely while traveling.   Which countries allow me to legally work remotely for a company in my home country (USA) while traveling in their country? The work has absolutely no connection to the destination country, it would take place identically entirely within the USA if I weren't traveling. Comprehensive list of tools that simplify the generation of LaTeX tables Manually hacking tables in LaTeX is one of the less funny things when preparing a document. Naturally, there are quite a few tools that promise to simplify this. In fact, I have somewhat lost track of all the tools available, and I'd like to gather your valuable experience into one big post. Some of the tools are mentioned in , but I feel there's much more around.  I'd suggest that somebody starts an overview with an alphabetic list (so that I can accept this answer and it stays on top), and that everyone replies with a "community wiki" entry, one reply per tool, and inserts the tool into the list.  Personally, I use Excel2LaTeX, but I'm unhappy with having to fire up Windows in order to generate the LaTeX code. I'm thinking of a rewrite as a standalone Python tool using the xlrd library, but I'm not too inclined to reinvent the wheel. can't get placeholder attribute to work in IE using iframe What is the best way to clear the CSS style "float"? Inversion in "only [adverb] have they" Is there a term for this word play where a song intentionally avoids completing a rhyme? Take this for example:  In this , at 1:04 to 1:10, the person goes on rapping with a rhyming word at the end of each line, but he pauses before the end of the last word and, being humans, we predict the next word (due to the hint from the rhyme) that he is going to say but he avoids it intentionally. Is there a word or phrase for this word play?     ...and the beat still knocks when I sort my socks   I'm five foot eleven of sex   from the tip of my head to my gorgeous...   knees    Not the best example I could find but I think it sums up my point quite well. Need help recalling name of sci-if story about earth evolving into electronic life forms Read a story once about earth being abandoned for long periods of time. Upon the return of man to earth all life forms, flora and fauna, have evolved into intricate electronic forms of themselves.   Would like to find that story and it's name. Disclaimer Yes, I am fully aware that what I am asking about is totally stupid and that anyone who would wish to try such a thing in production code should be fired and/or shot.  I'm mainly looking to see if can be done. Now that that's out of the way, is there any way to access private class members in C++ from outside the class?  For example, is there any way to do this with pointer offsets? (Naive and otherwise non-production-ready techniques welcome) Update As noted in the comments, I asked this question because I wanted to write a blog post on over-encapsulation (and how it affects TDD).  I wanted to see if there was a way to say &quot;using private variables isn't a 100% reliable way to enforce encapsulation, even in C++.&quot;  At the end, I decided to focus more on how to solve the problem rather than why it's a problem, so I didn't feature some of the stuff brought up here as prominently as I had planned, but I still left a link. At any rate, if anyone's interested in how it came out, here it is:   (I suggest reading it before you decide that I'm crazy). Russian babel and chemformula Why have a letter in a word when it’s silent in pronunciation, like the b in debt?  Can anyone please clarify my uncertainty here? Proof: How many digits does a number have? $\lfloor \log_{10} n \rfloor +1$ I read recently that you can find the number of digits in a number through the formula $\lfloor \log_{10} n \rfloor +1$ What's the logic behind this rather what's the proof? Is there is any reason to make the permissions on an overridden C++ virtual function different from the base class?  Is there any danger in doing so?  For example:  class base {     public:         virtual int foo(double) = 0; }  class child : public base {     private:         virtual int foo(double); }   The  says that it is a bad idea, but doesn't say why.  I have seen this idiom in some code and I believe that the author was attempting to make the class final, based on an assumption that it is not possible to override a private member function.  However,  shows an example of overriding private functions.  Of course  recommends against doing so.  My concrete questions:   Is there any technical problem with using a different permission for virtual methods in derived classes vs base class? Is there any legitimate reason to do so? With the confirmation that elements 113, 115, 117, and 118 are indeed fundamental elements that are now to be named on the periodic table, the next question is: what is the highest atomic number possible for an element? Feynman had a go at this years ago, and he derived (according to my limited understanding) that above element-137 (informally denoted 'Feynmanium') the electrons in the nearest orbit about the nucleus would be traveling at a velocity greater than the speed of light. (Note I am considering the Bohr model of the atom in this question.) I wished to demonstrate to my friends why this is and I came up with the following explanation.  According to Bohr's quantum condition, the angular momentum of an electron about the nucleus is given by $$ L=m_evr_n=n\hslash \implies r_n=\frac{n\hslash}{m_ev},$$ where $m_e$ is the mass of the electron, $v$ its velocity, $n$ an integer, and $r_n$ the radius of the $n$th possible orbit. Because we are concerned with the nearest orbit to the nucleus, $n=1$; and thus $$r=\frac{\hslash}{m_ev}.$$   Now, according to Coulomb's law, if the electron orbits about the nucleus the centripetal motion can be described by $$\frac{Ze^2}{4\pi\epsilon_or}=m_ev^2, $$ where $Z$ denotes the number of protons in the nucleus (the atomic number), and $e$ the elementary charge. Solving for $Z$ and substituting in $r$ from above yields $$Z=\frac{4\pi\epsilon_o \hslash v}{e^2}. $$ But what is $v$? Well, the maximum velocity an electron could ever have is the speed of light, and we wish to find the atomic number associated with an orbiting electron traveling at this speed, so we set $v=c$ and obtain our final result of $$Z=\frac{4\pi\epsilon_o\hslash c}{e^2}\approx 137.521,$$ which implies that for $Z&gt;137$, the electrons at a position of $n=1$ in the Bohr model would have a velocity $&gt;c$; and thus the highest atomic number achievable on the periodic table is 137.  Again, I just want to make sure this is a correct method for deriving element-137 before presenting. Perhaps one could explain how relativity plays a role here. I know Feynman used the Dirac equation to get this result...so could anyone (subsequently of course) expatiate on this in a simplistic manner? Thanks!