<?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>/home/ap0calypse &#187; ruby</title>
	<atom:link href="http://ap0calypse.agitatio.org/articles/category/coding/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://ap0calypse.agitatio.org</link>
	<description>yet another blog ...</description>
	<lastBuildDate>Fri, 23 Jul 2010 12:21:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>android + ASE + Perl = </title>
		<link>http://ap0calypse.agitatio.org/articles/android-ase-perl</link>
		<comments>http://ap0calypse.agitatio.org/articles/android-ase-perl#comments</comments>
		<pubDate>Fri, 02 Jul 2010 12:43:57 +0000</pubDate>
		<dc:creator>ap0calypse</dc:creator>
				<category><![CDATA[amusing]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ap0calypse.agitatio.org/?p=281</guid>
		<description><![CDATA[just started playing with my new motorola milestone with android 2.1. 
I had no idea how much fun it is to write perl-programs for this nice little device. I use the ASE (android scripting environment) which also supports python, lua, ruby &#8230;
You can get it on their website.
I guess I will write some programs soon [...]]]></description>
			<content:encoded><![CDATA[<p>just started playing with my new motorola milestone with android 2.1. <img src='http://ap0calypse.agitatio.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
I had no idea how much fun it is to write perl-programs for this nice little device. I use the ASE (android scripting environment) which also supports python, lua, ruby &#8230;</p>
<p>You can get it on <a href="http://code.google.com/p/android-scripting/">their website</a>.</p>
<p>I guess I will write some programs soon to see what&#8217;s possible. The only thing that sucks on the milestone is, that the dollar sign is only available via touchpad. That&#8217;s REALLY annoying. :/</p>
]]></content:encoded>
			<wfw:commentRss>http://ap0calypse.agitatio.org/articles/android-ase-perl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Please &#8230; use Here-Documents &#8230;</title>
		<link>http://ap0calypse.agitatio.org/articles/please-use-here-documents</link>
		<comments>http://ap0calypse.agitatio.org/articles/please-use-here-documents#comments</comments>
		<pubDate>Wed, 09 Jun 2010 09:57:31 +0000</pubDate>
		<dc:creator>ap0calypse</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ap0calypse.agitatio.org/?p=268</guid>
		<description><![CDATA[I can&#8217;t tell you how often I see scripts and programs which contain a huge amount of echo, print or whatever calls to produce output. It is ok if there are one or two lines to print out, but it becomes inefficient when used explicitly. In shell-scripts and Perl for example you could use so-called [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t tell you how often I see scripts and programs which contain a huge amount of echo, print or whatever calls to produce output. It is ok if there are one or two lines to print out, but it becomes inefficient when used explicitly. In shell-scripts and Perl for example you could use so-called Here-Documents. Never heard of them? Well, here some examples:</p>
<p>example: bash</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
<span style="color: #808080; font-style: italic;"># usage text</span>
usage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;This is the usage of blabla&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Parameters:&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; -f ... Parameter 1 blabla&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; -g ... Parameter 2 blablubb&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Well, here you can see that there are a lot of echo-calls (often there are MUCH more &#8230; :-/). Now, we learn about an exciting new way to shorten this. We use &#8220;cat&#8221;:</p>
<p>example: bash better</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
<span style="color: #808080; font-style: italic;"># usage text</span>
usage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;</span> EOUSAGE
&nbsp;
This is the usage of blabla
Parameters:
 -f ... Parameter <span style="color: #000000;">1</span> blabla
 -g ... Parameter <span style="color: #000000;">2</span> blablubb
&nbsp;
EOUSAGE
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>So, instead of using tons of calls, just do it with one &#8220;cat&#8221;. Maybe it seems a bit pedantic of me, but this example makes more sense if you encounter more text (like HTML-output) which is printed out to a document with thousands of &#8220;echo&#8221;-s.</p>
<p>You can do this in Perl similarly:</p>

<div class="wp_syntax"><div class="code"><pre class="perl"><span style="color: #808080; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #808080; font-style: italic;"># usage text</span>
<span style="color: #000000; font-weight: bold;">sub</span> usage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #66cc66;">&lt;&lt;</span><span style="color: #ff0000;">&quot;EOUSAGE&quot;</span>;
&nbsp;
This is the usage of blabla
Parameters:
 -f ... Parameter <span style="color: #cc66cc;">1</span> blabla
 -g ... Parameter <span style="color: #cc66cc;">2</span> blablubb
&nbsp;
EOUSAGE
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>or in Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
<span style="color:#008000; font-style:italic;"># usage text</span>
<span style="color:#9966CC; font-weight:bold;">def</span> usage
    <span style="color:#CC0066; font-weight:bold;">print</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span>EOUSAGE
&nbsp;
    This is the usage of blabla
    Parameters:
     <span style="color:#006600; font-weight:bold;">-</span>f ... <span style="color:#9900CC;">Parameter</span> <span style="color:#006666;">1</span> blabla
     <span style="color:#006600; font-weight:bold;">-</span>g ... <span style="color:#9900CC;">Parameter</span> <span style="color:#006666;">2</span> blablubb
&nbsp;
EOUSAGE
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>I guess you can do something like that or similarly in nearly every language. So PLEASE, if you have much text to display in your scripts, use Here-Documents.</p>
]]></content:encoded>
			<wfw:commentRss>http://ap0calypse.agitatio.org/articles/please-use-here-documents/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>well &#8230;. why not?</title>
		<link>http://ap0calypse.agitatio.org/articles/well-why-not</link>
		<comments>http://ap0calypse.agitatio.org/articles/well-why-not#comments</comments>
		<pubDate>Wed, 03 Dec 2008 13:01:28 +0000</pubDate>
		<dc:creator>ap0calypse</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ap0calypse.agitatio.org/?p=146</guid>
		<description><![CDATA[I&#8217;m currently thinking about writing my own blog-software. Yes, I know that there are hundreds of projects out there and some of them (like wordpress, which I currently use) are really good and have huge communities. But that&#8217;s not the point.
The reason why I&#8217;d like to do that is that wordpress is too feature-rich, too [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently thinking about writing my own blog-software. Yes, I know that there are hundreds of projects out there and some of them (like wordpress, which I currently use) are really good and have huge communities. But that&#8217;s not the point.</p>
<p>The reason why I&#8217;d like to do that is that wordpress is too feature-rich, too bloated for me. I don&#8217;t need 90 % of the functions it has to offer. All I want and need is a simple listing of stuff I&#8217;m currently thinking about or working at. Of course, there should be a nice interface for me to insert new articles, but I actually don&#8217;t need the &#8216;comment&#8217;-function. If someone wants to tell me something, he could drop me a line via e-mail too &#8230;</p>
<p>So, that&#8217;s why I&#8217;m thinking about creating my own blogware. It would be a nice exercise anyway. If I really complete this project I guess I&#8217;ll publish it under an open source license for anyone who wants to use or modify it for his/her needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://ap0calypse.agitatio.org/articles/well-why-not/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The only valid measurement &#8230;</title>
		<link>http://ap0calypse.agitatio.org/articles/the-only-valid-measurement</link>
		<comments>http://ap0calypse.agitatio.org/articles/the-only-valid-measurement#comments</comments>
		<pubDate>Wed, 10 Sep 2008 07:36:51 +0000</pubDate>
		<dc:creator>ap0calypse</dc:creator>
				<category><![CDATA[amusing]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ap0calypse.agitatio.org/?p=46</guid>
		<description><![CDATA[&#8230; of code quality:

I laughed very, very loud  
]]></description>
			<content:encoded><![CDATA[<p>&#8230; of code quality:</p>
<p><img src="http://www.osnews.com/images/comics/wtfm.jpg" alt="" width="427" height="402" /></p>
<p>I laughed very, very loud <img src='http://ap0calypse.agitatio.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ap0calypse.agitatio.org/articles/the-only-valid-measurement/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>introducing another script: shift-cipher</title>
		<link>http://ap0calypse.agitatio.org/articles/introducing-another-script-shift-cipher</link>
		<comments>http://ap0calypse.agitatio.org/articles/introducing-another-script-shift-cipher#comments</comments>
		<pubDate>Wed, 07 May 2008 12:49:36 +0000</pubDate>
		<dc:creator>ap0calypse</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ap0calypse.agitatio.org/?p=7</guid>
		<description><![CDATA[I was just surfing around in my script-directory and found another gem I scripted back in February. The main purpose was to decrypt a ciphered sentence. Although it would have only taken me a couple of seconds to decrypt it, I decided that it would be even more fun to script it   .
This is the result: shift-cipher
There is also [...]]]></description>
			<content:encoded><![CDATA[<p>I was just surfing around in my script-directory and found another gem I scripted back in February. The main purpose was to decrypt a ciphered sentence. Although it would have only taken me a couple of seconds to decrypt it, I decided that it would be even more fun to script it <img src='http://ap0calypse.agitatio.org/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  .</p>
<p>This is the result: <a href='http://ap0calypse.agitatio.org/wp-content/uploads/2008/06/shift-cipher'>shift-cipher</a></p>
<p>There is also a version available in Ruby: <a href="http://ap0calypse.agitatio.org/wp-content/uploads/2008/05/shift-cipher-ruby">shift-cipher-ruby</a></p>
<p>This script should work (as usual) on any current GNU/Linux Distribution or *BSD where Perl or Ruby is installed. It deals with one line of standard input, which means that you can simply pipe the output of a command-line tool into it. An example:</p>
<p><code>ap0calypse@shu:/home/ap0calypse/scripts&gt; echo "x adkt hwxuixcv" | shift-cipher<br />
shift by: 1 : y belu ixyvjydw<br />
shift by: 2 : z cfmv jyzwkzex<br />
shift by: 3 : a dgnw kzaxlafy<br />
shift by: 4 : b ehox labymbgz<br />
shift by: 5 : c fipy mbczncha<br />
shift by: 6 : d gjqz ncdaodib<br />
shift by: 7 : e hkra odebpejc<br />
shift by: 8 : f ilsb pefcqfkd<br />
shift by: 9 : g jmtc qfgdrgle<br />
shift by: 10 : h knud rgheshmf<br />
shift by: 11 : i love shifting<br />
shift by: 12 : j mpwf tijgujoh<br />
shift by: 13 : k nqxg ujkhvkpi<br />
shift by: 14 : l oryh vkliwlqj<br />
shift by: 15 : m pszi wlmjxmrk<br />
shift by: 16 : n qtaj xmnkynsl<br />
shift by: 17 : o rubk ynolzotm<br />
shift by: 18 : p svcl zopmapun<br />
shift by: 19 : q twdm apqnbqvo<br />
shift by: 20 : r uxen bqrocrwp<br />
shift by: 21 : s vyfo crspdsxq<br />
shift by: 22 : t wzgp dstqetyr<br />
shift by: 23 : u xahq eturfuzs<br />
shift by: 24 : v ybir fuvsgvat<br />
shift by: 25 : w zcjs gvwthwbu<br />
</code></p>
<p>As you can see, shifting this sentence by a value of 11 really starts making sense. This is a REALLY bad way to encrypt, but hey, it is still better than nothing.</p>
<p>NOTE: special characters (äöüß) are NOT supported. It works with a-z.</p>
]]></content:encoded>
			<wfw:commentRss>http://ap0calypse.agitatio.org/articles/introducing-another-script-shift-cipher/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
