Sometimes it can be useful to completely drop all tables in a database, for example to reset a DB to a previous version from a backup.
After checking that you are doing this on the right database and that you know what you are doing, you can do this:
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;
Just discovered a quick and dirty way to resize a bunch of jpeg files to a maximum resolution and size: mogrify -resize 1024×1024 -strip -define jpeg:extent=200kb *.jpg This command will resize all jpg images in the current directory with a maximum resolution of 1024px for each side (maintaining aspect ratio) and a maximum size of […]
Suppose you want to access some JSON data from a mobile app using Cordova. You have to bypass CORS restrictions in the web view, and to do that you have to provide some HTTP headers in your Django views.
Recently I had some fun with Heroku, the well known PaaS provider. I had a small personal Django project I use for invoicing that I ran locally with ./manage.py runserver when needed. That was a perfect candidate for the Heroku free plan because I need to access the app only occasionally.
FTP is not encrypted by default, and you have to put some effort to configure an FTP server which is protected from sniffing.
If you are a lazy sysadmin like me you’ll prefer to use a service you already have, which is encrypted by default and do not require a special firewall configuration other than the port 22 you are already using.
During the development of a Django model on your local machine is it often necessary to refine the most recent migration to cope with updates to the model, without polluting the migrations of the app with a new migration for each local update.
South had the update flag for the schemamigration command, but I didn’t find a similar functionality in the Django builtin makemigrations command introduced in Django 1.7.
So I put togheter a simple bash script to automate the process.
My latest hybrid app, CoolKids, let you track good and bad actions of your kids to help them in self-improving. I thought it would be nice to share kids achievements with family and friends on social networks, emails, IM, etc. This post shows how I did it.