<?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>Andreas Happe &#187; Software Development</title>
	<atom:link href="http://snikt.net/index.php/category/computer-stuff/programming-stuff/feed" rel="self" type="application/rss+xml" />
	<link>http://snikt.net</link>
	<description>Vi veri ueniversum vivus vici</description>
	<lastBuildDate>Wed, 10 Mar 2010 14:22:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generating PDFs from Ruby on Rails</title>
		<link>http://snikt.net/index.php/2010/03/03/generating-pdfs-from-ruby-on-rails</link>
		<comments>http://snikt.net/index.php/2010/03/03/generating-pdfs-from-ruby-on-rails#comments</comments>
		<pubDate>Wed, 03 Mar 2010 12:25:45 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[adobe pdf]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[prawn]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[wicked_pdf]]></category>
		<category><![CDATA[wkthmltopdf]]></category>

		<guid isPermaLink="false">http://snikt.net/?p=491</guid>
		<description><![CDATA[The problem
Ruby on Rails provides various helpers for generating dynamic web content but sometimes you need documents that users can easily store and share between them. The ubiquitous file format for this is Adobe PDF nowadays.
The common solution fro this problem is Prawn [github, introduction]. Alas it requires a custom DSL for document description, no existing Rails [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<h2>The problem</h2>
<p><a href="http://rubyonrails.org/">Ruby on Rails</a> provides various helpers for generating dynamic web content but sometimes you need documents that users can easily store and share between them. The ubiquitous file format for this is <a href="http://en.wikipedia.org/wiki/Adobe_PDF">Adobe PDF</a> nowadays.</p>
<p>The common solution fro this problem is Prawn [<a href="http://wiki.github.com/sandal/prawn/">github</a>, <a href="http://railscasts.com/episodes/153-pdfs-with-prawn">introduction</a>]. Alas it requires a custom DSL for document description, no existing Rails views or partials can be reused. An alternative is <a href="http://www.princexml.com/">princeXML</a> which transforms HTML/CSS into pdf through an external binary. This would allow reuse of existing templates and knowledge (think CSS designers) but has the downside of its price tag of $3800.</p>
<h2>The solution</h2>
<p>Enters <a href="http://github.com/mileszs/wicked_pdf">wicked_pdf</a>: it utilizes <a href="http://code.google.com/p/wkhtmltopdf/">wkhtmltopdf</a> to create a PDF document from a Rails HTML template. HTML rendering is done through the well-known webkit-engine. This allows developers to do PDFs in the right way™: define the document&#8217;s structure through a simple HTML document and theme them through CSS. You&#8217;ll get the automatic benefit of themability: exchange the CSS and you have another format. There are also lots of CSS artists out there that can supply you with different designs.</p>
<p><span id="more-491"></span></p>
<p>I&#8217;ve used this solution with a test Ruby on Rails 3.0-beta application, the steps involved were:</p>
<h3>Install <em>wkhtmltopdf:</em></h3>
<p><strong><span style="font-weight: normal; font-size: 13px;">This program will convert the HTML into the PDF format. To make it work you&#8217;ll need at least version 0.9 which isn&#8217;t installed in Ubuntu 9.10 by default. Just download the <a href="http://code.google.com/p/wkhtmltopdf/downloads/list">static compiled version</a> from the <a href="http://code.google.com/p/wkhtmltopdf/downloads/list">wkhtmltopdf website</a> and place it under <em>/usr/local/bin</em>. </span></strong></p>
<h3>Install the wicked_pdf plugin:</h3>
<p>Just install it in the usual Rails way:</p>
<pre>git submodule add ﻿git://github.com/mileszs/wicked_pdf.git vendor/plugins/wicked_pdf</pre>
<p>Additionally a sample configuration file is needed. You could use the plugin&#8217;s generator script for it but alas this didn&#8217;t work for me with Rails 3.0. Let&#8217;s just copy it form the plugin&#8217;s directory into config/initializers.</p>
<pre>$ cp vendor/plugins/wicked_pdf/generators/wicked_pdf/templates/wicked_pdf.rb config/initializers</pre>
<p>and alter the wkhtmltopdf path within it:</p>
<pre>  WICKED_PDF = {
       :exe_path =&gt; '/usr/local/bin/wkhtmltopdf-amd64'
  }</pre>
<h3>﻿﻿Add pdf instructions to your controller..</h3>
<p>For example I&#8217;m using the <em>invoice#index</em> action to render a simple PDF document.</p>
<pre>  format.pdf do
          @example_text = "some text"
          render :pdf =&gt; "file_name",
                 :template =&gt; 'offers/show.pdf.erb',
                 :layout =&gt; 'pdf',
                 :footer =&gt; {
                    :center =&gt; "Center",
                    :left =&gt; "Left",
                    :right =&gt; "Right"
                 }
  end</pre>
<p>We are rendering the view with a predefined footer containing some sample &#8220;center&#8221;, &#8220;left&#8221; and &#8220;right&#8221; strings. The <em>render :pdf</em> call has various options which can be seen on the wicked_pdf homepage.</p>
<h3>.. and create PDF templates</h3>
<p>The other half of the PDF templates is the view code consisting of a special layout and template for pdf generation.</p>
<p>The layout (<em>app/views/layouts/pdf.html.erb</em>) resembles a normal Ruby on Rails layout file:</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
    &lt;%= wicked_pdf_stylesheet_link_tag "pdf" %&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="content"&gt;
      &lt;%= yield %&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>The view code should not be too surprising, just place it under <em>app/views/offers/index.pdf.erb</em> :</p>
<pre>&lt;div id="someid"&gt;&lt;%= @example_text %&gt;&lt;/div&gt;</pre>
<p>Lets also create a simple CSS file (<span style="font-style: normal;"><em>public/stylesheets/pdf.css</em></span><span style="font-style: normal;">):</span></p>
<pre>#someid {
  margin-left: 430px;
  display: float;
  height: 150px;
  background-color: green;
  width: 250px;
}</pre>
<p><span style="font-style: normal;"> </span></p>
<p>This is the whole rendering code.</p>
<h3>Reference the PDF view and download it</h3>
<p><span style="font-style: normal;">We still need a reference to the newly created rendernig link, we can easily create this through:</span></p>
<pre><span style="font-style: normal;">link_to 'Create PDF document', invoice_path(@invoice, :format =&gt; :pdf)</span></pre>
<p><span style="font-style: normal;">When the link is clicked a pdf document will be generated and downloaded.</span></p>
<h2>Conclusion</h2>
<p>wicked_pdf allows easy pdf generation in a very Ruby on Rails&#8217; way. It&#8217;s free, it works and is easy to employ..</p>
<p><span style="font-style: normal;">..but not everything is perfect within the wicked_pdf world, especially error handlnig is lacking sometimes. When you&#8217;ve debugging initial problems you can expect the only error feedback to be a HTTP return code of 406. Just start with limited controller (rendering) options and double check that you&#8217;ve referenced the right view and layout paths and you should be fine.</span></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2010/03/03/generating-pdfs-from-ruby-on-rails/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SECOQC: We&#8217;ve done it</title>
		<link>http://snikt.net/index.php/2008/10/12/secoqc-weve-done-it</link>
		<comments>http://snikt.net/index.php/2008/10/12/secoqc-weve-done-it#comments</comments>
		<pubDate>Sun, 12 Oct 2008 19:01:34 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/?p=294</guid>
		<description><![CDATA[Over the last one and a half years I&#8217;ve been involved with the SECOQC project. It&#8217;s goal was to provide a prototype of a quantum key distribution network. Such a system would provide unconditional security, thus wouldn&#8217;t be isn&#8217;t vulnerable to improvements in computing power as traditional cryptography.
The final presentation of the prototype happened this [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Over the last one and a half years I&#8217;ve been involved with the <a href="http://www.secoqc.net">SECOQC</a> project. It&#8217;s goal was to provide a prototype of a quantum key distribution network. Such a system would provide unconditional security, thus <span style="text-decoration: line-through;">wouldn&#8217;t be</span> isn&#8217;t vulnerable to improvements in computing power as traditional cryptography.</p>
<p>The final presentation of the prototype happened this Wednesday. The last days and nights before that were filled with applying the last fixed but finally it was worth the time. But let the newspapers do the talking: <a href="http://futurezone.orf.at/it/stories/311988/">orf</a>, <a href="http://www.heise.de/newsticker/Erstes-Quantenkryptographie-Netz-in-Wien--/meldung/117082">heise</a>, <a href="http://derstandard.at/?id=1220460265474">der standard</a>, <a href="http://newsticker.sueddeutsche.de/list/id/213783">sueddeutsche</a>, <a href="http://www.telekom-presse.at/channel_computing/news_34403.html">Austrian Telekom News</a>. There was quite good news coverage in german-speaking Europe (and some eastern europe countries) but sadly the news didn&#8217;t seem to have jumped over the pond (at least some American physicists were at the presentation so it got noticed anyway).</p>
<p>Feels strange to know that something that big and cutting-edge is finally successfully finished.. and that I&#8217;m an unemployed student agai</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2008/10/12/secoqc-weve-done-it/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails vs. Java part2</title>
		<link>http://snikt.net/index.php/2008/02/24/ruby-on-rails-vs-java-part2</link>
		<comments>http://snikt.net/index.php/2008/02/24/ruby-on-rails-vs-java-part2#comments</comments>
		<pubDate>Sun, 24 Feb 2008 15:07:00 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2008/02/24/ruby-on-rails-vs-java-part2</guid>
		<description><![CDATA[As mentioned in part 1 my task is implementing a mail and campaigning module. I started out with a pure Ruby on Rails application and moved to a mixed Java/Rails applications as Ruby&#8217;s communication libraries where just lacking mandatory features. I choose Java/Hibernate/Spring as the combination should provide me with most needed features through an [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>As mentioned in part 1 my task is implementing a mail and campaigning module. I started out with a pure Ruby on Rails application and moved to a mixed Java/Rails applications as Ruby&#8217;s communication libraries where just lacking mandatory features. I choose Java/Hibernate/Spring as the combination should provide me with most needed features through an easily extend- and configurable framework. What are my findings so far?</p>
<p><span id="more-271"></span><strong>Lines of Code comparison</strong></p>
<p>Ruby beats Java if you want an easy and fast web development framework, but as soon as you exit the web user interface niche it looses many of its advantages, still the lines-of-code count in java is around 4 to 6 times as large as Rails&#8217;s. Good for you if you&#8217;re paid by the line of code that you write, bad for you if you want to get things done.</p>
<p>Both frameworks rely on convention over configuration. As I wrote the Java application after the Rail&#8217;s one I had to configure Java to fit Rail&#8217;s way which resulted in lots of configuration which would be unnecessary if I&#8217;d written the application in Java from day one. Much of the simpler code (setter/getter for entity classes) were also auto-generated, so the LOC count should be looked at with a grain of salt.</p>
<p><strong>Readability </strong></p>
<p>The Java code is better readable which surprised me. While the Ruby code is more verbose and beatifuller the Java code tends to be longer, but overall simpler structured. It is a lot easier to debug and as my application will be deployed as a war file in an Java Enterprise container there&#8217;s lot of functionality (e.g. logging) which can easily be tapped. I had some very ugly functions dealing with mime parts in Ruby, those are a lot easier to read because of the static typing. Once again: while duck-typing is perfect for writting an application quick, static typing might come in handy if you want your application to be robust and long-lived.</p>
<p><strong>Different approach to business object authority<br />
</strong></p>
<p>Another difference (and source of increased Java LOCs) is the different approach to business object responsibility. That term describes who is responsible for declaring objects, their content and constraints. Rail&#8217;s ActiveRecord maps the a database table into a business object data type, a row into an object and a attribute into a class member. Each change in the data backend automatically changes your business objects. You can write automatic tests to check if your object model is still sufficient, but those tests are not run automatically when the application starts. Some definitions (i.e. constraints and relationships) are defined on business object level, so you have split definitions between the database and your object model.</p>
<p>With hibernate you write your business objects and add annotations (as you do with Rails) to describe how they are mapped to the database. But the final  authority lies at the application and the business objects. If there&#8217;s a database change no attribute appears or disappears automatically, but an exception is raised on application startup. You have to write more code, but you have all your data definitions (incl. tables, attributes, relations and constraints) in one single conceptional place. You can even generate your database layout from your object model.</p>
<p>The later approach is clearer for me (and does less automagic than the Rails approach), but there&#8217;s also a payoff: you&#8217;ll need many more lines of code to define your business objects. Also if you want to add a change you&#8217;ll have to change your data definitions in the database as well as in your application. This will never happen in Rails with it&#8217;s D-R-Y way (Dont Repeat Yourself). Choose ease and speed of writing code vs. IMHO more safer code as your database format and input is double checked.</p>
<p>The next part will talk about the differences in Rails and Java/Springs exception handling.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2008/02/24/ruby-on-rails-vs-java-part2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails vs. Java, part 1</title>
		<link>http://snikt.net/index.php/2008/02/17/ruby-on-rails-vs-java-part-1</link>
		<comments>http://snikt.net/index.php/2008/02/17/ruby-on-rails-vs-java-part-1#comments</comments>
		<pubDate>Sun, 17 Feb 2008 17:05:38 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2008/02/17/ruby-on-rails-vs-java-part-1</guid>
		<description><![CDATA[One of the components of the system developed here at Blackwhale is an fairly advanced web mail/campaigning and analytics system. The first iteration of that component was fully implemented in Ruby on Rails. Writing the front end was fairly easy and fast, a perfect opportunity for Rails to display its strengths. On the back end [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>One of the components of the system developed here at <a href="http://www.blackwhale.net">Blackwhale</a> is an fairly advanced web mail/campaigning and analytics system. The first iteration of that component was fully implemented in <a href="http://www.rubyonrails.org">Ruby on Rails</a>. Writing the front end was fairly easy and fast, a perfect opportunity for Rails to display its strengths. On the back end and communication part on the other hand I stumbled into various problems:</p>
<ul>
<li>Compared to PHP, Python or Java there are just too few communication libraries. And even the libraries that exist are lacking fundamental features and almost all of them come without useable documentation. That there is no encryption (SSL or TLS) support in the whole Ruby 1.8 mail libraries is an outright shame. The IMAP library is so clumsy that a web company sells their own (still not perfect library) through their online store and they seem to make a good buck with it.
<p>On the Java side is just a completly different picture: Lots of libraries, even documented ones are available. After having to touch the <a href="http://tmail.rubyforge.org/">TMail</a> (rail&#8217;s MIME mail handler library) API using javax.mail is a heavenly gift. And it seems that the TMail generated MIME messages were invalid in a couple of cases. Not the best feature of a support library. Also the chance of finding unsolved known bugs and errors seems to be lot smaller in Java.</li>
<li>This brings me to another point: I might change my opinion on Java&#8217;s constraints on its users. Java tries hard to prevent errors (i.e. the forced exception catching). I always thought that that took too many stylish possibilities away from the user, but by now I must confess that I think that this is exactly what I want from something that I&#8217;m using on the network side. I&#8217;m a lazy programmer, I want to be reminded and forced to write secure and stable code. This is the quite different to Ruby and Rails &#8216;make it easy for the programmer&#8217; attitude.</li>
<li>Background processing is hard. As Ruby on Rails is not multi-thread safe you can&#8217;t just spawn a thread if you need to perform some longer running task. Another disadvantage of using a single-process model is that the long running request will occupy one rails worker (i.e. rails cluster process) until it has finished &#8211; in our case that costs us around 60MB of memory per long running request, even if it is just waiting for some simple SMTP feedback. If you can find a situation where you can delay the execution of a network related task (and if you don&#8217;t you&#8217;re not thinking) for two seconds, 6 requests per seconds will DoS a standard rails cluster.
<p>The only solution that&#8217;s actually usable is <a href="http://backgroundrb.rubyforge.org/">BackgroundRb</a>. But projects that just change their background communication system just don&#8217;t sound to production-grade ready for me. Also the admin start/stop scripts for their background server didn&#8217;t work too well for me.</li>
<li>For a language that interferes it&#8217;s object&#8217;s attribute types directly from the database the ActiveRecord layer is weak. Don&#8217;t get me wrong, I understand that the Simplicity is needed to make it easily usable but I ran into various situations where I&#8217;d love to have a full blown ORM behind me. One feature that is needed quite often by our application is inheritance. ActiveRecord only offers single table inheritance, and even there you have to make sure that each row is valid (ActiveRecord should have all needed information to do that by itself BTW) or you will run into problems later on. One problem is, that it tries to abstract too much functionality away from the database while not provided as advanced interfaces by itself. Data integrity handling? Abstracted away by rails, so all databases can be used the same. The drawback is, that the data constraints and relations are fully handled by rails and not passed on to the database. Any process that might produce invalid data (e.g. a faulty rails component) might corrupt the data. Rails is able to handle that cases by itself (due to ducktyping and very few default checks), but access that data with any other framework and it blows up directly into your face.</li>
<li>Transaction handling. Just try it. Then cry. Also I&#8217;m not sure if Transaction handling is even done on database level or in Rails (as done with constraints). If the later is true, it&#8217;s acutally not worth anything as soon as more processes try to access the database.</li>
</ul>
<p>The library and documentation problems where the main reason for me to reimplement the mailing and campaigning backend in Java. The front end is still a Rails application &#8212; which is exactly what Rails is for. As I&#8217;m no friend of blown-up EJB based solutions I&#8217;ve choosen a simple Spring and JPA based solution for that problem.</p>
<p>I&#8217;m currently testing the last features and replacing the Ruby code part by part. As soon as I&#8217;ve done that another blog post will examine the two implementations, how much time was spent on coding them and how they perform when compared to each other.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2008/02/17/ruby-on-rails-vs-java-part-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to enable TLS support in Ruby&#8217;s/Rails&#8217; Net::SMTP</title>
		<link>http://snikt.net/index.php/2007/12/19/how-to-enable-tls-support-in-rubysrails-netsmtp</link>
		<comments>http://snikt.net/index.php/2007/12/19/how-to-enable-tls-support-in-rubysrails-netsmtp#comments</comments>
		<pubDate>Wed, 19 Dec 2007 01:12:10 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2007/12/19/how-to-enable-tls-support-in-rubysrails-netsmtp/</guid>
		<description><![CDATA[Ruby on Rails uses Ruby 1.8 which still lacks support for STARTTLS or SSL. This was added in Ruby 1.9, but as this release is designated to be unstable (and only the road to a stable Ruby 2.0) Rails 2.0 doesn&#8217;t support running with it.
What to do? It&#8217;s a shame that a web framework like [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails uses Ruby 1.8 which still lacks support for STARTTLS or SSL. This was added in Ruby 1.9, but as this release is designated to be unstable (and only the road to a stable Ruby 2.0) Rails 2.0 doesn&#8217;t support running with it.</p>
<p>What to do? It&#8217;s a shame that a web framework like Rails doesn&#8217;t support secure transmission of mails.</p>
<p>So I rolled my own Ruby on Rails plugin that extends the  base Net::SMTP class with STARTTLS features. You can just call Net::SMTP.enable_tls (or do the same with an instance variable) to enable secure communications.</p>
<p>Honestly I didn&#8217;t write all the code on my own but searched the net and adapted some around-floating patches to this plugin as this is the easiest way of providing the needed TLS support to rails.</p>
<p>So if you need it, just <a href="http://happiness-is-slavery.net/wp-content/rails-plugins/">grab it from here</a>. More Information can be found in the plugin&#8217;s README file. Have fun and share your improvements to the plugin.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2007/12/19/how-to-enable-tls-support-in-rubysrails-netsmtp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to upgrade to Ruby on Rails 2.0</title>
		<link>http://snikt.net/index.php/2007/12/10/how-to-upgrade-to-ruby-on-rails-20</link>
		<comments>http://snikt.net/index.php/2007/12/10/how-to-upgrade-to-ruby-on-rails-20#comments</comments>
		<pubDate>Mon, 10 Dec 2007 01:36:18 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2007/12/10/how-to-upgrade-to-ruby-on-rails-20/</guid>
		<description><![CDATA[I wanted to upgrade on project of mine to Ruby on Rails 2.0 to automatically get some security and performance upgrades. So how to do it? My first try was:

checkout a new copy of my project from the SCM
upgrade the used rails version to EdgeRails
(through executing &#8220;rake rails:freeze:edge&#8221; twice)
adopted the RAILS_VERSION variable in config/environment.rb
Got a [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I wanted to upgrade on project of mine to <a href="http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done">Ruby on Rails 2.0</a> to automatically get some security and performance upgrades. So how to do it? My first try was:</p>
<ol>
<li>checkout a new copy of my project from the SCM</li>
<li>upgrade the used rails version to <a href="http://wiki.rubyonrails.org/rails/pages/EdgeRails">EdgeRails</a><br />
(through executing &#8220;<em>rake rails:freeze:edge</em>&#8221; twice)</li>
<li>adopted the RAILS_VERSION variable in <em>config/environment.rb</em></li>
<li>Got a &#8220;500 Internal Error&#8221; without any usable logging information on starting the Rails server (&#8220;<em>script/server</em>&#8220;)</li>
</ol>
<p>So what? I upgraded everything as planned and got an error without any real debugging help. What to do now?</p>
<p>After some googling around I found <a href="http://pastie.caboo.se/private/krcevozww61drdeza13e3a">Mislav Marohnic&#8217;s excellent r2check.rb script</a>. Just run it in your Rails directory and it will report a lot of errors and deprecated features that might hit you. One of those reported errors was the new notation for singular resources, after it converted my <em>resources.rb</em> the application finally started (albeit I had to fix some errors in the restful_authentication plugin, but nothing to heavy). So now I&#8217;m running Rails 2.0.1 and some pages really fell a lot faster.</p>
<p>Thank you very much for that script!</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2007/12/10/how-to-upgrade-to-ruby-on-rails-20/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails redux</title>
		<link>http://snikt.net/index.php/2007/11/12/ruby-on-rails-redux</link>
		<comments>http://snikt.net/index.php/2007/11/12/ruby-on-rails-redux#comments</comments>
		<pubDate>Sun, 11 Nov 2007 23:01:47 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2007/11/12/ruby-on-rails-redux/</guid>
		<description><![CDATA[Approximately one week ago I claimed that I was happy replacing Ruby on Rails with a conglomerate of Java frameworks. I&#8217;ve got wiser. Even with maven2 it&#8217;s too hard to get even a simple mavenized spring2, acegi, spring-jpa-hibernate configureation to work.
So I&#8217;m back to Rails. By now I feel more comfortable in the framework, but [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Approximately one week ago I claimed that I was happy replacing Ruby on Rails with a conglomerate of Java frameworks. I&#8217;ve got wiser. Even with maven2 it&#8217;s too hard to get even a simple mavenized spring2, acegi, spring-jpa-hibernate configureation to work.</p>
<p>So I&#8217;m back to Rails. By now I feel more comfortable in the framework, but there are still some open issues but most things just work (TM).</p>
<p align="right"><em>You&#8217;re an atheist?</em></p>
<p align="right"><em>Only on Christmas or Easter,<br />
the rest of the time it doesn&#8217;t really matter</em></p>
<p align="right">House, M.D.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2007/11/12/ruby-on-rails-redux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back in Vienna and small stuff</title>
		<link>http://snikt.net/index.php/2007/11/06/back-in-vienna-and-small-stuff</link>
		<comments>http://snikt.net/index.php/2007/11/06/back-in-vienna-and-small-stuff#comments</comments>
		<pubDate>Tue, 06 Nov 2007 02:07:51 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2007/11/06/back-in-vienna-and-small-stuff/</guid>
		<description><![CDATA[The last four days back home in Carinthia passed too fast.. and as soon as I was back in Vienna work covered me again.  I&#8217;ve finally finished my climbing lessons, didn&#8217;t even miss one of them. Now I hope that I can find the motivation to visit those halls of pain again. I&#8217;m more than [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The last four days back home in Carinthia passed too fast.. and as soon as I was back in Vienna work covered me again.  I&#8217;ve finally finished my climbing lessons, didn&#8217;t even miss one of them. Now I hope that I can find the motivation to visit those halls of pain again. I&#8217;m more than a little bit proud of my discipline, I even attended each Pencak Silat class until now &#8211; alas my performance in those ain&#8217;t the best.</p>
<p>I spent most of today&#8217;s afternoon coding a quite simple web application using JavaServer Pages with a <a href="http://www.springframework.org">Spring2</a>, Hibernate and Java Persistence Architecture back-end.  Security is handled through <a href="http://www.acegisecurity.org">acegi</a>, packaging through maven. Although this is more time-consuming compared to the last <a href="http://www.rubyonrails.org">Ruby on Rails</a> application I coded but there&#8217;s less Voodoo involved. Overall the resulting system feels more secure and stable.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2007/11/06/back-in-vienna-and-small-stuff/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Apache ActiveMQ</title>
		<link>http://snikt.net/index.php/2007/09/18/using-apache-activemq</link>
		<comments>http://snikt.net/index.php/2007/09/18/using-apache-activemq#comments</comments>
		<pubDate>Tue, 18 Sep 2007 12:53:22 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2007/09/18/using-apache-activemq/</guid>
		<description><![CDATA[I use Apache ActiveMQ for internal component communicatino in a project of mine. As only local (no distributed or network) communication is needed I configured it to use the VM transport, the fasted and most efficient way according to the online documentation. To prevent overhead objects instead of serialized XML is send through the queue [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://activemq.apache.org/">Apache ActiveMQ</a> for internal component communicatino in a project of mine. As only local (no distributed or network) communication is needed I configured it to use the <a href="http://activemq.apache.org/vm-transport-reference.html">VM transport</a>, the fasted and most efficient way according to the online documentation. To prevent overhead objects instead of serialized XML is send through the queue &#8211; profiling has shown that using <a href="http://www.jdom.org/">JDOM</a>&#8217;s XmlOutputter to generate XML is a major cpu hog. Another advantage of using the VM transport is that no dedicated broker is needed, the internal one is started automatically. So everything is peachy?</p>
<p>Unfortunately not.</p>
<p>The first profile run (using <a href="http://profiler4j.sourceforge.net/">Profiler4J</a>) showed unusual high cpu load while the system was running idle. Further analysis showed that ActiveMQ&#8217;s message receive function does do polling to get messages from the queue. This only affects the framework when running idle and shouldn&#8217;t use as much cpu when there&#8217;s actual work to do but still this is highly disturbing. After investigating the ActiveMQ documentation again (on a side node: there seems to be something that automatically destroys anything resembling documentation as soon as a project joins Apache) I found out that there&#8217;s another way of receiving messages. As it was an asynchronous listener based approach it should be easier on the processor. As a nice side effect the receiver side of my application&#8217;s action got simpler too.</p>
<p>Better results? No.</p>
<p>More than half of the systems CPU usage in the &#8220;now-not-idle-mode-anymore&#8221; still is generated by polled message queues. My solution to that problem (due to lack of documentation) was ripping out the ActiveMQ part altogether and replacing it with a simple <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html">java.util.concurrent.BlockingQueue</a>. It is thread-safe, simple to use and does a sort of sender side blocking (through a predefined queue size). In addition the data structure is a generic one, so some type-casts are avoided. CPU usage went down, a lot!</p>
<p>So what am I missing in the ActiveMQ picture? As it claims enterprise-grade this should not happen so I&#8217;m expecting an error on my side.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2007/09/18/using-apache-activemq/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>object-relational mappers in Java</title>
		<link>http://snikt.net/index.php/2007/08/26/object-relational-mappers-in-java</link>
		<comments>http://snikt.net/index.php/2007/08/26/object-relational-mappers-in-java#comments</comments>
		<pubDate>Sat, 25 Aug 2007 22:21:51 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://happiness-is-slavery.net/index.php/2007/08/26/object-relational-mappers-in-java/</guid>
		<description><![CDATA[After some time of absence to the Java, XML buzz world I had to reenter it lately for my master thesis. My current assignment is writing a data attraction and persistence layer.  After finding out that there&#8217;s a multitude of possible frameworks and systems which I might use for my problem I dived right [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>After some time of absence to the Java, XML buzz world I had to reenter it lately for my master thesis. My current assignment is writing a data attraction and persistence layer.  After finding out that there&#8217;s a multitude of possible frameworks and systems which I might use for my problem I dived right in, in contrary to <a href="http://en.wikipedia.org/wiki/BPEL">BPEL</a> engines most of them also worked.</p>
<p>The first step towards an advanced persistence solution was the usage of a<a href="http://en.wikipedia.org/wiki/Object-relational_mapping"> ORM mapper</a>. As the name implies those map between Java objects and relational data structures (i.e. databases). The programmer doesn&#8217;t see the underlying database world and just interacts with plain old Java objects. I started by using <a href="http://ibatis.apache.org/">iBatis</a> which occupies the one extreme of ORMs: the developer has to supply a SQL statement for each mapping. This also implies that the database schema is already defined before the ORMs is used. As I started from scratch I didn&#8217;t have a relational model, in fact I wanted to use an object-relational mapper to prevent myself from micro-designing the database layout.</p>
<p>The next contestant was <a href="http://www.hibernate.org/">Hibernate</a>. This is one of the if not the most powerful object mapper for Java. In contrast to iBatis the latest version depends solely on Java annotations and a simple config file (which defines the overall database connection and declares which classes are to be mapped).  I augmented my Java files and was ready to roll. After a bit of tweaking lazy loading also worked which isn&#8217;t to shabby for the invested time. Another advantage of Hibernate is HQL &#8211; the Hibernate Query Language: it provides the developer with an easy way of extracting Objects from databases through SQL-like queries.</p>
<p>But finally I settled with the <a href="http://java.sun.com/javaee/technologies/persistence.jsp">Java Persistence API</a> which is roughly the same as Hibernate but standardized through a JSR. There were minor differences with the annotations, but overall it was even simpler to use (the configuration file that stated which classes were to be persisted fell away). Under the hood I used Hibernate, but just through JPA, so performance and stability where the same.</p>
<p>The only drawback so far is the memory usage. JPA takes just all of it (and the JVM&#8217;s behaviour of starting memory reclaim as late as possible doesn&#8217;t help either). To ease this up I had to blurry the line between persistence and business layer a bit, this was felt as a step backwards as the goal was to minimize the persistence layer as much as possible.</p>
<p>As one of my thesis&#8217; mentors prefers XML databases I will be able to contrast this to a XML based solution soon.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://snikt.net/index.php/2007/08/26/object-relational-mappers-in-java/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
