I was looking for a way to get rsync to copy all the files in a particular directory and not recurse into the sub-directories. Unfortunately I couldn’t find an appropriate parameter and a quick search on Google turned up nothing (apart from a lot of other people asking the same question!)
So as a last resort I decided to use my brain, and I came up with a simple solution that works. It’s of the form:
rsync -avc --exclude "*/" ./source/* ./destination/
The above will copy all the files from the directory called “source” into the directory “destination” and will not recurse into any subdirectories of “source”.
A member of the team came to me the other day with a MySQL error that I’d not seen before:
Lost connection to MySQL server during query
The MySQL manual (http://dev.mysql.com/doc/refman/5.0/en/gone-away.html) says that it can be caused by:
applications that fork child processes, all of which try to use the same connection to the MySQL server
Which was exactly our case as we were creating a benchmarking tool that created child processes to concurrently query the website. So we checked the code to make sure that no database connections were shared between processes, and also that all connections were closed immediately after being used… but we still got the same error.
After a few minutes of scratching our heads, it dawned on us that we were using persistent connections, and of course when connection objects are destroyed the actual connections are not closed but are returned to a pool of connections, ready for re-use.
We changed the connections to non-persistent and Bob was our proverbial uncle!
A Python programmer recently asked me what an abstract class is, given the other explanations I found seemed to imply that you already really knew what one was – I decided to come up with my own:
An abstract class is a class that you cannot instantiate, they implement some base methods and guarantee that child classes will implement others.
In the animal world, a Mammal would be an abstract class – it defines that all Mammals have fur, teeth and give live birth – the specifics of which vary from species to species. You can’t create a Mammal, but you can create a Dog which extends the Mammal – has teeth, fur and the specific dog class can describe exactly how the live birth proceeds.
The Mammal class might also extend the Vertebrate class which defines things like bones, central nervous system and so on.