How can I delay JavaScript from executing? I'm new to JavaScript and pulling my hair out over this...   A demo of the problem is here:   And this is the script:  var sections = function() {   $('.image').each(function() {     var $this = $(this),         x = $this.find('img').width()     $this.width(x);   }); };  $(document).ready(function() {    sections();  });  $(window).resize(function() {   sections(); })   The width of an image is calculated and assigned to the image's container. The idea is that the row of images will always maintain their aspect ratio, without gaps between the containers.   The problem is the code fails about 50% of the time and the images just squish together. Resizing the window fixes it so I think it's something to do with the loading sequence.   I've tried using window.onload and img.onload instead of document.ready, and these didn't solve it. Have I missed something in my script?
Official way to ask jQuery wait for all images to load before executing something In jQuery when you do this:  $(function() {    alert("DOM is loaded, but images not necessarily all loaded"); });   It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obviously what we want if we're initializing any DOM stuff such as showing or hiding elements or attaching events.  Let's say though that I want some animation and I don't want it running until all the images are loaded. Is there an official way in jQuery to do this?  The best way I have is to use &lt;body onload="finished()"&gt;, but I don't really want to do that unless I have to.  Note: There is a  in Internet Explorer which actually does wait for all images to load before executing code inside $function() { }. So if you're using that platform you'll get the behavior I'm looking for instead of the correct behavior described above.
I have two partitions, one of them has a file system and the other is unallocated.  How to merge two partitions? When can we interchange “who/which" and "that”? So far I thought the words who and that are usually interchangeable:   There is the man who saw me.  There is the man that saw me.    Both sentences seem fine, who can be replaced with that. But in the following examples:   This is the man to whom I spoke.  This is the man to that I spoke.    The #2 sounds odd, which is why I don’t think it might be correct. The same observation for the words which and that, while   This is the ball which we used today.  This is the ball that we used today.    Seem to be in order and which can be replaced with that. But in the following examples the #2 sounds odd again.   This is the ball with which I scored.  This is the ball with that I scored.    I wonder if there’s any rule regarding the interchangeability of the above mentioned words. I need to (permanent) redirect all of the following:   www.example.com www.example.com/folder sub.example.com sub.example.com/folder   Basically, all URLs that are reachable without being intended to: www.new-example.com, I want to do this within Apache and using the mod_rewrite module via the .htaccess file. Does $A$ a UFD imply that  $A[T]$ is also a UFD? I'm trying to prove that $A$ a UFD implies that $A[T]$ is a UFD.   The only thing I am sure I could try to use is Gauss's lemma.  Also, how can we deduce that the polynomial rings $\mathbb{Z}[x_1,\ldots,x_n]$ and $k[x_1,\ldots,x_n]$ are UFDs? Average length of the longest segment This post is related to a previous SE post  concerning average length of a smallest segment.  A rope of 1m is divided into three pieces by two random points. Find the average length of the largest segment. My answer is 11/18.  Here is how I do it:  Here we have two independent random variables $X,Y$, both uniform on $[0,1]$. Let  $A=\min (X,Y), B=\max (X,Y)$ and $C=\max (A, 1-B, B-A)$. First we want to find the probability density function $f_C(a)$ of $C$. Let $F_C(a)$ be the cumulative distribution function. Then $$ F_C(a) = P(C\le a)=P(A\le a, 1-B\le a, B-A\le a).$$  By rewriting this probability as area in the unit square, I get $$F_C(a)=\left\{\begin{array}{ll} (3a-1)^2 &amp; \frac{1}{3}\le a\le \frac{1}{2}\\ 1-3(1-a)^2 &amp; \frac{1}{2}\le a\le 1\end{array}\right.$$ from which it follows that  $$f_C(a)=\left\{\begin{array}{ll} 6(3a-1) &amp; \frac{1}{3}\le a\le \frac{1}{2}\\ 6(1-a) &amp; \frac{1}{2}\le a\le 1\end{array}\right.$$ Therefore the expected value of $C$ is $$\int_{1/3} ^{1/2}6a(3a-1) da+\int_{1/2} ^{1}6a(1-a) da= \frac{11}{18}.$$  My questions are:  (A) Is there a "clever" way to figure out this number 11/18?  (B) What is the answer if the rope is divided into $n&gt;3$ segments? Does it matter what I choose for serialVersionUID when extending Serializable classes in Java? How to Count Duplicates in List with LINQ Is temperature in vacuum zero? From      The temperature of an ideal monatomic gas is a measure of the average kinetic energy of its atoms.    Now if I remove all the particles from the box shown below will the temperature be zero? How to find and replace a string by increasing its numerical part? My input file is,  ami21 ami65 ami67 ami66 ami88 ami76 ami29 ami55  ami54 ami32   Using a single command line I need the output as,  ami22 ami66 ami68 ami67 ami89 ami77 ami30 ami56 ami55 ami33   I used the command  awk -vRS=ami '{$0=$0+1;ORS=RT}++n' inputfile &gt; outputfile   but I got the outputfile as ami21ami65ami67ami66ami88ami76ami29ami55ami54ami32  i.e. all strings are written in same line and without space. Could anyone suggext me some better command line. Prove inequality using Schwarz's Lemma I'm having trouble proving the following:  Let $f$ be analytic on $D(0,R)$ and suppose there is a real constant A for which $\operatorname{Re}f(z) &lt; A$ for all $z \in D(0,R)$. If $f(0) = 0$, show that $|f(z)| \leq \frac{2A|z|}{R-|z|}$.   I was told to first start by showing that $|\frac{f(z)}{2A-f(z)}| \leq 1$ and also use the following result, which I was able to prove:  Let $f$ be analytic on $D(0,R)$ and let $f(0)=0$. If $|f(z)| \leq M$ for all $z \in D(0,R)$, then $|f(z)| \leq M|z|/R$ for all $z\in D(0,R)$.  Thanks in advance! Undefined control sequence error on \fancy@reset, \f@ncyolh and \f@ncyorh when using newlfm class How to add a script to Startup Applications from the command line? I have a shell script. I want to configure my script to run automatically during startup. I know how to do this from GUI. But I wanted to do this from terminal. How can I do this?  On a primary research I found that the file needs to be moved to /etc/int.d/ directory. But this operation needs sudo permission. I wanted to do this without super user permissions.   I also found that there are files under ~/.config/autostart/ which are having some settings regarding the startup applications. But I don't know how to edit them to achieve this.   Can someone tell me the exact procedure to achieve this? proof by induction: sum of binomial coefficients $\sum_{k=0}^n (^n_k) = 2^n$ I used Sound Juicer to rip a CD of audio for a language learning book so that I could listen to them on my Android. However, Sound Juicer seems to only have the option of numbering files without leading zeros. Like this:  track_1.mp3 track_10.mp3 track_11.mp3   This leads to some confused ordering on my music player. So, I want to add some zeros to the name, so that they're ordered properly, like this:  track_01.mp3 track_02.mp3 track_03.mp3   How do I accomplish this? I tried using GPRename, but while it has the ability to add numbers, it doesn't seem to have any options for adding leading zeros.  Is there a better program or something I can do at the command line? What is the difference between Halt and Shutdown commands? What is the difference between the halt and shutdown commands? Convert HTML to PDF in .NET I want to generate a PDF by passing HTML contents to a function. I have made use of iTextSharp for this but it does not perform well when it encounters tables and the layout just gets messy.  Is there a better way? Produce an explicit bijection between rationals and naturals? I think this is just something I've grown used to but can't remember any proof.  When differentiating and integrating with trigonometric functions, we require angles to be taken in radians. Why does it work then and only then? I know how to draw different shapes using tikz, like this:  \documentclass{minimal} \usepackage{tikz} \begin{document}  \begin{tikzpicture} \draw (0,0) ellipse (1 and 1.5)       (0,2.5) circle (1)       (2.5,0) circle (1.5); \end{tikzpicture}  \end{document}     However, I would like to put a number of different shapes together inside a node, and I couldn't yet find a simple way to do that. I will make a little figure to include in a large diagram which is already made of several nodes.  If this is not possible, or not easy, then how do I include a JPG or EPS file in a node?  Thank you! A current I flows through a solenoid (with n turns). Self inductance is $L$. If the magnetic flux is $\phi$, I am taught that $-n\phi=LI$  I dont understand the part with $n$, why do we have multiply by $n$? $\phi$ itself represents the whole magnetic flux there, if $\phi$ implied the flux only occurred by one coil, then it would be correct.   Moreover, flux change by a coil ($n$ turns) in $dt$ time is $d\phi$, so the induced electromagnetic force is   $$dE=n \cdot \frac{d\phi}{dt}$$   Why do we multiply by $n$ here? If $\phi$ means the whole flux, then why multiply?