How to save svg canvas to local filesystem

You can avoid a round trip to the server. Base64 encode your SVG xml. Then generate a link to that data. The user can right click on to save it locally. // This example was created using Protovis & jQuery // Base64 provided by http://www.webtoolkit.info/javascript-base64.html // Modern web browsers have a builtin function to this … Read more

SQLite3 database or disk is full / the database disk image is malformed

To repair a corrupt database you can use the sqlite3 commandline utility. Type in the following commands in a shell after setting the environment variables: cd $DATABASE_LOCATION echo ‘.dump’|sqlite3 $DB_NAME|sqlite3 repaired_$DB_NAME mv $DB_NAME corrupt_$DB_NAME mv repaired_$DB_NAME $DB_NAME This code helped me recover a SQLite database I use as a persistent store for Core Data and … Read more

How to check whether a directory is a sub directory of another directory

Python 3’s pathlib module makes this straightforward with its Path.parents attribute. For example: from pathlib import Path root = Path(‘/path/to/root’) child = root / ‘some”https://stackoverflow.com/”child”https://stackoverflow.com/”dir’ other = Path(‘/some/other/path’) Then: >>> root in child.parents True >>> other in child.parents False

How can I compare (directory) paths in C#?

GetFullPath seems to do the work, except for case difference (Path.GetFullPath(“test”) != Path.GetFullPath(“TEST”)) and trailing slash. So, the following code should work fine: String.Compare( Path.GetFullPath(path1).TrimEnd(‘\\’), Path.GetFullPath(path2).TrimEnd(‘\\’), StringComparison.InvariantCultureIgnoreCase) Or, if you want to start with DirectoryInfo: String.Compare( dirinfo1.FullName.TrimEnd(‘\\’), dirinfo2.FullName.TrimEnd(‘\\’), StringComparison.InvariantCultureIgnoreCase)

Wait Until File Is Completely Written

There is only workaround for the issue you are facing. Check whether file id in process before starting the process of copy. You can call the following function until you get the False value. 1st Method, copied directly from this answer: private bool IsFileLocked(FileInfo file) { FileStream stream = null; try { stream = file.Open(FileMode.Open, … Read more

Find size and free space of the filesystem containing a given file

This doesn’t give the name of the partition, but you can get the filesystem statistics directly using the statvfs Unix system call. To call it from Python, use os.statvfs(‘/home/foo/bar/baz’). The relevant fields in the result, according to POSIX: unsigned long f_frsize Fundamental file system block size. fsblkcnt_t f_blocks Total number of blocks on file system … Read more

How do I make my program watch for file modification in C++?

There are several ways to do this depending on the platform. I would choose from the following choices: Cross Platform Trolltech’s Qt has an object called QFileSystemWatcher which allows you to monitor files and directories. I’m sure there are other cross platform frameworks that give you this sort of capability too, but this one works … Read more