trying to count characters, words, and lines in C
Counting lines, words, characters and top ten words?
What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried:  import os  file_path = "/my/directory/filename.txt" directory = os.path.dirname(file_path)  try:     os.stat(directory) except:     os.mkdir(directory)         f = file(filename)   Somehow, I missed os.path.exists (thanks kanja, Blair, and Douglas). This is what I have now:  def ensure_dir(file_path):     directory = os.path.dirname(file_path)     if not os.path.exists(directory):         os.makedirs(directory)   Is there a flag for "open", that makes this happen automatically? Is it possible to restore a MySql database only using files from Data directory? I have a mysql installed inside a windows virtual machine. The hard drive was crashed and the system is not able to restore all again. But I can have access to entire c: ROOT. So I went to  c:/ProgramData/Mysql/Mysql Server 5.5/data/myDatabaseName    There I can see different files like: .frm, .opt, .trg and .trn. In a regular way, I could run a mysqldump to backup and restore all database from command line, but the system is not able to be restored. So I had to copy all these files and past inside inside the same  directory inside same database in another physical instance.   The issue is some tables are not been recognized by this new instance. So I think copy and past is not enough to restore the database.   What am I missing?    Note: Database has innoDb and Myisam tables. If $\gcd (a,b) = 1$, what can be said about $\gcd (a+b,a-b)$? Suppose $a, b \in \mathbb{Z}$, $a &gt; b$, and $\gcd (a,b) = 1$.  What can be said about $\gcd (a+b,a-b)$?  Is it true in general that $\gcd (a+b,a-b) \leq 2$? the largest integer $n$ for which $n+5$ divivides $n^5+5$? When we divide $n^5+5$ by $n+5$, we get a remainder $-620$, i.e., $n^5+5=K(n+5)-620$ , now how to proceed further? How do we know an $ \aleph_1 $ exists at all? I have two questions, actually. The first is as the title says: how do we know there exists an infinite cardinal such that there exists no other cardinals between it and $ \aleph_0 $? (We would have to assume or derive the existence of such an object before we label it something like $ \aleph_1 $.)  My second question is, can we say for certain if there's any limit to the number of cardinals existing between $ \aleph_0 $ and continuum (i.e. $ 2^{\aleph_0} $)? I mean, how could we know that there&#39;s not an infinite number of cardinals between the two - perhaps even more than $ \aleph_0 $? The following problem came up from a though I had while reading:  Let's say we have $M=\mathbb{Z}^n$ and we have another free $\mathbb{Z}$-module, $N$, inside of $M$ also with rank $n$.  We know we can make a matrix $A$ that changes $N$ to its representation in $M$ (ie has as columns the basis $N$ expressed in coordinates coming from the basis of $M$). If the index of $N$ in $M$ is $m$, I am pretty sure just from tinkering that the determinant of $A$ should also be $m$, however, I have not been able to show this.  It is unclear to me how to proceed. I though maybe I could do something related to the points in $\mathbb{Z}^n$ that are within the unit box of $N$, but I cannot really make sense of this.  Thank you for any help or direction. What does // mean in a path? I was working in my terminal, when I misspelled while cd to root (/). Accidentally, I typed // and I got in terminal:  root@weblocalhost://#   When i type pwd, i get response // but when I type ls -s i got same list as in / directory.  When you type more than 2, i.e. /// you get:  root@weblocalhost:/#   Always 1 / except for 2. Is there any difference and what is // for? What does a "Legacy USB Mouse" option in a BIOS mean?  Yes legacy usually means older revision, or obsolete. So legacy usb mouse means support for "old style usb mouses".     That's not really answering the question. As Mr. Tamm, my high school electricity teacher, liked to say, "Yes, and oranges taste orangey."   What does legacy USB mouse support mean?   What is a legacy USB mouse?  There's an "old style" USB mouse?  What changed between what version of usb and what version of usb that made mice incompatible? Why was the change made?  When was the change made? Who made the change? What was the virtue of the "new USB mouses" over the "old USB mouses"?   Put it another way:     What is the BIOS doing when "Legacy USB Mouse" option is enabled?   What is the BIOS doing when "Legacy USB Mouse" option is disabled?   See also Principle of Reflection on atomic level This well-observed phenomenon has, besides several others, always been a fascination to me. We are well aware of several theories, experiments, and practical applications of this well-known phenomenon, but is it established what goes on at the grassroots of reflection?  My high school teacher once told me that whenever light is incident on any reflecting surface, its electrons absorb the energy of the photon and release back the same energy. If this is actually true, then I have plenty of questions to continue, but if it is not, then what is reflection, and how and why does it take place? The third formula on the  states that $$\varphi (mn) = \varphi (m) \varphi (n) \cdot \dfrac{d}{\varphi (d)} $$ where $d = \gcd(m,n)$.  How is this claim justified?  Would we have to use the Chinese Remainder Theorem, as they suggest for proving that $\varphi$ is multiplicative? How to Self-Study Mathematical Methods? Edit:  Ok, user  made comment that truly helps narrow the focus of my question. Basically, I'm asking for a self-study course of Mathematical Methods.  Thanks to his recommendation I identified a book that is very close to the answer:  Mathematical Methods in the Physical Sciences by Mary L. Boas  Supposedly, the book covers most of the Math a person needs to learn in order to understand the simulations I presented.  Does this book suit my needs?    Hello,  I have always been interested on the idea to study Math at an Undergraduate level to be able to implement simulations like the followings:  Finite Difference Simulation of the Wave Equation    Heat Equation in Two Dimensions    Besides my precollege experience in Math, I have only been able to do very simple simulations due to my lack of knowledge of Advanced Math. Every time I ask about the inner workings of the simulations I get redirected to papers that look like foreign language to me and, unfortunately, I depend on easy-to-read tutorials to understand them, and while I have found   I'm more interested in reaching the solution myself.  I checked some of the questions related to book recommendations for self-study and while they are very helpful I'm interested in learning by example (There is a book called: "Accelerated C++ Practical Programming by Example" that fits very well my study habits)  Thanks in advance. How do Prestige Classes that advance spellcasting interact with racial spellcasting ability? For example Lets use the Marrutact from Sandstorm, it can cast as a 5th level wizard. if it then takes a prestige class that requires the ability to cast 1st level Arcane spells and advances arcane casting such as Abjurant Champion. assuming it meets all other prerequisites does the Marrutacts spellcasting improve when it takes a level in Abjurant Champion or does it gain no benefit? I have a group of objects of the same colour, consisting of compound paths, regular paths and groups of these. How to change the colour of all objects at once? When I tried to use colour picker or change it through color palette the colour remained the same but the graphics was rendered with a very tiny outline of the new colour, which I guess is not printable. Usually I had to change the colour of all objects individually.  Edit: I'm sorry if I was not too precise. I mean to apply new colour / swatch to all member objects of the group at once, not to change properties of a commonly shared swatch.    Edit 2: I received very useful answers, however my goal was to pick a colour from another object, serving as a source. When I tried to select all objects, for example with ctrl-a, and then use a eyedropper to pick up a desired colour, it didn't work for some objects in some groups. Please have a look at my answer where several methods are listed. about Linux's zip utility says this about the -u flag:     Replace (update) an existing entry in the zip archive only if it has been modified more recently than the version already in the zip archive. For example:          zip -u stuff *   will add any new files in the current directory, and update any files which        have been modified since the zip archive stuff.zip was last created/modified.   My question is, if a particular file has been removed since the last time it was zipped, whether -u will recognize that the file has been removed and thus remove it from the *.zip file?  Or, lacking timestamp information (since the file is now removed), it will leave the backed up file in *.zip, since there is no "newer" file? When is "EDIT"/"UPDATE" appropriate in a post? I often see questions edited into this form:     Lorem ipsum dolor sit amet blah blah blah paragraph paragraph original question.            UPDATE: The Lorem disappeared and left this message: "new information".   I find this format unaesthetic (since Stack Exchange posts are supposed to be useful in the long term and update boundaries are artifacts of the creation rather than the content) and feel that new information should, whenever possible, be incorporated into the original text “as if it had always been that way” if practical, and pointing out an update should be done mostly in comments.  Is this an appropriate writing style, and if so under what circumstances? If not, should it be removed or discouraged? Is there any practical difference between saving at 300ppi or 72ppi? I often see statements in discussions about web displayed image quality that go something like this: "I only upload pictures at 72 dpi and 1200 pixels on the long edge, so if someone copies and prints the image it won't look as good as if it were 300 dpi."  What? Have I missed something here?  Does an image edited and saved/exported with 1200x800 pixels at 300 ppi look any different online than the same image saved/exported with 1200x800 pixels at 72 ppi? Other than the metadata regarding ppi, is there any difference in the two images at all? If so, what is the difference? If I tell my printer to print the images at 4R (4X6 inches) will there be any difference at all in how the printer creates a print from the 1200x800 @ 300 dpi image versus the 1200x800 @ 72 dpi image? "Unable to connect to Upstart" error when installing git-all I am using 15.04.   So I'm working with git and I installed the standard version. I set up the ssh keys and was able to clone one of my repositories to the correct folder. Everything was working great and then I decided it was a good idea to install more packages. I ran sudo apt-get install git-all. I'm looking at error codes now having to deal with upstart.  start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused No apport report written because the error message indicates its a followup error from a previous failure. dpkg: error processing package runit (--configure):  subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of git-daemon-run:  git-daemon-run depends on runit; however:   Package runit is not configured yet.  dpkg: error processing package git-daemon-run (--configure):  dependency problems - leaving unconfigured Errors were encountered while processing:  runit  git-daemon-run E: Sub-process /usr/bin/dpkg returned an error code (1)   This is what happens when I even update/upgrade my system. At this point all I'm looking to do is be able to install software and update my current software. Is there any way I can potentially reverse this issue or at least correct it?   Edit: Thankfully this issue was solved only a day or two after it happened. The accepted answer worked perfectly and took care of my issue How to list all functions in a Python module? Consider these two sentences: "I gave him a pencil," and, "I gave a pencil to him."  Is it correct that the important part of the sentence is placed at the end? When we want to emphasize the pencil that I gave him, must we say, "I gave him a pencil?" When we want to emphasize that it is him to whom I gave a pencil, must we say, "I gave a pencil to him?" Is it safe to put a clothes washer outdoors? I will be short on usable indoor space for a while, but want to be able to wash clothes on site.   Are there any issues with putting a washer (and perhaps, a dryer) outdoors?  Perhaps it needs to be protected from the rain. Would an EZ-UP style canopy be sufficient?