Davide Cassenti

Davide Cassenti

Gentleman and Scholar Software Engineer

Archive for July, 2008

Weekend in Roma

Wednesday, July 30, 2008

Finally I’ve been in Roma, capital of my wonderful Italy and «caput mundi», capital of the world. The trip was pretty cool: I left from Milano on 24th by plane with Marco and Matteo, flying to Ciampino’s airport in about one hour; landing was not perfect, but we arrived safe and sound at about 18:40, on time. Reach Roma from there is pretty simple, you have several choiches and our was the train from Ciampino train station.

DSCN0299

Train was ok, the travel is fast, but we had little problems with the map and we arrived in the hotel only at 9pm. The hotel «Antico Acquedotto» was pretty good, situated near the ancient aqueduct, not very expansive, clean and nice: I would suggest you to choose it, it is just 15-20 minutes far from the Termini station. First thing to do in Roma after 5 hours of travel is, of course, going to a nice restaurant for dinner: we had a good pizza and an ice cream and then we went back to the hotel.

…this was just the first evening: read the rest of the post!

Automatic web site backup

Sunday, July 20, 2008

I have written a linux shell script to automatically backup a website: also, a php script can help to backup the database in case you do not have access to the database machine and cannot use the mysqldump command.

First of all, what will you need: the script uses wget and ncftp; you can download them with your favorite package manager on linux, e.g. on a debian machine:

# apt-get install wget
# apt-get install ncftp

The mysql backup script, instead, is written in PHP and it uses a nice PHP class written by Adam Globus-Hoenich which allows you to export mysql tables. Download the PHP class here. The PHP part should be put on your website, anywhere you like, like in the root directory; create on your site a directory where the backup will be created, let’s call it mysql_backup. Remember to protect this folder so that users cannot read it.

…no, it is not finished: click here to read the rest of the post!

Upload to Flickr with Python

Saturday, July 19, 2008

Today I have found an interesting python script that allows you to upload photos from a local directory to Flickr; I decided to modify it and post here my modifications. The original script can be found here.

The script is pretty easy to use: it searches image files in a given directory, check an history file in order to know if the photo has been already uploaded, and if it is not the case, upload it on flickr; it is possible to specify if the photo needs to be public, private or shared, which tags assign to it and which name/description add.

The only thing I didn’t like was the way used by the script to know if the file was been already uploaded: simply, only the file name was used; I decided to change the script in order to allow to rename or move the photos inside the same directory (and sub directories) that uploadr.py is checking: to do so, I use the md5 digest of the image file as key in the history file. Another little thing I have added, is a lock file: if the script is already running it will exit with an error message on the screen.

…no, it is not finished: click here to read the rest of the post!