<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Davide Cassenti &#187; Computer science</title>
	<atom:link href="http://davide.cassenti.it/category/computer-science/feed/" rel="self" type="application/rss+xml" />
	<link>http://davide.cassenti.it</link>
	<description></description>
	<lastBuildDate>Sat, 26 Jun 2010 05:57:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>No Facebook Day</title>
		<link>http://davide.cassenti.it/2010/06/11/no-facebook-day/</link>
		<comments>http://davide.cassenti.it/2010/06/11/no-facebook-day/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 00:23:37 +0000</pubDate>
		<dc:creator>Davide Cassenti</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Interestingness]]></category>

		<guid isPermaLink="false">http://davide.cassenti.it/?p=667</guid>
		<description><![CDATA[How much facebook-addicted are you? Can you stay one whole day without it?
On June, 23rd 2010 forget about the social network, don&#8217;t try to login with your mobile, avoid looking for someone to chat with&#8230; and disable all the mail notification. Can you live without it &#8211; for just a day?
Just a little experiment to [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_668" class="wp-caption alignright" style="width: 220px"><a href="http://vaime.org/nofbday"><img class="size-medium wp-image-668   " title="No Facebook Day" src="http://davide.cassenti.it/wp-content/uploads/2010/06/no_facebook_day-300x172.jpg" alt="no_facebook_day" width="210" height="120" /></a><p class="wp-caption-text">No Facebook Day - June 23rd, 2010</p></div>
<p>How much facebook-addicted are you? Can you stay one whole day without it?</p>
<p>On June, 23rd 2010 forget about the social network, don&#8217;t try to login with your mobile, avoid looking for someone to chat with&#8230; and disable all the mail notification. Can you live without it &#8211; for just a day?</p>
<p>Just a little experiment to see how many people would try to avoid connecting to the popular social network and find out if they are addicted.</p>
<p>Join the event: <a href="http://vaime.org/nofbday" target="_self">http://vaime.org/nofbday</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davide.cassenti.it/2010/06/11/no-facebook-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Linux from Windows</title>
		<link>http://davide.cassenti.it/2008/09/27/installing-linux-from-windows/</link>
		<comments>http://davide.cassenti.it/2008/09/27/installing-linux-from-windows/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 14:02:42 +0000</pubDate>
		<dc:creator>Davide Cassenti</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://davide.cassenti.net/?p=47</guid>
		<description><![CDATA[Today I decided to install Ubuntu on my laptop, since I need a linux platform for my work; Ubuntu is quite easy and fast to install and use, so I have chosen it. Once inserted the cd, the autoplay (which I hate, but I didn&#8217;t remove yet) showed me a window with an interesting choice: [...]]]></description>
			<content:encoded><![CDATA[<p>Today I decided to install <a href="http://www.ubuntu.org">Ubuntu</a> on my laptop, since I need a linux platform for my work; Ubuntu is quite easy and fast to install and use, so I have chosen it. Once inserted the cd, the autoplay (which I hate, but I didn&#8217;t remove yet) showed me a window with an interesting choice: <em>Install Ubuntu as Windows application</em>. I heard about this, but I didn&#8217;t know it was integrated on the last version of Ubuntu (version 8.04); also, I never tried it, so I decided it was a good moment to do so.</p>
<p style="text-align:center"><div id="attachment_407" class="wp-caption alignnone" style="width: 642px"><img src="http://davide.cassenti.it/wp-content/uploads/2008/09/wubi-1231.png" alt="Wubi setup" title="Wubi setup" width="632" height="397" class="size-full wp-image-407" /><p class="wp-caption-text">Wubi setup</p></div></p>
<p>Once clicked on that option, the <a href="http://wubi-installer.org">wubi</a> windows is shown: pretty simple as installing an application, it asks for the destination hard drive, the size and few other simple question, then the installation begins. If you are using the ubuntu&#8217;s cd it checks the files on it without downloading anything else and it install the operating system in few minutes: after the reboot you may choose the O.S. to load. The first time you choose Ubuntu the installation will be completed (~10-15 minutes), then your desktop is ready.</p>
<p style="text-align:center"><div id="attachment_406" class="wp-caption alignnone" style="width: 450px"><img src="http://davide.cassenti.it/wp-content/uploads/2008/09/boot-screen1.jpg" alt="Ubuntu boot screen" title="Ubuntu boot screen" width="440" height="287" class="size-full wp-image-406" /><p class="wp-caption-text">Ubuntu boot screen</p></div></p>
<p>I think this is the easiest way to install linux on a machine: no questions, no partition problems, fast and immediatly ready to use. It is not the best way, because it uses a virtual file system which is a bit slower, but it is a good choice for a fast intallation, as I needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://davide.cassenti.it/2008/09/27/installing-linux-from-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic web site backup</title>
		<link>http://davide.cassenti.it/2008/07/20/automatic-web-site-backup/</link>
		<comments>http://davide.cassenti.it/2008/07/20/automatic-web-site-backup/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 17:50:50 +0000</pubDate>
		<dc:creator>Davide Cassenti</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://davide.cassenti.net/?p=25</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>First of all, what will you need: the script uses <strong>wget</strong> and <strong>ncftp</strong>; you can download them with your favorite package manager on linux, e.g. on a debian machine:</p>
<pre>
# apt-get install wget
# apt-get install ncftp
</pre>
<p>The mysql backup script, instead, is written in PHP and it uses a nice PHP class written by <em>Adam Globus-Hoenich</em> which allows you to export mysql tables. <a href="http://davide.cassenti.net/wp-content/uploads/2008/07/sql_export.zip">Download the PHP class here</a>. 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&#8217;s call it <em>mysql_backup</em>. Remember to protect this folder so that users cannot read it.</p>
<p><span id="more-25"></span></p>
<p>Here&#8217;s the PHP script:</p>
<pre>
$server = "mysqlserveraddress";
$username = "dbusername";
$password = "dbpassword";
$db = "dbname";

$cnx = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($db, $cnx) or die(mysql_error());
$tables = mysql_list_tables($db) or die(mysql_error());

//Create a list of tables to be exported
$table_list = array();
while($t = mysql_fetch_array($tables)) {
	array_push($table_list, $t[0]);
}

//Instantiate the SQL_Export class
require("SQL_Export.php");
$e = new SQL_Export($server, $username, $password, $db, $table_list);
//Run the export
$dump = $e->export();

//Clean up the joint
mysql_close($e->cnx);
mysql_close($cnx);

$date = date( "Y-m-d" );
$fp = fopen( "mysql_backup/database.sql", "w" );
fwrite( $fp, "# DATABASE BACKUP " . $date . "\n\n" );
fwrite( $fp, $dump );
fclose( $fp );
</pre>
<p>The script uses the SqlExport class in order to write the dump of the table on a file, adding a comment with the current date to it. Let&#8217;s see the shell script now:</p>
<pre>
#!/bin/sh

#
# Created by Davide Cassenti <http://davide.cassenti.net>
# You can use, modify and distribute this script freely if you keep this comment lines intact.
#

CURDATE=`date +%Y-%m-%d`

# Create directories
mkdir /home/user/backup/www.yoursite.com/backup/
cd /home/user/backup/www.yoursite.com/

# Database dump
wget -q -O - http://www.yoursite.com/backupdb.php

# Enter the backup directory
cd backup

# Begin downloading files with ftp
ncftpget -R -u ftpusername -p ftppassword www.yoursite.com `pwd` /

# Return to the main directory
cd ..

# Tar and gzip the backup with the current date
tar czf $CURDATE.tgz backup
</pre>
<p>To use the script, simply modify the directories as you need, the name of the site and the ftp&#8217;s username and password. Save it, suppose in your home directory with a name such as <strong>site-backup.sh</strong> and add writing permission to the file. It would be useful to put the script in the crontab; for example, to call the script every night at midnight, modify the <strong>/etc/crontab</strong> adding the line:</p>
<pre>
0 0 * * * user /home/user/site-backup.sh
</pre>
<p>The script is pretty simple: first it creates the needed directories, if needed, then it will call the php script using wget; once done, it will begin to download files with ncftpget to the <em>backup</em> directory. At last, it tar and gzip it. The backup directory is not deleted, so that next time you run the script only the modified files will be downloaded. If you have any comment, let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://davide.cassenti.it/2008/07/20/automatic-web-site-backup/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Upload to Flickr with Python</title>
		<link>http://davide.cassenti.it/2008/07/19/upload-to-flickr-with-python/</link>
		<comments>http://davide.cassenti.it/2008/07/19/upload-to-flickr-with-python/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 15:12:40 +0000</pubDate>
		<dc:creator>Davide Cassenti</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://davide.cassenti.net/?p=20</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have found an interesting python script that allows you to upload photos from a local directory to <a href="http://www.flickr.com/">Flickr</a>; I decided to modify it and post here my modifications. The original script <a href="http://berserk.org/uploadr/">can be found here</a>.</p>
<p>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.</p>
<p>The only thing I didn&#8217;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.</p>
<p><span id="more-20"></span></p>
<p>The md5 digest is calculated by reading the content of the image file:</p>
<pre>
def uploadImage( self, image ):
	# calculate image md5
        image = str( image )
        f = open( image, 'r' )
        digestmd5 = str( md5.new( f.read() ).hexdigest() )
        f.close()

        if ( not self.uploaded.has_key( digestmd5 ) ):
            print "Uploading ", image , "...",
</pre>
<p>This digest is then used in the logUpload() function in order to save the information about the photo. The function is called if the upload is valid with a
<pre>self.logUpload( digestmd5 )</pre>
<p>. This is the new logUpload() function:</p>
<pre>
def logUpload( self, d ):
        d = str( d )
        self.uploaded[ d ] = "ok"
</pre>
<p>I&#8217;ve also changed a little thing in the upload() function: the history file is now opened and closed for each upload. This makes the script slower, I know, but in case of failure (such as a kill), we avoid the problem to have an inconsistent history file.</p>
<pre>
for image in newImages:
            self.uploaded = shelve.open( HISTORY_FILE )
            self.uploadImage( image )
            self.uploaded.close()
</pre>
<p>The script may be run using the
<pre>nohup python uploadr.py -d &#038;</pre>
<p> command or, better, by adding a new line in the crontab file to call the script every X minutes. Before using the script, you need to change the parameters at the beginning of the file, then at the first run you will be prompted to allow upload.py to access your flickr account. Here&#8217;s the configurations to change, they are pretty simple:</p>
<pre>
#
# Location to scan for new images
#
IMAGE_DIR = "/directory/with/photos/"
#
#   Flickr settings
#
FLICKR = {"title": "",
        "description": "",
        "tags": "auto-upload",
        "is_public": "0",
        "is_friend": "0",
        "is_family": "0" }
#
#   How often to check for new images to upload  (in seconds )
#
SLEEP_TIME = 60 * 60
#
#   File we keep the history of uploaded images in.
#
HISTORY_FILE = "uploadr.history"
</pre>
<p>You can <a href='http://davide.cassenti.net/wp-content/uploads/2008/07/uploadr.py.txt'>download my uploadr.py</a> script by <a href='http://davide.cassenti.net/wp-content/uploads/2008/07/uploadr.py.txt'>clicking here</a>: remember to remove the <em>.txt</em> extension to use it. If you have any comment, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://davide.cassenti.it/2008/07/19/upload-to-flickr-with-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Approach Simulator</title>
		<link>http://davide.cassenti.it/2008/07/18/approach-simulator/</link>
		<comments>http://davide.cassenti.it/2008/07/18/approach-simulator/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 12:00:02 +0000</pubDate>
		<dc:creator>Davide Cassenti</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Interestingness]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[pixel instrument]]></category>

		<guid isPermaLink="false">http://davide.cassenti.net/?p=14</guid>
		<description><![CDATA[Sometimes it is not easy to find the perfect girl; and sometimes, when we find her, we don&#8217;t know what to say. We would need to have a way to try before searching a girl in the real life: with Approach Simulator now you can!
Approach Simulator is a java game developed by me and Marco [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is not easy to find the perfect girl; and sometimes, when we find her, we don&#8217;t know what to say. We would need to have a way to try before searching a girl in the real life: with <a href="http://www.pixelinstrument.net/portfolio/oursoftware/approach/applet.php">Approach Simulator</a> now you can!</p>
<p>Approach Simulator is a java game developed by me and <a href="http://www.pixelinstrument.net/aboutus.php">Marco</a> for the Java exam at the <a href="http://www.unipv.it">University of Pavia</a>. The game has been written in few months and we gave particular attention to the programming details, while the graphic was not so well-designed; however, it is pleasant to play and, if you know italian, extremely funny.</p>
<p style="text-align:center"><a href='http://davide.cassenti.net/wp-content/uploads/2008/07/approach1.jpg'><img src="http://davide.cassenti.net/wp-content/uploads/2008/07/approach1-300x234.jpg" alt="" title="Approach Simulator\&#039;s main window" width="300" height="234" class="alignnone size-medium wp-image-15" /></a></p>
<p>In the game you will be a boy going around in order to find a girl: you can choose an <strong>Engineer</strong> (<em>Ingegnere</em>), an <strong>Artist</strong> (<em>Artista</em>), a <strong>Deejay</strong>, a <strong>Buff guy</strong> (<em>Palestrato</em>), a <strong>Rich man</strong> (<em>Riccone</em>) or a <strong>Sportsman</strong> (<em>Sportivo</em>) and begin to search a girl; you will see in the game all the people in the place you have chosen: a green circle rapresent you, while pink ones are girls and blue ones other boys.</p>
<p style="text-align:center"><a href='http://davide.cassenti.net/wp-content/uploads/2008/07/approach2.jpg'><img src="http://davide.cassenti.net/wp-content/uploads/2008/07/approach2-300x234.jpg" alt="" title="Approach simulator: in game" width="300" height="234" class="alignnone size-medium wp-image-16" /></a></p>
<p>You can use your keyboard to move around and talk with other people (you can move also sith mouse, but that was just an experiment for the exam, you cannot talk with others without the enter key); when you talk to a girl, a random <em>situation</em> will be played: the first sentence you can see depends on the type of your player, while the others depends on this situation. Actually there are just few situations in the game, all in italian, but they could be easily added.</p>
<p>When you meet a girl, you will see her kind: <strong>Easy</strong> (<em>Facile</em>), <strong>Timid</strong> (<em>Timida</em>), <strong>Intellectual</strong> (<em>LaIntellettuale</em>), <strong>Star</strong> (<em>Diva</em>) or <strong>Yokel</strong> (<em>Buzzurra</em>); you must be careful and choose the right sentence for the girl depending on her kind. And remember: when you talk with a girl, she may be bored and go away! Before she does so, you need to try to conquer her: once tried, you will tell her the last sentence, depending on your kind, and you will see if she wants you or not.</p>
<p>So, you <strong>want to try the game</strong>? It is pretty simple: first of all, you need <a href="http://www.java.com/">Java</a> installed on your system; once you have it, <a href="http://www.pixelinstrument.net/portfolio/oursoftware/approach/applet.php">click here to begin the game</a>. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://davide.cassenti.it/2008/07/18/approach-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
