<?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>gauda.de &#187; Ruby on Rails</title>
	<atom:link href="http://www.gauda.de/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gauda.de</link>
	<description>The work of Johannes Leers - a webworker from Siegen, Germany</description>
	<lastBuildDate>Tue, 15 Sep 2009 23:04:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use rails-footnotes to open files in NetBeans from Firefox</title>
		<link>http://www.gauda.de/ruby-on-rails/use-rails-footnotes-to-open-files-in-netbeans-from-firefox/</link>
		<comments>http://www.gauda.de/ruby-on-rails/use-rails-footnotes-to-open-files-in-netbeans-from-firefox/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 11:16:58 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.gauda.de/?p=53</guid>
		<description><![CDATA[Here is how to use rails-footnotes with NetBeans on linux!
Thanks to José Valim we have a nice new plugin for better debugging of Rails applications! In his blog post he describes how to open links to files on your hard disk with notepad++ on windows. I adapted this idea for opening files with netbeans on [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how to use <a href="http://github.com/josevalim/rails-footnotes/tree/master">rails-footnotes</a> with <a href="http://www.netbeans.org/">NetBeans</a> on linux!</p>

<a href='http://www.gauda.de/ruby-on-rails/use-rails-footnotes-to-open-files-in-netbeans-from-firefox/attachment/rails-footnote/' title='Clicking on the link ...'><img width="150" height="75" src="http://www.gauda.de/wordpress/wp-content/uploads/rails-footnote-150x75.png" class="attachment-thumbnail" alt="Clicking on the link ..." title="Clicking on the link ..." /></a>
<a href='http://www.gauda.de/ruby-on-rails/use-rails-footnotes-to-open-files-in-netbeans-from-firefox/attachment/netbeans/' title='... opens the file in Netbeans'><img width="150" height="150" src="http://www.gauda.de/wordpress/wp-content/uploads/netbeans-150x150.png" class="attachment-thumbnail" alt="... opens the file in Netbeans" title="... opens the file in Netbeans" /></a>

<p>Thanks to José Valim we have a nice new plugin for better debugging of Rails applications! In his <a href="http://josevalim.blogspot.com/2008/06/textmate-protocol-behavior-on-any.html">blog post</a> he describes how to open links to files on your hard disk with notepad++ on windows. I adapted this idea for opening files with netbeans on linux, and here is your way to go:</p>
<p>open <code>about:config</code> in firefox and add:</p>
<ul>
<li>string <code>network.protocol-handler.app.editor</code> with content <code>~/.editor.rb</code></li>
<li>bool <code>network.protocol-handler.external.editor</code> and set it to <code>true</code></li>
</ul>
<p>create the file ~/.editor.rb and make it executable: </p>
<pre>touch ~/.editor.rb &#038;&#038; chmod +x  ~/.editor.rb</pre>
<p>And here is the content:</p>
<pre class="prettyprint">#!/usr/bin/ruby
file = ARGV.first.split('file://').last.split('&#038;').first
line = /\&#038;line\=(\d+)/.match(ARGV.first)[1] rescue 0
`"/path/to/your/netbeans-dir/bin/netbeans" "#{file}:#{line}"`
`wmctrl -a "NetBeans IDE"`</pre>
<p>install <a href="http://sweb.cz/tripie/utils/wmctrl/">wmctrl</a></p>
<pre>sudo aptitude install wmctrl</pre>
<p>We&#8217;ll need this to give focus to the NetBeans window.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/use-rails-footnotes-to-open-files-in-netbeans-from-firefox/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Use to_money to convert a string to an integer</title>
		<link>http://www.gauda.de/ruby-on-rails/use-to_money-to-convert-a-string-to-an-integer/</link>
		<comments>http://www.gauda.de/ruby-on-rails/use-to_money-to-convert-a-string-to-an-integer/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 00:35:34 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.gauda.de/?p=43</guid>
		<description><![CDATA[Just a quick note: You can use the following code in your helpers/application_helper.rb to convert a string to an integer in your Rails application:
class String
  def to_money
    fee = self.match(/(\d+)(,&#124;.?)(\d{0,2})/)
    if %w(, .).include?(fee[2]) # 56,99 1.00 5,-
      return "#{fee[1]}#{fee[3].to_i.to_s.ljust(2, '0')}"
    [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note: You can use the following code in your <code>helpers/application_helper.rb</code> to convert a string to an integer in your Rails application:</p>
<pre class="prettyprint">class String
  def to_money
    fee = self.match(/(\d+)(,|.?)(\d{0,2})/)
    if %w(, .).include?(fee[2]) # 56,99 1.00 5,-
      return "#{fee[1]}#{fee[3].to_i.to_s.ljust(2, '0')}"
    elsif fee[1] &#038;&#038; fee[2].blank? # 5
      return "#{fee[1]}00"
    end
  end

  def to_money!
    self.replace to_money
  end
end</pre>
<p>Now you can do some fancy stuff like the following:</p>
<pre class="prettyprint">"12 Euro".to_money => 1200
"12 Dollar".to_money => 1200
"12.00 Dollar".to_money => 1200
"12,00 Euro".to_money => 1200
"12,- Euro".to_money => 1200
"1200 Euro".to_money => 120000
money = "12,8 Euro"
money.to_money!
puts money # => 1280</pre>
<p>You can read about the motivation why to use integer in favor of decimals in the database here: <a href="http://www.setfiremedia.com/blog/7-top-tips-for-coding-with-currency">7 Top Tips for Coding With Currency</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/use-to_money-to-convert-a-string-to-an-integer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tiny suggestion to mimetype_fu</title>
		<link>http://www.gauda.de/ruby-on-rails/tiny-suggestion-to-mimetype_fu/</link>
		<comments>http://www.gauda.de/ruby-on-rails/tiny-suggestion-to-mimetype_fu/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 00:06:29 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.gauda.de/ruby-on-rails/tiny-suggestion-to-mimetype_fu/</guid>
		<description><![CDATA[I made a suggestion to mimetype_fu and send it to the autor:
Instead of calling file with -ir and scanning the result like the plugin actually does in /vendor/plugins/mimetype-fu/lib/mimetype_fu.rb you could pass the -b option like this:
# mime = `file -ir #{file.path}`.scan(/.*: (.*);(.*)/)[0][0]
mime = `file -bir #{file.path}`.strip
The man page of file says: -b Do not prepend [...]]]></description>
			<content:encoded><![CDATA[<p>I made a suggestion to <a href="http://code.google.com/p/mimetype-fu/">mimetype_fu</a> and send it to the <a href="http://railsontherun.com/tags/mimetype_fu">autor</a>:<br />
Instead of calling <code>file</code> with <code>-ir</code> and scanning the result like the plugin actually does in <code>/vendor/plugins/mimetype-fu/lib/mimetype_fu.rb</code> you could pass the <code>-b</code> option like this:</p>
<pre class="prettyprint"># mime = `file -ir #{file.path}`.scan(/.*: (.*);(.*)/)[0][0]
mime = `file -bir #{file.path}`.strip</pre>
<p>The <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=file&#038;apropos=0&#038;sektion=0&#038;manpath=OpenBSD%20Current&#038;arch=i386&#038;format=html">man page of file</a> says: <code>-b Do not prepend filenames to output lines (brief mode)</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/tiny-suggestion-to-mimetype_fu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The way to the ideal template engine for rails</title>
		<link>http://www.gauda.de/ruby-on-rails/the-way-to-the-ideal-template-engine-for-rails/</link>
		<comments>http://www.gauda.de/ruby-on-rails/the-way-to-the-ideal-template-engine-for-rails/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 18:39:24 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.gauda.de/ruby-on-rails/the-way-to-the-ideal-template-engine-for-rails/</guid>
		<description><![CDATA[This post is still under development! Come back for updates!
Motivation
For our new Project at Datanion we need a template engine for Rails that hits the following requirements:

Up to date technology, this includes Rails 2.0 of course. A plus is active development of more than one guy
Easy to use for both, the developer ( me  [...]]]></description>
			<content:encoded><![CDATA[<h3 class="flash notice">This post is still under development! Come back for updates!</h3>
<h3>Motivation</h3>
<p>For our new Project at <a href="http://datanion.com">Datanion</a> we need a template engine for Rails that hits the following requirements:</p>
<ul>
<li>Up to date technology, this includes Rails 2.0 of course. A plus is active development of more than one guy</li>
<li>Easy to use for both, the developer ( me <img src='http://www.gauda.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) and the designers</li>
<li>Scalability</li>
<li>The option to disable e-ruby parsing or at least allow only a very downstripped version of it</li>
<li>The option to use different themes, each instance of the application will have its own <code>layout.html</code> and different <code>views</code>. Perhaps, but not limited, with the use of the <a href="http://mattmccray.com/svn/rails/plugins/theme_support/README">theme_support</a> or the <a href="http://box.svnrepository.com/svn/plugins/multi_site/README">MultiSite</a> plugin
</ul>
<h3>The candidates</h3>
<p>There are different template engines out there. These are the candidates I tested in the order I checked them:</p>
<ul>
<li><a href="http://www.liquidmarkup.org/">Liquid</a> &#8211; Liquid is an extraction from the e-commerce system Shopify. Shopify powers many thousands of e-commerce stores which all call for unique designs. For this we developed Liquid which allows our customers complete design freedom while maintaining the integrity of our servers.</li>
<li><a href="http://www.masterview.org/">Masterview</a> &#8211; MasterView is a ruby/rails optimized HTML/XHTML friendly template engine. It is designed to use the full power and productivity of rails including layouts, partials, and rails html helpers while still being editable/ styleable in a WYSIWYG HTML editor.</li>
<li><a href="http://amrita2.rubyforge.org/">Amrita2</a> &#8211; Amrita2 is a a xml/xhtml template library for Ruby. It makes html documents from a template and a model data.</li>
<li><a href="http://www.kuwata-lab.com/kwartz/">Kwartz</a> &#8211; Kwartz is a template system which realized the concept of &#8216;Independence of Presentation Logic&#8217; (IoPL).</li>
<li><a href="http://pagetemplate.org/">PageTemplate</a> &#8211; PageTemplate is a Ruby package which allows you to utilize text templates for your Web projects.</li>
</ul>
<h3>The pros and cons of each of them</h3>
<h4><a href="http://www.liquidmarkup.org/">Liquid</a></h4>
<p>I think Liquid is the most popular template engine. Developed for <a href="http://www.shopify.com/">shopify</a> it is in production use since June 2006 and is now used by many other hosted web applications. One could imagine that this is a pro for this engine, but my personal experiences are slightly different! The documentation is really lacking, sometimes outdated! The <a href="http://code.google.com/p/liquid-markup/wiki/UsingLiquidTemplates">wiki</a> contains code examples that will not run the way you expect:</p>
<pre class="prettyprint">
Hello tobi has {{ 'tobi' | length }} letters! # --> Hello tobi has tobi letters
Hello {{ '*tobi*' | textilize | upcase }} # --> Hello *TOBI*
</pre>
<p>The length bug is <a href="http://code.google.com/p/liquid-markup/issues/detail?id=10">known</a>, but it has not been fixed till now. At least the tiny &#8220;using liquid templates&#8221; wiki entry should be bug free.</p>
<h4><a href="http://www.masterview.org/">Masterview</a></h4>
<p>Well, not much to say&#8230; <a href="http://rubyforge.org/pipermail/masterview-users/2008-January/000276.html">Masterview isn&#8217;t Rails 2.0 ready</a>:<br />
<code>If you would send us any Rails 2.0 changes you find, then we'd be glad to get them in there.<br />
Even better, if you want to make the changes to the code and send us diff's along with a short explanation of each change, we can apply things even quicker. Ideally with test updates too, but we'll take whatever we can get <img src='http://www.gauda.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </code><br />
That is really pity because this engine has a nice feature: Designers can use their favourite WYSIWYG-editor to edit the templates, and test them locally without any aditional software installed! It would even be possible to use Masterview in <a href="http://www.adaruby.com/2006/11/08/easily-maintainable-designer-friendly-actionview-templates-using-masterview-liquid/">combination</a> with Liquid. The developer made a really nice presentation (<a href="http://masterview.org/presentations/mtnwestruby2007/masterview_evolution_070316.html">MasterView: Evolution of a WYSIWYG Template Engine</a>) and a <a href="http://masterview.org/media/html-to-live/screencast.html">sreencast</a>. I am discussing the ability of Masterview to play together with the theme_support plugin with the author <a href="http://rubyforge.org/pipermail/masterview-users/2008-February/000277.html">here</a>.</p>
<h4><a href="http://amrita2.rubyforge.org/">Amrita2</a></h4>
<p>This engine is not Rails specific so it runs natively in every Ruby application, but has a &#8216;RailsBridge&#8217; to communicate with your apps easily. Amrita2 <a href="http://rubyforge.org/pipermail/amrita2-users/2008-February/000016.html">just switched to Rails 2.0</a>, so the <a href="http://amrita2.rubyforge.org/Rails.html">Rails specific documentation</a> is still buggy and the samples are not in Rails 2.0 style (e.g. <code><a href="http://amrita2.rubyforge.org/rails/todoapp1/views/todo/">list.a2html</a></code> instead of <code>list.html.a2</code>). The idea behind Amrita2 is really similar to the one of Masterview: As the author writes, the template can be written by designers using almost any xhtml/xml editor and the output is controlled by data not by logic. So it&#8217;s easy to write, test and debug the code.</p>
<pre class="prettyprint">
### controllers/application.rb
class ApplicationController < ActionController::Base
  include Amrita2
end

### controllers/foos_controller.rb
class FoosController < ApplicationController
  def index
    @title = 'Hello ROR with Amrita2'
    @body  = 'Using Amrita2 with ROR is easy and fun!'
  end
end

### views/foos/index.html.a2
< h1 am:src='title'>hello world< /h1>
< p am:src='body'>Amrita2 is a html template library for Ruby< /p>
</pre>
<h4><a href="http://www.kuwata-lab.com/kwartz/">Kwartz</a></h4>
<p>First of all, I think Kwartz is fun to use. The documentation is really good and it would be easy to use for the developer and also the designers. But there is a deficit making it useless for me: Kwartz is not Rails 2.0 ready. I emailed the author of Kwartz and asked about Rails 2.0 support. I&#8217;ll keep you updated!</p>
<h4><a href="http://pagetemplate.org/">PageTemplate</a></h4>
<p>PageTemplate doesn&#8217;t have a &#8216;rails bridge&#8217; so you have to do this on your own:</p>
<pre class="prettyprint">
### controllers/application.rb
class ApplicationController < ActionController::Base
  require 'PageTemplate'
end

### controllers/foos_controller.rb
class FoosController < ApplicationController
  def index
    template = PageTemplate.new()
    template.load("#{RAILS_ROOT}/app/views/foos/index.html.erb")
    template['title'] = 'My PageTemplate Script'
    render :text => template.output, :layout => true
  end
end

### views/foos/index.html.erb
<strong>[%var title%]</strong>
</pre>
<p>I would consider this as a core-template engine, without any knickknack. If you like to write your own Rails template engine take PageTemplate as lesson <img src='http://www.gauda.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Conclusion</h3>
<p><code>comming soon...</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/the-way-to-the-ideal-template-engine-for-rails/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>I want to Rails and not to Javascript, or: Why ExtJS is not for me</title>
		<link>http://www.gauda.de/ruby-on-rails/i-want-to-rails-and-not-to-javascript-or-why-extjs-is-not-for-me/</link>
		<comments>http://www.gauda.de/ruby-on-rails/i-want-to-rails-and-not-to-javascript-or-why-extjs-is-not-for-me/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 00:13:34 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.gauda.de/ruby-on-rails/i-want-to-rails-and-not-to-javascript-or-why-extjs-is-not-for-me/</guid>
		<description><![CDATA[Ok, today I switched back to &#8216;traditional Rails&#8217; at expense of ExtJS. The plan was to build the admin-interface of our new application in ExtJS but after 10 days of working with it I changed back to Rails, and this are the reasons:

I want to Rails and not to Javascript!The brain eating syntax of Javascript [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, today I switched back to &#8216;traditional Rails&#8217; at expense of <a href="http://extjs.com/">ExtJS</a>. The plan was to build the admin-interface of our new application in ExtJS but after 10 days of working with it I changed back to Rails, and this are the reasons:</p>
<ul>
<li>I want to Rails and not to Javascript!<br />The brain eating syntax of Javascript drives me crazy! Brackets here, braces there. I think it is a general danger &#8216;railing&#8217;.</li>
<li>The documentation! It is complete but the examples are really lacking. Why can&#8217;t they just give an example how the code of a simple <a href="http://extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox">ComboBox</a> looks like?</li>
<li>The big learning curve! Our project has to be released in May this year. I know I can do it in Rails, but not learning a different framework in this time.</li>
<li>Error handling: It is such a pain! Even with <a href="http://www.getfirebug.com/">Firebug</a> you are not able to find and trace every error occuring!</li>
<li>Speed: The browser hangs for a second initializing the application.</li>
</ul>
<p>I won&#8217;t say ExtJS is dead for me. When the time comes I will re-learn it, but it&#8217;s definitely not the concept of rapid programming, and this is what I need this time! The progress I made the last ten days are out of all proportion to the time I used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/i-want-to-rails-and-not-to-javascript-or-why-extjs-is-not-for-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple File Upload with Ruby on Rails and file_column</title>
		<link>http://www.gauda.de/ruby-on-rails/multiple-file-upload-with-ruby-on-rails-and-file_column/</link>
		<comments>http://www.gauda.de/ruby-on-rails/multiple-file-upload-with-ruby-on-rails-and-file_column/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 18:24:51 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.gauda.de/ruby-on-rails/multiple-file-upload-with-ruby-on-rails-and-file_column/</guid>
		<description><![CDATA[I just found a multiple file upload script here, and a rewrite for the use with the nice file_column plugin. There was a conflict  with the mootools not playing well with prototype used by default in every Ruby on Rails application. So I&#8217;ve done a rewrite of the first version of this script. Of [...]]]></description>
			<content:encoded><![CDATA[<p>I just found a multiple file upload script <a href="http://the-stickman.com/web-development/javascript/multiple-file-uploader-mootools-version/">here</a>, and a <a href="http://www.silverscripting.com/blog/2007/12/18/multiple-file-upload-with-rails-file_column-plugin-and-mootools/">rewrite</a> for the use with the nice <a href="http://www.kanthak.net/opensource/file_column/">file_column</a> plugin. There was a conflict  with the mootools not playing well with prototype used by default in every Ruby on Rails application. So I&#8217;ve done a rewrite of the <a href="http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/">first version</a> of this script. Of course there are other (newer) file upload plugins like <a href="http://svn.techno-weenie.net/projects/plugins/attachment_fu/README">attachment_fu</a>, but they do not have the functionality I need. Generally they should work with this solution, too.<br />
Here is the demo (browse for an image):</p>
<p><script src="/wordpress/wp-content/uploads/2008/01/multi_selector.js" type="text/javascript"></script></p>
<input id="preview" name="preview_1" type="file" />
<div id="preview_list"></div>
<p><script type="text/javascript">
  var multi_selector = new MultiSelector( document.getElementById("preview_list"), 0, "preview", new Array("jpg", "gif", "png") );
  multi_selector.addElement( document.getElementById( "preview" ) );
</script></p>
<p>In your controller you just have to parse each param:</p>
<pre class="prettyprint">
  params[:previews].each do |preview|
    Preview.create(:filename => preview[1]) if !preview[1].blank?
  end
</pre>
<p>That&#8217;s it! Grab the script <a href="/wordpress/wp-content/uploads/2008/01/multi_selector.js">here</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/multiple-file-upload-with-ruby-on-rails-and-file_column/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>It&#8217;s the little things I like about Linux</title>
		<link>http://www.gauda.de/ruby-on-rails/its-the-little-things-i-like-about-linux/</link>
		<comments>http://www.gauda.de/ruby-on-rails/its-the-little-things-i-like-about-linux/#comments</comments>
		<pubDate>Tue, 08 Jan 2008 01:17:09 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[marius]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.gauda.de/random/its-the-little-things-i-like-about-linux/</guid>
		<description><![CDATA[Today I wrote some handy syncronization-scripts with the help of my freebsd-loving co-worker Marius. Till today I managed the syncronization of my local database with our production database with the help of phpMyAdmin.
An export of the 13mb sql file at the production server and an import at my machine took me at least five minutes [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wrote some handy syncronization-scripts with the help of my freebsd-loving co-worker Marius. Till today I managed the syncronization of my local database with our production database with the help of phpMyAdmin.<br />
An export of the 13mb sql file at the production server and an import at my machine took me at least five minutes (~2mb gzipped). Now take a look at this:</p>
<pre class="prettyprint">
[hans@zommuntu:~]$ time ssh user@production_server "mysqldump --add-drop-table database_to_process -uUSER -pPASSWORD | gzip" | gunzip | mysql -uLOCALUSER -pLOCALPASSWORD database_name
real    0m4.389s
user    0m0.592s
sys     0m0.052s
</pre>
<p>Under five seconds! woot!!<br />
Some words to explain this: First, you establish a ssh connection to the <code>production_server</code>. The gzipped dumped sql of the beloved <code>database_to_process</code> is transferred to your machine. Here it is gunzipped and written to your local database server into the <code>database_name</code>. The quotes are necessary as brackets to let the script know that the gzip command belongs to the ssh command.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/its-the-little-things-i-like-about-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Translate directly at your console!</title>
		<link>http://www.gauda.de/ruby-on-rails/translate-directly-at-your-console/</link>
		<comments>http://www.gauda.de/ruby-on-rails/translate-directly-at-your-console/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 00:12:33 +0000</pubDate>
		<dc:creator>Johannes Leers</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.gauda.de/ruby-on-rails/translate-directly-at-your-console/</guid>
		<description><![CDATA[Ever wanted to be able to translate directly at your cosole?

[hans@zommuntu:~/rails]$ de2en häuser
Homes
[hans@zommuntu:~/rails]$ en2de houses
Häuser

Save this ruby-script as en2de in your ~/bin:

#! /usr/bin/ruby

#
# Copyright (c) 2008 gauda.de
# All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Ruby itself.
#

require 'net/http'
require 'iconv'
require 'uri'

arg = URI.escape(Iconv.new('ISO-8859-15', 'UTF-8').iconv(ARGV[0]))
str [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to be able to translate directly at your cosole?<br />
<code><br />
[hans@zommuntu:~/rails]$ de2en häuser<br />
Homes<br />
[hans@zommuntu:~/rails]$ en2de houses<br />
Häuser<br />
</code><br />
Save this ruby-script as en2de in your <code>~/bin</code>:</p>
<pre class="prettyprint">
#! /usr/bin/ruby

#
# Copyright (c) 2008 gauda.de
# All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Ruby itself.
#

require 'net/http'
require 'iconv'
require 'uri'

arg = URI.escape(Iconv.new('ISO-8859-15', 'UTF-8').iconv(ARGV[0]))
str = Net::HTTP.new('www.google.com', 80).get("/translate_t?text=" + arg + "&#038;langpair=de|en").body.match(/id\=result_box\ dir\="ltr">(\S*)<\/div>/)
if str
  puts Iconv.new('UTF-8', 'ISO-8859-15').iconv(str[1])
else
  puts "error.."
end
</pre>
<p>Of course you can change the languages! Just edit the <code>langpair=de|en</code> at your will. Be sure to have ruby installed!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gauda.de/ruby-on-rails/translate-directly-at-your-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
