<?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>Functino &#187; Uncategorized</title>
	<atom:link href="http://functino.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://functino.com</link>
	<description>My daily struggle with webdevelopment</description>
	<lastBuildDate>Sun, 07 Mar 2010 19:38:24 +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>Twitter Api with Rails</title>
		<link>http://functino.com/2010/02/twitter-api-with-rails/</link>
		<comments>http://functino.com/2010/02/twitter-api-with-rails/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 19:39:54 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://functino.com/?p=1151</guid>
		<description><![CDATA[In a little app that I recently launched I tried to use Twitters API. Turns out it&#8217;s incredible easy to do so if you use Ruby on Rails.
Here are the things that I needed to do to get a first version running:
Create a new Rails application. Then create a Model Twitter that extends Rails&#8217; ActiveResource:

class [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://alsichsoaltwarwiedu.de">a little app that I recently launched</a> I tried to use <a href="http://apiwiki.twitter.com/">Twitters API</a>. Turns out it&#8217;s incredible easy to do so if you use Ruby on Rails.</p>
<p>Here are the things that I needed to do to get a first version running:<br />
Create a new Rails application. Then create a Model Twitter that extends Rails&#8217; ActiveResource:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Twitter <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveResource::Base</span>
  <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">site</span> = <span style="color:#996600;">&quot;http://twitter.com&quot;</span>
  <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">user</span> = <span style="color:#996600;">&quot;yourusername&quot;</span>
  <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">password</span> = <span style="color:#996600;">&quot;yourpassword&quot;</span>
  <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">element_name</span> = <span style="color:#996600;">&quot;status&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>As you can see you can add the credentials to your Twitter account. Because Twitter&#8217;s API uses &lt;status&gt; as root element of the API&#8217;s XML we set &#8220;elmenet_name&#8221; to status.</p>
<p>Well that&#8217;s all you have to do. Fire up the console (ruby script/console) type in</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Twitter.<span style="color:#9900CC;">post</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:update</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Yay, I just used the API&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p> and you will see you just twittered with rails.</p>
<p>Other operations are simple to. If you &#8211; for example &#8211; want to load all replies to your account just use:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Twitter.<span style="color:#9900CC;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:replies</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>.</p>
<p>Additional goody:<br />
If you want to use an URL-shortener within ruby you can use the API of <a href="http://is.gd">is.gd</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">url = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">get</span> <span style="color:#996600;">'is.gd'</span>, <span style="color:#996600;">'/api.php?longurl='</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">escape</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;http://somereallylongurl.com/blub&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      Twitter.<span style="color:#9900CC;">post</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:update</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Here: &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> url<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

 <img src="http://functino.com/wp-content/plugins/feed-statistics.php?view=1&post_id=1151" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://functino.com/2010/02/twitter-api-with-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Alternate Table Rows in CakePHP (and ZF, Rails, Smarty)</title>
		<link>http://functino.com/2009/04/alternate-table-rows-in-cakephp-and-zf-rails-smarty/</link>
		<comments>http://functino.com/2009/04/alternate-table-rows-in-cakephp-and-zf-rails-smarty/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 11:35:26 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://functino.com/?p=122</guid>
		<description><![CDATA[In my last posting I talked about alternating table row colors with plain PHP. But how is this handled in different frameworks like CakePHP, Zend Framework, Rails or Smarty?
[UPDATE: My CakePHP-Cycle-Helper is described here: http://functino.com/2009/07/cakephp-cycle-helper-alternating-row-colors-with-cake/]
I&#8217;m going to show you simple examples for each of this tools.
In Smarty you can alternate table row colors (or any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://functino.com/2009/04/zebra-tables-how-to-alternate-table-row-colors/">In my last posting</a> I talked about alternating table row colors with plain PHP. But how is this handled in different frameworks like CakePHP, Zend Framework, Rails or Smarty?</p>
<p>[UPDATE: My CakePHP-Cycle-Helper is described here: <a href="http://functino.com/2009/07/cakephp-cycle-helper-alternating-row-colors-with-cake/">http://functino.com/2009/07/cakephp-cycle-helper-alternating-row-colors-with-cake/</a>]</p>
<p>I&#8217;m going to show you simple examples for each of this tools.</p>
<p>In Smarty you can alternate table row colors (or any other thing) with the simple cycle function like this:<br />
<span id="more-122"></span></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">{section name=rows loop=$animals}
&lt;tr class=&quot;{cycle values=&quot;odd,even&quot;}&quot;&gt;
  &lt;td&gt;
    {$animals[rows]}
  &lt;/td&gt;
&lt;/tr&gt;
{/section}</pre></div></div>

<h3>Ruby on Rails</h3>
<p>In Ruby on Rails there is a very similar solution: The cycle helper. Use it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#0066ff; font-weight:bold;">@animals</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>animal<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
    &lt;tr class=&quot;<span style="color:#006600; font-weight:bold;">&lt;%</span>= cycle<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;even&quot;</span>, <span style="color:#996600;">&quot;odd&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&quot;&gt;
      &lt;td&gt;
        <span style="color:#006600; font-weight:bold;">&lt;%</span>= animal.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
      &lt;/td&gt;
   &lt;/tr&gt;
 <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Documentation is here:  <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001721">http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001721</a> </p>
<h3>Zend Framework</h3>
<p>Within Zend there is currently no such solution in the core. However there is a proposal for a rails-like cycle helper:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$cycle</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cycle</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;odd&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;even&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span> 
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">animals</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$animal</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span> 
  &lt;tr class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$cycle</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt; 
  &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$animal</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt; 
&lt;/tr&gt; 
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Instead of just using a cycle-function you have to create an instance of a cycle object and use that. The full proposal is here:  <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_View_Helper_Cycle+-+Kamil+Nowakowski">http://framework.zend.com/wiki/display/ZFPROP/Zend_View_Helper_Cycle+-+Kamil+Nowakowski</a> </p>
<h3>And finally Cake</h3>
<p>Cake has no built in cycle helper. If you use the cake bake generator you&#8217;ll get code like this for alternating row classes/colors:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$animals</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$animal</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
        <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' class=&quot;altrow&quot;'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;tr<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$class</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;</pre></div></div>

<p>It&#8217;s ugly, isn&#8217;t it?<br />
Like I said in my last posting, I think this would be a prettier solution:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$animals</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$animal</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;tr <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">' class=&quot;altrow&quot;'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;</pre></div></div>

<p>But I think we can do even better: Create a cycle helper for cake that behaves like the solution in Rails, Smarty or Zend. I&#8217;ve written a little helper that does exactly that and in my next posting I&#8217;m going to show you how I did it.</p>
<p>UPDATE:<br />
My CakePHP-Cycle-Helper is described here:<br />
<a href="http://functino.com/2009/07/cakephp-cycle-helper-alternating-row-colors-with-cake/">http://functino.com/2009/07/cakephp-cycle-helper-alternating-row-colors-with-cake/</a></p>
 <img src="http://functino.com/wp-content/plugins/feed-statistics.php?view=1&post_id=122" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://functino.com/2009/04/alternate-table-rows-in-cakephp-and-zf-rails-smarty/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hello World!</title>
		<link>http://functino.com/2009/02/hello-world/</link>
		<comments>http://functino.com/2009/02/hello-world/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 17:00:05 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://functino.com/?p=38</guid>
		<description><![CDATA[Welcome to my new blog. I&#8217;m using this blog to publish some code that I&#8217;ve written for several projects of mine. Most of the time this will be some Prototype &#38; Script.aculo.us classes or jQuery plugins.  I also plan to post some tips and hints on CakePHP,  Ruby on Rails, PHP and so on. I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to my new blog. I&#8217;m using this blog to publish some code that I&#8217;ve written for several projects of mine. Most of the time this will be some Prototype &amp; Script.aculo.us classes or jQuery plugins.  I also plan to post some tips and hints on CakePHP,  Ruby on Rails, PHP and so on. I&#8217;m surely not an expert in one of them &#8211; but I&#8217;m also sure I can provide some helpful tips to other beginners.</p>
<p>And last but not least:  I&#8217;m a german and this is my aproach to improve my english. Most of the time I have no problem with reading and understanding english:  That&#8217;s something I do all the time, reading english blogs, documentations and news or watching english series and movies. But when it comes to writing I have my problems.  So when I sound like a 3 year old boy &#8230; I&#8217;m sorry.  I hope to improve my english skills with this blog. If I type something horribly wrong leave a comment and correct me :)</p>
<p>And so it begins.</p>
 <img src="http://functino.com/wp-content/plugins/feed-statistics.php?view=1&post_id=38" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://functino.com/2009/02/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
