<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Flavio Castelli</title>
	
	<link>http://flavio.castelli.name</link>
	<description>debugging my life</description>
	<lastBuildDate>Fri, 20 Jan 2012 08:27:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/FlavioCastelli" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="flaviocastelli" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Introducing dister, a Heroku like solution for SUSE Studio</title>
		<link>http://flavio.castelli.name/introducing-dister-a-heroku-like-solution-for-suse-studio</link>
		<comments>http://flavio.castelli.name/introducing-dister-a-heroku-like-solution-for-suse-studio#comments</comments>
		<pubDate>Tue, 29 Mar 2011 14:39:21 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[openSUSE]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[suse studio]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=353</guid>
		<description><![CDATA[SUSE Studio is  an awesome tool, with a couple of clicks you can create an openSUSE/SUSE based system and deploy to your hard drive, an usb flash,  a live dvd, a VMware/VirtualBox/Xen server and even Amazon EC2 cloud. Suppose you want to create a tailored SUSE Studio appliance to run a Ruby on Rails app, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://susestudio.com" target="_blank">SUSE Studio</a> is  an awesome tool, with a couple of clicks you can create an openSUSE/SUSE based system and deploy to your hard drive, an usb flash,  a live dvd, a VMware/VirtualBox/Xen server and even Amazon EC2 cloud.</p>
<p>Suppose you want to create a tailored SUSE Studio appliance to run a Ruby on Rails app, this is a list of things you have to take care of:</p>
<ul>
<li>install all the gems required by the app (this can be a long list).</li>
<li>install and configure the database used by the app.</li>
<li>install and configure a webserver.</li>
<li>ensure all the required services are started at boot time.</li>
</ul>
<p>You can save some time by cloning <a href="http://susegallery.com/a/CZ0T0D/rails-in-a-box" target="_blank">this</a> appliance shared on <a href="http://susegallery.com/" target="_blank">SUSE Gallery</a>, but this is still going to be boring.</p>
<h2>Dister to the rescue!</h2>
<p>Dister is a command line tool similar to the one used by <a href="http://heroku.com" target="_blank">Heroku</a> (one of the coolest ways to run your Rails app into the cloud). Within a few steps you will be able to create a SUSE Studio appliance running your rails application, download it and deploy wherever you want.</p>
<p>Dister is named after SUSE Studio robot. It has been created by  <a href="http://opensuse.blip.tv/file/4678185/" target="_blank">Dominik Mayer</a> and me during the latest <a href="http://en.opensuse.org/Portal:Hackweek" target="_blank">hackweek</a>.</p>
<h2>How it works</h2>
<p>We are going to create a SUSE Studio appliance running a rails application called <em>&#8220;SUSE history&#8221;</em>. The app uses <a href="http://gembundler.com/" target="_blank">bundler</a> to handle its dependencies.<br />
This is its Gemfile file:</p>
<pre name="code" class="ruby:nocontrols">
﻿﻿source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'pg'
gem "flutie", "~&gt; 1.1"
</pre>
<p>As you can see the app uses rails3, the <a href="https://github.com/thoughtbot/flutie" target="_blank">flutie</a> gem and PostgreSQL as database.</p>
<h3>Appliance creation</h3>
<p>Move into the suse_history directory and execute the following command:</p>
<pre name="code" class="bash:nocontrols">
dister create suse_history
</pre>
<p><div id="attachment_361" class="wp-caption aligncenter" style="width: 635px"><a href="http://flavio.castelli.name/wp-content/uploads/2011/03/create.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/create.png" alt="dister create" title="dister create" width="625" height="213" class="size-full wp-image-361" /></a><p class="wp-caption-text">Creating a SUSE Studio appliance with dister</p></div><br />
As you can see dister has already done a couple of things for you:</p>
<ul>
<li>created an appliance using latest version of openSUSE supported by SUSE Studio (you can use a different base system of course)</li>
<li>added the <em>devel:language:ruby:extensions</em> repository to the appliance:  this repo contains tons of ruby packages (like <em>mod_passenger</em>)</li>
<li>installed a couple of things:
<ul>
<li><em>devel_C_C++</em> pattern: this will allow you to build native gems.
<li><em>devel_ruby</em> pattern: provides ruby, rubygems and a couple of development packages needed to build native gems.</li>
<li><em>rubygem-bundler</em>: bundler is required by dister in order to handle the dependencies of your rails application.</li>
<li><em>rubygem-passenger-apache2</em>: dister uses <a href="http://www.modrails.com/" target="_blank">passenger</a> and apache2 to deploy your rails application.</li>
<li><em>postgresql-server</em>: dister noticed suse_history uses PostgreSQL as database, hence it automatically installs it.</li>
<li><em>rubygem-pg</em>: dister noticed suse_history uses PostgreSQL as database, hence it automatically installs the ruby&#8217;s library forPostgreSQL.</li>
</ul>
</li>
<li>uploaded a custom build script which ensures:
<ul>
<li>mod_passenger module is loaded by Apache</li>
<li>both Apache and PostgreSQL are always started at boot time.</li>
<li>all dependencies are installed: this is done only during the first boot using bundler.</li>
<li>the database user required by your rails app is created. This is done only during the first boot using some SQL code.</li>
<li>the database used by the appliance is properly initialized (aka <em>rails db:create db:migrate</em>). This is done only during the first boot.</li>
</ul>
</li>
</ul>
<h3>Upload your code</h3>
<p>It&#8217;s time to upload suse_history code. This is done using the following command:</p>
<pre name="code" class="bash:nocontrols">
dister push
</pre>
<p><a href="http://flavio.castelli.name/wp-content/uploads/2011/03/push.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/push.png" alt="dister push output" title="dister push" width="770" height="1016" class="aligncenter size-full wp-image-366" /></a><br />
As you can see dister packaged the application source code and all its dependencies into a single archive. Then uploaded the archive to SUSE Studio as an overlay file. Dister uploaded also the configuration files required by Apache and by PostgreSQL setup.</p>
<h3>Build your appliance</h3>
<p>It&#8217;s build time!</p>
<pre name="code" class="bash:nocontrols">
dister build
</pre>
<p><a href="http://flavio.castelli.name/wp-content/uploads/2011/03/build.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/build.png" alt="dister build" title="dister build" width="1275" height="84" class="aligncenter size-full wp-image-370" /></a><br />
The appliance has automatically being built using the <em>raw disk</em>. You can use different formats of course.</p>
<h3>Testdrive</h3>
<p>Testdrive is one of the coolest features of SUSE Studio. Unfortunately dister doesn&#8217;t support it yet. Just visit your appliance page and start testdrive from your browser.<br />
Just enable testdrive networking and connect to your appliance:<br />
<a href="http://flavio.castelli.name/wp-content/uploads/2011/03/testdrive.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/testdrive.png" alt="suse history running inside of testdrive" title="suse history running inside of testdrive" width="720" height="865" class="aligncenter size-full wp-image-374" /></a></p>
<h3>Download</h3>
<p>Your appliance is working flawlessly. Download it and deploy it wherever you want.</p>
<pre name="code" class="bash:nocontrols">
dister download
</pre>
<h2>Current status</h2>
<p>As you can see dister handles pretty fine a simple Rails application, but there&#8217;s still room for improvements.</p>
<p>Here&#8217;s a small list of the things on my TODO list:</p>
<ul>
<li>The dependency management should install gems using rpm packages. This would make the installation of native gems easier, right now the user has to manually add all the development libraries required by the gem. Moreover it would reduce the size of the overlay files uploaded to SUSE Studio.</li>
<li>SUSE Studio Testdrive should be supported.</li>
<li>It should be possible to deploy the SUSE Studio directly to EC2.</li>
<li>Fix bugs!</li>
</ul>
<p>Bugs and enhancements are going to be tracked <a target="_blank" href="https://github.com/flavio/dister/issues">here</a>. </p>
<h2>Contribute</h2>
<p>Dister code can be found here on <a target="_blank" href="https://github.com/flavio/dister">github</a>, fork it and start contributing.</p>
<p>If you are a student you can work on dister during the next <a target="_blank" href="http://en.opensuse.org/openSUSE:GSOC_2011_Ideas#Heroku_like_solution_for_SUSE_Studio">Google Summer of code</a>, apply now!</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/introducing-dister-a-heroku-like-solution-for-suse-studio/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jump: a bookmarking system for the bash shell</title>
		<link>http://flavio.castelli.name/jump</link>
		<comments>http://flavio.castelli.name/jump#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:29:29 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=335</guid>
		<description><![CDATA[Let me introduce a small project I&#8217;ve been working on with a friend of mine, Giuseppe Capizzi. The project is called jump and ﻿allows you to quickly change directories in the bash shell using bookmarks. Thanks to Jump, you won&#8217;t have to type those long paths anymore. You can find jump&#8217;s source code, detailed documentation and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flavio.castelli.name/wp-content/uploads/2010/08/van-halen-jump.jpeg" rel="lightbox[335]"></a>Let me introduce a small project I&#8217;ve been working on with a friend of mine, <a href="http://twitter.com/gcapizzi" target="_blank">Giuseppe Capizzi</a>. The project is called <strong>jump</strong> and ﻿allows you to quickly change directories in the bash shell using bookmarks.</p>
<p>Thanks to Jump, you won&#8217;t have to type those long paths anymore.</p>
<p style="text-align: center;"><a href="http://flavio.castelli.name/wp-content/uploads/2010/08/van-halen-jump.jpeg" rel="lightbox[335]"><img class="aligncenter" title="van-halen-jump" src="http://flavio.castelli.name/wp-content/uploads/2010/08/van-halen-jump-300x222.jpg" alt="" width="300" height="222" /></a></p>
<p>You can find jump&#8217;s source code, detailed documentation and installation instructions <a href="http://github.com/flavio/jump" target="_blank">here</a>.</p>
<p>SUSE packages can be found <a href="http://software.opensuse.org/search?baseproject=ALL&amp;p=1&amp;q=rubygem-jump" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/jump/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Fast user switch plasmoid improvements</title>
		<link>http://flavio.castelli.name/fast-user-switch-plasmoid-improvements</link>
		<comments>http://flavio.castelli.name/fast-user-switch-plasmoid-improvements#comments</comments>
		<pubDate>Fri, 23 Jul 2010 22:32:31 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=320</guid>
		<description><![CDATA[Just a quick note, I released a new version of the fastuserswitch plasmoid. This new release implements all the improvements suggested by the users plus some minor fixes. Code can be downloaded from here. openSUSE packages are already available on the build service. These are some screenshots illustrating fastuserswitch&#8217;s new features.]]></description>
			<content:encoded><![CDATA[<p>Just a quick note, I released a new version of the fastuserswitch plasmoid. This new release implements all the improvements suggested by the users plus some minor fixes.</p>
<p>Code can be downloaded from <a href="http://gitorious.org/fast_user_switch" target="_blank">here</a>. openSUSE packages are already available on the <a href="http://software.opensuse.org/search?q=plasmoid-fastuserswitch&amp;baseproject=ALL&amp;lang=en&amp;exclude_debug=true" target="_blank">build service</a>.</p>
<p>These are some screenshots illustrating fastuserswitch&#8217;s new features.</p>

<a href='http://flavio.castelli.name/fast-user-switch-plasmoid-improvements/fastuserswitch01-2' title='fastuserswitch01'><img width="150" height="144" src="http://flavio.castelli.name/wp-content/uploads/2010/07/fastuserswitch011-150x144.png" class="attachment-thumbnail" alt="fastuserswitch01" title="fastuserswitch01" /></a>
<a href='http://flavio.castelli.name/fast-user-switch-plasmoid-improvements/fastuserswitch02-2' title='fastuserswitch02'><img width="150" height="150" src="http://flavio.castelli.name/wp-content/uploads/2010/07/fastuserswitch021-150x150.png" class="attachment-thumbnail" alt="fastuserswitch02" title="fastuserswitch02" /></a>
<a href='http://flavio.castelli.name/fast-user-switch-plasmoid-improvements/fastuserswitch03' title='fastuserswitch03'><img width="150" height="150" src="http://flavio.castelli.name/wp-content/uploads/2010/07/fastuserswitch03-150x150.png" class="attachment-thumbnail" alt="fastuserswitch03" title="fastuserswitch03" /></a>

]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/fast-user-switch-plasmoid-improvements/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Fast user switch plasmoid</title>
		<link>http://flavio.castelli.name/fast-user-switch-plasmoid</link>
		<comments>http://flavio.castelli.name/fast-user-switch-plasmoid#comments</comments>
		<pubDate>Thu, 15 Jul 2010 06:23:11 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[plasma]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=307</guid>
		<description><![CDATA[Last week my mother in law started to share her Linux laptop with my wife. Suddenly my wife asked me how she could switch from one user session to another. She was looking for something similar to OS X fast user switch feature but she couldn&#8217;t find it. In fact there wasn&#8217;t a fast and [...]]]></description>
			<content:encoded><![CDATA[<p>Last week my mother in law started to share her Linux laptop with my wife. Suddenly my wife asked me how she could switch from one user session to another. She was looking for something similar to <a href="http://bit.ly/auzc56" target="_blank">OS X fast user switch</a> feature but she couldn&#8217;t find it. In fact there wasn&#8217;t a fast and easy way to switch between users&#8217; sessions with KDE, until&#8230; now <img src='http://flavio.castelli.name/wp-content/plugins/smilies-themer/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<p>Let me introduce my first plasmoid: the fast user switch plasmoid. It&#8217;s a simple icon in the panel that allows users to swich to another open session or to open a new login page. Here you can see the mandatory screenshots.</p>

<a href='http://flavio.castelli.name/fast-user-switch-plasmoid/fastuserswitch01' title='fastuserswitch01'><img width="150" height="150" src="http://flavio.castelli.name/wp-content/uploads/2010/07/fastuserswitch01-150x150.png" class="attachment-thumbnail" alt="fastuserswitch01" title="fastuserswitch01" /></a>
<a href='http://flavio.castelli.name/fast-user-switch-plasmoid/fastuserswitch02' title='fastuserswitch02'><img width="150" height="150" src="http://flavio.castelli.name/wp-content/uploads/2010/07/fastuserswitch02-150x150.png" class="attachment-thumbnail" alt="fastuserswitch02" title="fastuserswitch02" /></a>

<p>You can find the source code <a href="http://gitorious.org/fast_user_switch#more" target="_blank">here</a>. Binary packages for openSUSE are already available on the <a href="http://software.opensuse.org/search?q=plasmoid-fastuserswitch&amp;baseproject=ALL&amp;lang=en&amp;exclude_debug=true" target="_blank">build service</a>.</p>
<h2>One last thought about KDM</h2>
<p>I think that KDM should allow to switch back to an already open session in a more transparent way. Right now if an user has already one session open, he goes back to the login screen and enters his credentials a <strong>new </strong> session is started. I think that most users would expect to be switched back to their already running session. Starting a new session is just confusing for them.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/fast-user-switch-plasmoid/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>QJson and Symbian</title>
		<link>http://flavio.castelli.name/qjson-symbian</link>
		<comments>http://flavio.castelli.name/qjson-symbian#comments</comments>
		<pubDate>Sat, 13 Mar 2010 23:55:51 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[qjson]]></category>
		<category><![CDATA[symbian]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=288</guid>
		<description><![CDATA[I&#8217;m really pleased to announce that latest version of QJson on master is working on Symbian. You can find the installation instruction here. Since I&#8217;m not a Symbian developer it has been a little hard for me to achieve that. I would like to thank Antti Luoma for his help. There are also good news [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really pleased to announce that latest version of QJson on master is working on Symbian. You can find the installation instruction <a href="http://qjson.sourceforge.net/get_it/symbian.html" target="_blank">here</a>.</p>
<p>Since I&#8217;m not a Symbian developer it has been a little hard for me to achieve that. I would like to thank <a href="http://gitorious.org/~anluoma" target="_blank">Antti Luoma</a> for his help.</p>
<p>There are also good news for Windows developers: now building QJson under Windows is easier. Checkout the new <a href="http://qjson.sourceforge.net/get_it/windows.html" target="_blank">installation instruction page</a>.</p>
<p>I hope this will help all the Windows developers who want to use QJson.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/qjson-symbian/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>QJson code moves to gitorious</title>
		<link>http://flavio.castelli.name/qjson-code-moves-to-gitorious</link>
		<comments>http://flavio.castelli.name/qjson-code-moves-to-gitorious#comments</comments>
		<pubDate>Sat, 05 Dec 2009 15:48:25 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[qjson]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=285</guid>
		<description><![CDATA[Just a quick note: I have just moved QJson source code to this git repository hosted by gitorious. I&#8217;ll keep the code on KDE&#8217;s svn synchronized with the git repository.]]></description>
			<content:encoded><![CDATA[<p>Just a quick note: I have just moved QJson source code to <a href="http://gitorious.org/qjson" target="_blank">this</a> git repository hosted by gitorious.</p>
<p>I&#8217;ll keep the code on KDE&#8217;s svn synchronized with the git repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/qjson-code-moves-to-gitorious/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>QJson: from QObject to JSON and vice-versa</title>
		<link>http://flavio.castelli.name/qjson-qobject-serialization-deserialization</link>
		<comments>http://flavio.castelli.name/qjson-qobject-serialization-deserialization#comments</comments>
		<pubDate>Fri, 04 Dec 2009 00:07:48 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[qjson]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=273</guid>
		<description><![CDATA[Some days ago I introduced the possibility to serialize a QObject instance to JSON. Today I&#8217;m going to show you the opposite operation: initializing a QObject using a JSON object. I refactored a bit my latest changes: I created a new class called QObjectHelper that provides the methods required to convert a QObject instance to [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I introduced the possibility to serialize a QObject instance to JSON. Today I&#8217;m going to show you the opposite operation: initializing a QObject using a JSON object.</p>
<p>I refactored a bit my latest changes: I created a new class called QObjectHelper that provides the methods required to convert a QObject instance to a QVariantMap and vice-versa.</p>
<p>This class can be used in conjunction with the Serializer and Parser classes to serialize and deserialize QObject instances to and from JSON.</p>
<p>Let me show a quick example, suppose the declaration of Person class looks like this:</p>
<pre name="code" class="cpp:nocontrols">
class Person : public QObject
{
  Q_OBJECT

  Q_PROPERTY(QString name READ name WRITE setName)
  Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber)
  Q_PROPERTY(Gender gender READ gender WRITE setGender)
  Q_PROPERTY(QDate dob READ dob WRITE setDob)
  Q_ENUMS(Gender)

public:
    Person(QObject* parent = 0);
    ~Person();

    QString name() const;
    void setName(const QString&amp; name);

    int phoneNumber() const;
    void setPhoneNumber(const int  phoneNumber);

    enum Gender {Male, Female};
    void setGender(Gender gender);
    Gender gender() const;

    QDate dob() const;
    void setDob(const QDate&amp; dob);

  private:
    QString m_name;
    int m_phoneNumber;
    Gender m_gender;
    QDate m_dob;
};</pre>
<h3>From QObject to JSON</h3>
<p>The following code will serialize an instance of Person to JSON :</p>
<pre name="code" class="cpp:nocontrols">
Person person;
person.setName("Flavio");
person.setPhoneNumber(123456);
person.setGender(Person::Male);
person.setDob(QDate(1982, 7, 12));

QVariantMap variant = QObjectHelper::qobject2qvariant(&#038;person);
Serializer serializer;
qDebug() << serializer.serialize( variant);
</pre>
<p>The generated output will be:</p>
<pre name="code" class="cpp:nocontrols">
{ "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 }
</pre>
<h3>From JSON to QObject</h3>
<p>Suppose you have the following JSON data stored into a QString: </p>
<pre name="code" class="cpp:nocontrols">
{ "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 }
</pre>
<p> The following code will initialize an already allocated instance of Person using the JSON values: </p>
<pre name="code" class="cpp:nocontrols">
Parser parser;
QVariant variant = parser.parse(json);

Person person;
QObjectHelper::qvariant2qobject(variant.toMap(), &#038;person);
</pre>
<h3>A new release</h3>
<p>These changes have been included inside the new release of QJson: 0.7.0.</p>
<p>Packages for openSUSE are building right now.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/qjson-qobject-serialization-deserialization/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>QJson: easier serialization of QObject instances to JSON</title>
		<link>http://flavio.castelli.name/qjson-easier-serialization-of-qobject-instances-to-json</link>
		<comments>http://flavio.castelli.name/qjson-easier-serialization-of-qobject-instances-to-json#comments</comments>
		<pubDate>Mon, 30 Nov 2009 19:20:58 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[qjson]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=263</guid>
		<description><![CDATA[I have just committed into trunk a couple of changes that make easier to serialize a QObject instance to JSON. This solution relies on the awesome Qt&#8217;s property system. Suppose the declaration of Person class looks like this: class Person : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(int phoneNumber READ phoneNumber [...]]]></description>
			<content:encoded><![CDATA[<p>I have just committed into trunk a couple of changes that make easier to serialize a QObject instance to JSON.</p>
<p>This solution relies on the awesome <a href="http://doc.trolltech.com/latest/properties.html" target="_blank">Qt&#8217;s property system</a>.</p>
<p>Suppose the declaration of Person class looks like this:</p>
<pre name="code" class="cpp:nocontrols">
class Person : public QObject
{
  Q_OBJECT

  Q_PROPERTY(QString name READ name WRITE setName)
  Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber)
  Q_PROPERTY(Gender gender READ gender WRITE setGender)
  Q_PROPERTY(QDate dob READ dob WRITE setDob)
  Q_ENUMS(Gender)

public:
    Person(QObject* parent = 0);
    ~Person();

    QString name() const;
    void setName(const QString&amp; name);

    int phoneNumber() const;
    void setPhoneNumber(const int  phoneNumber);

    enum Gender {Male, Female};
    void setGender(Gender gender);
    Gender gender() const;

    QDate dob() const;
    void setDob(const QDate&amp; dob);

  private:
    QString m_name;
    int m_phoneNumber;
    Gender m_gender;
    QDate m_dob;
};</pre>
<p>The following code will serialize an instance of Person to JSON:</p>
<pre name="code" class="cpp:nocontrols">
Person person;
person.setName("Flavio");
person.setPhoneNumber(123456);
person.setGender(Person::Male);
person.setDob(QDate(1982, 7, 12));

Serializer serializer;
qDebug() << serializer.serialize( &#038;person);
</pre>
<p>The generated output will be:</p>
<pre name="code" class="cpp:nocontrols">
{ "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 }
</pre>
<p>I hope you will find this new feature useful. I'm also considering to create a similar method inside the Parser class.</p>
<p>As usual suggestions are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/qjson-easier-serialization-of-qobject-instances-to-json/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>kaveau updates</title>
		<link>http://flavio.castelli.name/kaveau-updates</link>
		<comments>http://flavio.castelli.name/kaveau-updates#comments</comments>
		<pubDate>Mon, 14 Sep 2009 22:38:54 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kaveau]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=237</guid>
		<description><![CDATA[Some weeks have passed since the announcement of kaveau. I&#8217;m really proud and happy about this project because I received a lot of positive feedback messages and it has been chosen as one of the best Hackweek&#8217;s projects. In the meantime I kept working on kaveau, so let me show you what has changed: rdiff-backup [...]]]></description>
			<content:encoded><![CDATA[<p>Some weeks have passed since the announcement of kaveau. I&#8217;m really proud and happy about this project because I received a lot of positive feedback messages and it has been chosen as one of the best Hackweek&#8217;s projects.</p>
<p>In the meantime I kept working on kaveau, so let me show you what has changed:</p>
<ul>
<li><a href="http://rdiff-backup.nongnu.org/" target="_blank">rdiff-backup</a> has been replaced by <a href="http://www.samba.org/rsync/" target="_blank">rsync</a>.</li>
<li>the setup wizard has been improved according to the feedback messages I received.</li>
<li>old backups are now automatically removed.</li>
<li>the code has been refactored a lot.</li>
</ul>
<h3>The switch to rsync</h3>
<p>Previously kaveau used rdiff-backup as backup back-end. rdiff-backup is a great program but unfortunately it relies on the outdated <a href="http://librsync.sourceforge.net/" target="_blank">librsync</a> library. The latest release of librsync is dated 2004. It has a couple of serious bugs still open and, while rsync has reached version three, this library is still stuck at version one.</p>
<p>These are the reasons of the switch from rdiff-backup to rsync. This choice breaks the compatibility with the previous backups but it introduces a lot of advantages.<br />
One of the most important improvements brought by the adoption of rsync is an easier restore procedure: now <strong>all</strong> the backups can be accessed using a standard file manager, while previously rdiff-backup was needed to access the old backups.</p>
<h4>Backup directory structure</h4>
<p>On the backup device everything is saved under the <em>kaveau</em>/<em>hostname</em>/<em>username</em> path.</p>
<p>The directory will have a similar structure:</p>
<pre class="bash:nocontrols">drwxr-xr-x 3 flavio users 4096 2009-09-12 18:50 2009-09-12T18:50:19
drwxr-xr-x 3 flavio users 4096 2009-09-14 23:07 2009-09-14T23:07:46
drwxr-xr-x 3 flavio users 4096 2009-09-14 23:30 2009-09-14T23:30:36
lrwxrwxrwx 1 flavio users   19 2009-09-14 23:30 current -&gt; 2009-09-14T23:30:36</pre>
<p>As you can see there&#8217;s one directory per backup, plus a symlink called <em>current</em> pointing to the latest backup.</p>
<h3>Old backup deletion</h3>
<p>Nowadays big external storage devices are pretty cheap, but it&#8217;s always good to save some disk space.<br />
Now kaveau keeps:</p>
<ul>
<li>hourly backups for the past 24 hours.</li>
<li>daily backups for the past month.</li>
<li>weekly backups until the external disk is full.</li>
</ul>
<p>Thanks to hard links&#8217; magic, old backups can be deleted without causing damages to the other ones.</p>
<h3>Plans for the future</h3>
<p>Before starting to work on the restore user interface I will spend some time figuring out how to add support for network devices.</p>
<p>A lot of users requested this feature, hence I want to make them happy <img src='http://flavio.castelli.name/wp-content/plugins/smilies-themer/tango/face-smile.png' alt=':)' class='wp-smiley' /> .</p>
<p>I&#8217;m planning to use <a href="http://avahi.org/" target="_blank">avahi</a> to discover network shares (nfs, samba) or network machines running ssh and use them as backup devices. Honestly, I want to achieve something similar to <a href="http://www.apple.com/timecapsule/" target="_blank">Apple&#8217;s time capsule</a>.</p>
<p>As usual, feedback messages are really appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/kaveau-updates/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Using QJson under Windows</title>
		<link>http://flavio.castelli.name/using-qjson-under-windows</link>
		<comments>http://flavio.castelli.name/using-qjson-under-windows#comments</comments>
		<pubDate>Fri, 04 Sep 2009 12:44:42 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[qjson]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=228</guid>
		<description><![CDATA[Recently lots of people asked me how to build QJson under Windows. Most of them reported build/link errors, so I decided to try personally. The good news is that QJson can be successfully built under Window, I can show you proof I have written the build instructions on QJson website: just take a look here. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently lots of people asked me how to build QJson under Windows. Most of them reported build/link errors, so I decided to try personally.</p>
<p>The good news is that QJson can be successfully built under Window, I can show you proof <img src='http://flavio.castelli.name/wp-content/plugins/smilies-themer/tango/face-wink.png' alt=';)' class='wp-smiley' /> </p>

<a href='http://flavio.castelli.name/using-qjson-under-windows/qjson_windows_1' title='QJson unit test'><img width="150" height="150" src="http://flavio.castelli.name/wp-content/uploads/2009/09/qjson_windows_1-150x150.png" class="attachment-thumbnail" alt="QJson unit test" title="QJson unit test" /></a>
<a href='http://flavio.castelli.name/using-qjson-under-windows/qjson_windows_2' title='Building completed'><img width="150" height="150" src="http://flavio.castelli.name/wp-content/uploads/2009/09/qjson_windows_2-150x150.png" class="attachment-thumbnail" alt="Building completed" title="Building completed" /></a>

<p>I have written the build instructions on QJson website: just take a look <a href="http://qjson.sourceforge.net/download.html#windows" target="_blank">here</a>.</p>
<p>One last note: if you have problems with QJson please subscribe to the <a href="https://lists.sourceforge.net/lists/listinfo/qjson-devel" target="_blank">developer mailing list</a> and post a message.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/using-qjson-under-windows/feed</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>

