<?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; tool</title>
	<atom:link href="http://www.gauda.de/tag/tool/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>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>
