I am trying to identify records that expire within 1 year of today's date. This is the code I have and it doesn't work because I can't add or subtract integers from dates. Can someone assist? I know this is simple. from datetime import date  today = date.today()  mask = (df['[PCW]Contract (Expiration Date)'] &lt;= today + 365)
I have a Python  object. What is the best way to subtract one day?
Can you 'exit' a loop in PHP? I have a loop that is doing some error checking in my PHP code. Originally it looked something like this...  foreach($results as $result) {     if (!$condition) {         $halt = true;         ErrorHandler::addErrorToStack('Unexpected result.');     }      doSomething();  }  if (!$halt) {     // do what I want cos I know there was no error }   This works all well and good, but it is still looping through despite after one error it needn't. Is there a way to escape the loop? I am asked to prove this theorem:  If $f:U \rightarrow C$ is holomorphic in $U$ and invertible, $P\in U$ and if $D(P,r)$ is a sufficently small disc about P, then   $$f^{-1}(w) = \frac{1}{2\pi i} \oint_{\partial D(P,r)}{\frac{sf'(s)}{f(s)-w}}ds$$     The book says to "imitate the proof of the argument principle" but I am not seeing the connection. Safely turning a JSON string into an object Given a string of JSON data, how can I safely turn that string into a JavaScript object?  Obviously I can do this unsafely with something like:  var obj = eval("(" + json + ')');   but that leaves me vulnerable to the JSON string containing other code, which it seems very dangerous to simply eval. Was Mjolnir ever used for building something? In the movie Thor (2011), while he was about to crown Thor as the next king of Asgard, Allfather Odin describes the mighty hammer Mjolnir as the following:      So long entrusted with this mighty hammer, Mjolnir. Forged in the heart of a dying star, from the sacred metal of Uru. Only one may ift it. Only one is worthy. Who wields this hammer commands the lightning and the storm. Its power has no equal -- as a weapon, to destroy, or as a tool, to build. It is a fit companion for a King.   We know Mjolnir as a weapon of destruction but are there references where it is used to build something? Is there a robust command line tool for processing csv files? I work with CSV files and sometimes need to quickly check the contents of a row or column from the command line.  In many cases cut, head, tail, and friends will do the job; however, cut cannot easily deal with situations such as  "this, is the first entry", this is the second, 34.5   Here, the first comma is part of the first field, but cut -d, -f1 disagrees. Before I write a solution myself, I was wondering if anyone knew of a good tool that already exists for this job.  It would have to, at the very least, be able to handle the example above and return a column from a CSV formatted file.  Other desirable features include the ability to select columns based on the column names given in the first row, support for other quoting styles and support for tab-separated files.  If you don't know of such a tool but have suggestions regarding implementing such a program in Bash, Perl, or Python, or other common scripting languages, I wouldn't mind such suggestions. Windows 7 finding location of installed program Method to create a live USB disk (with persistence) which actually works? I've tried so many combinations - all I want is a fast Ubuntu Live USB disk with persistence that works. What I've tried so far:   Using unetbootin on my Mac, choosing some "Space used to preserve files across reboots (Ubuntu only)".   Result: Doesn't boot at all.  Using unetbootin on my Mac, choosing no such space.  Result: Boots fine and very fast (doesn't even show the annoying dialog "Try ubuntu/install ubuntu" at startup!), but has no persistence. (So I have to choose my keyboard layout, install programs I need, etc. every time)  Using Startup Disk Creator from my Ubuntu 11.04 installation.  Result: I cannot choose "reserved extra space" at all. It's greyed out. I know I know, there was bug , and many people say that the workaround from  works for them. But it doesn't work with Ubuntu 11.04 anymore (see also ).  Using Startup Disk Creator from my Kubuntu 10.10 installation, gnome version (usb-creator-gtk).   Result: I can select the "reserved extra space" option, but installation doesn't work (fails when installing the bootloader).  Using Startup Disk Creator from my Kubuntu 10.10 installation, kde version (usb-creator-kde).   Result: Actually works: Reserved space can be selected, installation works. But after booting, I get the screen "Try ubuntu/install ubuntu". Clicking on "Try ubuntu" takes me to the desktop - but only after waiting 5 minutes (every time!). It also doesn't seem to keep my keyboard settings.    I know, that instead of creating a startup disk, I could install a full ubuntu system on the USB stick. But as far as I know, this isn't very good, because /tmp and similar directories will then also be on the USB disk, which is a) slow, and b) not very good for the USB disk due to frequent overwriting.  I'm frustrated. So has anybody managed to create a working Ubuntu 11.04 Live USB disk with persistence? I saw him crossing the road.   I saw him cross the road.   Which one is correct and why? How Can I Concatenate Column A and Column B into Column C in Excel? Column A has first name.  Column B has last name.  I need column C to be "display name" (first name and last name separated by a space).  I assume this involves the concatenate function.  Bonus Question: Column D is email address.  I need column E to be "username" (everything in email address left of the @ symbol).  I assume this involves some regular expression function. Matrices: system that is "computationally singular" versus "exactly singular" I would like to know the mathematical concepts behind singular matrices. Matrices that do not have inverses in R throw one of two errors. I have provided some examples of both errors below:    Error in solve.default(W) :  system is computationally singular: reciprocal condition number = 1.58603e-17   Error in solve.default(Z) :  Lapack routine dgesv: system is exactly singular: U[2,2] = 0    Can anyone explain the difference between the two? Why is the first "nearly singular" whereas the second is "exactly singular"? Here's my attempt at it:  $query = $database-&gt;prepare('SELECT * FROM table WHERE column LIKE "?%"');  $query-&gt;execute(array('value'));  while ($results = $query-&gt;fetch())  {     echo $results['column']; } How to override parent functions in child themes? I've been reading around and trying to figure out how to do this, but for some reason I can't seem to override parent functions in my child theme.  I'm using TwentyTen as a parent - can anyone tell me why this function in my child theme isn't overriding the parent function please?  // Override read more link function osu_twentyten_continue_reading_link() {  return ' &lt;a href="'. get_permalink() . '"&gt;' . __( 'Read on &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten-child' ) . '&lt;/a&gt;'; } function osu_twentyten_auto_excerpt_more( $more ) {  return ' &amp;hellip;' . osu_twentyten_continue_reading_link(); } remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); add_filter( 'excerpt_more', 'osu_twentyten_auto_excerpt_more' );   I thought you had to remove the filter/action etc. before re-adding it right?  Thanks,  osu Does the series $\sum \sin^{(n)}(1)$ converge, where $\sin^{(n)}$ denotes the $n$-fold composition of $\sin$? Asymptotic of a sum involving binomial coefficients What makes induction (over natural numbers) a valid proof technique? Is $$ \dfrac{ P(0) \quad \forall i \in \mathbb{N}. P(i) \Rightarrow P(i+1) }{ \forall n \in \mathbb{N}.  P(n)} $$ just taken for granted as a proof rule, or can it be derived from more foundational axioms?  Similarly, can the principle of induction over well-founded sets be derived from something more foundational, or does it have to be assumed to be a valid inference rule? What theorems can I use to prove this? Why are there gaps in my IDENTITY column values? Splicing a list of arguments into a function with Sequence Multiple (diamond) inheritance compiles without "virtual", but doesn't with Shining a laser onto a mirror Theoretically, if I shined a laser at a mirror at an angle of 0 degrees so that the light was perfectly reflected back to the light source, then I should not be able to see the light because it is not reflected to my eyes.  | |  me | |============ laser | | |   However this is evidently not the case, as I am able to see the laser point on the mirror. Why is this the case? My initial assumption is that it is due to diffuse reflection on the imperfect mirror's surface, but I am not sure.