In python, I have code that needs to be triggered and the top of every minute.  I have a while loop.  What is the best why to watch the time and when a new minute start then execute?  Thanks    while True:    if TOP_OF_MIN:         run_code()
I want to repeatedly execute a function in Python every 60 seconds forever (just like an  in Objective C). This code will run as a daemon and is effectively like calling the python script every minute using a cron, but without requiring that to be set up by the user.  In , the solution appears to effectively just  for x seconds. I don't need such advanced functionality so perhaps something like this would work  while True:     # Code executed here     time.sleep(60)   Are there any foreseeable problems with this code?
Four tasks in parallel... how do I do that? I have a bunch of PNG images on a directory. I have an application called pngout that I run to compress these images. This application is called by a script I did. The problem is that this script does one at a time, something like this:  FILES=(./*.png) for f in  "${FILES[@]}" do         echo "Processing $f file..."         # take action on each file. $f store current file name         ./pngout -s0 $f R${f/\.\//} done   Processing just one file at a time, takes a lot of time. After running this app, I see that the CPU is just 10%. So I discovered that I can divide these files in 4 batches, put each batch in a directory and fire 4, from four terminal windows, four processes, so I have four instances of my script, at the same time, processing those images and the job takes 1/4 of the time.  The second problem is that I lost time dividing the images and batches and copying the script to four directories, open 4 terminal windows, bla bla...  How do that with one script, without having to divide anything?  I mean two things: first how do I from a bash script, fire a process to the background ? (just add &amp; to the end?) Second: how do I stop sending tasks to the background after sending the fourth tasks and put the script to wait until the tasks end? I mean, just sending a new task to the background as one tasks end, keeping always 4 tasks in parallel? if I do not do that the loop will fire zillions of tasks to the background and the CPU will clog. Can you decide to counterspell after another counterspell has failed? Understanding d-separation theory in causal Bayesian networks I am trying to understand the d-Separation logic in Causal Bayesian Networks. I know how the algorithm works, but I don't exactly understand why the "flow of information" works as stated in the algorithm.    For example in the graph above, lets think that we are only given X and no other variable has been observed. Then according to the rules of d-separation, the information flow from X to D:   X influences A, which is $P(A)\neq P(A|X)$. This is OK, since A causes X and if we know about the effect X, this affects our belief about the cause A. Information flows. X influences B,which is $P(B)\neq P(B|X)$. This is OK, since A has been changed by our knowledge about X, the change at A can influence our beliefs about its cause, B, as well. X influences C,which is $P(C)\neq P(C|X)$. This is OK because we know that B is biased by our knowledge about its indirect effect, X, and since B is biased by X, this will influence B's all direct and indirect effects. C is a direct effect of B and it is influenced by our knowledge about X.   Well, up to this point, everything is OK for me since the flow of the information occurs according to intuitive cause-effect relationships. But I don't get the special behavior of so called "V-structures" or "Colliders" in this scheme. According to the d-Separation theory, B and D are the common causes of C in the graph above and it says that if we did not observe C or any of its descendants, the flow information from X is blocked at C. Well, OK, but my question is why?  From the three steps above, started from X, we saw that C is influenced by our knowledge about X and the information flow occurred according to the cause-effect relationship. The d-Separation theory says that we cannot go from C to D since C is not observed. But I think that since we know that C is biased and D is a cause of C, D should be affected as well while the theory says the opposite. I am clearly missing something in my thinking pattern but can't see what it is.  So I need an explanation of why the flow of information blocked at C, if C is not observed. Is it possible to make armour that can survive /kill? /kill is said to be infinity damage but I have a question can you really survive it in Java edition. However, it is possible that you can pretty much survive this if you are on Minecraft Java Edition in 1.8 or lower and you can just have resistance 5 and you will survive this but can you make armour that helps you survive in 1.16 and in java-edition. Why isn't it $E \approx 27.642 \times mc^2$? Why is it that many of the most important physical equations don't have ugly numbers (i.e., "arbitrary" irrational factors) to line up both sides?   Why can so many equations be expressed so neatly with small natural numbers while recycling a relatively small set of physical and mathematical constants?  For example, why is mass–energy equivalence describable by the equation $E = mc^2$ and not something like $E \approx 27.642 \times mc^2$?  Why is time dilation describable by something as neat as $t' = \sqrt{\frac{t}{1 - \frac{v^2}{c^2}}}$ and not something ugly like $t' \approx 672.097 \times 10^{-4} \times \sqrt{\frac{t}{1 - \frac{v^2}{c^2}}}$.  ... and so forth.    I'm not well educated on matters of physics and so I feel a bit sheepish asking this.   Likewise I'm not sure if this is a more philosophical question or one that permits a concrete answer ... or perhaps even the premise of the question itself is flawed ... so I would gratefully consider anything that sheds light on the nature of the question itself as an answer.    EDIT: I just wished to give a little more context as to where I was coming from with this question based on some of the responses:  @Jerry Schirmer comments:      You do have an ugly factor of $2.997458 \times 10^8 m/s$ in front of everything. You just hide the ugliness by calling this number c.   These are not the types of "ugly constants" I'm talking about in that this number is the speed of light. It is not just some constant needed to balance two side of an equation.  @Carl Witthoft answers:      It's all in how you define the units ...   Of course this is true, we could in theory hide all sorts of ugly constants by using different units on the right and the left. But as in the case of $E=mc^2$, I am talking about equations where the units on the left are consistent with the units on the right, irrespective of the units used. As I mentioned on a comment there:     $E=mc^2$  could be defined using units like $m$ in imperial stones ($\textsf{S}$), $c$ in cubits/fortnight ($\textsf{CF}^{−1}$) and $E$ in ... umm ... $\textsf{SC}^2\textsf{F}^{−2}$ ... so long as the units are in the same system, we still don't need a fudge factor.   When the units are consistent in this manner, there's no room for hiding fudge constants. TikZ: remove margin, padding, border around nodes containing images I want to create a simple figure where images are connected with arrows. Here is what I did:  \begin{tikzpicture} \node[](A) {\includegraphics[width=0.2\textwidth]{a}}; \node[right=1mm of A](B) {\includegraphics[width=0.2\textwidth]{b}}; \draw[-&gt;] (A) to (B); \end{tikzpicture}     But I want the arrow to start and end right at the images with no space between. How can I do that? How Can I prove (a+b) mod m = (a mod m) + (b mod m)) mod m? modular arithmetic  How Can I prove (a+b) mod m = (a mod m) + (b mod m)) mod m ? New flagging dialog has a duplicate for duplicate We've changed the flagging format from today(AFAIK) as below,        looks good.  But, when I select it should be closed for another reason...  I can see the same reason duplicate on the top.        What is the need of placing that reason over there? It should not be there. Please remove the dupe. Assume you are given two objects whose exact locations are unknown, but are distributed according to normal distributions with known parameters (e.g. $a \sim N(m, s)$ and $b \sim N(v, t))$. We can assume these are both bivariate normals, such that the positions are described by a distribution over $(x,y)$ coordinates (i.e. $m$ and $v$ are vectors containing the expected $(x,y)$ coordinates for $a$ and $b$ respectively). We will also assume the objects are independent.  Does anyone know if the distribution of the squared Euclidean distance between these two objects is a known parametric distribution? Or how to derive the PDF / CDF for this function analytically? I have B1/B2 Visa. Can I travel for Business trip to US with this Visa? Ubuntu 17.10 GDM Auto-Login not working apt-get build-dep is unable to find a source package Why would a company like Apple be buying back its own shares? What is the reason that a company like AAPL is buying back its own shares? Does it have too much cash and it doesn't know what to do with it? So it is returning the cash back to investors? I'm new to regular expressions and would appreciate your help.  I'm trying to put together an expression that will split the example string using all spaces that are not surrounded by single or double quotes. My last attempt looks like this: (?!") and isn't quite working. It's splitting on the space before the quote.  Example input:   This is a string that "will be" highlighted when your 'regular expression' matches something.   Desired output:  This is a string that will be highlighted when your regular expression matches something.   Note that "will be" and 'regular expression' retain the space between the words. Unable to install rJava in R 3.0 in Ubuntu 13.04 URW-Garamond with mathdesign is typesetting vertical double-quote as vertical double-quote I just started using URW-Garamond with mathdesign, and it's typesetting straight double-quote character as a straight double-quote rather than a right double-quote.  How can I fix this?  That is, when I put this in my header:  \usepackage[T1]{fontenc} \usepackage[urw-garamond]{mathdesign}   I get a nice Garamond in my output, but " in my input file produces a Garamond version of the same character in the output.  If I use two single-quotes instead, it comes out properly as a double right-quote.  I could switch to typing '' or set up a macro, but this is undesirable for more than one reason.  Is there any way to use urw-garamond without this non-traditional behavior for "? As teenager Tom Riddle is speaking to Harry Potter in the Chamber of Secrets, both he and Harry are refering to the real Voldemort in the third person. If Tom Riddle had succeeded in sucking all the life energy out of Ginny and had come back alive, wouldn't that have meant there were two Voldemorts in the world? The wraith one which had lived in Quirrell, and the newly constituted one?  This Tom Riddle clearly doesn't have the memories of the wraith version.   As a bonus: If they both existed, would they have competed against each other? How do I tell a script to wait for a process to start accepting requests on a port? I need a command that will wait for a process to start accepting requests on a specific port.    Is there something in linux that does that?  while (checkAlive -host localhost -port 13000 == false)   do some waiting  ... I'm reading through  for the , which contains this figure on page 16:    This is of course an instrumentation amplifier that apparently uses an inverting amplifier's output instead of a ground in the lower-right corner of the above figure, but what really perplexes me is the 100 k&Omega; resistors attached directly to the noninverting inputs of three of the four amps. I don't recall seeing an instrumentation amplifier circuit in books or application notes that have them, and all of the instrumentation amplifiers I've built using the three op-amp scheme works fine without them.  The datasheets specifies an input resistance of 1012 &Omega;, which is 10,000,000 times greater than 100 k&Omega;, so it doesn't seem to add anything to the already high-impedance JFET inputs. I thought perhaps it has something to do with input bias currents, but that's just me making a wild stab in the dark.  Curiously, figure 26 in the same datasheet (page 18) shows a two-op-amp version of an instrumentation amplifier without the 100 k&Omega; resistors at the noninverting op-amp inputs!  What's the purpose of the 100 k&Omega; resistors at the noninverting inputs in the above circuit? Am I missing something completely obvious? Can we use CAPITAL LETTERS to indicate actions? While designing for the web or the mobile applications, a natural free flowing text can be used for the general content, but when it comes to actions... can we use CAPITAL LETTERS.