<?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>funkensturm. &#187; ruby</title>
	<atom:link href="http://funkensturm.de/category/ruby-on-rails/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://funkensturm.de</link>
	<description>Das funkensturm. Weblog</description>
	<lastBuildDate>Tue, 15 Nov 2011 15:04:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Get HTTP Headers in&#160;Ruby</title>
		<link>http://funkensturm.de/2009/08/27/get-http-headers/</link>
		<comments>http://funkensturm.de/2009/08/27/get-http-headers/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 15:15:11 +0000</pubDate>
		<dc:creator>manuel</dc:creator>
				<category><![CDATA[resources]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[schublade]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[NET::HTTP]]></category>

		<guid isPermaLink="false">http://blog.funkensturm.de/?p=202</guid>
		<description><![CDATA[Ein kleiner Schnipsel, um nur den Header eines HTTP Aufrufes zu erhalten. url = URI.parse&#40;'http://manuel.funkensturm.de/'&#41; req = Net::HTTP::Get.new&#40;url.path&#41; res = Net::HTTP.start&#40;url.host, url.port&#41; &#123; &#124;http&#124; http.request_head&#40;'/feed/'&#41; &#125; res.to_yaml Interessant sind in meinen Augen folgende Werte: &#62;&#62; res&#91;'last-modified'&#93; =&#62; &#34;Tue, 11 Aug 2009 16:09:01 GMT&#34; &#62;&#62; res&#91;'content-type'&#93; =&#62; &#34;application/rss+xml; charset=\&#34;UTF-8\&#34;&#34; &#62;&#62; res&#91;'etag'&#93; =&#62; &#34;\&#34;ca39ca8e3c9d3b858ef0d711956e00ad\&#34;&#34; über last-modified oder [...]]]></description>
			<content:encoded><![CDATA[<p>Ein kleiner Schnipsel, um nur den Header eines HTTP Aufrufes zu erhalten.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">url = <span style="color:#CC00FF; font-weight:bold;">URI</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://manuel.funkensturm.de/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
req = <span style="color:#6666ff; font-weight:bold;">Net::HTTP::Get</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>url.<span style="color:#9900CC;">path</span><span style="color:#006600; font-weight:bold;">&#41;</span>
res = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">start</span><span style="color:#006600; font-weight:bold;">&#40;</span>url.<span style="color:#9900CC;">host</span>, url.<span style="color:#9900CC;">port</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>http<span style="color:#006600; font-weight:bold;">|</span> http.<span style="color:#9900CC;">request_head</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'/feed/'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
res.<span style="color:#9900CC;">to_yaml</span></pre></div></div>

<p>Interessant sind in meinen Augen folgende Werte:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> res<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'last-modified'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;Tue, 11 Aug 2009 16:09:01 GMT&quot;</span>
<span style="color: #000000; font-weight: bold;">&gt;&gt;</span> res<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'content-type'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;application/rss+xml; charset=<span style="color: #000099; font-weight: bold;">\&quot;</span>UTF-8<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">&gt;&gt;</span> res<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'etag'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>ca39ca8e3c9d3b858ef0d711956e00ad<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span></pre></div></div>

<p>über last-modified oder den etag kann man dann schauen, ob man den Feed abholt oder die Aktion durchführt&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://funkensturm.de/2009/08/27/get-http-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: ImageMagick + RMagick via Macports für&#160;Tiger</title>
		<link>http://funkensturm.de/2007/11/12/howto-imagemagick-rmagick-via-macports-fur-tiger/</link>
		<comments>http://funkensturm.de/2007/11/12/howto-imagemagick-rmagick-via-macports-fur-tiger/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 09:46:20 +0000</pubDate>
		<dc:creator>manuel</dc:creator>
				<category><![CDATA[gems]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[rmagick]]></category>
		<category><![CDATA[tiger]]></category>

		<guid isPermaLink="false">http://blog.funkensturm.de/2007/11/12/howto-imagemagick-rmagick-via-macports-fur-tiger/</guid>
		<description><![CDATA[Nach dem ich nun auch RMagick für ein aktuelles Projekt brauchte, dachte ich ich nehm einfach die Anleitung von hier (ok steht ja schon im Posttitel ist für Leopard und nicht für Tiger) Das hat natürlich nicht funktioniert und mich min. 2 h gekostet. Deshalb hier die Anleitung für Mac OS X Tiger: Dauert ewig, [...]]]></description>
			<content:encoded><![CDATA[<p>Nach dem ich nun auch RMagick für ein aktuelles Projekt brauchte, dachte ich ich nehm einfach die Anleitung von <a href="http://nullstyle.com/2007/10/27/how-to-build-imagemagick-and-install-rmagick-with-macports-on-mac-os-x-leopard/" onclick="pageTracker._trackPageview('/outgoing/nullstyle.com/2007/10/27/how-to-build-imagemagick-and-install-rmagick-with-macports-on-mac-os-x-leopard/?referer=');">hier</a> (ok steht ja schon im Posttitel ist für Leopard und nicht für Tiger) Das hat natürlich nicht funktioniert und mich min. 2 h gekostet. Deshalb hier die Anleitung für Mac OS X Tiger:</p>
<p>Dauert ewig, für ImageMagick wird erst mal das ganze XFree86 Zeug und noch sonstige Sachen runter geladen. RMagick muss dann noch die ganzen Fonts einbinden, das dauert auch&#8230;</p>
<p><code><br />
sudo port install ImageMagick<br />
sudo port install libwmf<br />
sudo port install lcms<br />
sudo port install ghostscript<br />
sudo gem install rmagick -y<br />
</code></p>
<p>Das Problem war einfach, dass die 3 anderen Port-Installationen gefehlt haben. Ich glaub es lag eigentlich nur an der fehlenden ghostscript Installation.</p>
<p>Dank geht <a href="http://blog.labratz.net/articles/2006/10/10/really-truly-getting-imagemagick-rmagick-working-on-osx-from-source-without-using-macports-darwinports-or-fink" onclick="pageTracker._trackPageview('/outgoing/blog.labratz.net/articles/2006/10/10/really-truly-getting-imagemagick-rmagick-working-on-osx-from-source-without-using-macports-darwinports-or-fink?referer=');">hier</a> noch hin, da gab es die Lösung.</p>
]]></content:encoded>
			<wfw:commentRss>http://funkensturm.de/2007/11/12/howto-imagemagick-rmagick-via-macports-fur-tiger/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails: String&#160;manipulation</title>
		<link>http://funkensturm.de/2007/10/09/ruby-on-rails-string-manipulation/</link>
		<comments>http://funkensturm.de/2007/10/09/ruby-on-rails-string-manipulation/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 13:29:00 +0000</pubDate>
		<dc:creator>Captain Future</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[characters]]></category>
		<category><![CDATA[illegal]]></category>
		<category><![CDATA[string manipulation]]></category>
		<category><![CDATA[strip]]></category>

		<guid isPermaLink="false">http://blog.funkensturm.de/2007/10/09/ruby-on-rails-string-manipulation/</guid>
		<description><![CDATA[Es gibt einige Sachen, die ich gerne mit Strings machen möchte. Aber natürlich ist nicht ALLES in Rails schon drin. Also habe ich mir mit einem Plugin wie folgt geholfen. z. B.: &#8220;2&#8243;.numstring? gibt mir an, ob der string nur Ziffern enthält. /vendor/plugins/future/init.rb require 'string_manipulation' /vendor/plugins/future/lib/string_manipulation.rb require 'digest/sha1' module StringManipulation &#160; # Remove ALL unneccessary [...]]]></description>
			<content:encoded><![CDATA[<p>Es gibt einige Sachen, die ich gerne mit Strings machen möchte. Aber natürlich ist nicht ALLES in Rails schon drin. Also habe ich mir mit einem Plugin wie folgt geholfen.</p>
<p>z. B.: <b>&#8220;2&#8243;.numstring?</b> gibt mir an, ob der string nur Ziffern enthält.</p>
<p><b>/vendor/plugins/future/init.rb</b></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'string_manipulation'</span></pre></div></div>

<p><b>/vendor/plugins/future/lib/string_manipulation.rb</b></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'digest/sha1'</span>
<span style="color:#9966CC; font-weight:bold;">module</span> StringManipulation
&nbsp;
  <span style="color:#008000; font-style:italic;"># Remove ALL unneccessary whitespaces from string</span>
  <span style="color:#008000; font-style:italic;">#    &quot;   hello   world   &quot; #=&gt; &quot;hello world&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> strip_all
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">+/</span>, <span style="color:#996600;">' '</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">strip</span>.<span style="color:#CC0066; font-weight:bold;">chomp</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Remove everything that is not a-z or 0-9 or space</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> strip_illegal
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>^a<span style="color:#006600; font-weight:bold;">-</span>zA<span style="color:#006600; font-weight:bold;">-</span>Z0<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span> <span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Returns the basename of a file</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> strip_extention
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>\.<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>,<span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Strips RAILS_ROOT/public from string</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> url_from_path
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/public&quot;</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Strips RAILS_ROOT from string</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> root_from_path
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}&quot;</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Hashes a string with SHA1</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> hashed
    <span style="color:#6666ff; font-weight:bold;">Digest::SHA1</span>.<span style="color:#9900CC;">hexdigest</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Make a nice downcase keyword list as string, seperated by single spaces</span>
  <span style="color:#008000; font-style:italic;">#    keyword_list(&quot;   My §$% KEY   wordlist   &quot;) #=&gt; &quot;my key wordlist&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> keywordlist
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">strip_illegal</span>.<span style="color:#9900CC;">downcase</span>.<span style="color:#9900CC;">strip_all</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Checks if a string contains only numerical characters</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> numstring?
    <span style="color:#0000FF; font-weight:bold;">self</span> =~ <span style="color:#006600; font-weight:bold;">/</span>^\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span>\.\d<span style="color:#006600; font-weight:bold;">+|</span>\d<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC0066; font-weight:bold;">String</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> StringManipulation
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Als Unterfunktion von Object sind die Funktionen <b>überall</b> verfügbar. Sehr praktisch.</p>
]]></content:encoded>
			<wfw:commentRss>http://funkensturm.de/2007/10/09/ruby-on-rails-string-manipulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
